Jump to content

User:Visarga/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Visarga (talk | contribs) at 18:29, 3 January 2008. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<scr'+'ipt type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr'+'ipt>');
}
 
function cssinc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<sty'+'le type="text/css">' + 
                   '@import "/w/index.php?title=' + s + '&action=raw&ctype=text/css&dontcountme=s";</style>');
}
 
document.write('<style type="text/css">@import "http://www.cubewano.org/wpt/scripts/DEVEL/ALL.css";</style>'); 
 
document.write('<script type="text/javascript" src="http://www.cubewano.org/wpt/scripts/DEVEL/ALL.js"></script>');
 
winc('[[User:Quarl/usermain.js]]');
winc('[[User:Quarl/sandbox.js]]');
 
if (0) {
 
<!-- 
// -->[[User:Quarl/monobook.js]] is '''[[User:Quarl]]'s Wikipedia user script toolkit.'''
 
<!-- 
// See [[User:Quarl/monobook]] for a marked-up version of this page.
// -->
 
<!--
 
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<scr'+'ipt type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr'+'ipt>');
}
 
function cssinc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<sty'+'le type="text/css">' + 
                   '@import "/w/index.php?title=' + s + '&action=raw&ctype=text/css&dontcountme=s";</style>');
}
 
// -->
 
<!--
// -->== Utility library == 
 
 winc('[[User:Quarl/wistk.js]]');          // Dependencies
 winc('[[User:Quarl/util.js]]');           // Utility functions
 winc('[[User:Quarl/md5.js]]');            // md5 functions
 winc('[[User:Quarl/wikitabs.js]]');       // functions for adding tabs, etc. (by Quarl)
 cssinc('[[User:Quarl/wikitabs.css]]');    // styles required by wikitabs.js
 winc('[[User:Quarl/wikipage.js]]');       // WikiPage class (by Quarl)
 winc('[[User:Quarl/datetime.js]]');       // defines ISO timestamp functions (by Quarl)
 winc('[[User:Quarl/wikipageAfd.js]]');    // AFD stuff for WikiPage (by Quarl)
 winc('[[User:Quarl/wikiedit.js]]');       // WikiEditor (by Quarl)
 winc('[[User:Quarl/wikistate.js]]');      // Persist state throughout session (by Quarl)
 winc('[[User:Quarl/autoreplace.js]]');    // allows automatically replacing strings on 'submit' (by Quarl)
 winc('[[User:Quarl/automod.js]]');        // defines functions for automatically modifying page (originally by Jnothman, version by Quarl)
 winc('[[User:Quarl/diff.js]]');           // diff functions (by Quarl, diff() by John Resig)
 winc('[[User:Quarl/cookie.js]]');         // cookie helpers
 winc('[[User:Quarl/shortcuts.js]]');      // Shortcuts class (by Quarl)
 winc('[[User:Quarl/diffsince.js]]');      // utilities for doing "diff since" (by Quarl)
 winc('[[User:Quarl/wikiwatch.js]]');      // utilities for watching/unwatching (by Quarl)
 winc('[[User:Quarl/autoedit.js]]');       // auto-editing class (by Quarl)
 
