All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kohsuke.stapler.bind.js Maven / Gradle / Ivy

There is a newer version: 1.263
Show newest version
// bind tag takes care of the dependency as an adjunct

function makeStaplerProxy(url,crumb,methods) {
    if (url.substring(url.length - 1) !== '/') url+='/';
    var proxy = {};

    var stringify;
    if (Object.toJSON) // needs to use Prototype.js if it's present. See commit comment for discussion
        stringify = Object.toJSON;  // from prototype
    else if (typeof(JSON)=="object" && JSON.stringify)
        stringify = JSON.stringify; // standard

    var genMethod = function(methodName) {
        proxy[methodName] = function() {
            var args = arguments;

            // the final argument can be a callback that receives the return value
            var callback = (function(){
                if (args.length==0) return null;
                var tail = args[args.length-1];
                return (typeof(tail)=='function') ? tail : null;
            })();

            // 'arguments' is not an array so we convert it into an array
            var a = [];
            for (var i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy