more of new tiers buttons..
This commit is contained in:
parent
f5af0012f0
commit
6339510cb8
2 changed files with 57 additions and 77 deletions
|
@ -187,7 +187,7 @@ select {
|
||||||
background-color: #ffccbc;
|
background-color: #ffccbc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#newtier {
|
.newtiers {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
132
src/App.svelte
132
src/App.svelte
|
@ -23,6 +23,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reckonHasesCandidates() {
|
||||||
|
return diffArrr(hases, [
|
||||||
|
...frontmatter["triad"].map((t) => {
|
||||||
|
return t.fmKey;
|
||||||
|
}),
|
||||||
|
...frontmatter["ascriptions"].map((t) => {
|
||||||
|
return t.fmKey;
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
function diffArrr(arr, arrr) {
|
function diffArrr(arr, arrr) {
|
||||||
let diff = new Set(arr);
|
let diff = new Set(arr);
|
||||||
for (let e of arrr) {
|
for (let e of arrr) {
|
||||||
|
@ -31,57 +42,38 @@
|
||||||
return Array.from(diff);
|
return Array.from(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newTier(fmKeyType, fmKey, fmValue = "") {
|
function newTier(fmKeyType, fmKey, fmValue) {
|
||||||
console.log("newTier", fmKeyType, fmKey);
|
let tiers = [];
|
||||||
|
let candidates = [];
|
||||||
if (fmKeyType == "ascriptions" && fmKey == "_new") {
|
if (fmKey == "_new") {
|
||||||
hasesCandidates = [... new Set(reckonHasesCandidates())]
|
hasesCandidates = [... new Set(reckonHasesCandidates())]
|
||||||
if (hasesCandidates.length > 0) {
|
if (hasesCandidates.length > 0) {
|
||||||
fmKey = hasesCandidates[0]
|
fmKey = hasesCandidates[0]
|
||||||
console.log(hasesCandidates, fmKey)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let tiers = [];
|
|
||||||
let candidates = [];
|
|
||||||
METASP[fmKey].tiers.forEach((t) => {
|
|
||||||
if (fmValue.includes(t.file)) {
|
|
||||||
tiers.push(t);
|
|
||||||
} else {
|
|
||||||
candidates.push(t);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
frontmatter[fmKeyType].push({
|
|
||||||
fmKey: fmKey,
|
|
||||||
tiers: tiers,
|
|
||||||
candidates: [...new Set(candidates)],
|
|
||||||
});
|
|
||||||
frontmatter = { ...frontmatter };
|
|
||||||
}
|
|
||||||
|
|
||||||
function newHasTiers(arrgs) {
|
if (fmKey != "_new") {
|
||||||
let [fmKeyType, index, oldFmKey, newFmKey] = arrgs.detail;
|
if (fmValue) {
|
||||||
hasesCandidates = [... new Set(reckonHasesCandidates())]
|
METASP[fmKey].tiers.forEach((t) => {
|
||||||
console.log(hasesCandidates)
|
if (fmValue.includes(t.file)) {
|
||||||
if (fmKeyType=="triad" && oldFmKey == "_new") {
|
tiers.push(t);
|
||||||
if (hasesCandidates.length > 0) {
|
} else {
|
||||||
newFmKey = hasesCandidates[0];
|
candidates.push(t);
|
||||||
if (hasesCandidates.length > 1) {
|
|
||||||
oldFmKey = hasesCandidates[1]
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
return
|
tiers = [];
|
||||||
|
candidates = METASP[fmKey].tiers;
|
||||||
}
|
}
|
||||||
|
frontmatter[fmKeyType].push({
|
||||||
|
fmKey: fmKey,
|
||||||
|
tiers: tiers,
|
||||||
|
candidates: [...new Set(candidates)],
|
||||||
|
});
|
||||||
|
frontmatter = { ...frontmatter };
|
||||||
}
|
}
|
||||||
|
hasesCandidates = [... new Set(reckonHasesCandidates())]
|
||||||
frontmatter[fmKeyType][index] = {
|
toggleNewTiersButtons()
|
||||||
fmKey: newFmKey,
|
|
||||||
tiers: [],
|
|
||||||
candidates: METASP[newFmKey].tiers,
|
|
||||||
};
|
|
||||||
|
|
||||||
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
|
||||||
hasesCandidates = [...hasesCandidates, oldFmKey];
|
|
||||||
toggleNewTriadButton();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadHugoPageMetadata(editHash) {
|
function loadHugoPageMetadata(editHash) {
|
||||||
|
@ -131,22 +123,12 @@
|
||||||
const tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
const tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
||||||
title = repo.frontmatter[tkey];
|
title = repo.frontmatter[tkey];
|
||||||
|
|
||||||
toggleNewTriadButton();
|
toggleNewTiersButtons();
|
||||||
};
|
};
|
||||||
el.src = `../js/repo/${editHash}.js`;
|
el.src = `../js/repo/${editHash}.js`;
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reckonHasesCandidates() {
|
|
||||||
return diffArrr(hases, [
|
|
||||||
...frontmatter["triad"].map((t) => {
|
|
||||||
return t.fmKey;
|
|
||||||
}),
|
|
||||||
...frontmatter["ascriptions"].map((t) => {
|
|
||||||
return t.fmKey;
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
function addToCandidatesRemoveFromTiers(arrgs) {
|
function addToCandidatesRemoveFromTiers(arrgs) {
|
||||||
const [fmKeyType, index, fmKey, tier] = arrgs.detail;
|
const [fmKeyType, index, fmKey, tier] = arrgs.detail;
|
||||||
frontmatter[fmKeyType][index]["fmKey"] = fmKey;
|
frontmatter[fmKeyType][index]["fmKey"] = fmKey;
|
||||||
|
@ -186,26 +168,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newFrontmatter() {
|
function toggleNewTiersButtons() {
|
||||||
return Object.entries(frontmatter)
|
hasesCandidates = [... new Set(reckonHasesCandidates())]
|
||||||
.filter((val) => val[1].length == 0)
|
|
||||||
.map((key) => key[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleNewTriadButton() {
|
if (hasesCandidates.length == 0) {
|
||||||
const ct = Object.entries(frontmatter).filter((i) => i[1].length == 0 && i[0] == "triad");
|
document.querySelectorAll(".newtiers").forEach((button)=> {
|
||||||
if (document.getElementById("newtier")) {
|
button.style.display = "none";
|
||||||
if (ct.length == 0) {
|
})
|
||||||
document.getElementById("newtier").style.display = "none";
|
} else {
|
||||||
} else {
|
document.querySelectorAll(".newtiers").forEach((button)=> {
|
||||||
document.getElementById("newtier").style.display = "block";
|
button.style.display = "block";
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function newTriad() {
|
const ct = Object.entries(frontmatter).filter((i) => i[1].length == 0 && i[0] == "triad")[0];
|
||||||
newHasTiers({ detail: ["triad", 0, "_new", ""] });
|
if (!ct) {
|
||||||
}
|
document.getElementById("newtriad").style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function dispatchHash() {
|
function dispatchHash() {
|
||||||
const searchParams = new URLSearchParams(location.search);
|
const searchParams = new URLSearchParams(location.search);
|
||||||
|
@ -214,17 +194,17 @@
|
||||||
loadHugoPageMetadata(editHash);
|
loadHugoPageMetadata(editHash);
|
||||||
} else {
|
} else {
|
||||||
let newPage = searchParams.get("new");
|
let newPage = searchParams.get("new");
|
||||||
console.log(newPage);
|
console.log({newPage});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
dispatchHash();
|
dispatchHash();
|
||||||
// loadHugoPageMetadata();
|
// loadHugoPageMetadata();
|
||||||
console.dir(frontmatter);
|
console.dir({frontmatter});
|
||||||
});
|
});
|
||||||
|
|
||||||
$: hashChanged = () => dispatchHash();
|
$: hashChanged = () => dispatchHash();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
||||||
|
@ -244,7 +224,7 @@
|
||||||
{fmItem}
|
{fmItem}
|
||||||
{hases}
|
{hases}
|
||||||
{hasesCandidates}
|
{hasesCandidates}
|
||||||
on:hasTiersSelected={newHasTiers}
|
on:hasTiersSelected={newTier}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<SpTiers
|
<SpTiers
|
||||||
|
@ -265,8 +245,8 @@
|
||||||
{/each}
|
{/each}
|
||||||
{/each}
|
{/each}
|
||||||
<div class="buttons news">
|
<div class="buttons news">
|
||||||
<div id="newtier" class="button" on:click={newTriad}>NEW TIER</div>
|
<div id="newtriad" class="newtiers button" on:click={()=> newTier("triad", "_new", null)}>NEW TIER</div>
|
||||||
<div id="newascription" class="button" on:click={() => newTier("ascriptions", "_new")}>
|
<div id="newascription" class="newtiers button" on:click={() => newTier("ascriptions", "_new", null)}>
|
||||||
NEW ASCRIPTION
|
NEW ASCRIPTION
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue