summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/copy.js32
-rw-r--r--js/lmmtfy.js32
2 files changed, 64 insertions, 0 deletions
diff --git a/js/copy.js b/js/copy.js
new file mode 100644
index 0000000..3bc7707
--- /dev/null
+++ b/js/copy.js
@@ -0,0 +1,32 @@
+const dom_lmmtfy = document.getElementById("lmmtfy_url");
+const dom_copy = document.getElementById("lmmtfy_copy");
+
+dom_copy.onclick = lmmtfy_copy;
+
+function lmmtfy_copy()
+{
+ dom_lmmtfy.focus();
+ dom_lmmtfy.select();
+
+ try
+ {
+ // TODO: deprecated -- https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
+ if(document.execCommand('copy'))
+ dom_copy.innerHTML = "Copied!"
+
+ setTimeout(() =>
+ {
+ dom_copy.innerHTML = "Copy"
+ }, 3000);
+
+ }
+ catch(err)
+ {
+ dom_copy.innerHTML = "Error :(";
+ console.log('Oops, unable to copy');
+ }
+
+ // This unfocuses the element, but W3C decided to be funny with
+ // the naming.
+ document.activeElement.blur();
+}
diff --git a/js/lmmtfy.js b/js/lmmtfy.js
new file mode 100644
index 0000000..d0410ab
--- /dev/null
+++ b/js/lmmtfy.js
@@ -0,0 +1,32 @@
+const dom_query = document.getElementById("query");
+const dom_sect = document.getElementById("sect");
+const dom_man = document.getElementById("man");
+
+const query = dom_query.value;
+dom_query.value = "";
+
+let i = 0, j = 0;
+let elapsed = 0;
+let actions =
+[
+ [250, () => { dom_query.focus(); }, 1],
+ [150, () => { dom_query.value += query[j++]; }, query.length],
+ [250, () => { dom_man.focus(); }, 1],
+ [250, () => { dom_man.click(); }, 1],
+];
+
+function do_stuff()
+{
+ elapsed += 50;
+
+ if((elapsed % actions[i][0]) == 0)
+ {
+ actions[i][1]();
+ actions[i][2]--;
+ if(actions[i][2] <= 0) i++;
+ }
+
+ setTimeout(do_stuff, 50);
+}
+
+do_stuff();