FF and JS not giving my image as default

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpgames
    Contributor
    • Jan 2007
    • 783

    #1

    FF and JS not giving my image as default

    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
    Code:
      document.getElementById('markerImage').disabled = true;
    to this
    Code:
      document.getElementById('markerImage').disabled = false;
    This is what else I did:
    Code:
        if(hideEnd=='true') document.getElementById('hideEnd').checked = true;
        if(markerImage=='true') document.getElementById('markerImage').checked = true;
        if(markerImage=='true') document.getElementById('markerImage').checked = false;
    This is the original code that gives green marker as default.
    Code:
    function cTheme() {
      if(document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value!='none') {
        startIcon = theme['startIcon'+document.getElementById('theme').selectedIndex];
        endIcon = theme['endIcon'+document.getElementById('theme').selectedIndex];
        document.getElementById('background').value = theme['background'+document.getElementById('theme').selectedIndex];
        document.getElementById('borderColor').value = theme['borderColor'+document.getElementById('theme').selectedIndex];
        document.getElementById('pathColor').value = theme['pathColor'+document.getElementById('theme').selectedIndex];
        document.getElementById('markerColor').value = theme['markerColor'+document.getElementById('theme').selectedIndex];
        document.getElementById('trailColor').value = theme['trailColor'+document.getElementById('theme').selectedIndex];
        document.getElementById('backtrackColor').value = theme['backtrackColor'+document.getElementById('theme').selectedIndex];
      } else {
        startIcon = 'human.gif';
        endIcon = 'home.gif';
      }
      document.getElementById('backgroundSpan').style.backgroundColor = document.getElementById('background').value;
      document.getElementById('borderColorSpan').style.backgroundColor = document.getElementById('borderColor').value;
      document.getElementById('pathColorSpan').style.backgroundColor = document.getElementById('pathColor').value;
      document.getElementById('markerColorSpan').style.backgroundColor = document.getElementById('markerColor').value;
      document.getElementById('trailColorSpan').style.backgroundColor = document.getElementById('trailColor').value;
      document.getElementById('backtrackColorSpan').style.backgroundColor = document.getElementById('backtrackColor').value;
    }
    
    function cVersion() {
      document.getElementById('length').disabled = false;
      document.getElementById('bias').disabled = false;
      document.getElementById('shape').disabled = false;
      document.getElementById('border').disabled = false;
      document.getElementById('braid').disabled = false;
      document.getElementById('shape').disabled = false;
      document.getElementById('randomStart').disabled = false;
      document.getElementById('randomEnd').disabled = false;
      document.getElementById('randomEndSeconds').disabled = false;
      document.getElementById('hideEnd').disabled = false;
      document.getElementById('print').disabled = false;
      document.getElementById('background').disabled = false;
      document.getElementById('borderColor').disabled = false;
      document.getElementById('pathColor').disabled = false;
      document.getElementById('markerColor').disabled = false;
      document.getElementById('trailColor').disabled = false;
      document.getElementById('backtrackColor').disabled = false;
      document.getElementById('theme').disabled = false;
      document.getElementById('markerImage').disabled = false;
    
      if(document.getElementById('version').options[document.getElementById('version').selectedIndex].value==4) {
        document.getElementById('length').disabled = true;
        document.getElementById('bias').disabled = true;
        document.getElementById('shape').disabled = true;
      } else if(document.getElementById('version').options[document.getElementById('version').selectedIndex].value==5) {
        document.getElementById('length').disabled = true;
        document.getElementById('bias').disabled = true;
        document.getElementById('shape').disabled = true;
        document.getElementById('border').disabled = true;
        document.getElementById('braid').disabled = true;
        document.getElementById('shape').disabled = true;
        document.getElementById('randomStart').disabled = true;
        document.getElementById('randomEnd').disabled = true;
        document.getElementById('randomEndSeconds').disabled = true;
        document.getElementById('hideEnd').disabled = true;
        document.getElementById('print').disabled = true;
        document.getElementById('background').disabled = true;
        document.getElementById('borderColor').disabled = true;
        document.getElementById('pathColor').disabled = true;
        document.getElementById('markerColor').disabled = true;
        document.getElementById('trailColor').disabled = true;
        document.getElementById('backtrackColor').disabled = true;
        document.getElementById('theme').disabled = true;
        document.getElementById('markerImage').disabled = true;
      }
    }
    
    window.onload = function() {
    
      mazesmithMain = document.createElement("DIV");
      mazesmithMain.id = "mainSmithMain";
      mazesmithMain.innerHTML = echo + echoBasic;
      document.getElementById('mazesmith').appendChild(mazesmithMain);
    
      eventHandle();
      setKeys();
      setKCode();
    
      if(t!='') {
        document.getElementById('rows').value = rows;
        document.getElementById('cols').value = cols;
        document.getElementById('path').value = path;
        document.getElementById('length').value = length;
        document.getElementById('border').value = border;
        document.getElementById('braid').value = braid;
        document.getElementById('bias').options[(bias)].selected = true;
        document.getElementById('version').options[(version-1)].selected = true;
        document.getElementById('background').value = background;
        document.getElementById('borderColor').value = borderColor;
        document.getElementById('pathColor').value = pathColor;
        document.getElementById('markerColor').value = markerColor;
        document.getElementById('trailColor').value = trailColor;
        document.getElementById('backtrackColor').value = backtrackColor;
        if(randomStart=='true') document.getElementById('randomStart').checked = true;
        if(randomEnd=='true') document.getElementById('randomEnd').checked = true;
        document.getElementById('randomEndSeconds').value = randomEndSeconds;
        document.getElementById('shape').options[(shapeNo-1)].selected = true;
        if(hideEnd=='true') document.getElementById('hideEnd').checked = true;
        if(markerImage=='true') document.getElementById('markerImage').checked = true;
    
        document.bgColor = background;
        document.getElementById('title').style.color = borderColor;
        document.getElementById('title2').style.color = borderColor;
    
        cVersion();
      }
    
      document.getElementById('backgroundSpan').style.backgroundColor = document.getElementById('background').value;
      document.getElementById('borderColorSpan').style.backgroundColor = document.getElementById('borderColor').value;
      document.getElementById('pathColorSpan').style.backgroundColor = document.getElementById('pathColor').value;
      document.getElementById('markerColorSpan').style.backgroundColor = document.getElementById('markerColor').value;
      document.getElementById('trailColorSpan').style.backgroundColor = document.getElementById('trailColor').value;
      document.getElementById('backtrackColorSpan').style.backgroundColor = document.getElementById('backtrackColor').value;
    
      for(var a=0;a<=themes.length-1;a++) {
        var optionName = new Option(themes[a], a, true, true);
        document.getElementById('theme').options[document.getElementById('theme').length] = optionName;
      }
      var optionName = new Option('None', 'none', true, true);
      document.getElementById('theme').options[document.getElementById('theme').length] = optionName;
    
      if(t.length>22) { document.getElementById('theme').options[t[22]].selected = true; startIcon = theme['startIcon'+t[22]]; endIcon = theme['endIcon'+t[22]]; }
    
      if(configPanel==1) document.getElementById(conType).style.display = 'block';
      else createMainTable();
    }
    This is the check box part of the code:
    Code:
     <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...
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by tpgames
    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....
    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):

    Code:
    function cTheme() {
      if(document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value!='none') {
    //.....
    } else {
        startIcon = 'human.gif';
        endIcon = 'home.gif';
      }
    //.....
    }
    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?

    Comment

    • tpgames
      Contributor
      • Jan 2007
      • 783

      #3
      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?
      Code:
      # function cTheme() {
      #   if(document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value!='none') {
      # //.....
      # } else {
      #     startIcon = 'human.gif';
      #     endIcon = 'home.gif';
      #   }

      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.)

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by tpgames
        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.)
        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:
        Code:
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" Expires: Thur, 1 March 2007 13:00:00 GMT>
        <html>
        <head>
        <title> MAZES </title>
        <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
        <link type="text/css" rel="stylesheet" href="http://www.tpgames.net/gaming/2/puzzlers/mazes/adam.css"> 
        <link rel="shortcut icon" href="http://www.tpgames.net/tpgamesicon.gif">
        
        
        <style type="text/css">
          body {
            font-family: Arial,Sans;
            font-size: 12px;
          }
          input,select {
            font-size: 12px;
          }
        </style>
        
        <script type="text/javascript" src="http://www.tpgames.net/gaming/2/puzzlers/mazes/adam/z.js"></script>
        
        
        </head>
        
        <body>
        
        
        
        <div id="mazesmith"></div>
        
        </body>
        </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).

        Comment

        • tpgames
          Contributor
          • Jan 2007
          • 783

          #5
          I put function cTheme down to only
          Code:
            {    startIcon = 'human.gif';
            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!

          Comment

          • tpgames
            Contributor
            • Jan 2007
            • 783

            #6
            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?

            Comment

            • tpgames
              Contributor
              • Jan 2007
              • 783

              #7
              Code:
              <script type="text/javascript" src="http://www.tpgames.net/gaming/2/puzzlers/mazes/adam/z.js"></script>
              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.
              Code:
              /* Mazesmith themes */
              
              var themes = new Array('Human','Red Sands','Grass Field', 'Blue', 'BW');
              
              var startIcon = 'human.gif';
              var endIcon = 'home.gif';
              
              var theme = new Array();
              
              /*
              Name:	Human IMAGE THEMED
              Author:	TPKyteroo 
              */
              
              theme['startIcon0']	= 'human.gif';
              theme['endIcon0']	= 'home.gif';
              theme['background0']	= 'bubbles.gif';
              theme['borderColor0']	= '#0000ff';
              theme['pathColor0']	= 'bubbles.gif';
              theme['markerColor0']	= 'human.gif';
              theme['trailColor0']	= '#purple';
              theme['backtrackColor0']= '#777777';

              Comment

              Working...