By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,841 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,841 IT Pros & Developers. It's quick & easy.

FF and JS not giving my image as default

tpgames
100+
P: 785
I'm trying to get a maze to default to always giving me the image as the marker and never give me the color as the marker. The code requires you to check a box to get the image marker to be used. So, I thought if I put played around with the checked box function, I'd get what I want, but I don't.

I tried changing this
Expand|Select|Wrap|Line Numbers
  1.   document.getElementById('markerImage').disabled = true;
to this
Expand|Select|Wrap|Line Numbers
  1.   document.getElementById('markerImage').disabled = false;
This is what else I did:
Expand|Select|Wrap|Line Numbers
  1.     if(hideEnd=='true') document.getElementById('hideEnd').checked = true;
  2.     if(markerImage=='true') document.getElementById('markerImage').checked = true;
  3.     if(markerImage=='true') document.getElementById('markerImage').checked = false;
  4.  
This is the original code that gives green marker as default.
Expand|Select|Wrap|Line Numbers
  1. function cTheme() {
  2.   if(document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value!='none') {
  3.     startIcon = theme['startIcon'+document.getElementById('theme').selectedIndex];
  4.     endIcon = theme['endIcon'+document.getElementById('theme').selectedIndex];
  5.     document.getElementById('background').value = theme['background'+document.getElementById('theme').selectedIndex];
  6.     document.getElementById('borderColor').value = theme['borderColor'+document.getElementById('theme').selectedIndex];
  7.     document.getElementById('pathColor').value = theme['pathColor'+document.getElementById('theme').selectedIndex];
  8.     document.getElementById('markerColor').value = theme['markerColor'+document.getElementById('theme').selectedIndex];
  9.     document.getElementById('trailColor').value = theme['trailColor'+document.getElementById('theme').selectedIndex];
  10.     document.getElementById('backtrackColor').value = theme['backtrackColor'+document.getElementById('theme').selectedIndex];
  11.   } else {
  12.     startIcon = 'human.gif';
  13.     endIcon = 'home.gif';
  14.   }
  15.   document.getElementById('backgroundSpan').style.backgroundColor = document.getElementById('background').value;
  16.   document.getElementById('borderColorSpan').style.backgroundColor = document.getElementById('borderColor').value;
  17.   document.getElementById('pathColorSpan').style.backgroundColor = document.getElementById('pathColor').value;
  18.   document.getElementById('markerColorSpan').style.backgroundColor = document.getElementById('markerColor').value;
  19.   document.getElementById('trailColorSpan').style.backgroundColor = document.getElementById('trailColor').value;
  20.   document.getElementById('backtrackColorSpan').style.backgroundColor = document.getElementById('backtrackColor').value;
  21. }
  22.  
  23. function cVersion() {
  24.   document.getElementById('length').disabled = false;
  25.   document.getElementById('bias').disabled = false;
  26.   document.getElementById('shape').disabled = false;
  27.   document.getElementById('border').disabled = false;
  28.   document.getElementById('braid').disabled = false;
  29.   document.getElementById('shape').disabled = false;
  30.   document.getElementById('randomStart').disabled = false;
  31.   document.getElementById('randomEnd').disabled = false;
  32.   document.getElementById('randomEndSeconds').disabled = false;
  33.   document.getElementById('hideEnd').disabled = false;
  34.   document.getElementById('print').disabled = false;
  35.   document.getElementById('background').disabled = false;
  36.   document.getElementById('borderColor').disabled = false;
  37.   document.getElementById('pathColor').disabled = false;
  38.   document.getElementById('markerColor').disabled = false;
  39.   document.getElementById('trailColor').disabled = false;
  40.   document.getElementById('backtrackColor').disabled = false;
  41.   document.getElementById('theme').disabled = false;
  42.   document.getElementById('markerImage').disabled = false;
  43.  
  44.   if(document.getElementById('version').options[document.getElementById('version').selectedIndex].value==4) {
  45.     document.getElementById('length').disabled = true;
  46.     document.getElementById('bias').disabled = true;
  47.     document.getElementById('shape').disabled = true;
  48.   } else if(document.getElementById('version').options[document.getElementById('version').selectedIndex].value==5) {
  49.     document.getElementById('length').disabled = true;
  50.     document.getElementById('bias').disabled = true;
  51.     document.getElementById('shape').disabled = true;
  52.     document.getElementById('border').disabled = true;
  53.     document.getElementById('braid').disabled = true;
  54.     document.getElementById('shape').disabled = true;
  55.     document.getElementById('randomStart').disabled = true;
  56.     document.getElementById('randomEnd').disabled = true;
  57.     document.getElementById('randomEndSeconds').disabled = true;
  58.     document.getElementById('hideEnd').disabled = true;
  59.     document.getElementById('print').disabled = true;
  60.     document.getElementById('background').disabled = true;
  61.     document.getElementById('borderColor').disabled = true;
  62.     document.getElementById('pathColor').disabled = true;
  63.     document.getElementById('markerColor').disabled = true;
  64.     document.getElementById('trailColor').disabled = true;
  65.     document.getElementById('backtrackColor').disabled = true;
  66.     document.getElementById('theme').disabled = true;
  67.     document.getElementById('markerImage').disabled = true;
  68.   }
  69. }
  70.  
  71. window.onload = function() {
  72.  
  73.   mazesmithMain = document.createElement("DIV");
  74.   mazesmithMain.id = "mainSmithMain";
  75.   mazesmithMain.innerHTML = echo + echoBasic;
  76.   document.getElementById('mazesmith').appendChild(mazesmithMain);
  77.  
  78.   eventHandle();
  79.   setKeys();
  80.   setKCode();
  81.  
  82.   if(t!='') {
  83.     document.getElementById('rows').value = rows;
  84.     document.getElementById('cols').value = cols;
  85.     document.getElementById('path').value = path;
  86.     document.getElementById('length').value = length;
  87.     document.getElementById('border').value = border;
  88.     document.getElementById('braid').value = braid;
  89.     document.getElementById('bias').options[(bias)].selected = true;
  90.     document.getElementById('version').options[(version-1)].selected = true;
  91.     document.getElementById('background').value = background;
  92.     document.getElementById('borderColor').value = borderColor;
  93.     document.getElementById('pathColor').value = pathColor;
  94.     document.getElementById('markerColor').value = markerColor;
  95.     document.getElementById('trailColor').value = trailColor;
  96.     document.getElementById('backtrackColor').value = backtrackColor;
  97.     if(randomStart=='true') document.getElementById('randomStart').checked = true;
  98.     if(randomEnd=='true') document.getElementById('randomEnd').checked = true;
  99.     document.getElementById('randomEndSeconds').value = randomEndSeconds;
  100.     document.getElementById('shape').options[(shapeNo-1)].selected = true;
  101.     if(hideEnd=='true') document.getElementById('hideEnd').checked = true;
  102.     if(markerImage=='true') document.getElementById('markerImage').checked = true;
  103.  
  104.     document.bgColor = background;
  105.     document.getElementById('title').style.color = borderColor;
  106.     document.getElementById('title2').style.color = borderColor;
  107.  
  108.     cVersion();
  109.   }
  110.  
  111.   document.getElementById('backgroundSpan').style.backgroundColor = document.getElementById('background').value;
  112.   document.getElementById('borderColorSpan').style.backgroundColor = document.getElementById('borderColor').value;
  113.   document.getElementById('pathColorSpan').style.backgroundColor = document.getElementById('pathColor').value;
  114.   document.getElementById('markerColorSpan').style.backgroundColor = document.getElementById('markerColor').value;
  115.   document.getElementById('trailColorSpan').style.backgroundColor = document.getElementById('trailColor').value;
  116.   document.getElementById('backtrackColorSpan').style.backgroundColor = document.getElementById('backtrackColor').value;
  117.  
  118.   for(var a=0;a<=themes.length-1;a++) {
  119.     var optionName = new Option(themes[a], a, true, true);
  120.     document.getElementById('theme').options[document.getElementById('theme').length] = optionName;
  121.   }
  122.   var optionName = new Option('None', 'none', true, true);
  123.   document.getElementById('theme').options[document.getElementById('theme').length] = optionName;
  124.  
  125.   if(t.length>22) { document.getElementById('theme').options[t[22]].selected = true; startIcon = theme['startIcon'+t[22]]; endIcon = theme['endIcon'+t[22]]; }
  126.  
  127.   if(configPanel==1) document.getElementById(conType).style.display = 'block';
  128.   else createMainTable();
  129. }
  130.  
