User:Tyrok1/monobook.js: Difference between revisions

Let's try a cookie instead of an HTML5 data store
m (Another experiment)
(Let's try a cookie instead of an HTML5 data store)
Line 6:
========================================*/
 
function SectionLinkLoadFromStorageSectionLinkLoad()
{
//load cached language link info from the cookie
if((typeof localStorageJSON != "undefined") && (typeof localStorageJSON.languageLinksparse != "undefined"))
{
window.languageLinksvar cookieStart = JSONdocument.parse(localStoragecookie.getItemindexOf("languageLinks=")) || (new Object());
window.languageLinks = new Object();
if(cookieStart >= 0)
{
var cookieEnd = document.cookie.indexOf(";", cookieStart);
cookieStart += ("languageLinks=").length;
cookieEnd = (cookieEnd >= 0 ? cookieEnd : document.cookie.length);
var cookieVal = document.cookie.substring(cookieStart, cookieEnd);
window.languageLinks = JSON.parse(decodeURIComponent(cookieVal));
}
}
}
 
function SectionLinkSaveToStorageSectionLinkSave()
{
//save language link info to the cookie for later use
if((typeof localStorageJSON != "undefined") && (typeof windowJSON.languageLinksstringify != "undefined"))
{
localStorage.setItem("languageLinks",var data = encodeURIComponent(JSON.stringify(window.languageLinks));
document.cookie = "languageLinks=" + data;
}
}
Line 31 ⟶ 43:
if(typeof window.languageLinks == "undefined" || !window.languageLinks || !window.languageLinks.length)
{
window.languageLinks = new ArrayObject();
}
Line 85 ⟶ 97:
}
//save the link data to localStorage, if availablepossible,
//to reduce the number of requests
SectionLinkSaveToStorage();
SectionLinkSave();
//and if we've got a function to call when we're done, call it
Line 133 ⟶ 146:
//load stored data to reduce requests
SectionLinkLoad();
SectionLinkLoadFromStorage();
//check this page's "firstHeading" ID content for a category name
Anonymous user