-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script setup lang="ts"> | ||
import ftmlWorker from '../../module/ftml.web.worker.js?bundled-worker&dataurl'; | ||
let ftml = new Worker(ftmlWorker, { | ||
type: 'module', | ||
}); | ||
const jsonurl = "https://tech.scp-jp.org/scp-jp/tags/tags.json" | ||
const paramsTag = decodeURI(location.hash.replace("#", "")) | ||
fetch(jsonurl) | ||
.then(response => response.json()) | ||
.then(data => { | ||
const tags = data.filter(dict => dict.tag === paramsTag) | ||
if (tags.length > 0) { | ||
document.querySelector("div.tag-desc > div.tag-desc-title > h2 > span > span.tag-desc.tag")!.textContent = tags[0].tag | ||
document.querySelector("div.tag-desc > div.tag-desc-title > h2 > span > span.tag-desc.category")!.textContent = tags[0].category | ||
ftml.postMessage(tags[0].desc) | ||
} else { | ||
console.log("No match") | ||
} | ||
}); | ||
ftml.onmessage = (event: MessageEvent) => { | ||
const {html, styles } = event.data; | ||
const tagContent = document.querySelector("#page-content > div.tag-desc > div.tag-desc-body > div > p")!; | ||
tagContent.innerHTML = html.replace("\<wj-body class=\"wj-body\"\>", "").replace("\<\/wj-body\>", ""); | ||
const tagStyles = document.getElementById('tagStyles')!; | ||
if (styles.length > 0) { | ||
tagStyles.innerHTML = styles.map((v: string) => `<style>\n${v.replace(/\\</g, '<')}\n</style>`).join("\n\n"); | ||
} else { | ||
tagStyles.innerHTML = ""; | ||
} | ||
}; | ||
</script> | ||
<style> | ||
span.tag-desc.category { | ||
font-size: 0.8em; | ||
} | ||
span.tag-desc.tag { | ||
color: red; | ||
} | ||
.tag-desc-title h2 { | ||
text-align: center; | ||
} | ||
</style> | ||
<template> | ||
<div class="tag-desc"> | ||
<div class="tag-desc-title"> | ||
<h2> | ||
<span class="tag-desc-title-text"> | ||
<span class="tag-desc tag"></span> | ||
<span class="tag-desc category"></span> | ||
</span> | ||
</h2> | ||
</div> | ||
<div class="tag-desc-body"> | ||
<div class="tag-desc-body-text"> | ||
<p class="tag-desc-body-text"> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div id="tagStyles"></div> | ||
<hr /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters