Suradnik:Ivan Štambuk/monobook.js

Izvor: Wječnik

Napomena: Nakon objave možda ćete trebati očistiti međuspremnik svog preglednika kako biste vidjeli promjene.

  • Firefox / Safari: držite Shift i pritisnite Reload, ili pritisnite bilo Ctrl-F5 ili Ctrl-R (⌘-R na Macu)
  • Google Chrome: pritisnite Ctrl-Shift-R (⌘-Shift-R na Macu)
  • Internet Explorer / Edge: držite Ctrl i kliknite Refresh, ili pritisnite Ctrl-F5
  • Opera: pritisnite Ctrl-F5.
ta = new Object();
ta['pt-userpage'] = new Array('.','My user page');
ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re editing as');
ta['pt-mytalk'] = new Array('n','My talk page');
ta['pt-anontalk'] = new Array('n','Discussion about edits from this ip address');
ta['pt-preferences'] = new Array('','My preferences');
ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.');
ta['pt-mycontris'] = new Array('y','List of my contributions');
ta['pt-login'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-anonlogin'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-logout'] = new Array('o','Log out');
 
/* </pre>
===Tabs===
<pre> */
ta['ca-talk'] = new Array('t','Discussion about the content page');
ta['ca-edit'] = new Array('e','You can edit this page. Please use the preview button before saving.');
ta['ca-addsection'] = new Array('+','Add a comment to this discussion.');
ta['ca-viewsource'] = new Array('e','This page is protected. You can view its source.');
ta['ca-history'] = new Array('h','Past versions of this page.');
ta['ca-protect'] = new Array('=','Protect this page');
ta['ca-delete'] = new Array('d','Delete this page');
ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted');
ta['ca-move'] = new Array('m','Move this page');
ta['ca-nomove'] = new Array('','You don\'t have the permissions to move this page');
ta['ca-watch'] = new Array('w','Add this page to your watchlist');
ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist');
 
/* </pre>
===Left column Navigation bar===
<pre> */
ta['search'] = new Array('f','Search this wiki');
ta['p-logo'] = new Array('','Main Page');
ta['n-mainpage'] = new Array('z','Visit the Main Page');
ta['n-portal'] = new Array('','About the project, what you can do, where to find things');
/* ta['n-currentevents'] = new Array('','Find background information on current events'); */
ta['n-requestedarticles'] = new Array('','See list of requested words'); 
ta['n-recentchanges'] = new Array('r','The list of recent changes in the wiki.');
ta['n-discussionrooms'] = new Array('','Find out where you can discuss various aspects of Wiktionary');
ta['n-randompage'] = new Array('x','Load a random page');
ta['n-help'] = new Array('','The place to find out.');
ta['n-sitesupport'] = new Array('','Support us');
 
/* </pre>
===Toolbar section===
<pre> */
ta['t-whatlinkshere'] = new Array('j','List of all wiki pages that link here');
ta['t-recentchangeslinked'] = new Array('k','Recent changes in pages linked from this page');
ta['feed-rss'] = new Array('','RSS feed for this page');
ta['feed-atom'] = new Array('','Atom feed for this page');
ta['t-contributions'] = new Array('','View the list of contributions of this user');
ta['t-emailuser'] = new Array('','Send a mail to this user');
ta['t-upload'] = new Array('u','Upload images or media files');
ta['t-specialpages'] = new Array('q','List of all special pages');
 
