keys: speed up javascript search for header title
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 18 Jun 2017 07:50:25 +0000 (09:50 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 17 Jul 2017 15:13:43 +0000 (17:13 +0200)
Ignore subsequent headers to avoid duplicate work.

keys.js

diff --git a/keys.js b/keys.js
index 993e8f4..5dc2e2d 100644 (file)
--- a/keys.js
+++ b/keys.js
@@ -11,7 +11,9 @@ function setmode(classname) {
        var h3s = document.getElementsByTagName('TH');
        for (var i = 0; i < h3s.length; i++) {
                if (h3s[i].parentNode.style.display != 'block') continue;
-               document.getElementsByTagName('H2')[0].innerHTML = h3s[i].firstChild.data;
+               var header = h3s[i].firstChild.data;
+               document.getElementsByTagName('H2')[0].innerHTML = header;
+               break;
        }
 }