Skip to content

Commit

Permalink
✨ colmodの追加
Browse files Browse the repository at this point in the history
  • Loading branch information
r74tech committed Nov 1, 2023
1 parent 435d777 commit 038c9dc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/script/eventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from './elements';

import { loadlocales } from './locales';
import { displayLocalStorageData, displayData, displayDataPW } from './loader';
import { displayLocalStorageData, displayData } from './loader';

import { ftml } from './worker';

Expand Down
48 changes: 48 additions & 0 deletions src/script/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export default function wikidotmodule() {
const containers = document.querySelectorAll(".foldable-list-container");
containers.forEach((container) => {
container.addEventListener("click", foldableMenuToggle);
});
}





// Wikidot module
// 1. foldable-list
export const foldableMenuToggle = (event: Event) => {
let target = event.target;

if (!(target instanceof HTMLElement)) {
return;
}

if (target?.tagName === "A" && target.href !== "#" && !target.href.startsWith("javascript:")) {
return;
}

while (target && target.tagName.toLowerCase() !== "li") {
target = target.parentNode as HTMLElement | null;
}

if (!target) return;

if (!target.classList.contains("folded") && !target.classList.contains("unfolded")) {
return;
}

if (target.classList.contains("folded")) {
target.classList.replace("folded", "unfolded");
const list = target.querySelector("ul");
if (list) {
list.style.display = "";
}
} else {
target.classList.replace("unfolded", "folded");
const list = target.querySelector("ul");
if (list) {
list.style.display = "none";
}
}
};
2 changes: 2 additions & 0 deletions src/script/worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ftmlWorker from '../ftml.web.worker.js?bundled-worker&dataurl';
import { setInnerHtml } from './utils';
import wikidotmodule from './module';

export const ftml = new Worker(ftmlWorker, {
type: 'module',
Expand All @@ -23,6 +24,7 @@ const handleMessage = (event) => {
}

setInnerHtml(targetContent, cleanedHtml);
wikidotmodule();
};

ftml.onmessage = handleMessage;

0 comments on commit 038c9dc

Please sign in to comment.