/* </pre>
===Misc unsorted messages===
<pre> */
ta['ca-nstab-project'] = new Array('c','View the project page');
ta['ca-nstab-main'] = new Array('c','View the content page');
ta['ca-nstab-user'] = new Array('c','View the user page');
ta['ca-nstab-media'] = new Array('c','View the media page');
ta['ca-nstab-special'] = new Array('','This is a special page, you can\'t edit the page itself.');
ta['ca-nstab-wp'] = new Array('a','View the project page');
ta['ca-nstab-image'] = new Array('c','View the image page');
ta['ca-nstab-mediawiki'] = new Array('c','View the system message');
ta['ca-nstab-template'] = new Array('c','View the template');
ta['ca-nstab-help'] = new Array('c','View the help page');
ta['ca-nstab-category'] = new Array('c','View the category page');
ta['ca-nstab-appendix'] = new Array('c','View the appendix page');
ta['ca-nstab-concordance'] = new Array('c','View the concordance page');
ta['ca-nstab-index'] = new Array('c','View the index page');
ta['ca-nstab-rhymes'] = new Array('c','View the rhymes page');
ta['ca-nstab-transwiki'] = new Array('c','View the imported page');
ta['ca-nstab-wikisaurus'] = new Array('c','View the thesaurus page');
ta['ca-nstab-wt'] = new Array('c','View the shortcut target page');
ta['ca-nstab-citations'] = new Array('c','View the citations page');
ta['ca-nstab-quotations'] = new Array('c','View the quotations page');
 
/* </pre>
 
==addLoadEvent==
<pre> */
function addLoadEvent(func) 
{
  addOnloadHook( func );
}
 
/* </pre>
==Dynamic Navigation Bars (experimental)==
<pre> */
 // ============================================================
 // BEGIN Dynamic Navigation Bars (experimental)
 // FIXME: currently only works for one nav bar on a page at a time
 
 // set up the words in your language
 var NavigationBarHide = '[Hide]';
 var NavigationBarShow = '[Show]';
 
 // set up max count of Navigation Bars on page,
 // if there are more, all will be hidden
 // NavigationBarShowDefault = 0; // all bars will be hidden
 // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
 var NavigationBarShowDefault = 1;
 //Honor the User Preferences
 if ( getCookie('WiktionaryPreferencesShowNav') != 'true' ) {
         NavigationBarShowDefault = 0;
    } else {
      if ( wgNamespaceNumber == 0 ) NavigationBarShowDefault = 999 ;
    }
 
/* </pre>
===toggleNavigationBar===
<pre> */
 // shows and hides content and picture (if available) of navigation bars
 // Parameters:
 //     indexNavigationBar: the index of navigation bar to be toggled
 function toggleNavigationBar(indexNavigationBar)
 {
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
 
    if (!NavFrame || !NavToggle) {
        return false;
    }
 
    // if shown now
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'none';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'block';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'block';
            }
        }
    NavToggle.firstChild.data = NavigationBarHide;
    }
 }
 
/* </pre>
===createNavigationBarToggleButton===
<pre> */
 // adds show/hide-button to navigation bars
 function createNavigationBarToggleButton()
 {
    var indexNavigationBar = 0;
    // iterate over all < div >-elements
    for(
            var i=0; 
            NavFrame = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (NavFrame.className == "NavFrame") {
 
            indexNavigationBar++;
            var NavToggle = document.createElement("a");
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
 
            var NavToggleText = document.createTextNode(NavigationBarHide);
            NavToggle.appendChild(NavToggleText);
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            for(
              var j=0; 
              j < NavFrame.childNodes.length; 
              j++
            ) {
              if (NavFrame.childNodes[j].className == "NavHead") {
                NavFrame.childNodes[j].appendChild(NavToggle);
              }
            }
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
    // if more Navigation Bars found than Default: hide all
    if (NavigationBarShowDefault < indexNavigationBar) {
        for(
                var i=1; 
                i<=indexNavigationBar; 
                i++
        ) {
            toggleNavigationBar(i);
        }
    }
 
 }
 
 addLoadEvent(createNavigationBarToggleButton);
 
 // END Dynamic Navigation Bars
 // ============================================================
 
/* </pre>
 
==Cookies==
<pre> */
 
//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";
  }
}
 
