Difference between revisions 22233 and 24224 on pswiktionary/* Any JavaScript here will be loaded for all users on every page load. */ /*</pre> ==JavaScript standard library== <pre>*/ /*</pre> ===importScript=== <pre>*/ /** * importScript inserts a javascript page either * from Wiktionary: importScript('User:Connel MacKensie/yetanother.js'); * from another Wikimedia wiki: importScript('User:Lupin/insane.js','en.wikipedia.org'); * * by specifying the third argument, an oldid can be passed to ensure that updates to the script are not included. * by specifying the fourth argument, a specific version of JavaScript can be declared. * * based on [[w:MediaWiki:Common.js]] 2007-11-29 **/ function importScript(page, wiki, oldid, jsver) { //Default to local if ( !wiki ) { wiki=wgScript; } else { wiki='//'+escape(wiki)+'/w/index.php'; } var url = wiki + '?title=' + mw.util.wikiUrlencode( page ) + (oldid ? '&oldid='+encodeURIComponent( oldid ) : '') + '&action=raw&ctype=text/javascript'; //Only include scripts once if ( loadedScripts[url] ) { return false; } loadedScripts[url] = true; var scriptElem = document.createElement("script"); scriptElem.setAttribute("src",url); scriptElem.setAttribute("type", jsver ? "application/javascript;version=" + jsver : "text/javascript"); document.getElementsByTagName("head")[0].appendChild(scriptElem); return true; }⏎ ⏎ /*</pre> === DOM creation === <pre>*/ /** * Create a new DOM node for the current document. * Basic usage: var mySpan = newNode('span', "Hello World!") * Supports attributes and event handlers*: var mySpan = newNode('span', {style:"color: red", focus: function(){alert(this)}, id:"hello"}, "World, Hello!") (contracted; show full) newNode.addEventHandler = function(node, eventName, handler) { try{ node.addEventListener(eventName,handler,false); //W3C }catch(e){try{ node.attachEvent('on'+eventName,handler,"Language"); //MSIE }catch(e){ node['on'+eventName]=handler; }} //Legacy }; ⏎ ⏎ /*</pre> ⏎ === CSS === <pre>*/ /** * Cross browser CSS - yurk * @deprecated: Use mw.util.addCSS() instead */ var p_styleSheet=false; window.addCSSRule = function (selector,cssText){ mw.util.addCSS( selector+'{' + cssText + '}' ); } /*</pre> ===Cookies=== <pre> */ /* @deprecated: Use $.cookie instead */ 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=/" + ";expires="+expire.toGMTString(); // We need to delete the more specific paths for the next while. Safe to remove this by July 2011, if not before. 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"; } 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=/" + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } } /*</pre>⏎ ⏎ ==Wiktionary Customisation== <pre>*/ if ( document.getElementById('footer') ) { jQuery.ready() } //initialize the storage for script options. Gadgets that set script //options should also include this line as they are loaded before us. if ( typeof WiktScriptPrefs == 'undefined') { WiktScriptPrefs = {}; } /*</pre> ===[[MediaWiki:Youhavenewmessages]] to display differently for non-newbies with JS than for others=== <pre>*/ /* Suspected unresponsive page culprit: see the GP (Nov. 2010, "Blocking script execution on each page") */ /* if (wgUserGroups && wgUserGroups.join("").indexOf("autoconfirmed") > -1) { addCSSRule("mw.util.addCSS( '.msgfornewbies", " {display: none"}' ); }else{ addCSSRule("mw.util.addCSS( '.msgfornonnewbies", " {display: none"}' ); } */ /*</pre> ===[[WT:FEED]]=== <pre>*/ if ( !wgUserName ) { importScript('User:Conrad.Irwin/feedback.js'); } /*</pre> ===WT:PREFS=== <pre>*/ if ( getC$.cookie('WiktPrefs') || mw.config.get('wgPageName') == "Wiktionary:Per-browser_preferences") { //importScript('User:Connel_MacKenzie/custom.js'); importScript('User:Hippietrail/custom.js'); } /*</pre> ===Edit page javascript=== (contracted; show full)/*</pre> ====Geonotice==== <pre>*/ /*Ended December 2009 else if (wgPageName == "Special:Watchlist") //watchlist scripts { importScriptURI('http://toolserver.org/~para/geoip.fcgi'); addOnloadHook(function() { importScriptURI⏎ mw.loader.load('http://en.wiktionary.org/w/index.php?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600'); }); } */ /*</pre> ===Add editor.js for editing translations=== <pre>*/ importScript('User:Conrad.Irwin/editor.js'); (contracted; show full) // DID YOU MEAN var target = jQuery('#did-you-mean a').html(), pagetitle = jQuery('h1').first().text().trim(); if( target && target != pagetitle && !window.location.href.match(/[&\?]redirect=no|[&\?]action=(?!view)/) && ( getC$.cookie('WiktionaryDisableAutoRedirect') != 'true') && wgArticleId === 0 && !/Redirected from/.test(jQuery('#contentSub').html())) { document.location = mw.util.wikiGetlink( target ) + '?rdfrom=' + mw.util.wikiUrlencode( pagetitle ); } } // Random page in a given language (contracted; show full) for (var i = 0; i < this.toggles[category].length; i++ ) { if (this.statuses[category][i] != status) { this.toggles[category][i][status ? 0 : 1](); this.statuses[category][i] = status; } } document.getElementById('p-visibility-' + category).innerHTML = (status ? 'Hide ' : 'Show ') + category; var current = getC$.cookie('Visibility'); if (!current) current = ";"; current = current.replace(';' + category + ';', ';'); if (status) current = current + category + ";"; setC$.cookie('Visibility', current); }, currentStatus: function(category) { if (window.location.hash.toLowerCase().split('_')[0] == '#' + category.toLowerCase()) return true; if (window.location.href.search(/[?](.*&)?hidecats=/) > 0) { var hidecats = window.location.href; hidecats = hidecats.replace(/^[^?]+[?]((?!hidecats=)[^&]*&)*hidecats=/, ''); hidecats = hidecats.replace(/&.*/, ''); hidecats = hidecats.split(','); for (var i = 0; i < hidecats.length; ++i) if (hidecats[i] == category || hidecats[i] == 'all') return false; else if (hidecats[i] == '!' + category || hidecats[i] == 'none') return true; } if (getC$.cookie('WiktionaryPreferencesShowNav') == 'true') return true; if (getC$.cookie('Visibility').indexOf(';' + category + ';') >= 0) return true; // TODO check category-specific cookies return false; } }; /*</pre> === NavBars === (contracted; show full) } }) /*</pre> ===WT:ES Discussion tool=== <pre>*/ wgPageName == "Wiktionary:Etymology_scriptorium" && importScript("User:Yair rand/DiscussionSandbox.js"); All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://ps.wiktionary.org/w/index.php?diff=prev&oldid=24224.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|