summaryrefslogtreecommitdiff
path: root/layouts/partials/typeIndex.html
diff options
context:
space:
mode:
authorCraig Jennings <craigmartinjennings@gmail.com>2024-03-24 14:41:32 -0500
committerCraig Jennings <craigmartinjennings@gmail.com>2024-03-24 14:41:32 -0500
commit4aed6ea63ae93704b5d4cc07b528a0dd70a5d752 (patch)
treed7610e41ff54da3f340cec1c86134c189a44db8a /layouts/partials/typeIndex.html
initial commit; forked from https://github.com/Yukuro/hugo-theme-shell
Diffstat (limited to 'layouts/partials/typeIndex.html')
-rw-r--r--layouts/partials/typeIndex.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/layouts/partials/typeIndex.html b/layouts/partials/typeIndex.html
new file mode 100644
index 0000000..ab2526f
--- /dev/null
+++ b/layouts/partials/typeIndex.html
@@ -0,0 +1,66 @@
+<span id="ps1_01"></span> <span id="cd"></span> <br>
+<span id="ps1_02"></span> <span id="cat"></span> <br>
+<span id="std_out_01"></span> <br>
+<span id="ps1_03"></span> <span id="tree"></span> <br>
+<span id="std_out_02"></span> <br>
+<span id="ps1_04"></span>
+
+<script type="text/javascript">
+ async function typewriter(text, elementId, waitAfter) {
+ var n = 0,
+ isTag = false
+ addText = "";
+ const el = document.getElementById(elementId);
+
+ const wait = () => new Promise(r => setTimeout(r, waitAfter));
+ const nowait = () => new Promise(r => r());
+
+ const render = () => el.innerHTML = (text.slice(0, n + 1) + addText);
+
+ const cursor = document.createElement('span');
+ cursor.id = "blink";
+
+ el.style.setProperty("--cursor-visibility", "visible");
+ while (n < text.length) {
+ if (text.charAt(n + 1) === "<") isTag = true;
+ if (text.charAt(n + 1) === ">") isTag = false;
+
+ if (isTag) {
+ n++;
+ continue;
+ }
+
+ requestAnimationFrame(render);
+
+ if (waitAfter === 0) {
+ await nowait();
+ } else {
+ await wait();
+ }
+
+ n++;
+ }
+ el.style.setProperty("--cursor-visibility", "collapse");
+ }
+
+ function parseDelay(d) {
+ const parsed = parseInt(d, 10);
+ if (isNaN(parsed)) return 0;
+ return parsed;
+ }
+
+ const ps1Delay = parseDelay("{{ .ps1delay }}"),
+ stdoutDelay = parseDelay("{{ .stdoutdelay }}"),
+ commandDelay = parseDelay("{{ .commanddelay }}");
+ const typeeffetct = async () => {
+ await typewriter("{{ .env }}", "ps1_01", ps1Delay); await typewriter("{{ .cd }}", "cd", commandDelay);
+ await typewriter("{{ .envWithDir }}", "ps1_02", ps1Delay); await typewriter("{{ .cat }}", "cat", commandDelay);
+ await typewriter("{{ .description }}", "std_out_01", stdoutDelay);
+ await typewriter("{{ .envWithDir }}", "ps1_03", ps1Delay); await typewriter("{{ .tree }}", "tree", commandDelay);
+ await typewriter("{{ .leaf }}", "std_out_02", stdoutDelay);
+ await typewriter("{{ .envWithDir }}", "ps1_04", ps1Delay);
+ return;
+ }
+
+ typeeffetct()
+</script> \ No newline at end of file