1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 17:37:57 +01:00

Strip leading counts and trailing bangs from help tag links.

This commit is contained in:
Doug Kearns
2009-03-07 00:50:28 +11:00
parent 9d3a5ec939
commit 5f190d3443
4 changed files with 15 additions and 11 deletions

View File

@@ -1421,20 +1421,24 @@ window.liberator = liberator;
// FIXME: Ugly, etc.
window.addEventListener("liberatorHelpLink", function (event) {
let elem = event.target;
if (/^(option|mapping|command)$/.test(elem.className))
var tag = elem.textContent.replace(/\s.*/, "");
if (/^(mapping|command)$/.test(elem.className))
tag = tag.replace(/^\d+/, "");
if (elem.className == "command")
tag = tag.replace(/\[.*?\]/g, "");
tag = tag.replace(/\[.*?\]/g, "").replace(/!$/, "");
if (tag)
var page = liberator.findHelp(tag);
if (page)
{
elem.href = "chrome://liberator/locale/" + page;
if (buffer.URL.replace(/#.*/, "") == elem.href.replace(/#.*/, "")) // XXX
setTimeout(function () { content.postMessage("fragmentChange", "*"); }, 0);
}
},
true, true);
}, true, true);
// called when the chrome is fully loaded and before the main window is shown
window.addEventListener("load", liberator.startup, false);