This is the check box part of the code:
Expand|Select|Wrap|Line Numbers
  1.  <tr><td><span class="help" onclick="alert(\'Instead of using color markers, this option will use images.\')">(?)</span> Use images for markers</td><td style="text-align:right;"><input type="checkbox" id="markerImage" onfocus="focusObj = this.id;" /> \

Link to Full JS code

Link to Game


The other issue is that Firefox keeps giving me errors if I change the name of the js file and the link to the js file. Also, if I clear history, cookies, cache, etc., it refuses to give me the new gmaze.js file (which was why I was changing the name and link). It still gives me the original one with the original code. I'm about to quit using Firefox and try some other browser.
Thanks!

a long lost tpgames with my sister's old laptop as my died...
May 27 '09 #1
Share this Question
Share on Google+
6 Replies


Frinavale
Expert Mod 5K+
P: 9,731
@tpgames
Hey tpgames, long time no see :)

I followed the link to the site but didn't see a check box.
This line is using a select element (not a check box):

Expand|Select|Wrap|Line Numbers
  1. function cTheme() {
  2.   if(document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value!='none') {
  3. //.....
  4. } else {
  5.     startIcon = 'human.gif';
  6.     endIcon = 'home.gif';
  7.   }
  8. //.....
  9. }
It seems to me that you want to set the "theme" select element's SelectedIndex to "none".....in order to executed the Else block which sets the image.

