50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
|
|
|
|
import formatSource from "./format-source.js";
|
|
|
|
formatSource(
|
|
`
|
|
\<script type="module">
|
|
import { hashTwt } from "/web/dist/twtxt-lib.js";
|
|
|
|
let wasHashTwtResultAppended = false;
|
|
|
|
const formHash = document.forms["formHash"];
|
|
formHash.addEventListener("submit", (e) => {
|
|
e.preventDefault();
|
|
|
|
const content = formHash.elements["content"].value;
|
|
const created = formHash.elements["created"].value;
|
|
const version = parseInt(formHash.elements["version"].value, 10);
|
|
const url = formHash.elements["url"].value;
|
|
|
|
const hash = hashTwt(
|
|
{
|
|
content,
|
|
created,
|
|
url,
|
|
},
|
|
version,
|
|
);
|
|
|
|
const result = [
|
|
\`content: \${content}\`,
|
|
\`created: \${created}\`,
|
|
\`url: \${url}\`,
|
|
\`version: \${version}\`,
|
|
\`hash: \${hash}\`,
|
|
].join("\\n");
|
|
|
|
console.log(
|
|
(wasHashTwtResultAppended ? "\\n" : "") + result,
|
|
);
|
|
|
|
wasHashTwtResultAppended = true;
|
|
});
|
|
<\/script>
|
|
`,
|
|
"tabHashTwt-panel",
|
|
);
|
|
|
|
// @license-end
|