|
|
(2 mellanliggande versioner av en annan användare visas inte) |
Rad 1: |
Rad 1: |
| // <pre><nowiki> | | /** |
| | * Dynamic Navigation Bars. See [[Wikipedia:NavFrame]] |
| | * |
| | * Based on script from en.wikipedia.org, 2008-09-15. |
| | * |
| | * @source www.mediawiki.org/wiki/MediaWiki:Gadget-NavFrame.js |
| | * @maintainer Helder.wiki, 2012–2013 |
| | * @maintainer Krinkle, 2013 |
| | */ |
| | ( function () { |
|
| |
|
| | // Set up the words in your language |
| | var collapseCaption = 'hide'; |
| | var expandCaption = 'show'; |
|
| |
|
| | var navigationBarHide = '[' + collapseCaption + ']'; |
| | var navigationBarShow = '[' + expandCaption + ']'; |
|
| |
|
| /* | | /** |
| OCR button
| | * Shows and hides content and picture (if available) of navigation bars. |
| */ | | * |
| | | * @param {number} indexNavigationBar The index of navigation bar to be toggled |
| function addOCR(form,value){
| | * @param {jQuery.Event} e Event object |
| if(value =="OCR"){
| | */ |
| form.elements["wpSummary"].value="/*OCR*/";
| | function toggleNavigationBar( indexNavigationBar, e ) { |
| s = form.elements["wpTextbox1"].value;
| | var navChild, |
| form.elements["wpTextbox1"].value="{"+"{"+"OCR"+"}"+"}";
| | navToggle = document.getElementById( 'NavToggle' + indexNavigationBar ), |
| }
| | navFrame = document.getElementById( 'NavFrame' + indexNavigationBar ); |
| }
| |
|
| |
| function addOCRButton(){
| |
|
| |
| if((wgCanonicalNamespace == "Page") && (!wgCurRevisionId) && (self.proofreadPageViewURL)){
| |
| | |
| var sb = document.getElementById("wpSave");
| |
| if(sb){
| |
| sb.parentNode.innerHTML = '<input id="wpOcr" name="ocr" type="submit" tabindex="5" accesskey="o" value="OCR" title="OCR" onclick="addOCR(this.form,this.value);"/>'+sb.parentNode.innerHTML;
| |
|
| |
| }
| |
| var msg = document.getElementById("noTextMsg");
| |
| if(msg){
| |
| s = msg.innerHTML;
| |
| s = s.replace(/vous pouvez <a href=(.*?)<\/a> ou (.*?)modifier cette page<\/a>\./g, 'vous pouvez ajouter le texte, ou demander une OCR automatique depuis la $2page d\'édition</a>.' );
| |
| msg.innerHTML=s;
| |
|
| |
| }
| |
| var msg = document.getElementById("msgNewarticletext");
| |
| if(msg){
| |
| msg.innerHTML='You are editing a page that does not exist.<br/>You may request an OCR by clicking on the OCR button at the bottom of this page.';
| |
| }
| |
|
| |
|
| |
| }
| |
| }
| |
| //addOnloadHook(addOCRButton);
| |
| | |
| var proofreadpage_debug=1;
| |
| | |
| /**********************
| |
| *** Undocumented
| |
| *** by unknown
| |
| **********************/
| |
| | |
| function interwikiExtra() { | |
| // iterate over all <span>-elements | |
| for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
| |
| // if found a linkInfo span
| |
| if(a.className == "interwiki-info") { | |
| // iterate over all <li>-elements
| |
| var count=0;
| |
|
| |
| for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
| |
| if(b.className == "interwiki-" + a.id) {
| |
| b.innerHTML = b.innerHTML + " "+a.title;
| |
| if(a.title == "(vo)") {
| |
| b.title = "Texte original";
| |
| }
| |
| }
| |
| else if(b.className == "interwiki-" + a.id.substr(0,a.id.length-1)) {
| |
| count = count+1;
| |
| if(a.id.charAt(a.id.length-1) == count) {
| |
| b.innerHTML = b.innerHTML + " "+a.title;
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| | |
| addOnloadHook(interwikiExtra);
| |
| | |
| /**********************
| |
| *** Quality indicators on "article" tab
| |
| *** by [[user:ThomasV]]
| |
| **********************/
| |
| function icon_src(t){
| |
| var src='';
| |
| switch(t){
| |
| case "0%": src='http://upload.wikimedia.org/wikipedia/commons/8/8f/00%25.png'; break;
| |
| case "25%": src='http://upload.wikimedia.org/wikipedia/commons/5/5b/25%25.png'; break;
| |
| case "50%": src='http://upload.wikimedia.org/wikipedia/commons/3/3a/50%25.png'; break;
| |
| case "75%": src='http://upload.wikimedia.org/wikipedia/commons/c/cd/75%25.png'; break;
| |
| case "100%": src='http://upload.wikimedia.org/wikipedia/commons/6/64/100%25.png'; break;
| |
| }
| |
| return src;
| |
| }
| |
|
| |
|
| function pageQuality() {
| | // Prevent browser from jumping to href "#" |
| var a = document.getElementById("ca-nstab-main"); | | e.preventDefault(); |
| if(!a) return; | |
|
| |
|
| var q = document.getElementById("textquality")
| | if ( !navFrame || !navToggle ) { |
| if(q) { | | return false; |
| var new_img = document.createElement("img"); | |
| new_img.setAttribute("src", icon_src(q.className));
| |
| a.firstChild.appendChild(new_img);
| |
| } | | } |
|
| |
|
| for(var i=0; spanElem = document.getElementsByTagName("span")[i]; i++) { | | // If shown now |
| if (spanElem.className == "pagequality") { | | if ( navToggle.firstChild.data === navigationBarHide ) { |
| var new_img = document.createElement("img"); | | for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) { |
| new_img.setAttribute("src", icon_src(spanElem.title));
| | if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) { |
|
| | navChild.style.display = 'none'; |
| if(wgCanonicalNamespace == "Page") {
| |
| a.firstChild.appendChild(new_img);
| |
| }
| |
| else {
| |
| s1 = spanElem.parentNode.previousSibling; | |
| opttext = s1.firstChild.firstChild;
| |
| img = opttext.firstChild.nextSibling.nextSibling.nextSibling;
| |
| next = img.nextSibling;
| |
| opttext.removeChild(img);
| |
| opttext.insertBefore(new_img,next);
| |
| } | | } |
| } | | } |
| }
| | navToggle.firstChild.data = navigationBarShow; |
| }
| |
|
| |
| addOnloadHook(pageQuality);
| |
|
| |
|
| | | // If hidden now |
| | | } else if ( navToggle.firstChild.data === navigationBarShow ) { |
| /**********************
| | for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) { |
| *** Add quality buttons on edit view
| | if ( $( navChild ).hasClass( 'NavContent' ) || $( navChild ).hasClass( 'NavPic' ) ) { |
| *** by [[user:ThomasV]]
| | navChild.style.display = 'block'; |
| **********************/
| | } |
| | |
| function addQuality(form,value){
| |
| var text="";
| |
| switch(value){
| |
| case "25%": text = "Incomplete"; break;
| |
| case "50%": text = "Not formatted"; break;
| |
| case "75%": text = "Complete and formatted"; break;
| |
| case "100%": text = "Proofread"; break;
| |
| }
| |
| form.elements["wpSummary"].value="/* "+text+" */";
| |
|
| |
| if(wgCanonicalNamespace == "Page") { | |
| s = form.elements["headerTextbox"].value;
| |
| s = s.replace(/\{\{PageQuality\|(.*?)\}\}/gi,"")
| |
| form.elements["headerTextbox"].value="{"+"{PageQuality|"+value+"}"+"}"+s;
| |
|
| |
| } | |
| else {
| |
| s = form.elements["wpTextbox1"].value;
| |
| s = s.replace(/\{\{TextQuality\|(.*?)\}\}/gi,"")
| |
| form.elements["wpTextbox1"].value="{"+"{TextQuality|"+value+"}"+"}"+s;
| |
| }
| |
| }
| |
| | |
| | |
| | |
| function addQualityButtons(){
| |
| if( wgNamespaceNumber != 0) {
| |
| return;
| |
| }
| |
| var ig = document.getElementById("wpWatchthis");
| |
| if(ig) {
| |
| var f = document.createElement("span"); | |
| f.innerHTML = ' <input type="radio" name="quality" value="25%" onclick="addQuality(this.form,this.value)"><img src = "/wiki/Special:Filepath/25%25.png">'+'<input type="radio" name="quality" value="50%" onclick="addQuality(this.form,this.value)"><img src = "/wiki/Special:Filepath/50%25.png">'+'<input type="radio" name="quality" value="75%" onclick="addQuality(this.form,this.value)"><img src = "/wiki/Special:Filepath/75%25.png">'+'<input type="radio" name="quality" value="100%" onclick="addQuality(this.form,this.value)"><img src = "/wiki/Special:Filepath/100%25.png"> Text advancement';
| |
| ig.parentNode.insertBefore(f,ig.nextSibling.nextSibling.nextSibling)
| |
| }
| |
| }
| |
| | |
| addOnloadHook(addQualityButtons);
| |
| | |
| /**********************
| |
| *** Add arrows on sidebar to compare current page to interlanguage link'd page
| |
| *** by [[user:Pathoschild]], based on older script by unknown
| |
| **********************/
| |
| | |
| function BilingualLink() {
| |
| if(document.getElementById('p-lang') != null) {
| |
| // get list of links
| |
| var biboxes = document.getElementById('p-lang').getElementsByTagName('li');
| |
| | |
| // iterate over links
| |
| for(var i=0; i<biboxes.length; i++) {
| |
| // get link | |
| var bilink = biboxes[i].getElementsByTagName('a')[0];
| |
| | |
| // create new URL
| |
| var bilang = bilink.getAttribute('href').match(/http:\/\/([^\.]+)\.wikisource/)[1];
| |
| var bilanglink = wgServer + '/wiki/' + wgPageName + '?match=' + bilang;
| |
| | |
| // create link
| |
| var bianchor = document.createElement('a');
| |
| bianchor.setAttribute('href',bilanglink);
| |
| bianchor.setAttribute('title','Compare this page with the '+bilang+' version.');
| |
| bianchor.appendChild(document.createTextNode(' ⇔'));
| |
| | |
| // add link | |
| biboxes[i].appendChild(bianchor);
| |
| } | | } |
| | navToggle.firstChild.data = navigationBarHide; |
| } | | } |
| } | | } |
|
| |
|
| addOnloadHook(BilingualLink);
| | /** |
| | * Adds show/hide-button to navigation bars. |
| | * |
| | * @param {jQuery} $content |
| | */ |
| | function createNavigationBarToggleButton( $content ) { |
| | var i, j, navChild, navToggle, navToggleText, isCollapsed, |
| | indexNavigationBar = 0; |
| | // iterate over all < div >-elements |
| | var $divs = $content.find( 'div.NavFrame' ); |
| | $divs.each( function ( i, navFrame ) { |
| | indexNavigationBar++; |
| | navToggle = document.createElement( 'a' ); |
| | navToggle.className = 'NavToggle'; |
| | navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar ); |
| | navToggle.setAttribute( 'href', '#' ); |
| | $( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) ); |
|
| |
|
| /**********************
| | isCollapsed = $( navFrame ).hasClass( 'collapsed' ); |
| *** add menu on edit page /for selecting subsets of secial characters
| | // backwards compatibility for old technique where the collapsed class was not yet used |
| *** by [[user:Pathoschild]]
| | for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) { |
| *** - note: must match MediaWiki:Edittools
| | if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) { |
| **********************/
| | if ( navChild.style.display === 'none' ) { |
| function addCharSubsetMenu() {
| | isCollapsed = true; |
| var specialchars = document.getElementById('specialchars');
| | } |
| | |
| if (specialchars) {
| |
| var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
| |
| menu += "<option>Select</option>"; | |
| menu += "<option>Ligatures and symbols</option>";
| |
| menu += "<option>Accents</option>"; | |
| menu += "<option>Tildes</option>";
| |
| menu += "<option>Cedillas</option>";
| |
| menu += "<option>Diareses</option>";
| |
| menu += "<option>Circumflexes</option>";
| |
| menu += "<option>Macrons</option>";
| |
| menu += "<option>Other diacritics</option>";
| |
| menu += "<option>Greek</option>";
| |
| menu += "<option>Hebrew</option>";
| |
| menu += "<option>Cyrillic</option>";
| |
| menu += "</select>";
| |
| specialchars.innerHTML = menu + specialchars.innerHTML.replace(/_newline_/gm, "\n");
| |
| | |
| /* default subset - try to use a cookie some day */
| |
| chooseCharSubset(0);
| |
| }
| |
| }
| |
| | |
| /* 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';
| |
| }
| |
| }
| |
| | |
| addOnloadHook(addCharSubsetMenu);
| |
| | |
| /**********************
| |
| *** Display options (see [[template:option]])
| |
| *** by [[user:ThomasV]]
| |
| **********************/
| |
| | |
| //Cookies
| |
| function SetCookie(name,value) {
| |
| document.cookie = name + "=" + escape(value);
| |
| } | |
| | |
| function GetCookie(name) {
| |
| var i =0;
| |
| while (i < document.cookie.length) {
| |
| if (document.cookie.substr(i,name.length) == name) {
| |
| var valend = document.cookie.indexOf(";",i+name.length+1);
| |
| if (valend == -1) {
| |
| valend = document.cookie.length;
| |
| } | | } |
| return unescape(document.cookie.substring(i+name.length+1,valend));
| |
| } | | } |
| i = document.cookie.indexOf(" ", i) + 1;
| | if ( isCollapsed ) { |
| if (i == 0) { | | for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) { |
| break; | | if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) { |
| }
| | navChild.style.display = 'none'; |
| }
| |
| }
| |
| | |
| function OptionText() {
| |
| var indexNavigationBar = 0;
| |
| // iterate over all < span >-elements until class "OptionText" is found
| |
| for(var i=0; SpanElem = document.getElementsByTagName("span")[i]; i++) {
| |
| // if found an option span
| |
| if (SpanElem.className == "OptionText") {
| |
| //SpanElem.style.display = 'none';
| |
| OptionTitle = SpanElem.title;
| |
| OptionStyle = SpanElem.firstChild.getAttribute('style');
| |
|
| |
| //check if option was already encountered...
| |
| if(!document.getElementById(OptionTitle)) {
| |
| //read cookie | |
| var DisplayOptionDefault = true;
| |
| CookieDisplayOption = GetCookie("Display"+OptionTitle);
| |
| if (CookieDisplayOption ) {
| |
| if (CookieDisplayOption == "false") {
| |
| DisplayOptionDefault = false;
| |
| }
| |
| }
| |
| var PageDisplay = document.createElement("li");
| |
| PageDisplay.setAttribute('id', OptionTitle);
| |
| var PageDisplayLink = document.createElement("a");
| |
| | |
| OptionText = document.createTextNode("Désactiver "+OptionTitle);
| |
| PageDisplayLink.appendChild(OptionText);
| |
| PageDisplayLink.setAttribute('href','javascript:displayOptionText("'+OptionTitle+'","' + OptionStyle +'", '+DisplayOptionDefault+');');
| |
| PageDisplay.appendChild(PageDisplayLink);
| |
| | |
| var optlist = document.getElementById("optlist");
| |
| if(!optlist) {
| |
| var displayOptions = document.createElement("div"); | |
| displayOptions.style.marginTop = "0.7em";
| |
| displayOptions.innerHTML = '<h5>display options<\/h5><div class="pBody"><ul id="optlist"></ul><\/div>';
| |
| document.getElementById("p-tb").appendChild(displayOptions);
| |
| optlist = document.getElementById("optlist");
| |
| } | | } |
| optlist.appendChild(PageDisplay);
| |
| displayOptionText(OptionTitle,OptionStyle,DisplayOptionDefault);
| |
| } | | } |
| } | | } |
| }
| | navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide ); |
| }
| | navToggle.appendChild( navToggleText ); |
|
| |
|
| function displayOptionText(optiontitle, optionstyle, bool) {
| | // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) |
| SetCookie ("Display"+optiontitle,bool);
| | for ( j = 0; j < navFrame.childNodes.length; j++ ) { |
| var PageDisplayLink = document.getElementById(optiontitle).firstChild;;
| | if ( $( navFrame.childNodes[j] ).hasClass( 'NavHead' ) ) { |
|
| | navToggle.style.color = navFrame.childNodes[j].style.color; |
| // iterate over all < span >-elements
| | navFrame.childNodes[j].appendChild( navToggle ); |
| for(var i=0; SpanElem = document.getElementsByTagName("span")[i]; i++) {
| |
| // if found an option text
| |
| if ((SpanElem.className == "OptionText") && (SpanElem.title == optiontitle)) {
| |
| if(bool==true ) {
| |
| SpanElem.setAttribute('style',optionstyle); | |
| PageDisplayLink.firstChild.data = (optiontitle);
| |
| PageDisplayLink.setAttribute('href', 'javascript:displayOptionText("'+optiontitle+'","'+optionstyle+'", false);');
| |
| }
| |
| if(bool==false) {
| |
| SpanElem.setAttribute('style','null');
| |
| PageDisplayLink.firstChild.data = (optiontitle); | |
| PageDisplayLink.setAttribute('href', 'javascript:displayOptionText("'+optiontitle+'","'+optionstyle+'", true);');
| |
| } | | } |
| } | | } |
| }
| | navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar ); |
| }
| | } ); |
| | |
| addOnloadHook(OptionText);
| |
| | |
| /**********************
| |
| *** Automatically generate page footer from values in {{header}}
| |
| *** by [[user:GrafZahl]]
| |
| **********************/
| |
| | |
| function DisplayFooter() {
| |
| if(document.getElementById && wgNamespaceNumber==0) {
| |
| nofooter = document.getElementById('nofooter');
| |
| hp = document.getElementById('headerprevious');
| |
| hn = document.getElementById('headernext'); | |
| content = document.getElementById('bodyContent');
| |
| catlinks = document.getElementById('catlinks');
| |
| footer = document.createElement('table');
| |
|
| |
| if((!((hp) && (hn) && (content) && (footer))) ||
| |
| (nofooter))
| |
| return;
| |
|
| |
| footer.setAttribute('class', 'headertemplate');
| |
| footer.setAttribute('id', 'footertemplate');
| |
|
| |
| /* Begin footer HTML code */
| |
| tr = document.createElement('tr');
| |
| td = document.createElement('td');
| |
| td.setAttribute('align', 'left');
| |
| td.setAttribute('width', '33%');
| |
|
| |
| fp = hp.cloneNode(true);
| |
| fp.setAttribute('id', 'footerprevious');
| |
| td.appendChild(fp);
| |
|
| |
| tr.appendChild(td);
| |
|
| |
| td = document.createElement('td');
| |
| td.setAttribute('align', 'center');
| |
| td.setAttribute('width', '34%');
| |
| a = document.createElement('a');
| |
| a.setAttribute('href', '#top');
| |
| text = document.createTextNode('Return to the top of the page.');
| |
| a.appendChild(text);
| |
| td.appendChild(a);
| |
| tr.appendChild(td);
| |
|
| |
| td = document.createElement('td');
| |
| td.setAttribute('align', 'right');
| |
| td.setAttribute('width', '33%');
| |
|
| |
| fn = hn.cloneNode(true);
| |
| fn.setAttribute('id', 'footernext');
| |
| td.appendChild(fn);
| |
|
| |
| tr.appendChild(td);
| |
|
| |
| footer.appendChild(tr);
| |
|
| |
| /* End footer HTML code */
| |
|
| |
| if(catlinks) // place footer before category box
| |
| content.insertBefore(footer, catlinks);
| |
| else
| |
| content.appendChild(footer);
| |
| }
| |
| } | | } |
|
| |
|
| addOnloadHook(DisplayFooter);
| | mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton ); |
| | |
| /*************
| |
| *** Execute JS file in MediaWiki namespace with &usejs parameter on any page
| |
| *** by [[m:user:Pathoschild]] <http://meta.wikimedia.org/wiki/User:Pathoschild/Scripts/Usejs>
| |
| *************/
| |
| document.write('<script type="text/javascript" src="'
| |
| + 'http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Usejs.js'
| |
| + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
| |
|
| |
|
| // </nowiki></pre>
| | }()); |