MediaWiki:Onlyifediting.js
El Komunejo
(Malsamoj inter versioj)
E (2 versioj: Sistemaj paĝetoj) |
E (aldono) |
||
(4 mezaj versioj ne montrata.) | |||
Linio 1: | Linio 1: | ||
+ | //<source lang="javascript"> | ||
+ | /* z monobook.js wužiwarja Tlustulimu */ | ||
+ | /* z / from enwikt */ | ||
+ | function addLoadEvent(func) | ||
+ | { | ||
+ | if (window.addEventListener) | ||
+ | window.addEventListener("load", func, false); | ||
+ | else if (window.attachEvent) | ||
+ | window.attachEvent("onload", func); | ||
+ | } | ||
+ | |||
+ | /* z / from enwikit */ | ||
+ | //Cookie helpers | ||
+ | function setCookie(cookieName, cookieValue) { | ||
+ | var today = new Date(); | ||
+ | var expire = new Date(); | ||
+ | var nDays = 30; | ||
+ | expire.setTime( today.getTime() + (3600000 * 24 * nDays) ); | ||
+ | document.cookie = cookieName + "=" + escape(cookieValue) | ||
+ | + ";path=/w" | ||
+ | + ";expires="+expire.toGMTString(); | ||
+ | document.cookie = cookieName + "=" + escape(cookieValue) | ||
+ | + ";path=/wiki" | ||
+ | + ";expires="+expire.toGMTString(); | ||
+ | } | ||
+ | |||
+ | function getCookie(cookieName) { | ||
+ | var start = document.cookie.indexOf( cookieName + "=" ); | ||
+ | if ( start == -1 ) return ""; | ||
+ | var len = start + cookieName.length + 1; | ||
+ | if ( ( !start ) && | ||
+ | ( cookieName != document.cookie.substring( 0, cookieName.length ) ) ) | ||
+ | { | ||
+ | return ""; | ||
+ | } | ||
+ | var end = document.cookie.indexOf( ";", len ); | ||
+ | if ( end == -1 ) end = document.cookie.length; | ||
+ | return unescape( document.cookie.substring( len, end ) ); | ||
+ | } | ||
+ | |||
+ | function deleteCookie(cookieName) { | ||
+ | if ( getCookie(cookieName) ) { | ||
+ | document.cookie = cookieName + "=" + ";path=/w" + | ||
+ | ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; | ||
+ | document.cookie = cookieName + "=" + ";path=/wiki" + | ||
+ | ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; | ||
+ | } | ||
+ | } | ||
+ | |||
// Opcioj por la redaktilo por specialaj signoj in [[MediaWiki:Edittools]] | // Opcioj por la redaktilo por specialaj signoj in [[MediaWiki:Edittools]] | ||
// ĝi estas alligita je la fino de [[MediaWiki:Monobook.js]] | // ĝi estas alligita je la fino de [[MediaWiki:Monobook.js]] | ||
Linio 6: | Linio 55: | ||
if (specialchars) { | if (specialchars) { | ||
- | var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">"; | + | var menu = "<select id=\"charSubsetControl\" style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">"; |
- | menu += "<option> | + | menu += "<option>Esperanto</option>"; |
menu += "<option>Vikisintakso</option>"; | menu += "<option>Vikisintakso</option>"; | ||
- | menu += "<option> | + | menu += "<option value=\"Latina\">Latinidaj</option>"; |
- | menu += "<option> | + | menu += "<option>Greka</option>"; |
- | menu += "<option> | + | menu += "<option>Cirila</option>"; |
menu += "<option>Araba</option>"; | menu += "<option>Araba</option>"; | ||
- | menu += "<option> | + | menu += "<option value=\"AHD\">AHD-alfabeto</option>"; |
+ | menu += "<option value=\"Czech\">Ĉeĥa</option>"; | ||
menu += "<option>Cigana</option>"; | menu += "<option>Cigana</option>"; | ||
- | |||
- | |||
- | |||
- | |||
menu += "<option>Estona</option>"; | menu += "<option>Estona</option>"; | ||
menu += "<option>Franca</option>"; | menu += "<option>Franca</option>"; | ||
- | menu += "<option> | + | menu += "<option>Germana</option>"; |
- | + | ||
- | + | ||
menu += "<option>Havaja</option>"; | menu += "<option>Havaja</option>"; | ||
+ | menu += "<option>Hieroglifoj</option>"; | ||
menu += "<option>Hispana</option>"; | menu += "<option>Hispana</option>"; | ||
menu += "<option>Hungara</option>"; | menu += "<option>Hungara</option>"; | ||
menu += "<option>Islanda</option>"; | menu += "<option>Islanda</option>"; | ||
menu += "<option>Itala</option>"; | menu += "<option>Itala</option>"; | ||
- | |||
menu += "<option>Kataluna</option>"; | menu += "<option>Kataluna</option>"; | ||
- | menu += "<option>Latva</option>"; | + | menu += "<option>Kimra</option>"; |
- | menu += "<option>Litova</option>"; | + | menu += "<option>Kroata</option>"; |
+ | menu += "<option value=\"Let\">Latva</option>"; | ||
+ | menu += "<option value=\"Lit\">Litova</option>"; | ||
menu += "<option>Malnovangla</option>"; | menu += "<option>Malnovangla</option>"; | ||
- | menu += "<option>Malteza</option>"; | + | menu += "<option value=\"Malta\">Malteza</option>"; |
- | menu += "<option>Pinyin (ĉina latina)</option>"; | + | menu += "<option value=\"Pinjina\">Pinyin (ĉina latina)</option>"; |
menu += "<option>Pola</option>"; | menu += "<option>Pola</option>"; | ||
menu += "<option>Portugala</option>"; | menu += "<option>Portugala</option>"; | ||
+ | menu += "<option>Romaji</option>"; | ||
menu += "<option>Rumana</option>"; | menu += "<option>Rumana</option>"; | ||
- | menu += "<option>Serba (cirila)</option>"; | + | menu += "<option value=\"Serba\">Serba (cirila)</option>"; |
menu += "<option>Skandinava</option>"; | menu += "<option>Skandinava</option>"; | ||
menu += "<option>Slovaka</option>"; | menu += "<option>Slovaka</option>"; | ||
+ | menu += "<option>Soraba</option>"; | ||
menu += "<option>Turka</option>"; | menu += "<option>Turka</option>"; | ||
menu += "<option>Vjetnama</option>"; | menu += "<option>Vjetnama</option>"; | ||
+ | menu += "<option value=\"IPA\">IPA-alfabeto</option>"; | ||
menu += "</select>"; | menu += "</select>"; | ||
specialchars.innerHTML = menu + specialchars.innerHTML; | specialchars.innerHTML = menu + specialchars.innerHTML; | ||
- | // | + | /* default subset from cookie */ |
- | + | var s = parseInt( getCookie('edittoolscharsubset') ); | |
+ | if ( isNaN(s) ) s = 0; | ||
+ | |||
+ | /* update dropdown control to value of cookie */ | ||
+ | document.getElementById('charSubsetControl').selectedIndex = s; | ||
+ | |||
+ | /* display the subset indicated by the cookie */ | ||
+ | chooseCharSubset( s ); | ||
} | } | ||
} | } | ||
- | // | + | /* select subsection of special characters */ |
+ | function chooseCharSubset(s) { | ||
+ | var l = document.getElementById('specialchars').getElementsByTagName('p'); | ||
+ | for (var i = 0; i < l.length ; i++) { | ||
+ | l[i].style.display = i == s ? 'inline' : 'none'; | ||
+ | // l[i].style.visibility = i == s ? 'visible' : 'hidden'; | ||
+ | } | ||
+ | setCookie('edittoolscharsubset', s); | ||
+ | } | ||
+ | |||
+ | /* do any Wikipedia-specific customizations */ | ||
+ | /* from enwikt */ | ||
+ | function customizeWikipedia() { | ||
+ | // doRedirect(); | ||
+ | addCharSubsetMenu(); | ||
+ | // fixEditSectionWikifiedLinks(); | ||
+ | // wiktHeadingToolTips(); | ||
+ | } | ||
+ | |||
+ | addLoadEvent(customizeWikipedia); | ||
+ | |||
+ | //</source> |
Nuna versio ekde 20:04, 20. Dec 2009
//<source lang="javascript"> /* z monobook.js wužiwarja Tlustulimu */ /* z / from enwikt */ function addLoadEvent(func) { if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func); } /* z / from enwikit */ //Cookie helpers function setCookie(cookieName, cookieValue) { var today = new Date(); var expire = new Date(); var nDays = 30; expire.setTime( today.getTime() + (3600000 * 24 * nDays) ); document.cookie = cookieName + "=" + escape(cookieValue) + ";path=/w" + ";expires="+expire.toGMTString(); document.cookie = cookieName + "=" + escape(cookieValue) + ";path=/wiki" + ";expires="+expire.toGMTString(); } function getCookie(cookieName) { var start = document.cookie.indexOf( cookieName + "=" ); if ( start == -1 ) return ""; var len = start + cookieName.length + 1; if ( ( !start ) && ( cookieName != document.cookie.substring( 0, cookieName.length ) ) ) { return ""; } var end = document.cookie.indexOf( ";", len ); if ( end == -1 ) end = document.cookie.length; return unescape( document.cookie.substring( len, end ) ); } function deleteCookie(cookieName) { if ( getCookie(cookieName) ) { document.cookie = cookieName + "=" + ";path=/w" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; document.cookie = cookieName + "=" + ";path=/wiki" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } } // Opcioj por la redaktilo por specialaj signoj in [[MediaWiki:Edittools]] // ĝi estas alligita je la fino de [[MediaWiki:Monobook.js]] function addCharSubsetMenu() { var specialchars = document.getElementById('specialchars'); if (specialchars) { var menu = "<select id=\"charSubsetControl\" style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">"; menu += "<option>Esperanto</option>"; menu += "<option>Vikisintakso</option>"; menu += "<option value=\"Latina\">Latinidaj</option>"; menu += "<option>Greka</option>"; menu += "<option>Cirila</option>"; menu += "<option>Araba</option>"; menu += "<option value=\"AHD\">AHD-alfabeto</option>"; menu += "<option value=\"Czech\">Ĉeĥa</option>"; menu += "<option>Cigana</option>"; menu += "<option>Estona</option>"; menu += "<option>Franca</option>"; menu += "<option>Germana</option>"; menu += "<option>Havaja</option>"; menu += "<option>Hieroglifoj</option>"; menu += "<option>Hispana</option>"; menu += "<option>Hungara</option>"; menu += "<option>Islanda</option>"; menu += "<option>Itala</option>"; menu += "<option>Kataluna</option>"; menu += "<option>Kimra</option>"; menu += "<option>Kroata</option>"; menu += "<option value=\"Let\">Latva</option>"; menu += "<option value=\"Lit\">Litova</option>"; menu += "<option>Malnovangla</option>"; menu += "<option value=\"Malta\">Malteza</option>"; menu += "<option value=\"Pinjina\">Pinyin (ĉina latina)</option>"; menu += "<option>Pola</option>"; menu += "<option>Portugala</option>"; menu += "<option>Romaji</option>"; menu += "<option>Rumana</option>"; menu += "<option value=\"Serba\">Serba (cirila)</option>"; menu += "<option>Skandinava</option>"; menu += "<option>Slovaka</option>"; menu += "<option>Soraba</option>"; menu += "<option>Turka</option>"; menu += "<option>Vjetnama</option>"; menu += "<option value=\"IPA\">IPA-alfabeto</option>"; menu += "</select>"; specialchars.innerHTML = menu + specialchars.innerHTML; /* default subset from cookie */ var s = parseInt( getCookie('edittoolscharsubset') ); if ( isNaN(s) ) s = 0; /* update dropdown control to value of cookie */ document.getElementById('charSubsetControl').selectedIndex = s; /* display the subset indicated by the cookie */ chooseCharSubset( s ); } } /* select subsection of special characters */ function chooseCharSubset(s) { var l = document.getElementById('specialchars').getElementsByTagName('p'); for (var i = 0; i < l.length ; i++) { l[i].style.display = i == s ? 'inline' : 'none'; // l[i].style.visibility = i == s ? 'visible' : 'hidden'; } setCookie('edittoolscharsubset', s); } /* do any Wikipedia-specific customizations */ /* from enwikt */ function customizeWikipedia() { // doRedirect(); addCharSubsetMenu(); // fixEditSectionWikifiedLinks(); // wiktHeadingToolTips(); } addLoadEvent(customizeWikipedia); //</source>