mirror of
https://gitdab.com/cadence/breezewiki.git
synced 2026-03-05 13:40:27 -05:00
Fix tabs for jsonp
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// sample: bandori/wiki/BanG_Dream!_Wikia
|
||||
// sample: ensemble-stars/wiki/The_English_Ensemble_Stars_Wiki
|
||||
|
||||
import {h, htm, render, signal, computed, effect} from "./preact.js"
|
||||
import {h, htm, render, signal, computed, effect} from "preact"
|
||||
const html = htm.bind(h)
|
||||
|
||||
const now = signal(Date.now())
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import {h, htm, render, signal, computed, effect} from "./preact.js"
|
||||
import {h, htm, render, signal, computed, effect} from "preact"
|
||||
const html = htm.bind(h)
|
||||
|
||||
// *** Status
|
||||
|
||||
const loaded = signal(false)
|
||||
export {loaded}
|
||||
|
||||
// *** Loading indicator
|
||||
|
||||
render(html`Loading, please wait...`, document.getElementById("loading"))
|
||||
@@ -69,6 +74,7 @@ async function cont() {
|
||||
if (redirectTo) {
|
||||
redirectTo.click()
|
||||
}
|
||||
loaded.value = true
|
||||
})
|
||||
|
||||
xhr.open("POST", "/api/render/wiki")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {h, htm, render, signal, computed, effect} from "./preact.js"
|
||||
import {h, htm, render, signal, computed, effect} from "preact"
|
||||
const html = htm.bind(h)
|
||||
const classNames = classArr => classArr.filter(el => el).join(" ")
|
||||
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
"use strict";
|
||||
import {effect} from "preact"
|
||||
import {loaded} from "jsonp"
|
||||
|
||||
const tabFromHash = location.hash.length > 1 ? location.hash.substring(1) : null
|
||||
|
||||
for (const tabber of document.body.querySelectorAll(".wds-tabber")) {
|
||||
for (const [tab, content] of getTabberTabs(tabber)) {
|
||||
// set up click listener on every tab
|
||||
tab.addEventListener("click", e => {
|
||||
setCurrentTab(tabber, tab, content)
|
||||
e.preventDefault()
|
||||
})
|
||||
function setUpAllTabs() {
|
||||
for (const tabber of document.body.querySelectorAll(".wds-tabber")) {
|
||||
for (const [tab, content] of getTabberTabs(tabber)) {
|
||||
// set up click listener on every tab
|
||||
tab.addEventListener("click", e => {
|
||||
setCurrentTab(tabber, tab, content)
|
||||
e.preventDefault()
|
||||
})
|
||||
|
||||
// re-open a specific tab on page load based on the URL hash
|
||||
if (tab.dataset.hash === tabFromHash) {
|
||||
setCurrentTab(tabber, tab, content)
|
||||
tab.scrollIntoView()
|
||||
// re-open a specific tab on page load based on the URL hash
|
||||
if (tab.dataset.hash === tabFromHash) {
|
||||
setCurrentTab(tabber, tab, content)
|
||||
tab.scrollIntoView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,4 +40,16 @@ function setCurrentTab(tabber, tab, content) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!BWData.jsonp) {
|
||||
setUpAllTabs()
|
||||
} else if (loaded.value) {
|
||||
setUpAllTabs()
|
||||
} else {
|
||||
effect(() => {
|
||||
if (loaded.value) {
|
||||
setUpAllTabs()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
document.body.classList.remove("bw-tabs-nojs")
|
||||
|
||||
Reference in New Issue
Block a user