Skip to content

Commit

Permalink
chore: something
Browse files Browse the repository at this point in the history
  • Loading branch information
Burial0268 committed Aug 1, 2024
1 parent eae3df5 commit eb819f0
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions js/src/forum/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import app from "flarum/forum/app";
import createComponent from "./createComponent";
import { componentType } from "./createComponent";
import CommentPost from "flarum/forum/components/CommentPost";
import {extend} from "flarum/common/extend";
import downloadButtonInteraction from "./downloadButtonInteraction";

const createComponentIfNeeded = (containers: NodeListOf<Element>, type: componentType) => {
for (const container of Array.from(containers)) {
if (container.children.length === 0) {
createComponent(container as HTMLElement, type);
}
}
};

app.initializers.add("gbcl-fof-upload-qcloud", () => {
downloadButtonInteraction();
Expand All @@ -12,18 +20,7 @@ downloadButtonInteraction();
const playerContainers = document.querySelectorAll(".qcloud-player-container")
const pdfContainers = document.querySelectorAll('.qcloud-pdf-container');

if (playerContainers.length) {
for (const i of Array.from(playerContainers)) {
if (i.children.length) continue;
createComponent(i as HTMLElement, 'video')
}
}

if (pdfContainers.length) {
for (const i of Array.from(pdfContainers)) {
if (i.children.length) continue;
createComponent(i as HTMLElement, 'pdf')
}
}
createComponentIfNeeded(playerContainers, 'video');
createComponentIfNeeded(pdfContainers, 'pdf');
});
});

0 comments on commit eb819f0

Please sign in to comment.