war/src/main/webapp/scripts/hudson-behavior.js
// using tag names in CSS selector makes the processing faster
using tag names in CSS selector makes the processing faster
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() {
        var url = this.getAttribute("checkUrl");
        var depends = this.getAttribute("checkDependsOn");
        if (depends==null) {
            try {
                return eval(url); 
            } catch (e) {
                if (window.console!=null)  console.warn("Legacy checkUrl '" + url + "' is not valid Javascript: "+e);
                if (window.YUI!=null)      YUI.log("Legacy checkUrl '" + url + "' is not valid Javascript: "+e,"warn");
                return url; 
            }
        } else {
            var q = qs(this).addThis();
            if (depends.length>0)
                depends.split(" ").each(function (n) {
                    q.nearBy(n);
                });
            return url+ q.toString();
        }
    };
    var method = e.getAttribute("checkMethod") || "get";
    var url = e.targetUrl();
    try {
      FormChecker.delayedCheck(url, method, e.targetElement);
    } catch (x) {
        YAHOO.log("Failed to register validation method: "+e.getAttribute("checkUrl")+" : "+e);
        return;
    }
    var checker = function() {
        var target = this.targetElement;
        FormChecker.sendRequest(this.targetUrl(), {
            method : method,
            onComplete : function(x) {
                target.innerHTML = x.responseText;
                Behaviour.applySubtree(target);
            }
        });
    }
    var oldOnchange = e.onchange;
    if(typeof oldOnchange=="function") {
        e.onchange = function() { checker.call(this); oldOnchange.call(this); }
    } else
        e.onchange = checker;
    var v = e.getAttribute("checkDependsOn");
    if (v) {
        v.split(" ").each(function (name) {
            var c = findNearBy(e,name);
            if (c==null) {
                if (window.console!=null)  console.warn("Unable to find nearby "+name);
                if (window.YUI!=null)      YUI.log("Unable to find a nearby control of the name "+name,"warn")
                return;
            }
            $(c).observe("change",checker.bind(e));
        });
    }
    e = null; 
}
function registerValidator ( e ) { e . targetElement = findFollowingTR ( e , "validation-error-area" ) . firstChild . nextSibling ; e . targetUrl = function ( ) { var url = this . getAttribute ( "checkUrl" ) ; var depends = this . getAttribute ( "checkDependsOn" ) ; if ( depends == null ) { try { return eval ( url ) ; } catch ( e ) { if ( window . console != null ) console . warn ( "Legacy checkUrl '" + url + "' is not valid Javascript: " + e ) ; if ( window . YUI != null ) YUI . log ( "Legacy checkUrl '" + url + "' is not valid Javascript: " + e , "warn" ) ; return url ; } } else { var q = qs ( this ) . addThis ( ) ; if ( depends . length > 0 ) depends . split ( " " ) . each ( function ( n ) { q . nearBy ( n ) ; } ) ; return url + q . toString ( ) ; } } ; var method = e . getAttribute ( "checkMethod" ) || "get" ; var url = e . targetUrl ( ) ; try { FormChecker . delayedCheck ( url , method , e . targetElement ) ; } catch ( x ) { YAHOO . log ( "Failed to register validation method: " + e . getAttribute ( "checkUrl" ) + " : " + e ) ; return ; } var checker = function ( ) { var target = this . targetElement ; FormChecker . sendRequest ( this . targetUrl ( ) , { method : method , onComplete : function ( x ) { target . innerHTML = x . responseText ; Behaviour . applySubtree ( target ) ; } } ) ; } var oldOnchange = e . onchange ; if ( typeof oldOnchange == "function" ) { e . onchange = function ( ) { checker . call ( this ) ; oldOnchange . call ( this ) ; } } else e . onchange = checker ; var v = e . getAttribute ( "checkDependsOn" ) ; if ( v ) { v . split ( " " ) . each ( function ( name ) { var c = findNearBy ( e , name ) ; if ( c == null ) { if ( window . console != null ) console . warn ( "Unable to find nearby " + name ) ; if ( window . YUI != null ) YUI . log ( "Unable to find a nearby control of the name " + name , "warn" ) return ; } $ ( c ) . observe ( "change" , checker . bind ( e ) ) ; } ) ; } e = null ; }
using tag names in CSS selector makes the processing faster
using tag names in CSS selector makes the processing faster
// legacy behaviour where checkUrl is a JavaScript // need access to 'this', so no 'geval' // return plain url as fallback // this happens if the checkUrl refers to a non-existing element. // don't let this kill off the entire JavaScript // avoid memory leak