/* </pre>
 
==addCharSubsetMenu==
<pre> */
/* add menu for selecting subsets of secial characters */
/***** must match MediaWiki:Edittools *****/
function addCharSubsetMenu() {
  var edittools = document.getElementById('editpage-specialchars');
 
  if (edittools) {
    var menu = "<select id=\"charSubsetControl\" style=\"display:inline\" 
    menu += "<option>Templates</option>";
    menu += "<option>Latin/Roman</option>";
    menu += "<option>IPA</option>";
    menu += "<option>enPR</option>";
    menu += "<option>Misc.</option>";
    menu += "<option>Arabic</option>";
    menu += "<option>Armenian</option>";
    menu += "<option>Catalan</option>";
    menu += "<option>Cyrillic</option>";
    menu += "<option>Devanāgarī</option>";
    menu += "<option>Esperanto</option>";
    menu += "<option>Estonian</option>";
    menu += "<option>French</option>";
    menu += "<option>German</option>";
    menu += "<option>Gothic</option>";
    menu += "<option>Greek (Modern)</option>";
    menu += "<option>Greek (Ancient)</option>";
    menu += "<option>Hawaiian</option>";
    menu += "<option>Hebrew</option>";
    menu += "<option>Icelandic</option>";
    menu += "<option>Italian</option>";
    menu += "<option>Latvian/Lithuanian</option>";
    menu += "<option>Maltese</option>";
    menu += "<option>Old English</option>";
    menu += "<option>Pinyin</option>";
    menu += "<option>Portuguese</option>";
    menu += "<option>Romaji</option>";
    menu += "<option>Romanian</option>";
    menu += "<option>Scandinavian</option>";
    menu += "<option>Slavic Roman</option>";
    menu += "<option>Sorani Kurdish</option>";
    menu += "<option>Spanish</option>";
    menu += "<option>Turkish</option>";
    menu += "<option>Vietnamese</option>";
    menu += "<option>Welsh</option>";
    menu += "<option>Yoruba</option>";
    menu += "</select>";
    edittools.innerHTML = menu + edittools.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 );
  }
}
 
 
/* </pre>
===chooseCharSubsetMenu===
<pre> */
/* select subsection of special characters */
function chooseCharSubset(s) {
  var l = document.getElementById('editpage-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);
}
 
 
 
/* </pre>
 
==doRedirect==
<pre> */
 
/* Redirect if a case-insensitive search on an external link is found */
function doRedirect() {
  dym = document.getElementById('did-you-mean')
  if ( dym ) {
    if ( getCookie('WiktionaryDisableAutoRedirect') != 'true' ) {
      var dymtarget = dym.firstChild.title ;
      var target = dymtarget ;
      pagetitle = document.getElementsByTagName('h1').item(0).firstChild.nodeValue;
      if (pagetitle == target) {
        alert('No looping allowed.');
        return;
      }
      if ( pagetitle.toLowerCase().replace(/[^a-z]/g, "") != target.toLowerCase().replace(/[^a-z]/g, "") ) {
        alert(target + " does not match " + pagetitle);
        return;
      }
      if ( pagetitle.search(/Editing /g) != -1 ) return;
      pagenamee = pagetitle.replace(/\ /g, "_");
      document.location.replace( 'http://en.wiktionary.org/wiki/Special:Search/' + pagenamee ) ;
    }
  }
}
 
/* </pre>
 
==fixEditSectionWikifiedLinks==
<pre> */
// edit-section still doesn't return to correct spot if link contains a [[wikified]] term.
function fixEditSectionWikifiedLinks() {
  if (/\.5B/.test(window.location.href)) {
    var url=window.location.href.replace(/.5B.5B:/g,"").replace(/.5B/g, "").replace(/.5D/g, "");
    window.location = url;
  }
  //#capiche_and_.7B.7Btemp.7Calternative_spelling_of.7D.7D
  if (/\.7B\.7Btemp\.7C(.*?)\.7D\.7D/.test(window.location.href)) {
    var url=window.location.href.replace(/\.7B\.7Btemp.7C/, ".7B.7B");
    window.location = url;
  }
}
 
/* </pre>
 
==Hide "Main Page" heading and several other elements on the Main Page==
<pre> */
 var mpTitle = "Wiktionary:Main Page";
 var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
 var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
 
 if (isMainPage && !isDiff) document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
 
/* </pre>
 
== User Preferences (experimental) ==
<pre> */
// [[User:Connel MacKenzie/custom.js]] - User preferences
 document.write('<script type="text/javascript" src="/w/index.php?title=User:Connel_MacKenzie/custom.js&action=raw&ctype=text/javascript"><\/script>');
 
/* </pre>
 
== Wiktionary-specific tooltips ==
<pre> */
function wiktHeadingToolTips() {
}
 
// Disabled entirely, 1/5/2007 --~~~~
/*
  // only add heading tooltips in the article namespace
// try again, to turn it off 1/19/2007 --~~~~
//  if (document.getElementsByTagName('body')[0].className.match(/ns-0/)) {
 if (false) {
    // all level-2 headings are languages (or equivalents such as Translingual)
    var allh2s = document.getElementById('bodyContent').getElementsByTagName('h2');
 
    if (allh2s != -1) {
      for (var i = 0; i < allh2s.length; i++) {
        allh2s[i].title = 'The language this term belongs to';
      }
    }
 
    // level 3, 4, and 5 headings depend on their content
    var h345 = new Array('h3', 'h4', 'h5');
 
    for (var j = 0; j < h345.length ; j++) {
 
      var allh345s = document.getElementById('bodyContent').getElementsByTagName(h345[j]);
 
      if (allh345s != -1) {
        for (var i = 0; i < allh345s.length; i++) {
 
          // part of speech
          var ht = allh345s[i].innerHTML.replace(/^(?:\d+(?:\.\d+)* )?(.*)/, "$1");
          var ht2 = ht;
          if (ht.search(/editsection/) != -1) {
            ht = ht.split('<span class="mw-headline">',i)[1];
            if (!ht) ht = ht2.split(/<span class=mw-headline>/,i)[1];
            if (!ht) ht = "";
            ht = ht.split('</span>',i)[0];
          }
 
          if (ht == 'Adjective' || ht == 'Adverb' || ht == 'Conjunction' || ht == 'Interjection' || ht == 'Noun' || ht == 'Prefix' || ht == 'Preposition' || ht == 'Pronoun' || ht == 'Proper noun' || ht == 'Suffix' || ht == 'Verb' || ht == 'Verb form') {
            allh345s[i].title = 'Part of speech or function of this term';
 
          } else if (ht == 'Alternative spellings') {
            allh345s[i].title = 'Other ways to spell this term in the same language';
          } else if (ht == 'Anagrams') {
            allh345s[i].title = 'Terms spelled with the same letters in a different order';
          } else if (ht == 'Antonyms') {
            allh345s[i].title = 'Terms with the opposite meaning in at least one sense';
          } else if ( (ht == 'Etymology') || (ht == 'Etymology 1') || (ht == 'Etymology 2') || (ht == 'Etymology 3') || (ht == 'Etymology 4') ) {
            allh345s[i].title = 'The origin of this term';
          } else if (ht == 'Derived terms') {
            allh345s[i].title = 'Terms which are derived through applying derivational suffixes etc.';
          } else if (ht == 'Dictionary notes') {
            allh345s[i].title = 'How other dictionaries treat this term';
          } else if (ht == 'Homophones') {
            allh345s[i].title = 'Terms with the same pronunciation as this term in at least one dialect or accent';
          } else if (ht == 'Pronunciation') {
            allh345s[i].title = 'How to pronounce this term, possibly in various dialects';
          } else if (ht == 'References') {
            allh345s[i].title = 'Links to external language authorities';
          } else if (ht == 'Related terms') {
            allh345s[i].title = 'Terms which are related etymologically other than simple derivations';
          } else if (ht == 'See also') {
            allh345s[i].title = 'Terms which have a semantic relationship but not an etymological one';
          } else if (ht == 'Synonyms') {
            allh345s[i].title = 'Terms with the same meaning in at least one sense';
          } else if (ht == 'Translations') {
            allh345s[i].title = 'Equivalent terms in other languages';
          } else if (ht == 'Usage notes') {
            allh345s[i].title = 'Things to keep in mind when using this term';
          } else {
 
            // default case - warn that it's nonstandard (or just not handled yet)
            allh345s[i].title = '"' + ht + '" is not a standard Wiktionary heading';
          }
        }
      }
    }
  }
}
*/
// end block disable
 
/* </pre>
 
==Statistics==
* Hook to use LeonWP's toolserver statistics generator
*
<pre> */
 
 // ============================================================
 // BEGIN pageview counter
 // 	Please talk to de:User:LeonWeber before changing anything or 
 // 	if there are any issues with that.
 
 // this should be adjusted to a good value.
 // BE CAREFULL, you will break zedler if it's too low!
 // And then DaB. will kill Leon :-(
 var disable_counter = 0; // 0 = collect stats from anons, 1 = turn off entirely
 var counter_factor = 40; //Wikipedias are ~600.  Use Alexa for a WAG
 
 function pgcounter_setup()
 {
 	if( (disable_counter == 0) && (wgUserName == null) )
 	{
 		var url = window.location.href;
 		if(Math.floor(Math.random()*counter_factor)==4)  // the probability thing
  		{
  			if(wgIsArticle==true) // do not count history pages etc.
 			{
 				var pgcountNs = wgCanonicalNamespace;
 				if(wgCanonicalNamespace=="")
 				{
 					pgcountNs = "0";
 				}
  				var cnt_url = "http://pgcount.wikimedia.de/index.png?ns=" + pgcountNs + "&title=" + encodeURI(wgTitle) + "&factor=" + counter_factor + "&wiki=enwiktionary";
 				var img = new Image(); 
 				img.src = cnt_url;
 			}
 		}
 	}
 }
 // Do not use aOnloadFunctions[aOnloadFunctions.length] = pgcounter_setup;, some browsers don't like that.
 pgcounter_setup();
 
 // END pageview counter 
 // ============================================================
 
 
 
/* </pre>
 
==customizeWiktionary==
<pre> */
/* do any Wiktionary-specific customizations */
function customizeWiktionary() {
  doRedirect();
  addCharSubsetMenu();
  fixEditSectionWikifiedLinks();
  wiktHeadingToolTips();
}
 
addLoadEvent(customizeWiktionary);
 
/* Remember to keep [[MediaWiki:Standard.js]] in sync with this, for classic style! */
 
/* </pre>
 
== Link FA ==
<pre> */
 
function LinkFA() 
{
   // iterate over all <span>-elements
   for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
      // if found a FA span
      if(a.className == "FA") {
         // iterate over all &lt;li&gt;-elements
         for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
            // if found a FA link
            if(b.className == "interwiki-" + a.id) {
               b.className += " FA";
               b.title = "This article has gained featured status";
            }
         }
      }
   }
}
 
