Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
Line 24: | Line 24: | ||
mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' ); |
mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' ); |
||
$( '#megaheader img' ).css( 'opacity', 1 ); /* Thank you Jack Phoenix! */ |
$( '#megaheader img' ).css( 'opacity', 1 ); /* Thank you Jack Phoenix! */ |
||
− | }); |
||
− | |||
− | /** |
||
− | * Diverses fonctions manipulant les classes |
||
− | * Utilise des expressions régulières et un cache pour de meilleures perfs |
||
− | * isClass et whichClass depuis http://fr.wikibooks.org/w/index.php?title=MediaWiki:Common.js&oldid=140211 |
||
− | * hasClass, addClass, removeClass et eregReplace depuis http://drupal.org.in/doc/misc/drupal.js.source.html |
||
− | * surveiller l'implémentation de .classList http://www.w3.org/TR/2008/WD-html5-diff-20080122/#htmlelement-extensions |
||
− | */ |
||
− | function isClass(element, classe) { |
||
− | return hasClass(element, classe); |
||
− | } |
||
− | |||
− | function whichClass(element, classes) { |
||
− | var s=" "+element.className+" "; |
||
− | for(var i=0;i<classes.length;i++) |
||
− | if (s.indexOf(" "+classes[i]+" ")>=0) return i; |
||
− | return -1; |
||
− | } |
||
− | |||
− | function hasClass(node, className) { |
||
− | var haystack = node.className; |
||
− | if(!haystack) return false; |
||
− | if (className === haystack) { |
||
− | return true; |
||
− | } |
||
− | return (" " + haystack + " ").indexOf(" " + className + " ") > -1; |
||
− | } |
||
− | |||
− | function addClass(node, className) { |
||
− | if (hasClass(node, className)) { |
||
− | return false; |
||
− | } |
||
− | var cache = node.className; |
||
− | if (cache) { |
||
− | node.className = cache + ' ' + className; |
||
− | } else { |
||
− | node.className = className; |
||
− | } |
||
− | return true; |
||
− | } |
||
− | |||
− | function removeClass(node, className) { |
||
− | if (!hasClass(node, className)) { |
||
− | return false; |
||
− | } |
||
− | node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className); |
||
− | return true; |
||
− | } |
||
− | |||
− | function eregReplace(search, replace, subject) { |
||
− | return subject.replace(new RegExp(search,'g'), replace); |
||
− | } |
||
− | |||
− | /* Turning the regular pages into talk pages */ |
||
− | function TransformeEnDiscussion() { |
||
− | if( (wgPageName.search('Wikimedia_Canada:Discussions_in_English') != -1) |
||
− | || (wgPageName.search('Wikimedia_Canada:Discussions_en_français') != -1) |
||
− | || document.getElementById('transformeEnPageDeDiscussion')) { |
||
− | removeClass(document.body, 'ns-subject'); |
||
− | addClass(document.body, 'ns-talk'); |
||
− | } |
||
− | } |
||
− | addOnloadHook(TransformeEnDiscussion); |
||
− | |||
− | // Update from https://tools.wmflabs.org/intuition/wpAvailableLanguages.js.php - Last update: Fri, 06 Mar 2015 22:58:41 +0000 |
||
− | window.wpAvailableLanguages={"aa":"Qafár af","ab":"Аҧсшәа","ace":"Acèh","aeb":"تونسي","af":"Afrikaans","ak":"Akan","aln":"Gegë","als":"Alemannisch","am":"አማርኛ","an":"aragonés","ang":"Ænglisc","anp":"अङ्गिका","ar":"العربية","arc":"ܐܪܡܝܐ","arn":"mapudungun","arq":"جازايرية","ary":"Maġribi","arz":"مصرى","as":"অসমীয়া","ast":"asturianu","av":"авар","avk":"Kotava","ay":"Aymar aru","az":"azərbaycanca","azb":"تورکجه","ba":"башҡортса","bar":"Boarisch","bat-smg":"žemaitėška","bbc":"Batak Toba","bbc-latn":"Batak Toba","bcc":"بلوچی مکرانی","bcl":"Bikol Central","be":"беларуская","be-tarask":"беларуская (тарашкевіца)","be-x-old":"беларуская (тарашкевіца)","bg":"български","bgn":"بلوچی رخشانی","bh":"भोजपुरी","bho":"भोजपुरी","bi":"Bislama","bjn":"Bahasa Banjar","bm":"bamanankan","bn":"বাংলা","bo":"བོད་ཡིག","bpy":"বিষ্ণুপ্রিয়া মণিপুরী","bqi":"بختياري","br":"brezhoneg","brh":"Bráhuí","bs":"bosanski","bto":"Iriga Bicolano","bug":"ᨅᨔ ᨕᨘᨁᨗ","bxr":"буряад","ca":"català","cbk-zam":"Chavacano de Zamboanga","cdo":"Mìng-dĕ̤ng-ngṳ̄","ce":"нохчийн","ceb":"Cebuano","ch":"Chamoru","cho":"Choctaw","chr":"ᏣᎳᎩ","chy":"Tsetsêhestâhese","ckb":"کوردی","co":"corsu","cps":"Capiceño","cr":"Nēhiyawēwin \/ ᓀᐦᐃᔭᐍᐏᐣ","crh":"qırımtatarca","crh-cyrl":"къырымтатарджа (Кирилл)","crh-latn":"qırımtatarca (Latin)","cs":"čeština","csb":"kaszëbsczi","cu":"словѣньскъ \/ ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ","cv":"Чӑвашла","cy":"Cymraeg","da":"dansk","de":"Deutsch","de-at":"Österreichisches Deutsch","de-ch":"Schweizer Hochdeutsch","de-formal":"Deutsch (Sie-Form)","diq":"Zazaki","dsb":"dolnoserbski","dtp":"Dusun Bundu-liwan","dv":"ދިވެހިބަސް","dz":"ཇོང་ཁ","ee":"eʋegbe","egl":"Emiliàn","el":"Ελληνικά","eml":"emiliàn e rumagnòl","en":"English","eo":"Esperanto","es":"español","et":"eesti","eu":"euskara","ext":"estremeñu","fa":"فارسی","ff":"Fulfulde","fi":"suomi","fit":"meänkieli","fiu-vro":"Võro","fj":"Na Vosa Vakaviti","fo":"føroyskt","fr":"français","frc":"français cadien","frp":"arpetan","frr":"Nordfriisk","fur":"furlan","fy":"Frysk","ga":"Gaeilge","gag":"Gagauz","gan":"贛語","gan-hans":"赣语(简体)","gan-hant":"贛語(繁體)","gd":"Gàidhlig","gl":"galego","glk":"گیلکی","gn":"Avañe'ẽ","gom-latn":"Konknni","got":"\ud800\udf32\ud800\udf3f\ud800\udf44\ud800\udf39\ud800\udf43\ud800\udf3a","grc":"Ἀρχαία ἑλληνικὴ","gsw":"Alemannisch","gu":"ગુજરાતી","gv":"Gaelg","ha":"Hausa","hak":"客家語\/Hak-kâ-ngî","haw":"Hawai`i","he":"עברית","hi":"हिन्दी","hif":"Fiji Hindi","hif-latn":"Fiji Hindi","hil":"Ilonggo","ho":"Hiri Motu","hr":"hrvatski","hrx":"Hunsrik","hsb":"hornjoserbsce","ht":"Kreyòl ayisyen","hu":"magyar","hy":"Հայերեն","hz":"Otsiherero","ia":"interlingua","id":"Bahasa Indonesia","ie":"Interlingue","ig":"Igbo","ii":"ꆇꉙ","ik":"Iñupiak","ike-cans":"ᐃᓄᒃᑎᑐᑦ","ike-latn":"inuktitut","ilo":"Ilokano","inh":"ГӀалгӀай","io":"Ido","is":"íslenska","it":"italiano","iu":"ᐃᓄᒃᑎᑐᑦ\/inuktitut","ja":"日本語","jam":"Patois","jbo":"Lojban","jut":"jysk","jv":"Basa Jawa","ka":"ქართული","kaa":"Qaraqalpaqsha","kab":"Taqbaylit","kbd":"Адыгэбзэ","kbd-cyrl":"Адыгэбзэ","kg":"Kongo","khw":"کھوار","ki":"Gĩkũyũ","kiu":"Kırmancki","kj":"Kwanyama","kk":"қазақша","kk-arab":"قازاقشا (تٴوتە)","kk-cn":"قازاقشا (جۇنگو)","kk-cyrl":"қазақша (кирил)","kk-kz":"қазақша (Қазақстан)","kk-latn":"qazaqşa (latın)","kk-tr":"qazaqşa (Türkïya)","kl":"kalaallisut","km":"ភាសាខ្មែរ","kn":"ಕನ್ನಡ","ko":"한국어","ko-kp":"한국어 (조선)","koi":"Перем Коми","kr":"Kanuri","krc":"къарачай-малкъар","kri":"Krio","krj":"Kinaray-a","ks":"कॉशुर \/ کٲشُر","ks-arab":"کٲشُر","ks-deva":"कॉशुर","ksh":"Ripoarisch","ku":"Kurdî","ku-arab":"كوردي (عەرەبی)","ku-latn":"Kurdî (latînî)","kv":"коми","kw":"kernowek","ky":"Кыргызча","la":"Latina","lad":"Ladino","lb":"Lëtzebuergesch","lbe":"лакку","lez":"лезги","lfn":"Lingua Franca Nova","lg":"Luganda","li":"Limburgs","lij":"Ligure","liv":"Līvõ kēļ","lmo":"lumbaart","ln":"lingála","lo":"ລາວ","loz":"Silozi","lrc":"لوری","lt":"lietuvių","ltg":"latgaļu","lus":"Mizo ţawng","lv":"latviešu","lzh":"文言","lzz":"Lazuri","mai":"मैथिली","map-bms":"Basa Banyumasan","mdf":"мокшень","mg":"Malagasy","mh":"Ebon","mhr":"олык марий","mi":"Māori","min":"Baso Minangkabau","mk":"македонски","ml":"മലയാളം","mn":"монгол","mo":"молдовеняскэ","mr":"मराठी","mrj":"кырык мары","ms":"Bahasa Melayu","mt":"Malti","mus":"Mvskoke","mwl":"Mirandés","my":"မြန်မာဘာသာ","myv":"эрзянь","mzn":"مازِرونی","na":"Dorerin Naoero","nah":"Nāhuatl","nan":"Bân-lâm-gú","nap":"Napulitano","nb":"norsk bokmål","nds":"Plattdüütsch","nds-nl":"Nedersaksies","ne":"नेपाली","new":"नेपाल भाषा","ng":"Oshiwambo","niu":"Niuē","nl":"Nederlands","nl-informal":"Nederlands (informeel)","nn":"norsk nynorsk","no":"norsk bokmål","nov":"Novial","nrm":"Nouormand","nso":"Sesotho sa Leboa","nv":"Diné bizaad","ny":"Chi-Chewa","oc":"occitan","om":"Oromoo","or":"ଓଡ଼ିଆ","os":"Ирон","pa":"ਪੰਜਾਬੀ","pag":"Pangasinan","pam":"Kapampangan","pap":"Papiamentu","pcd":"Picard","pdc":"Deitsch","pdt":"Plautdietsch","pfl":"Pälzisch","pi":"पालि","pih":"Norfuk \/ Pitkern","pl":"polski","pms":"Piemontèis","pnb":"پنجابی","pnt":"Ποντιακά","prg":"Prūsiskan","ps":"پښتو","pt":"português","pt-br":"português do Brasil","qu":"Runa Simi","qug":"Runa shimi","rgn":"Rumagnôl","rif":"Tarifit","rm":"rumantsch","rmy":"Romani","rn":"Kirundi","ro":"română","roa-rup":"armãneashti","roa-tara":"tarandíne","ru":"русский","rue":"русиньскый","rup":"armãneashti","ruq":"Vlăheşte","ruq-cyrl":"Влахесте","ruq-latn":"Vlăheşte","rw":"Kinyarwanda","sa":"संस्कृतम्","sah":"саха тыла","sat":"Santali","sc":"sardu","scn":"sicilianu","sco":"Scots","sd":"سنڌي","sdc":"Sassaresu","se":"sámegiella","sei":"Cmique Itom","ses":"Koyraboro Senni","sg":"Sängö","sgs":"žemaitėška","sh":"srpskohrvatski \/ српскохрватски","shi":"Tašlḥiyt\/ⵜⴰⵛⵍⵃⵉⵜ","shi-latn":"Tašlḥiyt","shi-tfng":"ⵜⴰⵛⵍⵃⵉⵜ","si":"සිංහල","simple":"Simple English","sk":"slovenčina","sl":"slovenščina","sli":"Schläsch","sm":"Gagana Samoa","sma":"Åarjelsaemien","sn":"chiShona","so":"Soomaaliga","sq":"shqip","sr":"српски \/ srpski","sr-ec":"српски (ћирилица)","sr-el":"srpski (latinica)","srn":"Sranantongo","ss":"SiSwati","st":"Sesotho","stq":"Seeltersk","su":"Basa Sunda","sv":"svenska","sw":"Kiswahili","szl":"ślůnski","ta":"தமிழ்","tcy":"ತುಳು","te":"తెలుగు","tet":"tetun","tg":"тоҷикӣ","tg-cyrl":"тоҷикӣ","tg-latn":"tojikī","th":"ไทย","ti":"ትግርኛ","tk":"Türkmençe","tl":"Tagalog","tly":"толышә зывон","tn":"Setswana","to":"lea faka-Tonga","tokipona":"Toki Pona","tpi":"Tok Pisin","tr":"Türkçe","tru":"Ṫuroyo","ts":"Xitsonga","tt":"татарча\/tatarça","tt-cyrl":"татарча","tt-latn":"tatarça","tum":"chiTumbuka","tw":"Twi","ty":"reo tahiti","tyv":"тыва дыл","tzm":"ⵜⴰⵎⴰⵣⵉⵖⵜ","udm":"удмурт","ug":"ئۇيغۇرچە \/ Uyghurche","ug-arab":"ئۇيغۇرچە","ug-latn":"Uyghurche","uk":"українська","ur":"اردو","uz":"oʻzbekcha\/ўзбекча","uz-cyrl":"ўзбекча","uz-latn":"oʻzbekcha","ve":"Tshivenda","vec":"vèneto","vep":"vepsän kel’","vi":"Tiếng Việt","vls":"West-Vlams","vmf":"Mainfränkisch","vo":"Volapük","vot":"Vaďďa","vro":"Võro","wa":"walon","war":"Winaray","wo":"Wolof","wuu":"吴语","xal":"хальмг","xh":"isiXhosa","xmf":"მარგალური","yi":"ייִדיש","yo":"Yorùbá","yue":"粵語","za":"Vahcuengh","zea":"Zeêuws","zh":"中文","zh-classical":"文言","zh-cn":"中文(中国大陆)","zh-hans":"中文(简体)","zh-hant":"中文(繁體)","zh-hk":"中文(香港)","zh-min-nan":"Bân-lâm-gú","zh-mo":"中文(澳門)","zh-my":"中文(马来西亚)","zh-sg":"中文(新加坡)","zh-tw":"中文(台灣)","zh-yue":"粵語","zu":"isiZulu"}; |
||
− | |||
− | /** |
||
− | * AnonymousI18N |
||
− | * |
||
− | * Internationalisation for anonymous users. |
||
− | * |
||
− | * @author [[User:Krinkle]] |
||
− | * @stats [[File:Krinkle_AnonymousI18N.js]] |
||
− | */ |
||
− | mw.loader.using( 'mediawiki.user', function () { |
||
− | if ( mw.user.isAnon() ) { |
||
− | mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:AnonymousI18N.js&action=raw&ctype=text/javascript' ); |
||
− | } |
||
}); |
}); |
Revision as of 18:32, 3 February 2020
/* Interface modifications for anonymous users */
function removeSidebarSection(section) {
try {
var target = "p-" + section;
var sidebar = document.getElementById("mw-panel");
var element = document.getElementById(target);
sidebar.removeChild(element);
} catch (e) {
return;
}
}
function customizeSidebarForAnon() {
removeSidebarSection("tb");
}
if (wgUserName == null) {
addOnloadHook(customizeSidebarForAnon);
}
/* Add a few links to the toolbox */
addOnloadHook(function() {
mw.util.addPortletLink( 'p-tb', '/wiki/Special:RecentChanges', 'Recent changes', 't-recentchanges', 'Recent changes ', 'r', '#t-recentchangeslinked' );
$( '#megaheader img' ).css( 'opacity', 1 ); /* Thank you Jack Phoenix! */
});