X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/d1a47ecf1b72f55598b2728f82f6b4edb9ebcfa9..d4937c088ffb429c8b3fdf1b3d35b8cbc78d1290:/keys.js diff --git a/keys.js b/keys.js new file mode 100644 index 0000000..d891b52 --- /dev/null +++ b/keys.js @@ -0,0 +1,25 @@ +function setmode(classname) { + // set style for each #rows>li>ul>li to display:none unless it matches classname + var showclass = classname ? ' '+classname+'(?!\\w)' : '^$'; + var parentskip = /^keys/; + var row = document.getElementById('rows').firstChild; + do { + if (row.tagName == 'LI' && row.firstChild.tagName == 'UL' + && !row.firstChild.className.match(parentskip)) { + var el = row.firstChild.firstChild; + if (el) do { + if (el.tagName == 'LI') { + el.style.display = el.className.match(showclass) ? 'block' : 'none'; + } + } while (el = el.nextSibling); + } + } while (row = row.nextSibling); + + // update H2 to reflect the first part of a currently active (but hidden) H3 + var h3s = document.getElementsByTagName('H3'); + 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; + } +} +