Does that help at all?

The other issue is that Firefox keeps giving me errors if I change the name of the js file and the link to the js file. Also, if I clear history, cookies, cache, etc., it refuses to give me the new gmaze.js file (which was why I was changing the name and link). It still gives me the original one with the original code. I'm about to quit using Firefox and try some other browser.
.
What is the error?
Are you using FireBug?
May 27 '09 #2

tpgames
100+
P: 785
Hello Frinavale! It has been ages. :D

I'm seeing that the theme is set to none. The gmaze.js is exactly like what you posted. What am I seeing wrong? If I were to flip the theme code stuff and the else code stuff around, would it fix the problem, assuming I could get firefox to give me the NEW gmaze.js code and not the one in cache that it refuses to refresh?
Expand|Select|Wrap|Line Numbers
  1. # function cTheme() {
  2. #   if(document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value!='none') {
  3. # //.....
  4. # } else {
  5. #     startIcon = 'human.gif';
  6. #     endIcon = 'home.gif';
  7. #   }

The check box is found after you push "advance" and then look on the right side. I forgot to put in this bit of info. Sorry!

The Firefox browser error:
if I rename gmaze.js to z.js and change the link inside of errormaze.html to refer to z.js, firefox gives me a blank page. It never really clears the cache, history, etc. nor does it really reload the page. Thus, I could really never figure out what changes to the js code was working or not. Firefox kept insisting on giving me the original unchanged gmaze.js code no matter what I did. it refused to reload that gmaze.js file. So, do I have to reboot firefox everytime I change the js code and clear cache, etc in order to force firefox to read the js file anew?

