Jump to content

User:Twinzor/wikimark.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Twinzor (talk | contribs) at 00:31, 11 January 2009 (And a bugfix to that improvement). 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.
//<nowiki>
//WikiMark
//
//A bookmarking tool for Wikipedia.
//
//By User:Twinzor on enwp.
//
//99% of the code is copied from other scripts on WP.
//
//If you improve my sloppy code, I would
//appreaciate it if you could drop me
//a line on my talkpage. Thanks!
//
//To configure the script for yourself, you'll
//first have to copy it to a user subpage of
//you own.
//
//Configuration:

var wikimarkspage = "/WikiMarks"; //Where your WikiMarks are stored. Must begin with a /
var listtype = "*";               //Prefix for each WikiMark. Usually * or #, but can be anything.
var menulocation = "p-cactions";  //Menu location: "p-cactions" = Content actions, "p-personal" = Personal tools, "p-navigation", "p-toolbox".


//Don't edit after this unless you know what you're doing.

var wikimarklinkprefix = wgServer+wgScript;
var wikimarkEncodedUserName = encodeURIComponent(wgUserName);

addOnloadHook(WikiMarkInit);

function WikiMarkInit () {
    addPortletLink (menulocation, 'javascript:doAddWikiMark()', 'WikiMark', 'ca-addwikimark', 'WikiMark this page');
    addPortletLink (menulocation, wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage, 'My WikiMarks', 'ca-showwikimark', 'Open your WikiMarks');
}

function doAddWikiMark () {
    var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list.";
    var wikimarkNewpage = wgPageName;
    var f;
    f=document.createElement("IFRAME");
    f.id="WikiMarksLoader";
    f.onload=function() {
        var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list.";
        e=f.contentWindow.document.editform,e.wpTextbox1.value+=listtype+"["+"["+wikimarkNewpage+"]"+"]\n",e.wpSummary.value=wikimark_cmt,e.wpSave.click();
        var iframe = document.getElementById('WikiMarksLoader');
        iframe.parentNode.removeChild(iframe);
        jsMsg("'''"+wikimarkNewpage+"''' has been added to your WikiMarks.");
    };
    f.src=wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit",document.body.appendChild(f);
};

// </nowiki>