Jump to content

sadicq

Member
  • Posts

    273
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Romania

Everything posted by sadicq

  1. i'll take a look in an hour or two. right know i'm taking an online exam. lol
  2. Well, the precision of the new function made for checking the colors is not the same with the previous one (it only yells if the color is invalid and it says nothing more. Anyway I see you did not output the details ). But everything is by far better that the previous one. So here are the modifications you have to make: The html code must be changed to: <input name="tttbtc" type="text" class="clTextBox" id="tttbtc" style="text-align: center; text-transform: uppercase;" value="#333333" size="12" maxlength="7"/> <input name="tttbc" type="text" class="clTextBox" id="tttbc" style="text-align: center; text-transform: uppercase;" value="#5498FF" size="12" maxlength="7"> I removed only the "onblur entry". (i also added a backslash at the end of the <input /> block. XHTML compatible . One more thing you have to do inside the html: in the body tag put an onload="init();" statement. This way, <body>Will be <body onload="init();"> Now, let's move to the js file. 1. Remove all your previous code 2. Paste the following code: var _validatorArray = new Array(); function ColorValidator() { this.validate = function(text) { if(text.indexOf("#") != 0 || text.length != 7) return; text = text.substring(1).toUpperCase(); while(text.length > 0 && text.charAt(0) >= '0' && text.charAt(0) <= 'F') text = text.substring(1); return text.length == 0; } } function FieldValidator(field, validator) { this.field = field; this.validator = validator; this.index = -1; this.isValid= function() { return this.field.value.length == 0 || this.validator.validate(this.field.value); } this.verify = function() { if(!this.isValid()) { alert("The value you have entered ("+this.field.value+") does not represent a color (in #AAAAAA format) !"); this.field.focus(); this.field.select(); this.field.style.backgroundColor = "#EE1111"; setTimeout(new this.timer(this.index).time, 1000); } else if(this.field.value.length > 0) { this.field.style.backgroundColor = "#22EE22"; window.status = this.index; setTimeout(new this.timer(this.index).time, 500); } } this.timer = function(index) { this.time = function() { _validatorArray[index].field.style.backgroundColor = ""; } } this.focuser = function(index) { this.focus = function() { try { for(var i=0; i<_validatorArray.length; i++) if(i != index && !_validatorArray[i].isValid()) { window.event.cancelBubble = true; return false; } } catch(e){} return true; } } this.blurer = function(index) { this.blur = function() { try { _validatorArray[index].verify(); } catch(e){} } } _validatorArray[(this.index=_validatorArray.length++)] = this; field.attachEvent("onfocus", new this.focuser(this.index).focus); field.attachEvent("onblur", new this.blurer(this.index).blur); } function init() { new FieldValidator(document.getElementById("tttbtc"), new ColorValidator()); new FieldValidator(document.getElementById("tttbc"), new ColorValidator()); } in conclusion, when adding a new input, you'll have to do: 1. Make sure the current document's <body> has onload="init();" 2. Add a line like <input name="thename" type="text" class="clTextBox" id="thename" style="text-align: center; text-transform: uppercase;" value="#333333" size="12" maxlength="7"/> 3. Edit the init() function in the js file adding a line like this: new FieldValidator(document.getElementById("thename"), new ColorValidator()); Note: thename is the name of the new introduced input.
  3. Hehe, there's a small mistake in your script. Instead of window.onload=showtod Put window.onload=showtod()
  4. I've made a sample hta file to demonstrate the use of the code. It supports multiple fields that require validation (see the attacher on init). The validation function has been externalized (and re-written) and the FieldValidator mechanism can operate even with other validators than for color (ColorValidator). I've had some help with the code from a firend that knows what he's doing <html> <head> <script language="JavaScript"> var _validatorArray = new Array(); function ColorValidator(){ this.validate = function(text){ if(text.indexOf("#") != 0 || text.length != 7) return; text = text.substring(1).toUpperCase(); while(text.length > 0 && text.charAt(0) >= '0' && text.charAt(0) <= 'F') text = text.substring(1); return text.length == 0; } } function FieldValidator(field, validator){ this.field = field; this.validator = validator; this.index = -1; this.isValid= function(){ return this.field.value.length == 0 || this.validator.validate(this.field.value); } this.verify = function(){ if(!this.isValid()){ alert("The value you have entered ("+this.field.value+") does not represent a color (in #AAAAAA format) !"); this.field.focus(); this.field.select(); this.field.style.backgroundColor = "#EE1111"; setTimeout( new this.timer(this.index).time , 1000 ); }else if(this.field.value.length > 0){ this.field.style.backgroundColor = "#22EE22"; window.status = this.index; setTimeout( new this.timer(this.index).time , 500 ); } } this.timer = function(index){ this.time = function(){ _validatorArray[index].field.style.backgroundColor = ""; } } this.focuser = function(index){ this.focus = function(){ try{ for(var i=0; i<_validatorArray.length; i++) if(i != index && !_validatorArray[i].isValid()){ window.event.cancelBubble = true; return false; } }catch(e){} return true; } } this.blurer = function(index){ this.blur = function(){ try{ _validatorArray[index].verify(); }catch(e){} } } _validatorArray[(this.index=_validatorArray.length++)] = this; field.attachEvent( "onfocus", new this.focuser(this.index).focus ); field.attachEvent( "onblur", new this.blurer(this.index).blur ); } function init(){ new FieldValidator( document.getElementById("color_code"), new ColorValidator() ); new FieldValidator( document.getElementById("color_code2"), new ColorValidator() ); } </script> </head> <body onload="init();"> <input type="text" name="color_code" id="color_code" size="7"/> <br/> <input type="text" name="color_code2" id="color_code2" size="7"/> <br/> Some text to check for validation behaviour </body> </html>
  5. Removed. Read the next post because that is the correct bug fix .
  6. Actually I can see programs with false gcond and cond ... I modded my WPI a bit ...
  7. WPI Mod Installer [bETA] Important: Works with absolutely any (text) file, no WPI paths / vars being hardcoded in the source. Download the source and modify it to suit your own needs. [06.16 00:20] Code rewritten from scratch. This script will read all the info it needs from a text file located in the same directory with it and modify the WPI source accordingly. The modification file must have the .mod extension. Basically, it can be use for any other file to be edited. Let's get to the instructions: Put the script in a folder named "MOD Installer" under the WPI root. (If you don't like the name you can use another one). Put in the same folder all your mods you want to install (the .mod files). Run the script. In the upper side of its GUI, you will the list of the mods. Choose one and click Process. If anything goes fine, you will see a line like this in the right side of its GUI: Success | Completed editing file ... for each file that was modified. Then press Overwrite. If this actions is ok, the installation was succesful and in the right side you will see a line like this one: Completed | The program finished copying your files If something goes wrong along the install of a mod, you will see an error message and the install will be stopped: Error | File could not be found: ... Note that this program is not directly modifying your files, but modifying a copy of each one and then overwriting the orginal ones only if the install was successful and the user wants to do that. That's it with the installation. Now, here comes the interesting part about writing mods. Any mod must be an .mod file. Any mod must start with a template header: [WPI5 MOD NAME] The name of your mod. [DESCRIPTION] blah ... about the mod of course [VERSION] 1.0 [AUTHOR] whoever wrote it Next, each operation must be declared as a section of the ini. Including the header sections, the accepted sections are: [WPI5 MOD NAME] A line containing the name of the mod [DESCRIPTION] A line containing the description of the mod [VERSION] A line containing the version of the mod [AUTHOR] A line containing the author's name [FIND] A line/group of lines that can be searched for and then replaced/modified .. [FINDLINE] A bunch of text / a single line that can be searched for [ADDBEFORE] A line/group of lines to add before a previously found text/line [ADDAFTER] A line/group of lines to add after a previously found text/line [REPLACE] A line/group of lines to replace a previously found text/line [MODEND] A line that marks the end of the mod [OPEN] A line that marks the beggining of a new file Examples: [WPI5 MOD NAME] The name of your mod. [DESCRIPTION] blah ... about the mod of course [VERSION] 1.0 [AUTHOR] whoever wrote it [OPEN] Themes\Glossy\wpi.htm [FIND] <head> [ADDBEFORE] <beforetest> [FIND] <head> [ADDAFTER] <aftertest> [FIND] <body [REPLACE] <booody [FIND] <script type="text/javascript"> sizer(); </script> [REPLACE] <script type="text/javascript"> sizer(); </script> [FINDLINE] <body [REPLACE] <body> [MODEND] Let's explain each statement (I'll skip the header): [OPEN] Themes\Glossy\wpi.htm It tells the program where to execute the following actions (once a new [OPEN] statement is found, all further statements will be executed on that file). [FIND] <head> Finds all the occurances of the <head> text in the file. [ADDBEFORE] <beforetest> Adds before each of the previous found strings the <beforetest> text. [FIND] <head> Finds all the occurances of the <head> text in the file. [ADDAFTER] <aftertest> Adds before each of the previous found strings the <aftertest> text. [FIND] <body Find all the <body strings in the document (the exact match, case insensitive). [REPLACE] <booody Replaces all the previous found results with this: <booody [FIND] <script type="text/javascript"> sizer(); </script>Find all exact matches for the text (even the tabs, spaces, end-lines etc) [REPLACE] <script type="text/javascript"> sizer(); </script> Replaces all the previous found results with this text ... [FINDLINE] <body Find the line(s) that contain(s) the text <body .So, you can't use multi-line text with this one. [REPLACE] <body> Replaces the whole line previously found with the text. [MODEND] The end of the mod. I hope that's enough and I did not forget anything. This is beta software, so use it at your own risk. WPI_mod.au3 WPI_mod.exe
  8. It seems it was easier than I thought. I've done the mod installer but I have to do some more testing. I hope it will be ready tonight.
  9. I saw that some members posted some mods for the vanilla WPI. But with the release of the new version which is not compatible with the older themes, I had to redo all my modifications... and they were not few ... So I came up with the idea of making a mod installer. I'm only going to do this if you people are requesting it because there are at least 2 days of work for that. So, if anybody finds this useful, post here and I'll get to work
  10. oneless, try this: Open boxes.js Find and delete if (DoGray) txt += (' disabled'); MAVERICKS CHOICE, I see no problem with my media player. Actually I see no code was changed, so please check that your melodies are in the audio folder and the media player is at least showing itself.
  11. Modify the multi-defaults to use the optgroup tag: Open wpi.htm Find //Add defaults, all, none Before, add document.write('<optgroup label="WPI">'); Find document.write('<option value="------">------</option>'); Replace with: document.write('</optgroup>'); if (Configurations.length > 1 || (Configurations.length == 1 && Configurations[0] != "")) { document.write('<optgroup label="User defined">'); Find document.write('</select> '); Before, add document.write('</optgroup>'); } The result: This modification includes the fix for a small bug: if multiple defaults is selected and no configuraion is declared, than an empty line is added to the list. With this mod, there is no empty line Edit: Am I the only one posting in this forum?
  12. Actually when I posted that I was not intending to modify the WPI calls. I was going to start another program separately from the installer which would have monitored the progress and would have updated the progress bar. The problem was that the installer is a .hta, so it runs mshta.exe which I don't how to attach to. So I gave up on Autoit and started coding some VBscript. Right now I have no clue about how this can be done, but I hope I'll come up with a solution.
  13. You're welcome. I'm glad it is working because I wrote it in less than 10 minutes .
  14. I'm starting working on this progressbar today. I just found out that I'll have some free time. I already solved the problem with the installer that stays in the current line very simple (it took less than 5 minutes): InstallShell.Run("cmd /c start program", 0, true)
  15. I can't reproduce the problem. Can you send me your config?
  16. This is a mod which will display your programs although conditions are not met (even gcond is evaluated). The only difference between the items with false conditions and the ones with true ones is a small text displayed in front of the false ones like this: [False Cond] displayed in red. The purpose: if you used more than one DVD for one isntall you know you'll find this useful ... you can slect for install apps that are not on the curent dvd, but at the same time you know which ones really are ... Edits: File: Wpiscripts\boxes.js Find // We only display things that pass condition tests, unless we are in debug mode. before, add var conditionfailed = 0; Find debug("Condition failed: " + c + " -- not rendering " + prog[i], 1); continue; replace with debug("Condition failed: " + c + " -- not rendering " + prog[i], 1); conditionfailed = 1; Find if (DoGray) before, add if (conditionfailed == 1) txt += '<font class="conditionfailed">[False Cond]</font>'; File: Themes\ThemeName\wpi.css Add this at the end: .conditionfailed { font-family: arial; font-weight: bold; color : #FF0000; font-size : 8pt; margin-left: 5px; margin-top: 10px; margin-bottom: 50px; } The result can be seen here:
  17. Tooltip bug: every tooltip should have a z-index declared. Or it may happen something like this: Edit: Hm .. I see a z-index declared. I don't know why that happens and I don't have time to search any further.
  18. I just thought about a new request: more control over the media player: * should it or shouldn't it autostart playing the melody? * should it loop? (eventually loops count) * volume level (which value should it start from?) I think these are easy to implement and useful. For wmp (greater than v7) these are really easy to implement using the MP Object Model. For mplayer2, they use different vars and methods, but I'm sure the loop count is easy to do, the autostart the same, only the volume could represent a problem in mp2.
  19. Audio Player Configuration Bug: when adding a new melody, if the list is empty, an empty line still remains at the top of the list. Not a big bug, but it should be esthetic
  20. just noticed that the audio player embeds mplayer2, but the volume value is 68. I guess this was supposed to be 68%, but the mplayer2 works like this: 1 (50%) - 0 (100%). so, a value of 0 for the volume var will make it 100% actually. Oh, and btw, I don't think the player is embeded 100% correctly. Shouldn't it have an object tag? Just asking because I'm not sure ... I know it can be omitted, but I think it is cooler to have it included correctly.
  21. I'm so sorry I can't tell you ... I forgot about this thread Anyway, later is better than never, so here it is: the program I promised I'll make (it took me less than 5 minutes ) Usage: put this app in the system32 folder. Then make all your uninstaller point to %windir%\system32\thisprogram.exe /f folder_to_delete /u original_uninstaller note that you have to use absolute paths. The code (as simple as it can be): #include "Process.au3" #NoTrayIcon Opt("MustDeclarevars",1) Global $folder_to_delete, $uninstaller, $k If $CmdLine[0] <> 0 Then For $k = 1 To $CmdLine[0] Step 1 If $CmdLine[$k] == "/f" And $k < $CmdLine[0] Then $folder_to_delete = $CmdLine[$k + 1] ElseIf $CmdLine[$k] == "/u" And $k < $CmdLine[0] Then $uninstaller = $CmdLine[$k + 1] EndIf Next Run($uninstaller) _RunDOS("rd /s /q """ & $folder_to_delete & """") EndIf EDIT: cannot add the attachement. here is the download link. Btw, to edit an "Add/Remove program entry" look in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ProgramName] for the UninstallString entry and modify it to suit your needs. For some programs, the ProgramName can be actually a string like {E9787678-1033-0000-8E67-000000000001}. Just look in the registry in the uninstall key ...
  22. just noticed that on the WPI homepage the link in the "Updated by ... " points to hasi001's profile. And I don't think this is supposed to be this way.
  23. This function returns 1 if the value you pass to it is a valid hex color code and 0 if it is not. function validcolor(colorcode) { if (colorcode.substr(0,1) == "#") { colorcode = colorcode.substring(1); if (colorcode.length == 6) { var aux = 0; for (aux = 0; aux < 6; aux++) { var character = colorcode.substr(aux,1) if (character != 0 && character != 1 && character != 2 && character != 3 && character != 4 && character != 5 && character != 6 && character != 7 && character != 8 && character != 9 && character.toLowerCase() != 'a' && character.toLowerCase() != 'b' && character.toLowerCase() != 'c' && character.toLowerCase() != 'd' && character.toLowerCase() != 'e' && character.toLowerCase() != 'f') { alert('Your hex code contains a character that is not allowed (only 1..9 and A..F allowed)'); return 0; } } return 1; } else { alert('Invalid string lenght'); return 0; } } else { alert('The string should start with the \"#\" character'); return 0; } } I implemented only 6 chars long hex codes, but I know colors can be defined using 3 chars hex codes ... Modify it yourself or tell me if there is something you don't like. Use it like this (in your case): if (validcolor(document.all["colorcodetextbox"].value)) { "My code goes here that needs to run if above is true" } Offtopic: school .... I just got home ...
  24. http://www.softpedia.com/get/Authoring-too...t-Install.shtml Rate WPI on softpedia. Too bad it is not the latest version.
  25. Congrats for the fix. I would have helped you but my local time was 4Am when you posted ... and in the morning (and now it's morning ) I'm at school . I just love the classes that are held in the multimedia lab (I pay no attention to the class ).
×
×
  • Create New...