aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/util.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-03-02 16:23:39 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-03-02 16:23:39 +0100
commitea71f2b3c7d6b7e8a2a63669aa818d79ad85ffa0 (patch)
tree0eb77d02fef588fdc9a52db656a8b5bd453f3eb2 /data/lib/util.js
parent40a7136e0946f1f9d938fd65e0f416cd3455413f (diff)
downloadbugzilla-triage-ea71f2b3c7d6b7e8a2a63669aa818d79ad85ffa0.tar.gz
Separate logging front-end into special content script.
Diffstat (limited to 'data/lib/util.js')
-rw-r--r--data/lib/util.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/data/lib/util.js b/data/lib/util.js
index 6c204ff..0ecc318 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -80,6 +80,56 @@ function getBugNoFromURL(url) {
}
}
+/**
+ * Create a A element leadink nowhere, but with listener running a callback on the click
+ *
+ * @param id String with a id to be added to the element
+ * @param text String with a string to be added as a textContent of the element
+ * @param parent Node which is a parent of the object
+ * @param callback Function to be called after clicking on the link
+ * @param params Array with parameters of the callback
+ * @param Boolean before if there should be a <br> element before.
+ * @return none
+ */
+function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) {
+ params = valToArray(params);
+ var locParent = {};
+
+ // Yes, I want != here, not !==
+ if (covered != null) {
+ locParent = document.createElement(covered);
+ parent.appendChild(locParent);
+ } else {
+ locParent = parent;
+ }
+
+ var newAElem = document.createElement("a");
+ newAElem.setAttribute("id", id);
+ if (accesskey) {
+ newAElem.setAttribute("accesskey", accesskey);
+ }
+ newAElem.textContent = text;
+
+ if (typeof callback === "string") {
+ newAElem.setAttribute("href", callback);
+ } else {
+ newAElem.setAttribute("href", "");
+ newAElem.addEventListener("click", function(evt) {
+ callback.apply(null, params);
+ evt.stopPropagation();
+ evt.preventDefault();
+ }, false);
+ }
+
+ if ((before === "br") || (before === true)) {
+ locParent.appendChild(document.createElement("br"));
+ } else if (before === "dash") {
+ locParent.appendChild(document.createTextNode("\u00A0-\u00A0"));
+ }
+
+ locParent.appendChild(newAElem);
+}
+
/*
* From <a> element diggs out just plain email address
* Note that bugzilla.gnome.org doesn't have mailto: url but