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 03:17, 10 January 2009 (Sigh...). 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
var wikimarkspage = "/WikiMarks";
var wikimarklinkprefix = wgServer+wgScript;
var wikimarkEncodedUserName = encodeURIComponent(wgUserName);

addOnloadHook(WikiMarkInit);

function WikiMarkInit () {
    addPortletLink ('p-cactions', 'javascript:doAddWikiMark()', 'WikiMark', 'ca-addwikimark', 'WikiMark this page');
    addPortletLink ('p-cactions', 'javascript:doShowWikiMarks()', 'My WikiMarks', 'ca-showwikimark', 'Open your WikiMarks');
}

function doGoToWikiMarksPage () {
    window.location = wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit";
}

function doAddWikiMarkForm () {
    var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list.";
    var e;
    e=f.contentWindow.document.editform,e.wpTextbox1.value+="["+"["+wikimarkNewpage+"]"+"]\n",e.wpSummary.value=wikimark_cmt,e.wpSave.click();
/*
    document.editform.wpTextbox1.value = "Does this even work?";
    document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "["+"["+wikimarkNewpage+"]"+"]\n";
    document.editform.wpSummary.value = wikimark_cmt;
    document.editform.submit(); */
}

function doAddWikiMark () {
    var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list.";
    var wikimarkNewpage = wgPageName;
    var f;
    f=document.createElement("IFRAME");
    f.onload=doAddWikiMarkForm();
    f.src=wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit",document.body.appendChild(f);
/*
    doGoToWikiMarksPage();
    document.location.href = wikimarklinkprefix+"?title="+wikimarkNewpage;
*/
};

function doShowWikiMarks () {
    document.location.href = wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage;
};


// </nowiki>