the other half or smth
This commit is contained in:
parent
ad32ca9c46
commit
b323a78e38
@ -37,7 +37,7 @@ function process_content(content)
|
|||||||
<span
|
<span
|
||||||
class="clickable"
|
class="clickable"
|
||||||
onclick="showPopup('REPLACE_WORD','REPLACE_SEARCH','REPLACE_DATA')"
|
onclick="showPopup('REPLACE_WORD','REPLACE_SEARCH','REPLACE_DATA')"
|
||||||
onmouseover="checkHover('REPLACE_WORD','REPLACE_SEARCH','REPLACE_DATA')"
|
onmouseover="checkHover('REPLACE_WORD','REPLACE_SEARCH',this,'REPLACE_DATA')"
|
||||||
onmouseout="clearHover()">
|
onmouseout="clearHover()">
|
||||||
REPLACE_PRINT
|
REPLACE_PRINT
|
||||||
</span>
|
</span>
|
||||||
|
67
main.js
67
main.js
@ -11,7 +11,6 @@ let timeout = "";
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
createWordList();
|
createWordList();
|
||||||
// injectWords();
|
|
||||||
document.querySelector("#popup-container").addEventListener("click", () => {
|
document.querySelector("#popup-container").addEventListener("click", () => {
|
||||||
document.querySelector("#popup-container").style.opacity = 0;
|
document.querySelector("#popup-container").style.opacity = 0;
|
||||||
document.querySelector("#popup-container").style.pointerEvents = "none";
|
document.querySelector("#popup-container").style.pointerEvents = "none";
|
||||||
@ -25,9 +24,11 @@ function cleanWord(word) {
|
|||||||
return word.replace(/[^a-zA-Z]/g, "").toLowerCase();
|
return word.replace(/[^a-zA-Z]/g, "").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPopup(ogword, word, quirks) {
|
function showPopup(ogword, word, quirks = "") {
|
||||||
|
try {
|
||||||
clearHover();
|
clearHover();
|
||||||
//same shit as in smolpopup
|
//same shit as in smolpopup
|
||||||
|
//todo: make all of this less sphagetti LOL
|
||||||
let p = document.querySelector("#popup");
|
let p = document.querySelector("#popup");
|
||||||
let c = document.querySelector("#popup-container");
|
let c = document.querySelector("#popup-container");
|
||||||
word = cleanWord(word);
|
word = cleanWord(word);
|
||||||
@ -45,16 +46,21 @@ function showPopup(ogword, word, quirks) {
|
|||||||
p.querySelector("#popup-type").innerText = words[word]["type"];
|
p.querySelector("#popup-type").innerText = words[word]["type"];
|
||||||
p.querySelector("#popup-meaning").innerText = words[word]["meaning"];
|
p.querySelector("#popup-meaning").innerText = words[word]["meaning"];
|
||||||
let wq = "";
|
let wq = "";
|
||||||
//todo: make all of this less sphagetti LOL
|
|
||||||
if (quirks.trim() != "") {
|
if (quirks.trim() != "") {
|
||||||
wq = quirks.split(" ").join(", ");
|
wq = quirks.split(" ").join(", ");
|
||||||
}
|
}
|
||||||
p.querySelector("#popup-quirks").innerText = wq;
|
p.querySelector("#popup-quirks").innerText = wq;
|
||||||
c.style.opacity = 1;
|
c.style.opacity = 1;
|
||||||
c.style.pointerEvents = "all";
|
c.style.pointerEvents = "all";
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
//eya
|
||||||
|
//failure is expected,
|
||||||
|
//but mightaswell print less RED ERRORs to the console
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSmolPopup(ogword, word, quirks) {
|
function showSmolPopup(ogword, word, self, quirks) {
|
||||||
let p = document.querySelector("#smol-popup");
|
let p = document.querySelector("#smol-popup");
|
||||||
word = cleanWord(word);
|
word = cleanWord(word);
|
||||||
if (currentFont == "r") {
|
if (currentFont == "r") {
|
||||||
@ -79,19 +85,24 @@ function showSmolPopup(ogword, word, quirks) {
|
|||||||
p.style.opacity = 1;
|
p.style.opacity = 1;
|
||||||
p.style.pointerEvents = "all";
|
p.style.pointerEvents = "all";
|
||||||
// set position to cursor position (but we dont have the event)
|
// set position to cursor position (but we dont have the event)
|
||||||
let rect = document.body.getBoundingClientRect();
|
let rect = self.getBoundingClientRect();
|
||||||
let x = rect.left + window.event.clientX;
|
let x = rect.left+rect.width/2;
|
||||||
let y = rect.top + window.event.clientY;
|
let y = rect.top;
|
||||||
p.style.left = x - 100 + "px";
|
p.style.left = x - 100 + "px";
|
||||||
p.style.top = y + 25 + "px";
|
p.style.top = y + 25 + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkHover(ogword, word, quirks = "") {
|
function checkHover(ogword, word, self, quirks = "") {
|
||||||
if (timeout != "") {
|
if (timeout != "") {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
showSmolPopup(ogword, word, quirks);
|
try {
|
||||||
|
showSmolPopup(ogword, word, self, quirks);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
//i fucking love error handling
|
||||||
|
}
|
||||||
}, 450);
|
}, 450);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +120,7 @@ function createWordList() { //sometimes i really dislike javascript..
|
|||||||
t.querySelectorAll("tr").forEach(element => {
|
t.querySelectorAll("tr").forEach(element => {
|
||||||
if (element.querySelector("td")) {
|
if (element.querySelector("td")) {
|
||||||
let e = element.querySelectorAll("td");
|
let e = element.querySelectorAll("td");
|
||||||
let n = e[1].innerText.replace(".", "");
|
let n = cleanWord(e[1].innerText);
|
||||||
words[n] = {};
|
words[n] = {};
|
||||||
words[n]["heonian"] = e[0].innerText;
|
words[n]["heonian"] = e[0].innerText;
|
||||||
words[n]["romanization"] = e[1].innerText.replace(". ", "");
|
words[n]["romanization"] = e[1].innerText.replace(". ", "");
|
||||||
@ -120,42 +131,6 @@ function createWordList() { //sometimes i really dislike javascript..
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function injectWords() {
|
|
||||||
Object.values(words).forEach(word => {
|
|
||||||
document.querySelectorAll(".convo p").forEach(convo => {
|
|
||||||
if (convo.innerText.includes(word["romanization"])) {
|
|
||||||
let m = convo.innerHTML.split(word["romanization"]);
|
|
||||||
let newhtml = document.createElement("p");
|
|
||||||
let c = m.length*2-1;
|
|
||||||
for (let x = 0; x < c; x++) {
|
|
||||||
if (x % 2 == 0) {
|
|
||||||
newhtml.innerHTML += m[x/2];
|
|
||||||
} else {
|
|
||||||
var e = document.createElement("span");
|
|
||||||
e.innerText = word["romanization"];
|
|
||||||
e.classList.add("clickable");
|
|
||||||
newhtml.appendChild(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
convo.innerHTML = newhtml.innerHTML;
|
|
||||||
convo.querySelectorAll(".clickable").forEach(element => {
|
|
||||||
element.addEventListener('click', function(e) {
|
|
||||||
showPopup(element.innerText);
|
|
||||||
}, false);
|
|
||||||
element.addEventListener('mouseover', function(e) {
|
|
||||||
checkHover(element.innerText, e);
|
|
||||||
}
|
|
||||||
, false);
|
|
||||||
element.addEventListener('mouseout', function(e) {
|
|
||||||
clearHover();
|
|
||||||
}
|
|
||||||
, false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function fontButton() {
|
function fontButton() {
|
||||||
if (currentFont == "r") {
|
if (currentFont == "r") {
|
||||||
document.querySelector("#style-heonian").disabled = false;
|
document.querySelector("#style-heonian").disabled = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user