d.kyle.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-02 21:10 UTC
trying to find info on saving movable divs w/ cookies
problem: i have a page full of divs (a la iGoogle) that are movable. i need to be able to save the page layout pref. in cookies when the user leaves the page, so the divs will appear in the same configuration when they user comes back. so far my searches have been fruitless. i''m using sortables in script.aculo.us, and i think what i need might already be in the code someplace. but i''m a total n00b, so if anyone can point me in the right direction, i''d be much abliged. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Jul-02 21:20 UTC
Re: trying to find info on saving movable divs w/ cookies
Are you sure you want to store it in cookies, and not something more durable? In addition to the obvious issues of users rejecting/ deleting cookies, you''re limited to 20 per domain, an upper size limit of each cookie (4K), and the browser may limit the total number of cookies allowed across all sites. If storing the position is important, you may wish to put it in a db via Ajax calls. Check the docs for functions to get an element''s position. TAG On Jul 2, 2007, at 3:10 PM, d.kyle.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > problem: i have a page full of divs (a la iGoogle) that are movable. i > need to be able to save the page layout pref. in cookies when the user > leaves the page, so the divs will appear in the same configuration > when they user comes back. so far my searches have been fruitless. > > i''m using sortables in script.aculo.us, and i think what i need might > already be in the code someplace. but i''m a total n00b, so if anyone > can point me in the right direction, i''d be much abliged. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
1) You need to, without using cookies, be able to store your screen layout information in a single string. I suggest name/value pairs using a simple separator that you and then Split() to get back your data. 2) Re-build your screen layout using that same string. 3) Once you''ve mastered that then move onto storing the same data in a cookie, since cookies can only store strings. Here''s a few simple functions for reading/writing cookies. function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return "" } function setCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) } On Jul 2, 5:10 pm, "d.kyle.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <d.kyle.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> problem: i have a page full of divs (a la iGoogle) that are movable. i > need to be able to save the page layout pref. in cookies when the user > leaves the page, so the divs will appear in the same configuration > when they user comes back. so far my searches have been fruitless. > > i''m using sortables in script.aculo.us, and i think what i need might > already be in the code someplace. but i''m a total n00b, so if anyone > can point me in the right direction, i''d be much abliged.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
d.kyle.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-06 17:45 UTC
Re: trying to find info on saving movable divs w/ cookies
i would love to be able to store the information in a DB. unfortunately, i''d have more luck curing cancer than i would getting access to our DBs from the systems guys. however, the TOS of the app i''m building this for requires users to accept cookies, as we use them for other authentication purposes. so that''s not an issue. plus, my superiors prefer things done fast rather than done right, so i''m ok w/ quick and dirty. On Jul 2, 5:20 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> Are you sure you want to store it in cookies, and not something more > durable? In addition to the obvious issues of users rejecting/ > deleting cookies, you''re limited to 20 per domain, an upper size > limit of each cookie (4K), and the browser may limit the total number > of cookies allowed across all sites. If storing the position is > important, you may wish to put it in a db via Ajax calls. > > Check the docs for functions to get an element''s position. > > TAG > > On Jul 2, 2007, at 3:10 PM, d.kyle.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > problem: i have a page full of divs (a la iGoogle) that are movable. i > > need to be able to save the page layout pref. in cookies when the user > > leaves the page, so the divs will appear in the same configuration > > when they user comes back. so far my searches have been fruitless. > > > i''m using sortables in script.aculo.us, and i think what i need might > > already be in the code someplace. but i''m a total n00b, so if anyone > > can point me in the right direction, i''d be much abliged.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Jul-06 17:57 UTC
Re: trying to find info on saving movable divs w/ cookies
Allow me to provide a somewhat more helpful link to Prototype''s position functions: http://prototypejs.org/api/position FYI, one of the core developers just mentioned these functions will be moved to the Element namespace in version 1.6 I don''t know what that means for the future of Position namespace, i.e. whether they will keep it backwards compatible or not. TAG On Jul 6, 2007, at 11:45 AM, d.kyle.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > i would love to be able to store the information in a DB. > unfortunately, i''d have more luck curing cancer than i would getting > access to our DBs from the systems guys. however, the TOS of the app > i''m building this for requires users to accept cookies, as we use them > for other authentication purposes. so that''s not an issue. plus, my > superiors prefer things done fast rather than done right, so i''m ok w/ > quick and dirty. > > On Jul 2, 5:20 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: >> Are you sure you want to store it in cookies, and not something more >> durable? In addition to the obvious issues of users rejecting/ >> deleting cookies, you''re limited to 20 per domain, an upper size >> limit of each cookie (4K), and the browser may limit the total number >> of cookies allowed across all sites. If storing the position is >> important, you may wish to put it in a db via Ajax calls. >> >> Check the docs for functions to get an element''s position. >> >> TAG >> >> On Jul 2, 2007, at 3:10 PM, d.kyle.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >> >> >> >>> problem: i have a page full of divs (a la iGoogle) that are >>> movable. i >>> need to be able to save the page layout pref. in cookies when the >>> user >>> leaves the page, so the divs will appear in the same configuration >>> when they user comes back. so far my searches have been fruitless. >> >>> i''m using sortables in script.aculo.us, and i think what i need >>> might >>> already be in the code someplace. but i''m a total n00b, so if anyone >>> can point me in the right direction, i''d be much abliged. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---