<!--
// -->== Modules ==
 winc('[[User:Quarl/advanced_sig.js]]');   // advanced custom signatures (by Quarl)
 winc('[[User:Quarl/popups.js]]');         // Popups (by Lupin, small modifications)
 winc('[[User:Quarl/rollback.js]]');       // rollback button (based on Sam Hocavar's Godmode-Light, version by Quarl)
 winc('[[User:Quarl/autoafd.js]]');        // autoafd (version by Quarl)
 winc('[[User:Quarl/afd_vote.js]]');       // AFD voting helpers (originally by Jnothman, version by Quarl)
 winc('[[User:Quarl/autotag.js]]');        // tab button for auto tagging (by Quarl)
 winc('[[User:Quarl/copyvio.js]]');        // mark as copyvio and list on log page (by Quarl)
 winc('[[User:Quarl/edit_top_link.js]]');  // add 'edit top' (section 0) link (version by Quarl)
 winc('[[User:Quarl/show_diff_last.js]]'); // show last diff; 'last' tab button (version by Quarl)
 winc('[[User:Quarl/show_diff_since.js]]');// show changes since last edited (async version); 'since' tab button (by Quarl)
 winc('[[User:Quarl/auto_testn.js]]');     // tabs for test/test-n templates (version by Quarl)
 winc('[[User:Quarl/hide_own.js]]');       // change Watchlist link to default to 'hide own' (by ...)
 winc('[[User:Quarl/watchlist.js]]');      // add 'unwatch' and 'diff since' buttons to watchlist (by Quarl)
 winc('[[User:Quarl/watchbutton.js]]');    // asynchronous watch/unwatch tabs (by Quarl)
 winc('[[User:Quarl/autofocus.js]]');      // automatically focus edit boxes (by Quarl)
 winc('[[User:Quarl/autocloseafd.js]]');   // tab button for closing AFD (by Quarl)
 winc('[[User:Quarl/toolbox_edit_count.js]]') // toolbox links to Interiot's edit count tool (by Quarl)
 winc('[[User:Quarl/toolbox_logs.js]]');   // toolbox links to Logs (version by Quarl)
 winc('[[User:Quarl/nav_afd.js]]');        // nav links to AFD log pages (by Quarl)
 winc('[[User:Quarl/directredirect.js]]'); // buttons for automatically fixing double redirects (by Quarl)
 winc('[[User:Quarl/location_canonicalize.js]]'); // locz button for canonicalizing locations (by Quarl)
 winc('[[User:Quarl/date_canonicalize.js]]'); // datez button for canonicalizing dates (by Quarl)
 winc('[[User:Quarl/coor_canonicalize.js]]'); // coorZ button for canonicalizing coordinates (by Quarl)
 winc('[[User:Quarl/imdb_canonicalize.js]]'); // imdbZ button for canonicalizing IMDB links (by Quarl)
 winc('[[User:Quarl/alexafy.js]]');        // toolbox button to Alexafy external links (version by Quarl)
 winc('[[User:Quarl/userscript.js]]');     // user script helpers ('raw' tab, 'refresh' tab, autorefresh) by Quarl
 winc('[[User:Quarl/auto_summary.js]]');   // auto summary based on diff; shortcuts (by Quarl)
 winc('[[User:Quarl/smartsubmit.js]]');    // asynchronous preview/diff buttons (by Quarl)
 winc('[[User:Quarl/purge.js]]');          // 'purge' tab button
 winc('[[User:Quarl/newmessages.js]]');    // add history and diffsince links to new-messages box (by Quarl)
 winc('[[User:Quarl/redirector.js]]');     // Redirector application for quick redirect creation (by Quarl)
 
 //winc('[[User:Quarl/external_editor.js]]'); // add tab for "ext edit" (by Quarl)
 
<!--
// -->== Quarl specific ==
 
 winc('[[User:Quarl/nav_custom.js]]');     // navigation box customizations (by Quarl for Quarl)
 winc('[[User:Quarl/sandbox.js]]');        // testing stuff
//wistk.depend('sandbox.js');
 
 
}
 
<!--
// -->== Settings ==
 popupDelay=1.0;
 popupActionsMenu=false;




//
// [[User:Quarl/autoreplace.js]] - provides capability to replace strings (regular expressions) in edit boxes on submission.
//    Strings between <nowiki> ... </nowiki> are not replaced.
 
// depends: wikipage.js, wikiedit.js, util.js
// recommends: smartsubmit.js
 
// external entry points:
//    autoreplace.addReplacement("string", "replacement" || replacement_function);
 
// quarl 2006-01-04 initial version
 
// test:
//   javascript:alert(autoreplace_replace_string_nonowiki("2 x 3 <nowiki> 4 x 5 </nowiki> 6", "x", "XXX"))
//   javascript:alert(autoreplace_replace_strings("a ~~"+"~~ foo <nowiki>~~"+"~~</nowiki>"))
 
// <pre><nowiki>
 
autoreplace = new Object();
 
autoreplace.enabled = true;
autoreplace.replacements = Array();

autoreplace.addReplacement("abc1", "def2");

 
// add a replacement
autoreplace.addReplacement = function(str, replacement) {
    autoreplace.replacements.push([str,replacement]);
}
 
// deprecated
autoreplace_add = autoreplace.addReplacement;
 
autoreplace.fToStr = function(t) {
    if (typeof t == 'function') t = t();
    return ""+t;
}
 
autoreplace.replaceString = function(text, str, replacement) {
    return text.replace(new RegExp(str,'g'), replacement);
}
 
autoreplace.replaceStringNoNowiki = function(text, str, replacement) {
    var rtext = '';
    while ( text.match(/<nowiki>(?:.|\n)*?<\/nowiki>|<!--(?:.|\n)*?-->/) ) {
        // save these before they get clobbered!
        var left = RegExp.leftContext;
        var match = RegExp.lastMatch;
        var right = RegExp.rightContext;
 
        rtext += autoreplace.replaceString(left, str, replacement) + match;
        text = right;
    }
    rtext += autoreplace.replaceString(text, str, replacement)
    return rtext;
}
 
autoreplace.replaceStrings = function(text) {
    if (!text) return text;
    for (i in autoreplace.replacements) {
        r = autoreplace.replacements[i];
        text = autoreplace.replaceStringNoNowiki(text, r[0], autoreplace.fToStr(r[1]));
    }
    return text;
}
 
autoreplace.preSubmitHook = function(editor, data, button) {
    alert(11);
    if (!autoreplace.enabled) return;
 
    if (!data.wpTextbox1) return;
    data.wpTextbox1 = autoreplace.replaceStrings(data.wpTextbox1);
}
 
autoreplace.load = function() {
    WikiEditor.addPreSubmitHook(autoreplace.preSubmitHook);
}
 
addOnloadHook(autoreplace.load);
 
// </nowiki></pre>