User:Tyrok1/monobook.js: Difference between revisions
Content added Content deleted
(Obvious typo) |
(Testing new version of language example link script) |
||
Line 5: | Line 5: | ||
Fe 4.0.280. |
Fe 4.0.280. |
||
========================================*/ |
========================================*/ |
||
function SectionLinkLoadFromStorage() |
|||
{ |
|||
⚫ | |||
{ |
|||
window.languageLinks = JSON.parse(localStorage.languageLinks); |
|||
} |
|||
} |
|||
function SectionLinkSaveToStorage() |
|||
{ |
|||
if((typeof localStorage != "undefined") && (typeof window.languageLinks != "undefined")) |
|||
{ |
|||
localStorage.languageLinks = JSON.stringify(window.languageLinks); |
|||
} |
|||
} |
|||
function SectionLinkCreateLoadClosure(request) |
function SectionLinkCreateLoadClosure(request) |
||
Line 13: | Line 29: | ||
//done loading |
//done loading |
||
//initialize the "languages with link information" array |
//initialize the "languages with link information" array |
||
if(typeof |
if(typeof window.languageLinks == "undefined") |
||
⚫ | |||
window.localStorage = new Array(); |
|||
} |
|||
⚫ | |||
{ |
{ |
||
window.languageLinks = new Array(); |
|||
} |
} |
||
Line 70: | Line 82: | ||
//add the language to our array for later use |
//add the language to our array for later use |
||
window.languageLinks[curTitle] = { aName: curAName, href: curHREF, title: curTitle }; |
|||
} |
} |
||
⚫ | |||
//save the link data to localStorage, if available |
|||
SectionLinkSaveToStorage(); |
|||
//and if we've got a function to call when we're done, call it |
//and if we've got a function to call when we're done, call it |
||
Line 116: | Line 131: | ||
return; |
return; |
||
} |
} |
||
//load stored data to reduce requests |
|||
SectionLinkLoadFromStorage(); |
|||
//check this page's "firstHeading" ID content for a category name |
//check this page's "firstHeading" ID content for a category name |
||
Line 127: | Line 145: | ||
//check to see if we already have link information about the current language |
//check to see if we already have link information about the current language |
||
if( |
if(window.languageLinks && window.languageLinks[langName]) |
||
{ |
{ |
||
//we do |
//we do |
||
Line 135: | Line 153: | ||
if(aEls[i].href.indexOf("#") < 0) |
if(aEls[i].href.indexOf("#") < 0) |
||
{ |
{ |
||
aEls[i].href += "#" + encodeURIComponent( |
aEls[i].href += "#" + encodeURIComponent(window.languageLinks[langName].aName); |
||
} |
} |
||
} |
} |