[TYPO3-dev] Set and read cookies
Tapio Markula
tapio.markula at xetpoint.fi
Wed Jul 16 23:06:35 CEST 2008
Tapio Markula
> that would be nice solution - one function istead of own function for
> every level and there would not be level restrictions. I have thought
> that too.
here the final HTML-code, which will be created by a plugin
function ReadCookie(cookieName) {
var theCookie=""+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=="") return "";
var ind1=theCookie.indexOf(";",ind);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
function saveLevel(value,level) {
var name = "menuCookieLevel_"+level;
var date = new Date();
date.setTime(date.getTime()+(24*60*60*1000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
var name2 = "level"+level+"PrevItem";
document.cookie = name2+"="+value+expires+"; path=/";
}
function closePrevLevel(value,level) {
name="level"+level+"PrevItem";
var previousItem = ReadCookie(name);
if(value!=previousItem) {
tx_dropdownsitemap_pi1_swapClassesClose(previousItem);
}
}
function clearCookieLevel(value,level) {
var name = "menuCookieLevel_"+level;
var date = new Date();
date.setTime(date.getTime()+(-(24*60*60*1000)));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
}
cookies allows to store to next page call current situation and close
previous opened menu in menus, which created by dropdown_sitemap.
expAll=1 + dynamic JS-based menu has huge disadvantage as normal menu
without cookies
More information about the TYPO3-dev
mailing list