Difference between revisions of "User:Tobias Alcaraz/common.min.js"

From Mine Blocks Wiki
Jump to navigation Jump to search
If you find a typo, inconsistency, or error, please sign up and help out the wiki! We can't do it without your help! :D Thank you!

(Created page with "!function(){var t,e,i,n,a={"\\&":"&","<":"<",">":">"},r=function(t){return t.replace(/\\\\/g,"\").replace(/\\&|[<>]/g,function(t){return a[t]})},s=$(),o=$(wind...")
 
 
Line 1: Line 1:
!function(){var t,e,i,n,a={"\\&":"&#38;","<":"&#60;",">":"&#62;"},r=function(t){return t.replace(/\\\\/g,"&#92;").replace(/\\&|[<>]/g,function(t){return a[t]})},s=$(),o=$(window);$("#mw-content-text").on({"mouseenter.minetip":function(a){s.remove();var l=$(this),c=l.attr("data-minetip-title");if(void 0===c&&void 0!==(c=l.attr("title"))&&(c=$.trim(c.replace(/&/g,"\\&")),l.attr("data-minetip-title",c)),"Empty"!==c){if(void 0===c||""!==c&&""===c.replace(/&([0-9a-fl-or])/g,"")){var m,d=l[0];do{d.hasAttribute("title")&&(m=d.title),d=d.firstChild}while(d&&1===d.nodeType);if(void 0===m)return;c||(c=""),c+=$.trim(m.replace(/&/g,"\\&")),l.attr("data-minetip-title",c)}if(l.data("minetip-ready")||(l.find("[title]").addBack().removeAttr("title"),l.data("minetip-ready",!0)),""!==c&&"Invisible-sprite"!==c){var p='<span class="minetip-title">'+r(c)+"&r</span>",u=$.trim(l.attr("data-minetip-text"));u&&(p+='<span class="minetip-description">'+(u=r(u).replace(/\\\//g,"&#47;")).replace(/\//g,"<br>")+"&r</span>"),p=p.replace(/&r/g,""),(s=$('<div id="minetip-tooltip">')).html(p).appendTo("body"),t=o.width(),e=o.height(),i=s.outerWidth(!0),n=s.outerHeight(!0),l.trigger("mousemove",a)}}},"mousemove.minetip":function(a,r){if(s.length){var o=(a=r||a).clientY-34,l=a.clientX+14;l+i>t&&(l-=i+36),l<0?(l=0,(o-=n-22)<0&&(o+=n+47)):o<0?o=0:o+n>e&&(o=e-n),s.css({top:o,left:l})}else $(this).trigger("mouseenter")},"mouseleave.minetip":function(){s.length&&(s.remove(),s=$())}},".minetip, .invslot-item")}(),jQuery(function(t){function e(){var e=t(this).children(),i=e.filter(".ts-active"),n=i.next();0===n.length&&(n=e.first()),i.removeClass("ts-active"),n.addClass("ts-active")}t(".ts-container").each(function(){var i,n=t(this);if(n.children().length>1){"string"==typeof(i=n.attr("data-delay-ms"))||"number"==typeof i?(i=i||0)<100&&(i=100):i=1500,n.data("delayms",i),n.on("tsanimate",e),n.trigger("tsanimate");var a=window.setInterval(function(){n.trigger("tsanimate")},i);n.mouseenter(function(){n.parents(".ts-sync").length||clearInterval(a)}).mouseleave(function(){n.parents(".ts-sync").length||(a=window.setInterval(function(){n.trigger("tsanimate")},i))}),t(".ts-sync").each(function(){t(this).mouseenter(function(){clearInterval(a)}).mouseleave(function(){a=window.setInterval(function(){n.trigger("tsanimate")},i)})})}})});
+
function setColorScheme(e){switch(e){case"dark":syntaxHighlighterConfig={backgroundColor:"transparent",foregroundColor:"unset",boldOrItalicColor:"#44466d",commentColor:"#4d1a19",entityColor:"#474d23",externalLinkColor:"",headingColor:"#44466d",hrColor:"#44466d",listOrIndentColor:"#4d1a19",parameterColor:"#66331e",signatureColor:"#66331e",tagColor:"#662946",tableColor:"#5e5129",templateColor:"#5e5129",wikilinkColor:"#245477"};break;case"light":syntaxHighlighterConfig={boldOrItalicColor:"#e4e5f3",commentColor:"#f8dbda",entityColor:"#e8ebda",externalLinkColor:"#dbeceb",headingColor:"#e4e5f3",hrColor:"#e4e5f3",listOrIndentColor:"#f8dbda",parameterColor:"#f5e0d8",signatureColor:"#f5e0d8",tagColor:"#f6dde9",tableColor:"#f0ebdb",templateColor:"#f0ebdb",wikilinkColor:"#d9eaf6"};break;default:syntaxHighlighterConfig={boldOrItalicColor:"#e4e5f3",commentColor:"#f8dbda",entityColor:"#e8ebda",externalLinkColor:"#dbeceb",headingColor:"#e4e5f3",hrColor:"#e4e5f3",listOrIndentColor:"#f8dbda",parameterColor:"#f5e0d8",signatureColor:"#f5e0d8",tagColor:"#f6dde9",tableColor:"#f0ebdb",templateColor:"#f0ebdb",wikilinkColor:"#d9eaf6"};break}}function getPreferredColorScheme(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(mw.loader.load("//code.jquery.com/jquery-3.6.0.min.js"),mw.loader.load("//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript"),function(){var e,t,r,o,i={"\\&":"&#38;","<":"&#60;",">":"&#62;"},a=function(e){return e.replace(/\\\\/g,"&#92;").replace(/\\&|[<>]/g,(function(e){return i[e]}))},n=$(),l=$(window);$("#mw-content-text").on({"mouseenter.minetip":function(i){n.remove();var d=$(this),s=d.attr("data-minetip-title");if(void 0===s&&void 0!==(s=d.attr("title"))&&(s=$.trim(s.replace(/&/g,"\\&")),d.attr("data-minetip-title",s)),"Empty"!==s){if(void 0===s||""!==s&&""===s.replace(/&([0-9a-fl-or])/g,"")){var c,m=d[0];do{m.hasAttribute("title")&&(c=m.title),m=m.firstChild}while(m&&1===m.nodeType);if(void 0===c)return;s||(s=""),s+=$.trim(c.replace(/&/g,"\\&")),d.attr("data-minetip-title",s)}if(d.data("minetip-ready")||(d.find("[title]").addBack().removeAttr("title"),d.data("minetip-ready",!0)),""!==s&&"Invisible-sprite"!==s){var f='<span class="minetip-title">'+a(s)+"&r</span>",g=$.trim(d.attr("data-minetip-text"));g&&(f+='<span class="minetip-description">'+(g=a(g).replace(/\\\//g,"&#47;")).replace(/\//g,"<br>")+"&r</span>"),f=f.replace(/&r/g,""),(n=$('<div id="minetip-tooltip">')).html(f).appendTo("body"),e=l.width(),t=l.height(),r=n.outerWidth(!0),o=n.outerHeight(!0),d.trigger("mousemove",i)}}},"mousemove.minetip":function(i,a){if(n.length){var l=(i=a||i).clientY-34,d=i.clientX+14;d+r>e&&(d-=r+36),d<0?(d=0,(l-=o-22)<0&&(l+=o+47)):l<0?l=0:l+o>t&&(l=t-o),n.css({top:l,left:d})}else $(this).trigger("mouseenter")},"mouseleave.minetip":function(){n.length&&(n.remove(),n=$())}},".minetip, .invslot-item")}(),jQuery((function(e){function t(){var t=e(this).children(),r=t.filter(".ts-active"),o=r.next();0===o.length&&(o=t.first()),r.removeClass("ts-active"),o.addClass("ts-active")}e(".ts-container").each((function(){var r,o=e(this);if(o.children().length>1){"string"==typeof(r=o.attr("data-delay-ms"))||"number"==typeof r?(r=r||0)<100&&(r=100):r=1500,o.data("delayms",r),o.on("tsanimate",t),o.trigger("tsanimate");var i=window.setInterval((function(){o.trigger("tsanimate")}),r);o.mouseenter((function(){o.parents(".ts-sync").length||clearInterval(i)})).mouseleave((function(){o.parents(".ts-sync").length||(i=window.setInterval((function(){o.trigger("tsanimate")}),r))})),e(".ts-sync").each((function(){e(this).mouseenter((function(){clearInterval(i)})).mouseleave((function(){i=window.setInterval((function(){o.trigger("tsanimate")}),r)}))}))}}))})),window.matchMedia){var colorSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)");colorSchemeQuery.addEventListener("change",setColorScheme(getPreferredColorScheme()))}

Latest revision as of 17:14, 2 January 2022

function setColorScheme(e){switch(e){case"dark":syntaxHighlighterConfig={backgroundColor:"transparent",foregroundColor:"unset",boldOrItalicColor:"#44466d",commentColor:"#4d1a19",entityColor:"#474d23",externalLinkColor:"",headingColor:"#44466d",hrColor:"#44466d",listOrIndentColor:"#4d1a19",parameterColor:"#66331e",signatureColor:"#66331e",tagColor:"#662946",tableColor:"#5e5129",templateColor:"#5e5129",wikilinkColor:"#245477"};break;case"light":syntaxHighlighterConfig={boldOrItalicColor:"#e4e5f3",commentColor:"#f8dbda",entityColor:"#e8ebda",externalLinkColor:"#dbeceb",headingColor:"#e4e5f3",hrColor:"#e4e5f3",listOrIndentColor:"#f8dbda",parameterColor:"#f5e0d8",signatureColor:"#f5e0d8",tagColor:"#f6dde9",tableColor:"#f0ebdb",templateColor:"#f0ebdb",wikilinkColor:"#d9eaf6"};break;default:syntaxHighlighterConfig={boldOrItalicColor:"#e4e5f3",commentColor:"#f8dbda",entityColor:"#e8ebda",externalLinkColor:"#dbeceb",headingColor:"#e4e5f3",hrColor:"#e4e5f3",listOrIndentColor:"#f8dbda",parameterColor:"#f5e0d8",signatureColor:"#f5e0d8",tagColor:"#f6dde9",tableColor:"#f0ebdb",templateColor:"#f0ebdb",wikilinkColor:"#d9eaf6"};break}}function getPreferredColorScheme(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(mw.loader.load("//code.jquery.com/jquery-3.6.0.min.js"),mw.loader.load("//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript"),function(){var e,t,r,o,i={"\\&":"&#38;","<":"&#60;",">":"&#62;"},a=function(e){return e.replace(/\\\\/g,"&#92;").replace(/\\&|[<>]/g,(function(e){return i[e]}))},n=$(),l=$(window);$("#mw-content-text").on({"mouseenter.minetip":function(i){n.remove();var d=$(this),s=d.attr("data-minetip-title");if(void 0===s&&void 0!==(s=d.attr("title"))&&(s=$.trim(s.replace(/&/g,"\\&")),d.attr("data-minetip-title",s)),"Empty"!==s){if(void 0===s||""!==s&&""===s.replace(/&([0-9a-fl-or])/g,"")){var c,m=d[0];do{m.hasAttribute("title")&&(c=m.title),m=m.firstChild}while(m&&1===m.nodeType);if(void 0===c)return;s||(s=""),s+=$.trim(c.replace(/&/g,"\\&")),d.attr("data-minetip-title",s)}if(d.data("minetip-ready")||(d.find("[title]").addBack().removeAttr("title"),d.data("minetip-ready",!0)),""!==s&&"Invisible-sprite"!==s){var f='<span class="minetip-title">'+a(s)+"&r</span>",g=$.trim(d.attr("data-minetip-text"));g&&(f+='<span class="minetip-description">'+(g=a(g).replace(/\\\//g,"&#47;")).replace(/\//g,"<br>")+"&r</span>"),f=f.replace(/&r/g,""),(n=$('<div id="minetip-tooltip">')).html(f).appendTo("body"),e=l.width(),t=l.height(),r=n.outerWidth(!0),o=n.outerHeight(!0),d.trigger("mousemove",i)}}},"mousemove.minetip":function(i,a){if(n.length){var l=(i=a||i).clientY-34,d=i.clientX+14;d+r>e&&(d-=r+36),d<0?(d=0,(l-=o-22)<0&&(l+=o+47)):l<0?l=0:l+o>t&&(l=t-o),n.css({top:l,left:d})}else $(this).trigger("mouseenter")},"mouseleave.minetip":function(){n.length&&(n.remove(),n=$())}},".minetip, .invslot-item")}(),jQuery((function(e){function t(){var t=e(this).children(),r=t.filter(".ts-active"),o=r.next();0===o.length&&(o=t.first()),r.removeClass("ts-active"),o.addClass("ts-active")}e(".ts-container").each((function(){var r,o=e(this);if(o.children().length>1){"string"==typeof(r=o.attr("data-delay-ms"))||"number"==typeof r?(r=r||0)<100&&(r=100):r=1500,o.data("delayms",r),o.on("tsanimate",t),o.trigger("tsanimate");var i=window.setInterval((function(){o.trigger("tsanimate")}),r);o.mouseenter((function(){o.parents(".ts-sync").length||clearInterval(i)})).mouseleave((function(){o.parents(".ts-sync").length||(i=window.setInterval((function(){o.trigger("tsanimate")}),r))})),e(".ts-sync").each((function(){e(this).mouseenter((function(){clearInterval(i)})).mouseleave((function(){i=window.setInterval((function(){o.trigger("tsanimate")}),r)}))}))}}))})),window.matchMedia){var colorSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)");colorSchemeQuery.addEventListener("change",setColorScheme(getPreferredColorScheme()))}