Thanks!
(ps. My laptop died which is why I've not been here in ages! I now have my sister's old laptop, but don't know how long it will last.)
May 27 '09 #3

Frinavale
Expert Mod 5K+
P: 9,731
@tpgames
Ok let's solve one problem at a time.
Let's get FireFox to load the right external JavaScript file first.

When I followed the link I noticed that in the JavaScript file loaded is named "gmaze.js"

Seeing that you're working with the JavaScript file named "z.js" you need to change the external JavaScript file being referenced.

Change your html to the following:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" Expires: Thur, 1 March 2007 13:00:00 GMT>
  2. <html>
  3. <head>
  4. <title> MAZES </title>
  5. <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
  6. <link type="text/css" rel="stylesheet" href="http://www.tpgames.net/gaming/2/puzzlers/mazes/adam.css"> 
  7. <link rel="shortcut icon" href="http://www.tpgames.net/tpgamesicon.gif">
  8.  
  9.  
  10. <style type="text/css">
  11.   body {
  12.     font-family: Arial,Sans;
  13.     font-size: 12px;
  14.   }
  15.   input,select {
  16.     font-size: 12px;
  17.   }
  18. </style>
  19.  
  20. <script type="text/javascript" src="http://www.tpgames.net/gaming/2/puzzlers/mazes/adam/z.js"></script>
  21.  
  22.  
  23. </head>
  24.  
  25. <body>
  26.  
  27.  
  28.  
  29. <div id="mazesmith"></div>
  30.  
  31. </body>
  32. </html>
Notice the <script> tag...make sure the URL is properly taking you to the "z.js" file (if it's not in the "gaming/2/puzzlers/mazes/adam" folder).
May 27 '09 #4

tpgames
100+
P: 785
I put function cTheme down to only
Expand|Select|Wrap|Line Numbers
  1.   {    startIcon = 'human.gif';
  2.   endIcon = 'home.gif';} 
and deleted everything else that came after the "IF" bit, but it didn't work, not even in IE. Which leads me to think that the issue is more complicated then a simple fix. The game worked but still gave me the default green. What I did didn't even break the code.

Now I'm really confused. Thanks!
May 27 '09 #5

tpgames
100+
P: 785
I renamed everything back to gmaze.js because firefox refused to recognize any other js file name. What I mean is that I am actually using gmaze.js as the file to change because when I change the name in the html file to a new link and name firefox doesn't read it.

However, do you want me to change the js file name to z.js to see if we can get Firefox to work properlly?
May 27 '09 #6

tpgames
100+
P: 785
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="http://www.tpgames.net/gaming/2/puzzlers/mazes/adam/z.js"></script>
  2.  
This is the exact link I change errormaze.html too. I copied gmaze.js exactly as written into z.js. The result: blank page and no mazes. This is the same code that I accessed in IE that resulted in the game being seen. However, in IE, (which never saw the game before), accessed gmaze.js from errormaze.html.

When I did a search for "gmaze" inside the js codes, I didn't find anything. So, I couldn't find anywheres in the code that would dictate that the file must be named 'gmaze.js' in order for the game to show up.

And nothing in the other js file that the code does access can I find that dictates gmaze.js must be used as a name.
Expand|Select|Wrap|Line Numbers
  1. /* Mazesmith themes */
  2.  
  3. var themes = new Array('Human','Red Sands','Grass Field', 'Blue', 'BW');
  4.  
  5. var startIcon = 'human.gif';
  6. var endIcon = 'home.gif';
  7.  
  8. var theme = new Array();
  9.  
  10. /*
  11. Name:    Human IMAGE THEMED
  12. Author:    TPKyteroo 
  13. */
  14.  
  15. theme['startIcon0']    = 'human.gif';
  16. theme['endIcon0']    = 'home.gif';
  17. theme['background0']    = 'bubbles.gif';
  18. theme['borderColor0']    = '#0000ff';
  19. theme['pathColor0']    = 'bubbles.gif';
  20. theme['markerColor0']    = 'human.gif';
  21. theme['trailColor0']    = '#purple';
  22. theme['backtrackColor0']= '#777777';
  23.  
  24.  
May 27 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.