diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-04-28 13:28:55 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-06-05 14:47:40 +0200 |
commit | 55d9a312fbba91f1bcf5e3f3291b7bece8abb178 (patch) | |
tree | bb9ef165b425273da47aa000268395f87f26678e /data/lib/jumpNextBug.js | |
parent | 34bbe8e7306a0d0ec014db7512788ed92c625d19 (diff) | |
download | bugzilla-triage-55d9a312fbba91f1bcf5e3f3291b7bece8abb178.tar.gz |
Reformatting to MoFo coding style
Diffstat (limited to 'data/lib/jumpNextBug.js')
-rw-r--r-- | data/lib/jumpNextBug.js | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/data/lib/jumpNextBug.js b/data/lib/jumpNextBug.js index 348c776..b777fe8 100644 --- a/data/lib/jumpNextBug.js +++ b/data/lib/jumpNextBug.js @@ -2,16 +2,53 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; -var nextElement = {}; -var nextRE = new RegExp("Next"); +(function createRelationElements() { + var relation = {}; + var linkLabels = [ + "First", "Last", "Prev", "Next" + ]; + var labelToRelation = { + "First" : { + rel : "start" + }, + "Last" : { + rel : "last" + }, + "Prev" : { + rel : "prev" + }, + "Next" : { + rel : "next" + } + }; -var aNavigElements = document.querySelectorAll("#bugzilla-body .navigation a"); -var filteredElements = Array.filter(aNavigElements, function(elem) { - return nextRE.test(elem.textContent); -}); -console.log("filteredElements.length = " + filteredElements.length); -if (filteredElements.length > 0) { - nextElement = filteredElements[0]; - nextElement.setAttribute("accesskey", "n"); - nextElement.innerHTML = "<u>N</u>ext"; -} + function createLinkRel(rel, href) { + var newLinkElement = document.createElement("link"); + newLinkElement.setAttribute("rel", rel); + newLinkElement.setAttribute("href", href); + document.getElementsByTagName("head")[0] + .appendChild(newLinkElement); + } + + var aNavigElements = document + .querySelectorAll("#bugzilla-body .navigation a"); + Array.forEach(aNavigElements, function(elem) { + var labelText = elem.textContent.trim(); + if (isInList(labelText, linkLabels)) { + labelToRelation[labelText].href = elem + .getAttribute("href"); + } + ; + }); + console.myDebug("labelToRelation = " + + labelToRelation.toSource()); + + for ( var key in labelToRelation) { + if (labelToRelation.hasOwnProperty(key)) { + relation = labelToRelation[key]; + if (relation.href) { + createLinkRel(relation.rel, relation.href); + } + } + } +})(); |