]> git.armaanb.net Git - chorizo.git/blobdiff - user-scripts/hints.js
Rename project to chorizo
[chorizo.git] / user-scripts / hints.js
index 0db5349668d2aebbb16c9dee3a3ebbd4550eeb56..01fc6408c4e12fb06a0a6adb212aae12a123c06e 100644 (file)
@@ -1,5 +1,5 @@
-// This is NOT a core component of lariza, but an optional user script.
-// Please refer to lariza.usage(1) for more information on user scripts.
+// This is NOT a core component of chorizo, but an optional user script.
+// Please refer to chorizo.usage(1) for more information on user scripts.
 
 // Press "f" (open link in current window) or "F" (open in new window)
 // to activate link hints. After typing the characters for one of them,
@@ -9,7 +9,7 @@
 // flaws. For more background on this topic, see this blog post:
 // https://www.uninformativ.de/blog/postings/2020-02-24/0/POSTING-en.html
 
-// Based on the following, but modified for lariza and personal taste:
+// Based on the following, but modified for chorizo and personal taste:
 //
 // easy links for surf
 // christian hahn <ch radamanthys de>, sep 2010
@@ -32,7 +32,7 @@ function update_highlights_or_abort()
     var col_sel, col_unsel;
     var longest_id = 0;
 
-    if (document.lariza_hints.state === "follow_new")
+    if (document.chorizo_hints.state === "follow_new")
     {
         col_unsel = "#DAFFAD";
         col_sel = "#FF5D00";
@@ -43,21 +43,21 @@ function update_highlights_or_abort()
         col_sel = "#33FF00";
     }
 
-    for (var id in document.lariza_hints.labels)
+    for (var id in document.chorizo_hints.labels)
     {
-        var label = document.lariza_hints.labels[id];
+        var label = document.chorizo_hints.labels[id];
         var bgcol = col_unsel;
 
         longest_id = Math.max(longest_id, id.length);
 
-        if (document.lariza_hints.box.value !== "")
+        if (document.chorizo_hints.box.value !== "")
         {
-            submatch = id.match("^" + document.lariza_hints.box.value);
+            submatch = id.match("^" + document.chorizo_hints.box.value);
             if (submatch !== null)
             {
                 var href_suffix = "";
                 var box_shadow_inner = "#B00000";
-                if (id === document.lariza_hints.box.value)
+                if (id === document.chorizo_hints.box.value)
                 {
                     bgcol = col_sel;
                     box_shadow_inner = "red";
@@ -91,16 +91,16 @@ function update_highlights_or_abort()
         label.span.style.backgroundColor = bgcol;
     }
 
-    if (document.lariza_hints.box.value.length > longest_id)
+    if (document.chorizo_hints.box.value.length > longest_id)
         set_state("inactive");
 }
 
 function open_match()
 {
-    var choice = document.lariza_hints.box.value;
-    var was_state = document.lariza_hints.state;
+    var choice = document.chorizo_hints.box.value;
+    var was_state = document.chorizo_hints.state;
 
-    var elem = document.lariza_hints.labels[choice].elem;
+    var elem = document.chorizo_hints.labels[choice].elem;
     set_state("inactive");  /* Nukes labels. */
 
     if (elem)
@@ -153,20 +153,20 @@ function set_state(new_state)
 {
     console.log("[hints] New state: " + new_state);
 
-    document.lariza_hints.state = new_state;
+    document.chorizo_hints.state = new_state;
 
-    if (document.lariza_hints.state === "inactive")
+    if (document.chorizo_hints.state === "inactive")
     {
         nuke_labels();
 
         // Removing our box causes unwanted scrolling. Just hide it.
-        document.lariza_hints.box.blur();
-        document.lariza_hints.box.value = "";
-        document.lariza_hints.box.style.visibility = "hidden";
+        document.chorizo_hints.box.blur();
+        document.chorizo_hints.box.value = "";
+        document.chorizo_hints.box.style.visibility = "hidden";
     }
     else
     {
-        if (document.lariza_hints.labels === null)
+        if (document.chorizo_hints.labels === null)
             create_labels();
 
         // What a terrible hack.
@@ -176,11 +176,11 @@ function set_state(new_state)
         // input element is currently focused. So ... yup, we install an
         // invisible text box (opacity 0) and focus it while follow mode
         // is active.
-        var box = document.lariza_hints.box;
+        var box = document.chorizo_hints.box;
         if (box === null)
         {
-            document.lariza_hints.box = document.createElement("input");
-            box = document.lariza_hints.box;
+            document.chorizo_hints.box = document.createElement("input");
+            box = document.chorizo_hints.box;
 
             box.addEventListener("keydown", on_box_key);
             box.addEventListener("input", on_box_input);
@@ -190,7 +190,7 @@ function set_state(new_state)
             box.style.top = "0px";
             box.type = "text";
 
-            box.setAttribute("lariza_input_box", "yes");
+            box.setAttribute("chorizo_input_box", "yes");
 
             document.body.appendChild(box);
         }
@@ -204,12 +204,12 @@ function set_state(new_state)
 
 function create_labels()
 {
-    document.lariza_hints.labels = new Object();
+    document.chorizo_hints.labels = new Object();
 
     var selector = "a[href]:not([href=''])";
-    if (document.lariza_hints.state !== "follow_new")
+    if (document.chorizo_hints.state !== "follow_new")
     {
-        selector += ", input:not([type=hidden]):not([lariza_input_box=yes])";
+        selector += ", input:not([type=hidden]):not([chorizo_input_box=yes])";
         selector += ", textarea, select, button";
     }
 
@@ -242,7 +242,7 @@ function create_labels()
         span.style.visibility = "hidden";
         span.style.zIndex = "2147483647";  // Max for WebKit according to luakit
 
-        document.lariza_hints.labels[label_id] = {
+        document.chorizo_hints.labels[label_id] = {
             "elem": elem,
             "span": span,
             "parent_style": null,
@@ -272,9 +272,9 @@ function create_labels()
 
 function nuke_labels()
 {
-    for (var id in document.lariza_hints.labels)
+    for (var id in document.chorizo_hints.labels)
     {
-        var label = document.lariza_hints.labels[id];
+        var label = document.chorizo_hints.labels[id];
 
         reset_parent_style(label);
 
@@ -285,7 +285,7 @@ function nuke_labels()
             label.elem.parentNode.removeChild(label.span);
     }
 
-    document.lariza_hints.labels = null;
+    document.chorizo_hints.labels = null;
 }
 
 function on_box_input(e)
@@ -319,7 +319,7 @@ function on_window_key(e)
         return;
     }
 
-    if (document.lariza_hints.state === "inactive")
+    if (document.chorizo_hints.state === "inactive")
     {
         if (e.key === key_follow)
             set_state("follow");
@@ -328,12 +328,12 @@ function on_window_key(e)
     }
 }
 
-if (document.lariza_hints === undefined)
+if (document.chorizo_hints === undefined)
 {
-    document.lariza_hints = new Object();
-    document.lariza_hints.box = null;
-    document.lariza_hints.labels = null;
-    document.lariza_hints.state = "inactive";
+    document.chorizo_hints = new Object();
+    document.chorizo_hints.box = null;
+    document.chorizo_hints.labels = null;
+    document.chorizo_hints.state = "inactive";
 
     document.addEventListener("keyup", on_window_key);