/* </pre> 
 
== Interproject links ==
<pre> */
/*
#########
### ProjectLinks
###  by [[user:Pathoschild]] (idea from an older, uncredited script)
###    * generates a sidebar list of links to other projects from {{projectlinks}}
#########
*/
function Projectlinks() {
        var elements = new Array();
        var spans = document.getElementsByTagName('span');
 
        // filter for projectlinks
        for (var i=0, j=0; i<spans.length; i++) {
                if (spans[i].className == 'interProject') {
                        elements[j] = spans[i].getElementsByTagName('a')[0];
                        j++;
                }
        }
 
        // sort alphabetically
        function sortbylabel(a,b) {
                // get labels
                a = a.innerHTML.replace(/^.*<a[^>]*>(.*)<\/a>.*$/i,'$1');
                b = b.innerHTML.replace(/^.*<a[^>]*>(.*)<\/a>.*$/i,'$1');
 
                // return sort order
                if (a < b) return -1;
                if (a > b) return 1;
                return 0;
        }
        elements.sort(sortbylabel);
 
        if (j) {
                // create navbox
                var plheader = document.createElement('h5');
                plheader.appendChild(document.createTextNode('In other projects'));
                var plbox = document.createElement('div');
                plbox.setAttribute('class','pBody');
                plbox.setAttribute('style','margin-top:0.7em;');
                var pllist = document.createElement('ul');
 
                // append
                for (var i=0; i<elements.length; i++) {
                        var plitem = document.createElement('li');
                        plitem.appendChild(elements[i]);
                        pllist.appendChild(plitem);
                }
                plbox.appendChild(plheader);
                plbox.appendChild(pllist);
                document.getElementById("p-tb").appendChild(plbox);
        }
}
 
addLoadEvent(Projectlinks);