User:Mikimik/js/shared.js

/* ============== w:en:User:Mikimik/js/shared.js - shared functions ============== */ function getParamValue ( paramName ) {   if ( !location.search ) return null; var m = RegExp("[&?]" + paramName + "=([^&]*)").exec( location.search ); if ( m ) { try { return decodeURIComponent( m[1] );                               // decodeURIComponent cannot handle Windows-1255 encoded hebrew } catch( err ) { try { return decodeURIComponent( unescape( m[1] ) );               // unescape only handles ASCII %00-%FF (this will corrupt unicode chars) } catch( err ) {} }   }    return null; }

function encodeTextToWikiURL ( text ) {   return encodeURIComponent(text).replace(/%2F/g,"/").replace(/%24/g,"$").replace(/%2C/g,",").replace(/%3A/g,":").replace(/%40/g,"@"); }

// - run only once -

function runOnlyOnceCheck                                                  // check if any function was loaded twice and remove the earlier instance { try { var functsOnlyOnce = []; for ( var i = onloadFuncts.length-1 ; i >= 1 ; i-- )                     // check all onload functions from end to beginning, {                                                                        // not including the current function var name = /function *([^ (]*)/.exec(onloadFuncts[i].toString)[1]; // get function name        if ( !name ) name = onloadFuncts[i].toString;                       // if it doesn't have a name - use the function's text        if ( functsOnlyOnce[name] )                                           // if a function with the same name already exists,            onloadFuncts[i] = function emptyFunctDummy { return; };         // replace it with an empty function         else functsOnlyOnce[name] = true;    }  } catch ( e )  {    return;  } }

if ( !doneOnloadHook ) onloadFuncts.splice ( 0, 0, runOnlyOnceCheck );  // if the window "load" event hasn't fired yet - // insert runOnlyOnceCheck as the first function to be executed

// import scripts

mImportScript ("User:Mikimik/js/displayRemoteInfoInline.js", "http://he.wikipedia.org");     // display remote link info in an iframe if ( !getParamValue("displaylinkinfo") ) {   importStylesheetURI ("http://en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=User:Mikimik/js/shared.css");    // import shared.css

mImportScript ("User:Mikimik/js/ShortNSSearch.js", "http://he.wikipedia.org");    // search using short name spaces

mImportScript ("User:Mikimik/js/customizeBars.js", "http://he.wikipedia.org");    // customize the sidebar and the personal toolbar

mImportScript ("User:Mikimik/js/sisterwikis.js", "http://he.wikipedia.org");      // create sister wikis box

mImportScript ("User:Mikimik/js/customizeTabs.js", "http://he.wikipedia.org");    // customize page tabs

mImportScript ("User:Mikimik/js/customizeContent.js", "http://he.wikipedia.org"); // customize content area

mImportScript ("User:Mikimik/js/customizeWLRC.js", "http://he.wikipedia.org");    // customize Recent Changes and Watch List

mImportScript ("User:Lupin/popups.js", "http://en.wikipedia.org");                // pop-up

mImportScript ("User:Cacycle/wikEd.js", "http://en.wikipedia.org");               // wikEd: in-browser text editor

mImportScript ("MediaWiki:Gadget-EditReplace.js", "http://he.wikipedia.org");     // adds a replace option to toolbar in edit mode

mImportScript ("MediaWiki:SubPagesLink.js", "http://he.wikipedia.org");           // adds a link to the page's subpages

mImportScript ("MediaWiki:Gadget-DiffBytes.js", "http://he.wikipedia.org");       // shows byte size difference in history page

mImportScript ("User:Mikimik/js/displayLocalInfoInline.js", "http://he.wikipedia.org"); // show local information below a page headline

importScriptURI ("http://localhost/wiki-js/local_en.js");                         // *** local_en_1.js on local machine *** }