// // JavaScript for Hudson // See http://www.ibm.com/developerworks/web/library/wa-memleak/?ca=dgr-lnxw97JavascriptLeaks // for memory leak patterns and how to prevent them. // // create a new object whose prototype is the given object function object(o) { function F() {} F.prototype = o; return new F(); } // id generator var iota = 0; // Form check code //======================================================== var FormChecker = { // pending requests queue : [], inProgress : false, delayedCheck : function(url, method, target) { this.queue.push({url:url, method:method, target:target}); this.schedule(); }, sendRequest : function(url, params) { if (params.method == "post") { var idx = url.indexOf('?'); params.parameters = url.substring(idx + 1); url = url.substring(0, idx); } new Ajax.Request(url, params); }, schedule : function() { if (this.inProgress) return; if (this.queue.length == 0) return; var next = this.queue.shift(); this.inProgress = true; this.sendRequest(next.url, { method : next.method, onComplete : function(x) { next.target.innerHTML = x.responseText; FormChecker.inProgress = false; FormChecker.schedule(); } }); } } // find the nearest ancestor node that has the given tag name function findAncestor(e, tagName) { do { e = e.parentNode; } while(e.tagName!=tagName); return e; } function findFollowingTR(input, className) { // identify the parent TR var tr = input; while (tr.tagName != "TR") tr = tr.parentNode; // then next TR that matches the CSS do { tr = tr.nextSibling; } while (tr.tagName != "TR" || tr.className != className); return tr; } // shared tooltip object var tooltip; // Behavior rules //======================================================== // using tag names in CSS selector makes the processing faster function registerValidator(e) { e.targetElement = findFollowingTR(e, "validation-error-area").firstChild.nextSibling; e.targetUrl = function() { return eval(this.getAttribute("checkUrl")); }; var method = e.getAttribute("checkMethod"); if (!method) method = "get"; FormChecker.delayedCheck(e.targetUrl(), method, e.targetElement); var checker = function() { var target = this.targetElement; FormChecker.sendRequest(this.targetUrl(), { method : method, onComplete : function(x) { target.innerHTML = x.responseText; } }); } var oldOnchange = e.onchange; if(typeof oldOnchange=="function") { e.onchange = function() { checker.call(this); oldOnchange.call(this); } } else e.onchange = checker; e.onblur = checker; e = null; // avoid memory leak } /** * Wraps a