initial public commit
This commit is contained in:
40
public/demo/hashTwt-example-source.js
Normal file
40
public/demo/hashTwt-example-source.js
Normal file
@@ -0,0 +1,40 @@
|
||||
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 url = formHash.elements["url"].value;
|
||||
|
||||
const hash = hashTwt({
|
||||
content,
|
||||
created,
|
||||
url,
|
||||
});
|
||||
|
||||
const result = [
|
||||
\`content: \${content}\`,
|
||||
\`created: \${created}\`,
|
||||
\`url: \${url}\`,
|
||||
\`hash: \${hash}\`,
|
||||
].join("\\n");
|
||||
|
||||
console.log(
|
||||
(wasHashTwtResultAppended ? "\\n" : "") + result,
|
||||
);
|
||||
|
||||
wasHashTwtResultAppended = true;
|
||||
});
|
||||
<\/script>
|
||||
`,
|
||||
"tabHashTwt-panel",
|
||||
);
|
||||
Reference in New Issue
Block a user