User:Sergekorjian/common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*mw.loader.using('mediawiki.user', function () { $(document).ready(function () { var rand = Math.floor((Math.random() * 10) + 1); //if(rand > 5){ if (1) { 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 ""; }*/ if (getCookie("butterbarHide") != "1") { $('#content').animateRotate(360, 5000, function () { }); } setCookie("butterbarHide", "1", 365); function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 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 ""; }