Thanks for the help.  I'll try getting that to work.

On Sep 25, 8:34 am, Matt Foster <[EMAIL PROTECTED]> wrote:
> I don't believe that any object in preferences is going to save a DOM
> node.  You could serialize it into an HTML string and save that.
>
> On Sep 24, 3:50 pm, jamim <[EMAIL PROTECTED]> wrote:
>
> > I've now noticed that what appears to be saved, may not be what I
> > intended.  What is returned from prefs.getArray is a DocumentFragment
> > as expected, but it doesn't have any childNodes, which is unexpected.
> > Not sure how to view exactly what info is in there, but it doesn't
> > seem to be complete.
>
> > On Sep 24, 12:42 pm, jamim <[EMAIL PROTECTED]> wrote:
>
> > > Ya, I did create a new instance of the _IG_Prefs class at the
> > > beginning of my script.
>
> > > I tried setting the prefs array like you recommended - with the entire
> > > array and not each individual element but it didn't work either.
> > > Looks like that way, the array isn't even saved when I click on
> > > another tab and then back to the Playlist tab (the way it was working
> > > previously).
>
> > > I had though that the items would be added to the array individually
> > > based on the documentation 
> > > here:http://code.google.com/apis/gadgets/docs/legacy/fundamentals.html#list
> > > specifically, this line "For example, the following excerpt adds the
> > > values "Nokia" and "CNET" to the list: " when read in context, seemed
> > > to imply that.
>
> > > On Sep 24, 12:11 pm, Matt Foster <[EMAIL PROTECTED]> wrote:
>
> > > > You probably have done this as you noted it in the subject, but i
> > > > didn't see it in the code.  Although prefs is used throughout the
> > > > entire documentation, it is not actually a global variable in the
> > > > gadget environment.  It is an instance of the _IG_Prefs class.
>
> > > > var prefs = new _IG_Prefs();  // as noted you probably know this but
> > > > just covering the bases.
>
> > > > Where I think your real problem lies is in the prefs.setArray
> > > > execution.  It is expecting to receive the entire array, where you're
> > > > iterating over that array and sticking each item inside, this is in
> > > > essence overwriting the last value each iteration, not to mention the
> > > > fact that its the wrong data type, its expecting an array.
>
> > > > prefs.setArray("songArray", songArr);
>
> > > >http://code.google.com/apis/gadgets/docs/legacy/reference.html#Core
>
> > > > On Sep 23, 3:32 pm, jamim <[EMAIL PROTECTED]> wrote:
>
> > > > > I'm trying to save an array, and it is saving if I click on another
> > > > > tab and then back to this "Playlist" tab, but when the page is
> > > > > refreshed (and this tab is on a timer to refresh every 30 seconds) the
> > > > > array is lost.  The data that populates the array is retrieved from an
> > > > > xsl file and each element is a DocumentFragment (a fragment of a
> > > > > document tree). Here's my code:
>
> > > > > var xsltProcessor = new XSLTProcessor();
> > > > > xsltProcessor.importStylesheet(xsl);
> > > > > var song = xsltProcessor.transformToFragment(xml,document);
> > > > > songArr = prefs.getArray('songArray');
>
> > > > > // if there are already songs in array
> > > > > if(songArr.length > 0)
> > > > > {
> > > > >         var last_song = songArr.slice(songArr.length-1);
>
> > > > >         // if new song isn't already in array
> > > > >         if(last_song.childNodes[2].textContent !=
> > > > > song.childNodes[2].textContent)
> > > > >         {
> > > > >                 if(songArr.length != 5)         // if array isn't 
> > > > > "full"
> > > > >                 {
> > > > >                         songArr.push(song);
> > > > >                 }
> > > > >                 else
> > > > >                 {
> > > > >                         songArr.shift();
> > > > >                         songArr.push(song);
> > > > >                 }
> > > > >         }}
>
> > > > > else    // array is empty
> > > > > {
> > > > >         songArr.push(song);}
>
> > > > > document.getElementById(id).innerHTML = "";
> > > > > for(i=0; i<songArr.length; i++)
> > > > > {
> > > > >         document.getElementById(id).appendChild(songArr[i]);
> > > > >         prefs.setArray('songArray', songArr[i]);
>
> > > > > }
>
> > > > > As of now, only one song is ever getting output.  I'm trying to output
> > > > > 5.  The complete code for the gadget is 
> > > > > here:http://kexp-developing-gadget.googlecode.com/svn/trunk/kexp_rss_gadge...
>
> > > > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Gadgets-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to