MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Cryptshare Documentation
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 80: | Zeile 80: | ||
var SideBar = { | var SideBar = { | ||
normalizeName : function(name) { | normalizeName : function(name) { | ||
var normalizedName = name.replaceAll("_", " ") | |||
normalizedName.replaceAll("%26", "&") | |||
normalizedName.replaceAll("%2B", "+") | |||
return normalizedName | |||
}, | }, | ||
getPageName : function(url) { | getPageName : function(url) { | ||
Zeile 94: | Zeile 97: | ||
selectMenuItem : function(name) { | selectMenuItem : function(name) { | ||
console.log("SideBar Navigation - Selecting ", name) | console.log("SideBar Navigation - Selecting ", name) | ||
$('#sidebar-navigation a:contains("' + name + '")').toggleClass("selected") | var item = $('#sidebar-navigation a:contains("' + name + '")') | ||
if (item.length === 0) // MediaWiki makes an uppercase URL in some cases | |||
item = $('#sidebar-navigation a:contains("' + name.toLowerCase() + '")') | |||
if (item.length === 0) { // Handling titles containing a minus character | |||
for (splitItem of name.split(" ")) { | |||
if (splitItem.length > 2) { // If the splitted item has at least 3 chars | |||
// console.log("Searching: ", splitItem); | |||
var result = $('#sidebar-navigation a:contains("' + splitItem + '")') | |||
console.log("Result: ", result); | |||
// console.log("Result length: ", result.length); | |||
if (result.length > 0) { | |||
$(result).toggleClass("selected") | |||
break | |||
} | |||
} | |||
} | |||
} else if (item) { | |||
$(item).toggleClass("selected") | |||
} | |||
}, | }, | ||
updateSelectedMenuItem : function() { | updateSelectedMenuItem : function() { |
Version vom 14. Oktober 2021, 10:20 Uhr
function executeStatisticsTools(current_page) { // Google Analytics (function (i, s, o, g, r, a, m) { i["GoogleAnalyticsObject"] = r; (i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments); }), (i[r].l = 1 * new Date()); (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]); a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); })( window, document, "script", "https://www.google-analytics.com/analytics.js", "ga" ); ga("create", "UA-24783289-5", "auto"); ga("set", "anonymizeIp", true); ga("require", "displayfeatures"); ga("require", "linkid", "linkid.js"); if (current_page) { ga("send", current_page); } else { ga("send", "pageview"); } // Bing (function (w, d, t, r, u) { var f, n, i; (w[u] = w[u] || []), (f = function () { var o = { ti: "28001641" }; (o.q = w[u]), (w[u] = new UET(o)), w[u].push("pageLoad"); }), (n = d.createElement(t)), (n.src = r), (n.async = 1), (n.onload = n.onreadystatechange = function () { var s = this.readyState; (s && s !== "loaded" && s !== "complete") || (f(), (n.onload = n.onreadystatechange = null)); }), (i = d.getElementsByTagName(t)[0]), i.parentNode.insertBefore(n, i); })(window, document, "script", "//bat.bing.com/bat.js", "uetq"); } if (Cookiebot) { window.addEventListener( "CookiebotOnAccept", function (e) { if (Cookiebot.consent.statistics) { executeStatisticsTools(); } }, false ); } function markAnonymousUser() { if ($("#pt-login").length > 0) { $(document.body).addClass("anonymous"); } } $(document).ready(function () { markAnonymousUser(); SideBar.updateSelectedMenuItem(); }); var SideBar = { normalizeName : function(name) { var normalizedName = name.replaceAll("_", " ") normalizedName.replaceAll("%26", "&") normalizedName.replaceAll("%2B", "+") return normalizedName }, getPageName : function(url) { var pos = url.lastIndexOf(":") var lastPos = url.indexOf("?") if (lastPos === -1) lastPos = url.indexOf("&") if (lastPos === -1) return decodeURI(url.substring(pos + 1)) else return decodeURI(url.substring(pos + 1, lastPos)) }, selectMenuItem : function(name) { console.log("SideBar Navigation - Selecting ", name) var item = $('#sidebar-navigation a:contains("' + name + '")') if (item.length === 0) // MediaWiki makes an uppercase URL in some cases item = $('#sidebar-navigation a:contains("' + name.toLowerCase() + '")') if (item.length === 0) { // Handling titles containing a minus character for (splitItem of name.split(" ")) { if (splitItem.length > 2) { // If the splitted item has at least 3 chars // console.log("Searching: ", splitItem); var result = $('#sidebar-navigation a:contains("' + splitItem + '")') console.log("Result: ", result); // console.log("Result length: ", result.length); if (result.length > 0) { $(result).toggleClass("selected") break } } } } else if (item) { $(item).toggleClass("selected") } }, updateSelectedMenuItem : function() { SideBar.selectMenuItem(SideBar.normalizeName(SideBar.getPageName(window.location.href))) } }