User:Gxnx0xmx0xn/monobook.js

This is an old revision of this page, as edited by Gxnx0xmx0xn (talk | contribs) at 00:40, 8 March 2015. 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.
//importScript('User:Twinzor/wikimark.js');
//WikimarkConfigViewMenu = "navigation";        //These two variables set in which menu you'd like the WikiMark tabs to appear. Can be different for each tab.
//WikimarkConfigAddMenu = "toolbar";         //Options: cactions, personal, toolbox, navigation

//WikimarkConfigPopup = 0;                    //Set to 1 to get your WikiMarks in a neat box without having to leave your current page.
//WikimarkConfigPopShow = 0;                  //These two variables set how the popup is shown/hidden if enabled
//WikimarkConfigPopHide = 0;                  //Options: 0 = clicking link, 2 = hovering over, 1 = both
//WikimarkConfigKeepSection = 1;              //Change to 1 if you'd like to be able to WikiMark specific sections

//<nowiki>
//WikiMark
//
//A bookmarking tool for Wikipedia.
//
//By User:Twinzor on enwp.
//Adapted in 2015 by User:Gxnx0xmx0xn on enwp.
//
//Reading configuration or setting defaults if not present:
 
if(typeof WikimarkConfigWikimarksPage == 'undefined') {
    var wikimarkspage = "/WikiMarks";
}
else {
    var wikimarkspage = "/"+WikimarkConfigWikimarksPage;
}
 
if(typeof WikimarkConfigKeepSection == 'undefined') {
    var wikimarksect = 0;
}
else {
    var wikimarksect = WikimarkConfigKeepSection;
}
 
if(typeof WikimarkConfigListType == 'undefined') {
    var listtype = "*";
}
else {
    var listtype = WikimarkConfigListType;
}
 
if(typeof WikimarkConfigAddMenu == 'undefined') { 
    var addMenulocation = "p-cactions";
    var menuPrefix = "ca-";
}
else if( WikimarkConfigAddMenu == "cactions" ) {
    var addMenulocation = "p-cactions";
    var menuPrefix = "ca-";
} 
else if( WikimarkConfigAddMenu == "personal" ) {
    var addMenulocation = "p-personal";
    var menuPrefix = "pt-";
} 
else if( WikimarkConfigAddMenu == "toolbox" ) {
    var addMenulocation = "p-tb";
    var menuPrefix = "t-";
} 
else if( WikimarkConfigAddMenu == "navigation" ) {
    var addMenulocation = "p-navigation";
    var menuPrefix = "n-";
} 
else {
    var addMenulocation = "p-cactions";
    var menuPrefix = "ca-";
}
 
if(typeof WikimarkConfigPopup == 'undefined') { 
    var wmPopup = 0; 
}
else if( WikimarkConfigPopup == 1 ) {
    var wmPopup = 1; 
} 
 
if(typeof WikimarkConfigViewMenu == 'undefined') { 
    var viewMenulocation = "p-cactions"; 
    var menuPrefixV = "ca-";
}
else if( WikimarkConfigViewMenu == "cactions" ) {
    var viewMenulocation = "p-cactions";
    var menuPrefixV = "ca-";
} 
else if( WikimarkConfigViewMenu == "personal" ) {
    var viewMenulocation = "p-personal";
    var menuPrefixV = "pt-";
} 
else if( WikimarkConfigViewMenu == "toolbox" ) {
    var viewMenulocation = "p-tb";
    var menuPrefixV = "t-";
} 
else if( WikimarkConfigViewMenu == "navigation" ) {
    var viewMenulocation = "p-navigation";
    var menuPrefixV = "n-";
} 
else {
    var viewMenulocation = "p-cactions";
    var menuPrefixV = "ca-";
}
 
if(typeof WikimarkConfigWikimarksUsername == 'undefined') {
    var wikimarkEncodedUserName = encodeURIComponent(wgUserName);
}
else {
    var wikimarkEncodedUserName = WikimarkConfigWikimarksUsername;
}
 
if(typeof WikimarkConfigPopShow == 'undefined') {
WikimarkConfigPopShow=0;
}
if(typeof WikimarkConfigPopHide == 'undefined') {
WikimarkConfigPopHide=0
}
 
var myBkmShowOnHover = WikimarkConfigPopShow;    
var myBkmHideOnHover = WikimarkConfigPopHide;
var wikimarklinkprefix = wgServer+wgScript;
 
$(WikiMarkInit);
 
function WikiMarkInit () {
    if(typeof WikimarkConfigViewNextTo == 'undefined') { 
        var viewNextto = '';
    }
    else {
        var viewNextto = document.getElementById(menuPrefixV+WikimarkConfigViewNextTo);
    }
 
    if(typeof WikimarkConfigAddNextTo == 'undefined') { 
        var addNextto = '';
    }
    else {
        var addNextto = document.getElementById(menuPrefix+WikimarkConfigAddNextTo);
    }
    addPortletLink (addMenulocation, 'javascript:doAddWikiMark()', 'WikiMark yo', menuPrefix+'addwikimark', 'WikiMark this page', '', addNextto);
    if(wmPopup == 0) {
        addPortletLink (viewMenulocation, wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage, 'My WikiMarks', menuPrefixV+'showwikimark', 'Open your WikiMarks', '', viewNextto);
    }
    else {
        myBookmarksLoad();
    }
}
 
function doAddWikiMark () {
    var wikimarkNewpage = wgPageName.replace(/_/g, " ");
    if(wikimarkNewpage.indexOf("File:")==0) {
        wikimarkNewpage = ":" + wikimarkNewpage;
    }
    else if(wikimarkNewpage.indexOf("Category:")==0) {
        wikimarkNewpage = ":" + wikimarkNewpage;
    }
    var wikimarkNewpageName = wikimarkNewpage;
    if(wikimarksect == 1) {
        var newpageURL = ___location.href;
        if(newpageURL.indexOf("#")) {
            anchor = newpageURL.split("#");
            newpageSect = anchor[1];
            var wikimarkNewpageLink = wikimarkNewpage;
            wikimarkNewpage = wikimarkNewpage + "#" + newpageSect;
            wikimarkNewpage = wikimarkNewpage.replace(/_/g, " ");
            wikimarkNewpageName = wikimarkNewpageLink + " (Section: " + newpageSect + ")";
        }
    }
    var f;
 //   f=document.createElement("IFRAME");
    f=window.open(wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit&output=embed")
    f.id="WikiMarksLoader";
//    f.setAttribute("src", wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit&output=embed"); 
//    f.style.width = 640+"px"; 
//    f.style.height = 480+"px"; 
    if(wikimarkNewpageName == wikimarkNewpage) {
        var wikimarkLinktext = wikimarkNewpage;
    }
    else {
        var wikimarkLinktext = wikimarkNewpage+"|"+wikimarkNewpageName;
    }
    f.onload=function() {
        var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list.";
        e=f.document.editform;
        e.wpTextbox1.value+=listtype+"["+"["+wikimarkLinktext+"]"+"]\n";
        e.wpSummary.value=wikimark_cmt;
        e.wpSave.click();
        f.close();
  //      var iframe = document.getElementById('WikiMarksLoader');
 //       jsMsg("'''"+wikimarkNewpageName+"''' has been added to your WikiMarks.");
//        iframe.style.display="block";
    };
 //   f.src=wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit",document.body.appendChild(f);
// document.body.appendChild(f);
}
 

// </nowiki>