Common.js: Difference between revisions
From Blood on the Clocktower Wiki
(Created page with "$("li:contains('Toolbox')").hide(); $("img").contextmenu(function() { return false; }); $(document).ready(function() { var e_interactions = document.querySelector("#interactions"); var language = e_interactions.dataset.language; var href = window.location.href var slash = href.indexOf("/", 8) var hashtag = href.indexOf("#") var key = href.substring(slash + 1, hashtag == -1 ? href.length : hashtag) .replace...") |
No edit summary |
||
Line 5: | Line 5: | ||
}); | }); | ||
/* | |||
$(document).ready(function() | $(document).ready(function() | ||
{ | { | ||
Line 96: | Line 97: | ||
}); | }); | ||
}); | }); | ||
*/ |
Revision as of 19:20, 5 March 2023
$("li:contains('Toolbox')").hide(); $("img").contextmenu(function() { return false; }); /* $(document).ready(function() { var e_interactions = document.querySelector("#interactions"); var language = e_interactions.dataset.language; var href = window.location.href var slash = href.indexOf("/", 8) var hashtag = href.indexOf("#") var key = href.substring(slash + 1, hashtag == -1 ? href.length : hashtag) .replace(" ", "") .replace("-", "") .replace("'", "") .replace("_", "") .replace("%27", "") .toLowerCase(); fetch("https://interactions.patters.live/api/interactions/by-key/" + key + "/" + language) .then(function(response) { if (!response) { return; } response.json() .then(function(interactions) { interactions.sort(function(a, b) { var aKey = (a.primaryKey !== key ? a.primaryKey : a.secondaryKey) var bKey = (b.primaryKey !== key ? b.primaryKey : b.secondaryKey) if (aKey < bKey) return -1; if (aKey > bKey) return 1; return 0; }) var content = "" var table = document.createElement("table") var tr = document.createElement("tr") var thRole = document.createElement("th") thRole.style.fontWeight = "bold" var thDescription = document.createElement("th") thDescription.style.fontWeight = "bold" thRole.innerText = "Character" thDescription.innerText = "Description" tr.append(thRole) tr.append(thDescription) table.append(tr); for (var i = 0; i < interactions.length; i++) { var interaction = interactions[i] var tr = document.createElement("tr") var tdRole = document.createElement("td") var tdValue = document.createElement("td") if (interaction.primaryKey !== key) { tdRole.innerText = interaction.primary tdValue.innerText = interaction.value } else { tdRole.innerText = interaction.secondary tdValue.innerText = interaction.value } tr.append(tdRole) tr.append(tdValue) table.append(tr) } e_interactions.append(table) }); }); }); */