Google Gadget

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 1051109210
    New Member
    • Mar 2007
    • 29

    Google Gadget

    Code:
    function checkWin()
    { 
    var val0;
     var val1;
     var val2;
    var status = _gel(status);                 //prob here
     
     // check columns
     for(var y = 0; y < 3; y++)
     {
       val0 = _gel('b0_'+y +".value");               //prob here
            val1 = _gel('b1_'+y +".value");
            val2 = _gel('b2_'+y +".value");
    
    if(val0 == 'X' && val1 == 'X' && val2 == 'X')
       {
          status.innerText = "X WINS!";
          return true;
       }
       else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
       {
          status.innerText = "O WINS!";
          return true;
       }
     }
    
     // check rows
     for(var x = 0; x < 3; x++)
     {
       val0 = _gel('b'+ x + '_0').value;
       val1 = _gel('b'+ x + '_1').value;
       val2 = _gel('b'+ x + '_2').value;
       if(val0 == 'X' && val1 == 'X' && val2 == 'X')
       {
          status.innerText = "X WINS!";
          return true;
       }
       else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
       {
          status.innerText = "O WINS!";
          return true;
       }
     }
    
     // check top left to lower right diagonal
     val0 = _gel('b0_0').value;
     val1 = _gel('b1_1').value;
     val2 = _gel('b2_2').value;
     if(val0 == 'X' && val1 == 'X' && val2 == 'X')
     {
       status.innerText = "X WINS!";
       return true;
     }
     else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
     {
       status.innerText = "O WINS!";
       return true;
     }
    
     // check lower left to top right diagonal
     val0 = _gel('b2_0').value;
     val1 = _gel('b1_1').value;
     val2 = _gel('b0_2').value;
     if(val0 == 'X' && val1 == 'X' && val2 == 'X')
     {
       status.innerText = "X WINS!";
     return true;
     }
     else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
     {
       status.innerText = "O WINS!";
       return true;
     }
    
     // no winner yet  return false;
    }
    Im doin a google gadget and having prob with my _gel
    this is a tic toe game
    firstly (i put in comment) is that i cant get the status
    second is i want to get the y value of my label name( my labels for playin are labeled as b0_0 b0_1 as so forth)
    the sdk says object expected
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    How is the _gel function defined?

    Comment

    • 1051109210
      New Member
      • Mar 2007
      • 29

      #3
      i var val0 earlier then val0=_gel...... ...

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        I can see that, but can you post the code for it.

        Comment

        • 1051109210
          New Member
          • Mar 2007
          • 29

          #5
          huh sorry i dont quite understn

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You've posted the code for the checkWin function, but some of the statements use a _gel function. Can you post the code for that too?

            Comment

            • 1051109210
              New Member
              • Mar 2007
              • 29

              #7
              Oh sorry I found out my prob. The method document.getEle mentsById() is specific to DOM interaction in the browser. Google Desktop does not support these DOM calls.
              Thank you for your concern in lookin into this though!
              cheers!

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Thanks for that information. I would assume that was in the _gel() function. Just to point out that it's document.getEle mentById() (with no "s").

                Finally, as a matter of interest, what's the alternative for Google Desktop?

                Comment

                • 1051109210
                  New Member
                  • Mar 2007
                  • 29

                  #9
                  Hahah i did it the very simple way ....novice way by calling the elements one by one... not actually overcomin the document/_gel way but i got my work done

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Thanks. You never know who and how many it may help.

                    Comment

                    Working...