]> git.armaanb.net Git - chorizo.git/blobdiff - user-scripts/hints.js
draft 4
[chorizo.git] / user-scripts / hints.js
index c1854c366e260e924692056b1ab1c3164fcfe9d5..aa5daa2ddf7889f5c0cecdbe349796e07e0bac9e 100644 (file)
@@ -1,6 +1,6 @@
 // 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.
-
+// 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,
 // press Enter to confirm. Press Escape to abort.
@@ -8,7 +8,7 @@
 // This is an "80% solution". It works for many web sites, but has
 // 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 chorizo and personal taste:
 //
 // easy links for surf
@@ -28,20 +28,13 @@ var key_follow_new_win = "F";
 
 function update_highlights_or_abort() {
     var submatch;
-    var col_sel, col_unsel;
     var longest_id = 0;
 
-    if (document.chorizo_hints.state === "follow_new") {
-        col_unsel = "#DAFFAD";
-        col_sel = "#FF5D00";
-    } else {
-        col_unsel = "#A7FFF5";
-        col_sel = "#33FF00";
-    }
+    const color = (document.chorizo_hints.state === "follow_new") ? "#ffccff"
+        : "#99ffcc";
 
     for (var id in document.chorizo_hints.labels) {
         var label = document.chorizo_hints.labels[id];
-        var bgcol = col_unsel;
 
         longest_id = Math.max(longest_id, id.length);
 
@@ -49,12 +42,9 @@ function update_highlights_or_abort() {
             submatch = id.match("^" + document.chorizo_hints.box.value);
             if (submatch !== null) {
                 var href_suffix = "";
-                var box_shadow_inner = "#B00000";
                 if (id === document.chorizo_hints.box.value) {
-                    bgcol = col_sel;
-                    box_shadow_inner = "red";
                     if (label.elem.tagName.toLowerCase() === "a")
-                        href_suffix = ": <span style='font-size: 75%'>" +
+                        href_suffix = ": <span>" +
                                       label.elem.href + "</span>";
                 }
 
@@ -65,8 +55,7 @@ function update_highlights_or_abort() {
                 label.span.style.visibility = "visible";
 
                 save_parent_style(label);
-                label.elem.style.boxShadow = "0 0 5pt 2pt black, 0 0 0 2pt " +
-                                             box_shadow_inner + " inset";
+                label.elem.style.boxShadow = "0 0 5px 5px red";
             } else {
                 label.span.style.visibility = "hidden";
                 reset_parent_style(label);
@@ -76,7 +65,7 @@ function update_highlights_or_abort() {
             label.span.innerHTML = id;
             reset_parent_style(label);
         }
-        label.span.style.backgroundColor = bgcol;
+        label.span.style.backgroundColor = color;
     }
 
     if (document.chorizo_hints.box.value.length > longest_id)
@@ -195,12 +184,13 @@ function create_labels() {
         } while (n !== 0);
 
         var span = document.createElement("span");
-        span.style.border = "black 1pt solid";
+        span.style.border = "black 1px solid";
         span.style.color = "black";
         span.style.fontFamily = "monospace";
-        span.style.fontSize = "10pt";
+        span.style.fontSize = "10px";
         span.style.fontWeight = "normal";
-        span.style.margin = "0px 2pt";
+        span.style.margin = "0px 2px";
+        span.style.padding = "1px 5px";
         span.style.position = "absolute";
         span.style.textTransform = "lowercase";
         span.style.visibility = "hidden";
@@ -216,13 +206,10 @@ function create_labels() {
         // placement results, but we can *only* do this for <a> ...
         var tag_name = elem.tagName.toLowerCase();
         if (tag_name === "a") {
-            span.style.borderTopLeftRadius = "10pt";
-            span.style.borderBottomLeftRadius = "10pt";
-            span.style.padding = "0px 2pt 0px 5pt";
+            span.style.borderRadius = "2px";
             elem.appendChild(span);
         } else {
-            span.style.borderRadius = "10pt";
-            span.style.padding = "0px 5pt";
+            span.style.borderRadius = "10px";
             elem.parentNode.insertBefore(span, elem);
         }