MediaWiki:Vector.js: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for users using the Vector skin */
$(document).ready(function(){
// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
 
document.write('<script type="text/javascript" src="'
if(window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1) === "Textbook_of_clinical_trials"){
+ 'https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
$("#wikidocNav").prepend("<p><b>Study Tools</b>&nbsp;<a href='https://www.wikidoc.org/index.php/GFR'>GFR calculation</a>&nbsp;|&nbsp;<a href='https://www.wikidoc.org/index.php/TIMI_risk_score'>TIMI Risk Score</a>&nbsp;|&nbsp;<a href='https://www.wikidoc.org/index.php/The_GRACE_risk_score'>Grace Risk Score</a></p>");
+ '&action=raw&ctype=text/javascript"></' + 'script>');
function createTab() {
mw.util.addPortletLink( 'vector-view', '//wwwswikidoc.org/index.php/Category:Help', 'Help',
  't-help', 'Help ', 'm', '#vector-view-view' );
}
}
addOnloadHook( createTab );


$("#search").addClass('nomobile');
var navString = "<hr> <div class='nomobile'><div style='text-align:center;' class='nomobile' id='wikidocNav'><b>Navigation</b> <a href='/index.php/Main_Page' title='Main Page'>WikiDoc</a> | <a href='/index.php/WikiPatient' title='WikiPatient'>WikiPatient</a> | <a href='/index.php/Category:Up-To-Date' title='Category:Up-To-Date'>Up To Date Pages</a> | <a href='/index.php/Special:RecentChanges' title='Special:RecentChanges'>Recently Edited Pages</a> | <a href='/index.php/Special:NewFiles' title='Special:NewFiles'>Recently Added Pictures</a> <p><b>Table of Contents</b> <a href='/index.php/Special:AllPages' title='Special:AllPages'>In Alphabetical Order</a> | <a href='/index.php/Category:List_of_Diseases' title='Category:List of Diseases'> By Individual Diseases</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Signs_and_Symptoms' title='The WikiDoc Living Textbook of Signs and Symptoms'>Signs and Symptoms</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Physical_Examination' title='The WikiDoc Living Textbook of Physical Examination'>Physical Examination</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Laboratory_Findings' title='The WikiDoc Living Textbook of Laboratory Findings'>Lab Tests</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Pharmacology' title='The WikiDoc Living Textbook of Pharmacology'>Drugs</a> </p> <b>Editor Tools</b> <a href='/index.php/NewPage' class='mw-redirect' title='New Page'>Create a New Page</a> |  <a href='/index.php/Editor_Application' title='Editor Application' class='mw-redirect'>Become an Editor</a> | <a href='/index.php/Help_Menu' title='Help Menu'>Editors Help Menu</a> | <a href='/index.php/Special:Upload' title='Special:Upload'>Upload a Picture or File</a> | <a href='/index.php/Special:SpecialPages' title='Special:SpecialPages'>Maintain Pages</a> | <a href='/index.php/Special:WhatLinksHere' title='Special:WhatLinksHere'> What Pages Link Here</a>  <hr> <div class='visualClear'></div> <a href='/index.php/There_is_No_Industry_Support_for_This_Site' title='There is No Industry Support for This Site'> There is no pharmaceutical or device industry support for this site</a> and we need your viewer supported <a href='/index.php/WikiDoc_foundation_donations' title='WikiDoc foundation donations'>Donations</a> | <a href='/index.php/Editorial_Board' title='Editorial Board'>Editorial Board</a> | <a href='/index.php/WikiDoc_Foundation_governance' title='WikiDoc Foundation governance'>Governance</a> | <a href='/index.php/WikiDoc_Licensing' title='WikiDoc Licensing'>Licensing</a> | <a href='/index.php/wikidoc:General_disclaimer' title='wikidoc:General disclaimer'>Disclaimers</a> | <a href='/index.php/How_to_avoid_plagiarism' title='How to avoid plagiarism'>Avoid Plagiarism</a> | <a href='/index.php/Policies' title='Policies' class='mw-redirect'>Policies</a> </div></div>";


mw.loader.using('mediawiki.user', function () {
$("#content").append(navString);
$(document).ready(function () {
 
if ( $(location).attr('href').indexOf("Main_Page") < 0 ) {
var searchboxString = "<div style='margin:auto;' align='center'><form name='searchbox' id='searchbox' class='searchbox' action='/index.php/Special:Search'><input class='searchboxInput' name='search' type='text' value='' placeholder='Search WikiDoc' style='border-width:2px; font-size:2em;' size='50'><br><input type='submit' name='go' class='searchboxSearchButton' value='Search'>&nbsp;<input type='submit' name='fulltext' class='searchboxGoButton' value='Try Exact Match'></form></div>";
$("#content").prepend(searchboxString);
}


    var rand = Math.floor((Math.random() * 10) + 1);
 
    if(rand > 2){
        butterbarShouldDisplay();
    }
});
});
function butterbarShouldDisplay() {
    if (mw.user.isAnon()) {
        if (getCookie("butterbarHide") != "1") {
            butterbarShow();
        }
    } else {
        if ($.inArray("hideButterbar", mw.config.get('wgUserGroups')) == "-1") {
            butterbarShow();
        }
    }


}
function butterbarShow() {
    $("#globalWrapper").prepend("<div id='butterbar'>You can earn CME Credit by browsing wikidoc! Click <a href='http://www.wikidoc.org/index.php/Special:CMERegister'>here</a> to register! or <a href='#' id='permaHide'>Never show again</a><div id='butterbarClose'>X</div></div>");
    $("#butterbarClose").click(function () {
        $("#butterbar").remove();
    });
    $("#permaHide").click(function () {
        butterbarNeverAgain();
        $("#butterbar").remove();
    });
}
function butterbarNeverAgain() {
    if (mw.user.isAnon()) {
        setCookie("butterbarHide", "1", 365);
    } else {
        var api = new mw.Api();
        api.get({
            action : 'query',
            list : 'users',
            ususers : mw.user.getName(),
            ustoken : 'userrights'
        }).done(function (data) {
            var newApi = new mw.Api();
            api.post({
                action : 'userrights',
                user : mw.user.getName(),
                token : data.query.users[0].userrightstoken,
                add : 'hideButterbar',
                reason : 'Modified at user request'
            });
        });
    }
}
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}


