1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-29 06:02:27 +01:00

Fix some generally silly, stupid, and/or annoying help quirks.

This commit is contained in:
Kris Maglione
2008-12-20 23:48:56 -05:00
parent 2f0132cabc
commit df7c7c9d51
4 changed files with 59 additions and 41 deletions

View File

@@ -76,8 +76,8 @@ tag=<span class="tag">|</span>
key=<div class="key">|</div>
option=<a class="option" href="#">|</a>
option2=<a class="option" href="#">'|'</a>
command=<a class="command">|</a>
mapping=<a class="mapping">|</a>
command=<a class="command" href="#">|</a>
mapping=<a class="mapping" href="#">|</a>
argument=<span class="argument">|</span>
argument2=<span class="argument">&#123;|&#125;</span>
argument3=<span class="argument">[|]</span>

View File

@@ -1,7 +1,27 @@
function checkFragment()
{
let frag = document.location.hash.substr(1);
if (!frag || document.getElementById(frag))
return;
let elem = document.evaluate('//*[@class="tag" and text()="' + frag + '"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);
if (elem)
window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context
}
document.addEventListener("load", checkFragment, true);
window.addEventListener("message", function (event) {
if (event.data == "fragmentChange")
checkFragment();
}, true);
document.addEventListener("click", function (event) {
let elem = event.target;
if (/^(option|mapping|command)$/.test(elem.className))
elem.setAttribute("href", "chrome://liberator/content/help.xul?" + encodeURIComponent(elem.textContent.replace(/\s.*/, "")));
var tag = elem.textContent.replace(/\s.*/, "");
if (elem.className == "command")
tag = tag.replace(/\[.*?\]/g, "");
if (tag)
elem.href = "chrome://liberator/content/help.xul?" + encodeURIComponent(tag);
}, true);