Difference between revisions of "MediaWiki:Common.js"
(typo fix) |
m (Restored static glider after celebrating 50 year for a year and honoring the late John H. Conway.) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
console && console.log("Welcome to the%cwiki. Since you're reading this, why not make the wiki more awesome?", 'padding:15px 135px;line-height:42px;background:url(https://ackspace.nl/w/images/3/3b/Wiki_logo.png) no-repeat;'); | console && console.log("Welcome to the%cwiki. Since you're reading this, why not make the wiki more awesome?", 'padding:15px 135px;line-height:42px;background:url(https://ackspace.nl/w/images/3/3b/Wiki_logo.png) no-repeat;'); | ||
+ | //https://github.com/dlom/favicon.js | ||
+ | /* http://mit-license.org/ */ | ||
+ | (function (root, factory) { | ||
+ | if (typeof define === "function" && define["amd"]) { | ||
+ | // AMD. Register as an anonymous module. | ||
+ | define([], factory); | ||
+ | } else if (typeof module === "object" && module["exports"]) { | ||
+ | // Node. Does not work with strict CommonJS, but | ||
+ | // only CommonJS-like environments that support module.exports, | ||
+ | // like Node. | ||
+ | module["exports"] = factory(); | ||
+ | } else { | ||
+ | // Browser globals (root is window) | ||
+ | root["favicon"] = factory(); | ||
+ | } | ||
+ | }(typeof self !== "undefined" ? self : this, function () { | ||
+ | var doc = document; | ||
+ | // private | ||
+ | |||
+ | var head = doc.getElementsByTagName("head")[0]; | ||
+ | var loopTimeout = null; | ||
+ | var changeFavicon = function(iconURL) { | ||
+ | var newLink = doc.createElement("link"); | ||
+ | newLink.type = "image/x-icon"; | ||
+ | newLink.rel = "icon"; | ||
+ | newLink.href = iconURL; | ||
+ | removeExistingFavicons(); | ||
+ | head.appendChild(newLink); | ||
+ | }; | ||
+ | var removeExistingFavicons = function() { | ||
+ | var links = head.getElementsByTagName("link"); | ||
+ | for (var i = 0; i < links.length; i++) { | ||
+ | if (/\bicon\b/i.test(links[i].getAttribute("rel"))) { | ||
+ | head.removeChild(links[i]); | ||
+ | } | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | // public | ||
+ | |||
+ | var favicon = { | ||
+ | "defaultPause": 2000, | ||
+ | "change": function(iconURL, optionalDocTitle) { | ||
+ | clearTimeout(loopTimeout); | ||
+ | if (optionalDocTitle) { | ||
+ | doc.title = optionalDocTitle; | ||
+ | } | ||
+ | if (iconURL !== "") { | ||
+ | changeFavicon(iconURL); | ||
+ | } | ||
+ | }, | ||
+ | "animate": function(icons, optionalDelay) { | ||
+ | clearTimeout(loopTimeout); | ||
+ | // preload icons | ||
+ | icons.forEach(function(icon) { | ||
+ | (new Image()).src = icon; | ||
+ | }); | ||
+ | optionalDelay = optionalDelay || this["defaultPause"]; | ||
+ | var iconIndex = 0; | ||
+ | changeFavicon(icons[iconIndex]); | ||
+ | loopTimeout = setTimeout(function animateFunc() { | ||
+ | iconIndex = (iconIndex + 1) % icons.length; | ||
+ | changeFavicon(icons[iconIndex]); | ||
+ | loopTimeout = setTimeout(animateFunc, optionalDelay); | ||
+ | }, optionalDelay); | ||
+ | }, | ||
+ | "stopAnimate": function() { | ||
+ | clearTimeout(loopTimeout); | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | return favicon; | ||
+ | })); | ||
+ | |||
+ | var glider=[ | ||
+ | "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAEJQTFRF////AAAAPz8/f39/QEBAgICAfn5+Pj4+PwAAgAAAQAAAfgAA/wAAfwAAREREiIiIOgAAdwAAOwAAQ0NDAQEB////mIKWXwAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAABIAAAASABGyWs+AAAAZElEQVRIx+3WuRLAIAhFUQJods32/9+a+r0UlqbgdhSHsWFGGSg1yGlWYWACpYyzBQjwH6AZ0pFm8QQ5L5h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nLpRPAAAADlQTFRF////Pz8/f39/QEBAAAAAgICAfn5+AQEBOzs7dnZ2d3d3QwAAiAAARAAAfgAA/wAAfwAAPwAA////Lstd1AAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAABIAAAASABGyWs+AAAAYUlEQVRIx+3Wuw7AIAiFYZDa0ru+/8t2PofB0Q78G8YvcSFRtEBKsy2UFIEKzTVBgv8AXSHlOQA+sArZEAyflCDBNLBRvkMegB9QuHBe0B1WlMHzQi1BgnmAvz+8H71B/QPzsyL15A3W+gAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wNi0wM1QwOToyNzowMSswMjowMFFdyYEAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDYtMDNUMDk6Mjc6MDErMDI6MDAgAHE9AAAAQ3RFWHRzdmc6YmFzZS11cmkAZmlsZTovLy9ob21lL21hcnRpam4udGltbWVybWFucy9EZXNrdG9wL2Fja2dsaWRlcjMuc3Zn6BFQegAAAABJRU5ErkJggg==" | ||
+ | ]; | ||
+ | //favicon.animate(glider, 500); |
Latest revision as of 21:17, 11 April 2021
/* Any JavaScript here will be loaded for all users on every page load. */ console && console.log("Welcome to the%cwiki. Since you're reading this, why not make the wiki more awesome?", 'padding:15px 135px;line-height:42px;background:url(https://ackspace.nl/w/images/3/3b/Wiki_logo.png) no-repeat;'); //https://github.com/dlom/favicon.js /* http://mit-license.org/ */ (function (root, factory) { if (typeof define === "function" && define["amd"]) { // AMD. Register as an anonymous module. define([], factory); } else if (typeof module === "object" && module["exports"]) { // Node. Does not work with strict CommonJS, but // only CommonJS-like environments that support module.exports, // like Node. module["exports"] = factory(); } else { // Browser globals (root is window) root["favicon"] = factory(); } }(typeof self !== "undefined" ? self : this, function () { var doc = document; // private var head = doc.getElementsByTagName("head")[0]; var loopTimeout = null; var changeFavicon = function(iconURL) { var newLink = doc.createElement("link"); newLink.type = "image/x-icon"; newLink.rel = "icon"; newLink.href = iconURL; removeExistingFavicons(); head.appendChild(newLink); }; var removeExistingFavicons = function() { var links = head.getElementsByTagName("link"); for (var i = 0; i < links.length; i++) { if (/\bicon\b/i.test(links[i].getAttribute("rel"))) { head.removeChild(links[i]); } } }; // public var favicon = { "defaultPause": 2000, "change": function(iconURL, optionalDocTitle) { clearTimeout(loopTimeout); if (optionalDocTitle) { doc.title = optionalDocTitle; } if (iconURL !== "") { changeFavicon(iconURL); } }, "animate": function(icons, optionalDelay) { clearTimeout(loopTimeout); // preload icons icons.forEach(function(icon) { (new Image()).src = icon; }); optionalDelay = optionalDelay || this["defaultPause"]; var iconIndex = 0; changeFavicon(icons[iconIndex]); loopTimeout = setTimeout(function animateFunc() { iconIndex = (iconIndex + 1) % icons.length; changeFavicon(icons[iconIndex]); loopTimeout = setTimeout(animateFunc, optionalDelay); }, optionalDelay); }, "stopAnimate": function() { clearTimeout(loopTimeout); } }; return favicon; })); var glider=[ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAEJQTFRF////AAAAPz8/f39/QEBAgICAfn5+Pj4+PwAAgAAAQAAAfgAA/wAAfwAAREREiIiIOgAAdwAAOwAAQ0NDAQEB////mIKWXwAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAABIAAAASABGyWs+AAAAZElEQVRIx+3WuRLAIAhFUQJods32/9+a+r0UlqbgdhSHsWFGGSg1yGlWYWACpYyzBQjwH6AZ0pFm8QQ5L5hmaBF6gjFYN2gPEKAfKBUqDI4Tuj4HxN20sAmaJxogQDfwUPz9eQF9UxaBD+Q9jQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wNi0wM1QwOToyNzo1NiswMjowMNwa+WsAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDYtMDNUMDk6Mjc6NTYrMDI6MDCtR0HXAAAAQ3RFWHRzdmc6YmFzZS11cmkAZmlsZTovLy9ob21lL21hcnRpam4udGltbWVybWFucy9EZXNrdG9wL2Fja2dsaWRlcjQuc3ZnWjGMagAAAABJRU5ErkJggg==", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAD9QTFRF////Pz8/f39/AAAAfn5+Pj4+QEBAgICAREREiIiIOzs7dnZ2QwAAiAAARAAAfgAA/wAAfwAAAQEBPwAA////ODX2SQAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAABIAAAASABGyWs+AAAAYUlEQVRIx+3SOQ7AIAxEUbMECFkI4f53TT3jgjIU/p1lPYsCcR5ygeK9eIE8g0h7Awb+Ay5C6ntvtJeUocQzH1BPojkbMLAOKDtU6gFVBcKk84LuKWgP1A0YWAe81OjQ+ACuUCDjPmZ3hAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wNi0wM1QwOToyMzozMCswMjowMHBOZawAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDYtMDNUMDk6MjM6MzArMDI6MDABE90QAAAAQ3RFWHRzdmc6YmFzZS11cmkAZmlsZTovLy9ob21lL21hcnRpam4udGltbWVybWFucy9EZXNrdG9wL2Fja2dsaWRlcjEuc3ZnktEDGgAAAABJRU5ErkJggg==", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwEAYAAAAHkiXEAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dE////////CVj33AAAAAlwSFlzAAAASAAAAEgARslrPgAAAXZJREFUeNrt3DFuhDAUhOFxxK2QAAlzJpfQcicKG4n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