|
Post by microfarad on Apr 30, 2010 22:27:53 GMT -5
Veers WarSim issues. I'm glad to see this new war calculator but, unfortunately, it doesn't work. Every time I hit calculate it calculates just fine, but then the page immediately begins to refresh. Also, I've seen the source code for WarSim, and I am warning you now, use very small bonuses...
|
|
|
Post by General Veers on Apr 30, 2010 22:31:51 GMT -5
Yes, the JavaScript version of WarSim is far from complete, although I now know the layout works as expected. I need help getting input from a webpage, interpreting and processing the input to a usable form (i.e. performing calculations to find new values), and then outputting back to the webpage using JavaScript and HTML.
Is anyone able to help? Just look at the page source for any of the Forum Game pages in the Forum Games board.
|
|
|
Post by microfarad on Apr 30, 2010 22:47:38 GMT -5
Well, as I said in the chat, you could make an applet and host it in a drop-box, you could let me do the same thing with Silverlight, or you could use <button onClick="">
|
|
|
Post by Qwerty on May 1, 2010 1:32:06 GMT -5
Would sticking it in an iframe help?
|
|
|
Post by microfarad on May 1, 2010 9:25:18 GMT -5
No, it would refresh the frame, the data would be lost anyways. Oh hey der! HE GOT IT! It makes you jump to the top of the page, no big deal. I can live with that. So Veers, we went through a great many ideas last night. What worked? <input type="button onClick=""/> ? <a href="#" onClick=""><input type="button/></a> ? I tinkered around a bit last night after you logged out. I got the <input type="button onClick=""/> to work for me...
Again, I must warn you. Use very small bonuses.
Edit: Veers, did you notice that it completely fails to work? Yeah, there are LOTS of glitches. OMG, it doesn't even get close to working... WHAT DID U DO??? (I can always make a Silverlight thing to embed... *Looks hopefully at Veers*)
|
|
|
Post by xShadowLordx on May 1, 2010 12:16:09 GMT -5
Veers, you really didn't have to go to all this trouble. I was just fine with using it in the command prompt. That way we wouldn't be having all these problems.
|
|
|
Post by General Veers on May 1, 2010 14:27:58 GMT -5
Edit: Veers, did you notice that it completely fails to work? Yeah, there are LOTS of glitches. OMG, it doesn't even get close to working... WHAT DID U DO??? (I can always make a Silverlight thing to embed... *Looks hopefully at Veers*) Neither have I finished it, nor have I stated that it was finished. When it is finished, I will say so; until then, I will remove the JavaScript version of WarSim from the Forum Games header. I must ask that you all continue using the *.class file, just as TheShadowLord seems to be doing. In the meantime, I would like help with JavaScript and HTML I/O. Having learned from past experience (i.e. the skin), I will not externally host any code.
|
|
|
Post by microfarad on May 1, 2010 18:18:58 GMT -5
Well, I know you SAID you tried this, but, really, it just HAS to work. It works fine for me...
<html> <head> <script type="text/javascript"> function hello() { document.getElementById("box").value="hi"; } </script> </head> <body> <form> <input type="button" value="CLICK!!!" onClick="hello();"/> <input type="text" id="box"/> </form> </body> </html>
Or you could let me embed a Silverlight applet! :) It could contain all sorts of useful calculators for games, and I could update it without you needing to change any code!
|
|
|
Post by General Veers on May 1, 2010 19:11:24 GMT -5
Look for yourself at the source code of my JS/HTML version of WarSim. If you look, the only significant differences between what you have and what I have is that I use the "name" attribute instead of the "id" attribute. Some minor differences include the fact that onClick refers to a function that itself calls ancillary functions and that I give different names to different inputs. Another possible difference is that I use variables (with global scope) within the JS portion of the code.
Look at the source code and see for yourself the similarities to your suggestions! With Firefox, go to the toolbar, click "View," and click "Page Source." Do a search within the source for the word "WarSim" until you come across my code.
Concerning embedding, I refuse to have most anything externally hosted (with a few Proboard Support code exceptions). When a server becomes temporarily unavailable, so does any code that it hosts. I had to go through the H/F for this site and replace all of the externally hosted code references with the actual codes, bothering GGoodie various times for help. I am not going through that again, and I doubt any of the other staff would be able to do that.
If you want to make an applet anyways, then by all means go ahead and turn it into an applet, keeping my copyright notice visible. Add yourself to the copyright notice for doing a translation from Java to Silverlight, but please keep mine.
|
|
|
Post by microfarad on May 1, 2010 19:49:40 GMT -5
Naturally, I would keep your Copyright there. The Silverlight application would be hosted in a drop-box, I doubt that the drop-box is going to go offline... It could become a very functional tool, with multiple uses. We could have a map generator, a WarSim, a random number generator, and... other stuff. It would be really awesome!
I don't find any differences concerning except your use of "name" instead of "id". Try changing that...
|
|
|
Post by General Veers on May 1, 2010 20:29:37 GMT -5
After changing "name" to "id" and changing occurrences of document.WarSim.nameOfInput.value to document.WarSim.getElementById("nameOfInput").value, it still doesn't work.
|
|
|
Post by microfarad on May 1, 2010 21:20:33 GMT -5
Well, here is what I would do if I were you. I would give up and let Micro Farad make a Silverlight application to embed. :)
|
|
|
Post by General Veers on May 3, 2010 15:48:54 GMT -5
I am getting very close. With the exception of user-defined bonuses, WarSim is functional. WarSim WILL determine who has the homeland advantage, but it will NOT determine if there are any other bonuses... I beleive the error resides within this block of code.
function determineBonusDifference() { var limit; if(bonusOff != bonusDef) { limit = (document.Warsim.checkInstantWin.checked) ? 100 : 95; if(chanceOff + (bonusOff - bonusDef)/2 >= limit) { chanceOff = limit; chanceDef = 100 - limit; } else if(chanceDef + (bonusDef - bonusOff)/2 >= limit) { chanceOff = 100 - limit; chanceDef = limit; } else { chanceOff += (bonusOff - bonusDef)/2; chanceDef += (bonusDef - bonusOff)/2; } } }
Help would be greatly appreciated...
|
|
|
Post by microfarad on May 3, 2010 17:22:12 GMT -5
First off, try opening brackets on the following line...
Thingy that needs brackets { stuff in brackets }
|
|
|
Post by General Veers on May 5, 2010 14:50:07 GMT -5
Apparently, my mistake was merely forgetting to capitalize the "s" of "Warsim" in the reference to the "checkInstantWin" checkbox. I fixed this and tested WarSim. It is now fully operational!Granted, the Java version has more tools to it (e.g. flip a coin, add individual boni), but this includes the much-needed winning cap. I beleive the error resides within this block of code.
function determineBonusDifference() { var limit; if(bonusOff != bonusDef) { limit = (document.Warsim.checkInstantWin.checked) ? 100 : 95; if(chanceOff + (bonusOff - bonusDef)/2 >= limit) { chanceOff = limit; chanceDef = 100 - limit; } else if(chanceDef + (bonusDef - bonusOff)/2 >= limit) { chanceOff = 100 - limit; chanceDef = limit; } else { chanceOff += (bonusOff - bonusDef)/2; chanceDef += (bonusDef - bonusOff)/2; } } }
|
|
|
Post by microfarad on May 5, 2010 17:45:11 GMT -5
LOL, that's why I don't write code in notepad. :D Glad to see you got it!
|
|
|
Post by General Veers on May 5, 2010 18:04:39 GMT -5
I didn't write code in Notepad. I wrote it in Notepad++, which has syntax color-codes and syntax highlighting.
|
|
|
Post by microfarad on May 5, 2010 18:14:00 GMT -5
But alas, it doesn't keep track of your object and tell you which ones you miss-spelled.
|
|