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

Google Gadget

P: 29
Expand|Select|Wrap|Line Numbers
  1. function checkWin()
  2. var val0;
  3.  var val1;
  4.  var val2;
  5. var status = _gel(status);                 //prob here
  6.  
  7.  // check columns
  8.  for(var y = 0; y < 3; y++)
  9.  {
  10.    val0 = _gel('b0_'+y +".value");               //prob here
  11.         val1 = _gel('b1_'+y +".value");
  12.         val2 = _gel('b2_'+y +".value");
  13.  
  14. if(val0 == 'X' && val1 == 'X' && val2 == 'X')
  15.    {
  16.       status.innerText = "X WINS!";
  17.       return true;
  18.    }
  19.    else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
  20.    {
  21.       status.innerText = "O WINS!";
  22.       return true;
  23.    }
  24.  }
  25.  
  26.  // check rows
  27.  for(var x = 0; x < 3; x++)
  28.  {
  29.    val0 = _gel('b'+ x + '_0').value;
  30.    val1 = _gel('b'+ x + '_1').value;
  31.    val2 = _gel('b'+ x + '_2').value;
  32.    if(val0 == 'X' && val1 == 'X' && val2 == 'X')
  33.    {
  34.       status.innerText = "X WINS!";
  35.       return true;
  36.    }
  37.    else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
  38.    {
  39.       status.innerText = "O WINS!";
  40.       return true;
  41.    }
  42.  }
  43.  
  44.  // check top left to lower right diagonal
  45.  val0 = _gel('b0_0').value;
  46.  val1 = _gel('b1_1').value;
  47.  val2 = _gel('b2_2').value;
  48.  if(val0 == 'X' && val1 == 'X' && val2 == 'X')
  49.  {
  50.    status.innerText = "X WINS!";
  51.    return true;
  52.  }
  53.  else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
  54.  {
  55.    status.innerText = "O WINS!";
  56.    return true;
  57.  }
  58.  
  59.  // check lower left to top right diagonal
  60.  val0 = _gel('b2_0').value;
  61.  val1 = _gel('b1_1').value;
  62.  val2 = _gel('b0_2').value;
  63.  if(val0 == 'X' && val1 == 'X' && val2 == 'X')
  64.  {
  65.    status.innerText = "X WINS!";
  66.  return true;
  67.  }
  68.  else if(val0 == 'O' && val1 == 'O' && val2 == 'O')
  69.  {
  70.    status.innerText = "O WINS!";
  71.    return true;
  72.  }
  73.  
  74.  // no winner yet  return false;
  75. }
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
Jan 24 '09 #1
Share this Question
Share on Google+
9 Replies


acoder
Expert Mod 15k+
P: 16,027
How is the _gel function defined?
Jan 26 '09 #2

P: 29
i var val0 earlier then val0=_gel.........
Feb 7 '09 #3

acoder
Expert Mod 15k+
P: 16,027
I can see that, but can you post the code for it.
Feb 7 '09 #4

P: 29
huh sorry i dont quite understn
Feb 8 '09 #5

acoder
Expert Mod 15k+
P: 16,027
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?
Feb 9 '09 #6

P: 29
Oh sorry I found out my prob. The method document.getElementsById() 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!
Feb 10 '09 #7

acoder
Expert Mod 15k+
P: 16,027
Thanks for that information. I would assume that was in the _gel() function. Just to point out that it's document.getElementById() (with no "s").

Finally, as a matter of interest, what's the alternative for Google Desktop?
Feb 10 '09 #8

P: 29
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
Feb 11 '09 #9

acoder
Expert Mod 15k+
P: 16,027
Thanks. You never know who and how many it may help.
Feb 12 '09 #10

Post your reply

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