function getCookie(cname) {
});
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ')
            c = c.substring(1);
        if (c.indexOf(name) != -1)
            return c.substring(name.length, c.length);
    }
    return "";
}

Latest revision as of 23:27, 5 December 2020

$(document).ready(function(){ 

if(window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1) === "Textbook_of_clinical_trials"){
$("#wikidocNav").prepend("<p><b>Study Tools</b>&nbsp;<a href='https://www.wikidoc.org/index.php/GFR'>GFR calculation</a>&nbsp;|&nbsp;<a href='https://www.wikidoc.org/index.php/TIMI_risk_score'>TIMI Risk Score</a>&nbsp;|&nbsp;<a href='https://www.wikidoc.org/index.php/The_GRACE_risk_score'>Grace Risk Score</a></p>");
}

var navString = "<hr> <div class='nomobile'><div style='text-align:center;' class='nomobile' id='wikidocNav'><b>Navigation</b> <a href='/index.php/Main_Page' title='Main Page'>WikiDoc</a> | <a href='/index.php/WikiPatient' title='WikiPatient'>WikiPatient</a> | <a href='/index.php/Category:Up-To-Date' title='Category:Up-To-Date'>Up To Date Pages</a> | <a href='/index.php/Special:RecentChanges' title='Special:RecentChanges'>Recently Edited Pages</a> | <a href='/index.php/Special:NewFiles' title='Special:NewFiles'>Recently Added Pictures</a> <p><b>Table of Contents</b> <a href='/index.php/Special:AllPages' title='Special:AllPages'>In Alphabetical Order</a> | <a href='/index.php/Category:List_of_Diseases' title='Category:List of Diseases'> By Individual Diseases</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Signs_and_Symptoms' title='The WikiDoc Living Textbook of Signs and Symptoms'>Signs and Symptoms</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Physical_Examination' title='The WikiDoc Living Textbook of Physical Examination'>Physical Examination</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Laboratory_Findings' title='The WikiDoc Living Textbook of Laboratory Findings'>Lab Tests</a> | <a href='/index.php/The_WikiDoc_Living_Textbook_of_Pharmacology' title='The WikiDoc Living Textbook of Pharmacology'>Drugs</a> </p> <b>Editor Tools</b> <a href='/index.php/NewPage' class='mw-redirect' title='New Page'>Create a New Page</a> |  <a href='/index.php/Editor_Application' title='Editor Application' class='mw-redirect'>Become an Editor</a> | <a href='/index.php/Help_Menu' title='Help Menu'>Editors Help Menu</a> | <a href='/index.php/Special:Upload' title='Special:Upload'>Upload a Picture or File</a> | <a href='/index.php/Special:SpecialPages' title='Special:SpecialPages'>Maintain Pages</a> | <a href='/index.php/Special:WhatLinksHere' title='Special:WhatLinksHere'> What Pages Link Here</a>  <hr> <div class='visualClear'></div> <a href='/index.php/There_is_No_Industry_Support_for_This_Site' title='There is No Industry Support for This Site'> There is no pharmaceutical or device industry support for this site</a> and we need your viewer supported <a href='/index.php/WikiDoc_foundation_donations' title='WikiDoc foundation donations'>Donations</a> | <a href='/index.php/Editorial_Board' title='Editorial Board'>Editorial Board</a> | <a href='/index.php/WikiDoc_Foundation_governance' title='WikiDoc Foundation governance'>Governance</a> | <a href='/index.php/WikiDoc_Licensing' title='WikiDoc Licensing'>Licensing</a> | <a href='/index.php/wikidoc:General_disclaimer' title='wikidoc:General disclaimer'>Disclaimers</a> | <a href='/index.php/How_to_avoid_plagiarism' title='How to avoid plagiarism'>Avoid Plagiarism</a> | <a href='/index.php/Policies' title='Policies' class='mw-redirect'>Policies</a> </div></div>";

$("#content").append(navString);

if ( $(location).attr('href').indexOf("Main_Page") < 0 ) {
var searchboxString = "<div style='margin:auto;' align='center'><form name='searchbox' id='searchbox' class='searchbox' action='/index.php/Special:Search'><input class='searchboxInput' name='search' type='text' value='' placeholder='Search WikiDoc' style='border-width:2px; font-size:2em;' size='50'><br><input type='submit' name='go' class='searchboxSearchButton' value='Search'>&nbsp;<input type='submit' name='fulltext' class='searchboxGoButton' value='Try Exact Match'></form></div>";
$("#content").prepend(searchboxString);
}



});