a:51:{s:9:"#provides";s:4:"dojo";s:9:"#resource";s:12:"_base/xhr.js";s:9:"#requires";a:4:{i:0;a:2:{i:0;s:6:"common";i:1;s:19:"dojo._base.Deferred";}i:1;a:2:{i:0;s:6:"common";i:1;s:15:"dojo._base.json";}i:2;a:2:{i:0;s:6:"common";i:1;s:15:"dojo._base.lang";}i:3;a:2:{i:0;s:6:"common";i:1;s:16:"dojo._base.query";}}s:14:"dojo.__XhrArgs";a:6:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:13:"dojo.__IoArgs";}s:4:"call";a:1:{i:0;s:13:"dojo.__IoArgs";}}s:6:"source";s:76:" this.handleAs = handleAs; this.sync = sync; this.headers = headers;";s:7:"summary";s:123:"In addition to the properties listed for the dojo._IoArgs type, the following properties are allowed for dojo.xhr* methods.";s:7:"private";b:1;s:9:"classlike";b:1;}s:23:"dojo.__XhrArgs.handleAs";a:4:{s:8:"instance";s:14:"dojo.__XhrArgs";s:4:"type";s:7:"String?";s:7:"summary";s:106:"Acceptable values are: text (default), json, json-comment-optional, json-comment-filtered, javascript, xml";s:14:"private_parent";b:1;}s:19:"dojo.__XhrArgs.sync";a:4:{s:8:"instance";s:14:"dojo.__XhrArgs";s:4:"type";s:8:"Boolean?";s:7:"summary";s:91:"false is default. Indicates whether the request should be a synchronous (blocking) request.";s:14:"private_parent";b:1;}s:22:"dojo.__XhrArgs.headers";a:4:{s:8:"instance";s:14:"dojo.__XhrArgs";s:4:"type";s:7:"Object?";s:7:"summary";s:47:"Additional HTTP headers to send in the request.";s:14:"private_parent";b:1;}s:16:"dojo._blockAsync";a:2:{s:7:"private";b:1;s:7:"summary";s:0:"";}s:21:"dojo._contentHandlers";a:3:{s:4:"type";s:6:"Object";s:7:"private";b:1;s:7:"summary";s:0:"";}s:15:"dojo.rawXhrPost";a:2:{s:7:"aliases";s:12:"dojo.xhrPost";s:7:"summary";s:0:"";}s:14:"dojo.rawXhrPut";a:2:{s:7:"aliases";s:11:"dojo.xhrPut";s:7:"summary";s:0:"";}s:17:"dojo.formToObject";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:8:"formNode";a:1:{s:4:"type";s:15:"DOMNode||String";}}s:6:"source";s:738:" var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object";s:7:"summary";s:262:"dojo.formToObject returns the values encoded in an HTML form as string properties in an object which it then returns. Disabled form elements, buttons, and other non-value form elements are skipped. Multi-select elements are returned as an array of string values.";s:11:"description";s:540:"This form:
yields this object structure as the result of a call to formToObject(): { blah: "blah", multi: [ "thud", "thonk" ] };";s:7:"returns";s:6:"Object";}s:18:"dojo.objectToQuery";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"map";a:1:{s:4:"type";s:6:"Object";}}s:6:"source";s:3378:"dojo.provide("dojo._base.xhr"); dojo.require("dojo._base.Deferred"); dojo.require("dojo._base.json"); dojo.require("dojo._base.lang"); dojo.require("dojo._base.query"); //>>excludeStart("webkitMobile", kwArgs.webkitMobile); (function(){ //>>excludeEnd("webkitMobile"); var _d = dojo; function setValue(/*Object*/obj, /*String*/name, /*String*/value){ //summary: // For the named property in object, set the value. If a value // already exists and it is a string, convert the value to be an // array of values. var val = obj[name]; if(_d.isString(val)){ obj[name] = [val, value]; }else if(_d.isArray(val)){ val.push(value); }else{ obj[name] = value; } } dojo.formToObject = function(/*DOMNode||String*/ formNode){ // summary: // dojo.formToObject returns the values encoded in an HTML form as // string properties in an object which it then returns. Disabled form // elements, buttons, and other non-value form elements are skipped. // Multi-select elements are returned as an array of string values. // description: // This form: // // |
// | // | // | // | // |
// // yields this object structure as the result of a call to // formToObject(): // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object } dojo.objectToQuery = function(/*Object*/ map){ // summary: // takes a name/value mapping object and returns a string representing // a URL-encoded version of that object. // example: // this object: // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; // // yields the following query string: // // | "blah=blah&multi=thud&multi=thonk" // FIXME: need to implement encodeAscii!! var enc = encodeURIComponent; var pairs = []; var backstop = {}; for(var name in map){ var value = map[name]; if(value != backstop[name]){ var assign = enc(name) + "="; if(_d.isArray(value)){ for(var i=0; i < value.length; i++){ pairs.push(assign + enc(value[i])); } }else{ pairs.push(assign + enc(value)); } } } return pairs.join("&"); // String";s:7:"summary";s:105:"takes a name/value mapping object and returns a string representing a URL-encoded version of that object.";s:7:"returns";s:13:"Object|String";}s:16:"dojo.formToQuery";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:8:"formNode";a:1:{s:4:"type";s:15:"DOMNode||String";}}s:6:"source";s:63:" return _d.objectToQuery(_d.formToObject(formNode)); // String";s:7:"summary";s:121:"Returns a URL-encoded string representing the form passed as either a node or string ID identifying the form to serialize";s:7:"returns";s:6:"String";}s:15:"dojo.formToJson";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:8:"formNode";a:1:{s:4:"type";s:15:"DOMNode||String";}s:11:"prettyPrint";a:2:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";}}s:6:"source";s:69:" return _d.toJson(_d.formToObject(formNode), prettyPrint); // String";s:7:"summary";s:95:"return a serialized JSON string from a form node or string ID identifying the form to serialize";s:7:"returns";s:6:"String";}s:18:"dojo.queryToObject";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"str";a:1:{s:4:"type";s:6:"String";}}s:6:"source";s:5000:"dojo.provide("dojo._base.xhr"); dojo.require("dojo._base.Deferred"); dojo.require("dojo._base.json"); dojo.require("dojo._base.lang"); dojo.require("dojo._base.query"); //>>excludeStart("webkitMobile", kwArgs.webkitMobile); (function(){ //>>excludeEnd("webkitMobile"); var _d = dojo; function setValue(/*Object*/obj, /*String*/name, /*String*/value){ //summary: // For the named property in object, set the value. If a value // already exists and it is a string, convert the value to be an // array of values. var val = obj[name]; if(_d.isString(val)){ obj[name] = [val, value]; }else if(_d.isArray(val)){ val.push(value); }else{ obj[name] = value; } } dojo.formToObject = function(/*DOMNode||String*/ formNode){ // summary: // dojo.formToObject returns the values encoded in an HTML form as // string properties in an object which it then returns. Disabled form // elements, buttons, and other non-value form elements are skipped. // Multi-select elements are returned as an array of string values. // description: // This form: // // |
// | // | // | // | // |
// // yields this object structure as the result of a call to // formToObject(): // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object } dojo.objectToQuery = function(/*Object*/ map){ // summary: // takes a name/value mapping object and returns a string representing // a URL-encoded version of that object. // example: // this object: // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; // // yields the following query string: // // | "blah=blah&multi=thud&multi=thonk" // FIXME: need to implement encodeAscii!! var enc = encodeURIComponent; var pairs = []; var backstop = {}; for(var name in map){ var value = map[name]; if(value != backstop[name]){ var assign = enc(name) + "="; if(_d.isArray(value)){ for(var i=0; i < value.length; i++){ pairs.push(assign + enc(value[i])); } }else{ pairs.push(assign + enc(value)); } } } return pairs.join("&"); // String } dojo.formToQuery = function(/*DOMNode||String*/ formNode){ // summary: // Returns a URL-encoded string representing the form passed as either a // node or string ID identifying the form to serialize return _d.objectToQuery(_d.formToObject(formNode)); // String } dojo.formToJson = function(/*DOMNode||String*/ formNode, /*Boolean?*/prettyPrint){ // summary: // return a serialized JSON string from a form node or string // ID identifying the form to serialize return _d.toJson(_d.formToObject(formNode), prettyPrint); // String } dojo.queryToObject = function(/*String*/ str){ // summary: // returns an object representing a de-serialized query section of a // URL. Query keys with multiple values are returned in an array. // description: // This string: // // | "foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&" // // results in this object structure: // // | { // | foo: [ "bar", "baz" ], // | thinger: " spaces =blah", // | zonk: "blarg" // | } // // Note that spaces and other urlencoded entities are correctly // handled. // FIXME: should we grab the URL string if we're not passed one? var ret = {}; var qp = str.split("&"); var dec = decodeURIComponent; _d.forEach(qp, function(item){ if(item.length){ var parts = item.split("="); var name = dec(parts.shift()); var val = dec(parts.join("=")); if(_d.isString(ret[name])){ ret[name] = [ret[name]]; } if(_d.isArray(ret[name])){ ret[name].push(val); }else{ ret[name] = val; } } }); return ret; // Object";s:7:"summary";s:128:"returns an object representing a de-serialized query section of a URL. Query keys with multiple values are returned in an array.";s:7:"returns";s:13:"Object|String";}s:43:"dojo._contentHandlers.json-comment-optional";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"xhr";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:198:" var handlers = _d._contentHandlers; if(xhr.responseText && xhr.responseText.indexOf("\/*") != -1){ return handlers["json-comment-filtered"](xhr); }else{ return handlers["json"](xhr); }";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:13:"dojo.__IoArgs";a:5:{s:4:"type";s:8:"Function";s:6:"source";s:9839:"dojo.provide("dojo._base.xhr"); dojo.require("dojo._base.Deferred"); dojo.require("dojo._base.json"); dojo.require("dojo._base.lang"); dojo.require("dojo._base.query"); //>>excludeStart("webkitMobile", kwArgs.webkitMobile); (function(){ //>>excludeEnd("webkitMobile"); var _d = dojo; function setValue(/*Object*/obj, /*String*/name, /*String*/value){ //summary: // For the named property in object, set the value. If a value // already exists and it is a string, convert the value to be an // array of values. var val = obj[name]; if(_d.isString(val)){ obj[name] = [val, value]; }else if(_d.isArray(val)){ val.push(value); }else{ obj[name] = value; } } dojo.formToObject = function(/*DOMNode||String*/ formNode){ // summary: // dojo.formToObject returns the values encoded in an HTML form as // string properties in an object which it then returns. Disabled form // elements, buttons, and other non-value form elements are skipped. // Multi-select elements are returned as an array of string values. // description: // This form: // // |
// | // | // | // | // |
// // yields this object structure as the result of a call to // formToObject(): // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object } dojo.objectToQuery = function(/*Object*/ map){ // summary: // takes a name/value mapping object and returns a string representing // a URL-encoded version of that object. // example: // this object: // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; // // yields the following query string: // // | "blah=blah&multi=thud&multi=thonk" // FIXME: need to implement encodeAscii!! var enc = encodeURIComponent; var pairs = []; var backstop = {}; for(var name in map){ var value = map[name]; if(value != backstop[name]){ var assign = enc(name) + "="; if(_d.isArray(value)){ for(var i=0; i < value.length; i++){ pairs.push(assign + enc(value[i])); } }else{ pairs.push(assign + enc(value)); } } } return pairs.join("&"); // String } dojo.formToQuery = function(/*DOMNode||String*/ formNode){ // summary: // Returns a URL-encoded string representing the form passed as either a // node or string ID identifying the form to serialize return _d.objectToQuery(_d.formToObject(formNode)); // String } dojo.formToJson = function(/*DOMNode||String*/ formNode, /*Boolean?*/prettyPrint){ // summary: // return a serialized JSON string from a form node or string // ID identifying the form to serialize return _d.toJson(_d.formToObject(formNode), prettyPrint); // String } dojo.queryToObject = function(/*String*/ str){ // summary: // returns an object representing a de-serialized query section of a // URL. Query keys with multiple values are returned in an array. // description: // This string: // // | "foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&" // // results in this object structure: // // | { // | foo: [ "bar", "baz" ], // | thinger: " spaces =blah", // | zonk: "blarg" // | } // // Note that spaces and other urlencoded entities are correctly // handled. // FIXME: should we grab the URL string if we're not passed one? var ret = {}; var qp = str.split("&"); var dec = decodeURIComponent; _d.forEach(qp, function(item){ if(item.length){ var parts = item.split("="); var name = dec(parts.shift()); var val = dec(parts.join("=")); if(_d.isString(ret[name])){ ret[name] = [ret[name]]; } if(_d.isArray(ret[name])){ ret[name].push(val); }else{ ret[name] = val; } } }); return ret; // Object } /* from refactor.txt: all bind() replacement APIs take the following argument structure: { url: "blah.html", // all below are optional, but must be supported in some form by // every IO API timeout: 1000, // milliseconds handleAs: "text", // replaces the always-wrong "mimetype" content: { key: "value" }, // browser-specific, MAY be unsupported sync: true, // defaults to false form: dojo.byId("someForm") } */ // need to block async callbacks from snatching this thread as the result // of an async callback might call another sync XHR, this hangs khtml forever // must checked by watchInFlight() dojo._blockAsync = false; dojo._contentHandlers = { text: function(xhr){ return xhr.responseText; }, json: function(xhr){ return _d.fromJson(xhr.responseText || null); }, "json-comment-filtered": function(xhr){ // NOTE: the json-comment-filtered option was implemented to prevent // "JavaScript Hijacking", but it is less secure than standard JSON. Use // standard JSON instead. JSON prefixing can be used to subvert hijacking. if(!dojo.config.useCommentedJson){ console.warn("Consider using the standard mimetype:application/json." + " json-commenting can introduce security issues. To" + " decrease the chances of hijacking, use the standard the 'json' handler and" + " prefix your json with: {}&&\n" + "Use djConfig.useCommentedJson=true to turn off this message."); } var value = xhr.responseText; var cStartIdx = value.indexOf("\/*"); var cEndIdx = value.lastIndexOf("*\/"); if(cStartIdx == -1 || cEndIdx == -1){ throw new Error("JSON was not comment filtered"); } return _d.fromJson(value.substring(cStartIdx+2, cEndIdx)); }, javascript: function(xhr){ // FIXME: try Moz and IE specific eval variants? return _d.eval(xhr.responseText); }, xml: function(xhr){ var result = xhr.responseXML; //>>excludeStart("webkitMobile", kwArgs.webkitMobile); if(_d.isIE && (!result || !result.documentElement)){ var ms = function(n){ return "MSXML" + n + ".DOMDocument"; } var dp = ["Microsoft.XMLDOM", ms(6), ms(4), ms(3), ms(2)]; _d.some(dp, function(p){ try{ var dom = new ActiveXObject(p); dom.async = false; dom.loadXML(xhr.responseText); result = dom; }catch(e){ return false; } return true; }); } //>>excludeEnd("webkitMobile"); return result; // DOMDocument } }; dojo._contentHandlers["json-comment-optional"] = function(xhr){ var handlers = _d._contentHandlers; if(xhr.responseText && xhr.responseText.indexOf("\/*") != -1){ return handlers["json-comment-filtered"](xhr); }else{ return handlers["json"](xhr); } }; dojo.__IoArgs = function(){ // url: String // URL to server endpoint. // content: Object? // Contains properties with string values. These // properties will be serialized as name1=value2 and // passed in the request. // timeout: Integer? // Milliseconds to wait for the response. If this time // passes, the then error callbacks are called. // form: DOMNode? // DOM node for a form. Used to extract the form values // and send to the server. // preventCache: Boolean? // Default is false. If true, then a // "dojo.preventCache" parameter is sent in the request // with a value that changes with each request // (timestamp). Useful only with GET-type requests. // handleAs: String? // Acceptable values depend on the type of IO // transport (see specific IO calls for more information). // load: Function? // function(response, ioArgs){} response is of type Object, ioArgs // is of type dojo.__IoCallbackArgs. This function will be // called on a successful HTTP response code. // error: Function? // function(response, ioArgs){} response is of type Object, ioArgs // is of type dojo.__IoCallbackArgs. This function will // be called when the request fails due to a network or server error, the url // is invalid, etc. It will also be called if the load or handle callback throws an // exception, unless djConfig.debugAtAllCosts is true. This allows deployed applications // to continue to run even when a logic error happens in the callback, while making // it easier to troubleshoot while in debug mode. // handle: Function? // function(response, ioArgs){} response is of type Object, ioArgs // is of type dojo.__IoCallbackArgs. This function will // be called at the end of every request, whether or not an error occurs. this.url = url; this.content = content; this.timeout = timeout; this.form = form; this.preventCache = preventCache; this.handleAs = handleAs; this.load = load; this.error = error; this.handle = handle;";s:7:"private";b:1;s:9:"classlike";b:1;s:7:"summary";s:0:"";}s:17:"dojo.__IoArgs.url";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:6:"String";s:7:"summary";s:23:"URL to server endpoint.";s:14:"private_parent";b:1;}s:21:"dojo.__IoArgs.content";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:7:"Object?";s:7:"summary";s:118:"Contains properties with string values. These properties will be serialized as name1=value2 and passed in the request.";s:14:"private_parent";b:1;}s:21:"dojo.__IoArgs.timeout";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:8:"Integer?";s:7:"summary";s:96:"Milliseconds to wait for the response. If this time passes, the then error callbacks are called.";s:14:"private_parent";b:1;}s:18:"dojo.__IoArgs.form";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:8:"DOMNode?";s:7:"summary";s:76:"DOM node for a form. Used to extract the form values and send to the server.";s:14:"private_parent";b:1;}s:26:"dojo.__IoArgs.preventCache";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:8:"Boolean?";s:7:"summary";s:189:"Default is false. If true, then a "dojo.preventCache" parameter is sent in the request with a value that changes with each request (timestamp). Useful only with GET-type requests.";s:14:"private_parent";b:1;}s:22:"dojo.__IoArgs.handleAs";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:7:"String?";s:7:"summary";s:98:"Acceptable values depend on the type of IO transport (see specific IO calls for more information).";s:14:"private_parent";b:1;}s:18:"dojo.__IoArgs.load";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:9:"Function?";s:7:"summary";s:163:"function(response, ioArgs){} response is of type Object, ioArgs is of type dojo.__IoCallbackArgs. This function will be called on a successful HTTP response code.";s:14:"private_parent";b:1;}s:19:"dojo.__IoArgs.error";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:9:"Function?";s:7:"summary";s:487:"function(response, ioArgs){} response is of type Object, ioArgs is of type dojo.__IoCallbackArgs. This function will be called when the request fails due to a network or server error, the url is invalid, etc. It will also be called if the load or handle callback throws an exception, unless djConfig.debugAtAllCosts is true. This allows deployed applications to continue to run even when a logic error happens in the callback, while making it easier to troubleshoot while in debug mode.";s:14:"private_parent";b:1;}s:20:"dojo.__IoArgs.handle";a:4:{s:8:"instance";s:13:"dojo.__IoArgs";s:4:"type";s:9:"Function?";s:7:"summary";s:188:"function(response, ioArgs){} response is of type Object, ioArgs is of type dojo.__IoCallbackArgs. This function will be called at the end of every request, whether or not an error occurs.";s:14:"private_parent";b:1;}s:21:"dojo.__IoCallbackArgs";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:8:{s:4:"args";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:44:"the original object argument to the IO call.";}s:3:"xhr";a:2:{s:4:"type";s:14:"XMLHttpRequest";s:7:"summary";s:87:"For XMLHttpRequest calls only, the XMLHttpRequest object that was used for the request.";}s:3:"url";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:98:"The final URL used for the call. Many times it will be different than the original args.url value.";}s:5:"query";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:90:"For non-GET requests, the name1=value1&name2=value2 parameters sent up in the request.";}s:8:"handleAs";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:56:"The final indicator on how the response will be handled.";}s:2:"id";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:75:"For dojo.io.script calls only, the internal script ID used for the request.";}s:9:"canDelete";a:2:{s:4:"type";s:7:"Boolean";s:7:"summary";s:212:"For dojo.io.script calls only, indicates whether the script tag that represents the request can be deleted after callbacks have been called. Used internally to know when cleanup can happen on JSONP-type requests.";}s:4:"json";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:242:"For dojo.io.script calls only: holds the JSON response for JSONP-type requests. Used internally to hold on to the JSON responses. You should not need to access it directly -- the same object should be passed to the success callbacks directly.";}}s:6:"source";s:171:" this.args = args; this.xhr = xhr; this.url = url; this.query = query; this.handleAs = handleAs; this.id = id; this.canDelete = canDelete; this.json = json;";s:7:"private";b:1;s:9:"classlike";b:1;s:7:"summary";s:0:"";}s:26:"dojo.__IoCallbackArgs.args";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:6:"Object";s:7:"summary";s:44:"the original object argument to the IO call.";s:14:"private_parent";b:1;}s:25:"dojo.__IoCallbackArgs.xhr";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:14:"XMLHttpRequest";s:7:"summary";s:87:"For XMLHttpRequest calls only, the XMLHttpRequest object that was used for the request.";s:14:"private_parent";b:1;}s:25:"dojo.__IoCallbackArgs.url";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:6:"String";s:7:"summary";s:98:"The final URL used for the call. Many times it will be different than the original args.url value.";s:14:"private_parent";b:1;}s:27:"dojo.__IoCallbackArgs.query";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:6:"String";s:7:"summary";s:90:"For non-GET requests, the name1=value1&name2=value2 parameters sent up in the request.";s:14:"private_parent";b:1;}s:30:"dojo.__IoCallbackArgs.handleAs";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:6:"String";s:7:"summary";s:56:"The final indicator on how the response will be handled.";s:14:"private_parent";b:1;}s:24:"dojo.__IoCallbackArgs.id";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:6:"String";s:7:"summary";s:75:"For dojo.io.script calls only, the internal script ID used for the request.";s:14:"private_parent";b:1;}s:31:"dojo.__IoCallbackArgs.canDelete";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:7:"Boolean";s:7:"summary";s:212:"For dojo.io.script calls only, indicates whether the script tag that represents the request can be deleted after callbacks have been called. Used internally to know when cleanup can happen on JSONP-type requests.";s:14:"private_parent";b:1;}s:26:"dojo.__IoCallbackArgs.json";a:4:{s:8:"instance";s:21:"dojo.__IoCallbackArgs";s:4:"type";s:6:"Object";s:7:"summary";s:242:"For dojo.io.script calls only: holds the JSON response for JSONP-type requests. Used internally to hold on to the JSON responses. You should not need to access it directly -- the same object should be passed to the success callbacks directly.";s:14:"private_parent";b:1;}s:15:"dojo._ioSetArgs";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:4:{s:4:"args";a:2:{s:4:"type";s:13:"dojo.__IoArgs";s:7:"summary";s:93:"The args object passed into the public io call. Recognized properties on the args object are:";}s:9:"canceller";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:146:"The canceller function used for the Deferred object. The function will receive one argument, the Deferred object that is related to the canceller.";}s:9:"okHandler";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:187:"The first OK callback to be registered with Deferred. It has the opportunity to transform the OK response. It will receive one argument -- the Deferred object returned from this function.";}s:10:"errHandler";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:220:"The first error callback to be registered with Deferred. It has the opportunity to do cleanup on an error. It will receive two arguments: error (the Error object) and dfd, the Deferred object returned from this function.";}}s:6:"source";s:1970:" var ioArgs = {args: args, url: args.url}; //Get values from form if requestd. var formObject = null; if(args.form){ var form = _d.byId(args.form); //IE requires going through getAttributeNode instead of just getAttribute in some form cases, //so use it for all. See #2844 var actnNode = form.getAttributeNode("action"); ioArgs.url = ioArgs.url || (actnNode ? actnNode.value : null); formObject = _d.formToObject(form); } // set up the query params var miArgs = [{}]; if(formObject){ // potentially over-ride url-provided params w/ form values miArgs.push(formObject); } if(args.content){ // stuff in content over-rides what's set by form miArgs.push(args.content); } if(args.preventCache){ miArgs.push({"dojo.preventCache": new Date().valueOf()}); } ioArgs.query = _d.objectToQuery(_d.mixin.apply(null, miArgs)); // .. and the real work of getting the deferred in order, etc. ioArgs.handleAs = args.handleAs || "text"; var d = new _d.Deferred(canceller); d.addCallbacks(okHandler, function(error){ return errHandler(error, d); }); //Support specifying load, error and handle callback functions from the args. //For those callbacks, the "this" object will be the args object. //The callbacks will get the deferred result value as the //first argument and the ioArgs object as the second argument. var ld = args.load; if(ld && _d.isFunction(ld)){ d.addCallback(function(value){ return ld.call(args, value, ioArgs); }); } var err = args.error; if(err && _d.isFunction(err)){ d.addErrback(function(value){ return err.call(args, value, ioArgs); }); } var handle = args.handle; if(handle && _d.isFunction(handle)){ d.addBoth(function(value){ return handle.call(args, value, ioArgs); }); } d.ioArgs = ioArgs; // FIXME: need to wire up the xhr object's abort method to something // analagous in the Deferred return d;";s:7:"summary";s:89:"sets up the Deferred and ioArgs property on the Deferred so it can be used in an io call.";s:7:"private";b:1;}s:17:"dojo._ioCancelAll";a:4:{s:4:"type";s:8:"Function";s:6:"source";s:133:" try{ _d.forEach(_inFlight, function(i){ try{ i.dfd.cancel(); }catch(e){/*squelch*/} }); }catch(e){/*squelch*/}";s:7:"summary";s:77:"Cancels all pending IO requests, regardless of IO type (xhr, script, iframe).";s:7:"private";b:1;}s:13:"dojo._ioWatch";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:4:{s:3:"dfd";a:2:{s:4:"type";s:8:"Deferred";s:7:"summary";s:29:"The Deferred object to watch.";}s:10:"validCheck";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:89:"used to check if the IO request is still valid. Gets the dfd object as its only argument.";}s:7:"ioCheck";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:80:"used to check if basic IO call worked. Gets the dfd object as its only argument.";}s:9:"resHandle";a:2:{s:4:"type";s:8:"Function";s:7:"summary";s:67:"used to process response. Gets the dfd object as its only argument.";}}s:6:"source";s:498:" var args = dfd.ioArgs.args; if(args.timeout){ dfd.startTime = (new Date()).getTime(); } _inFlight.push({dfd: dfd, validCheck: validCheck, ioCheck: ioCheck, resHandle: resHandle}); if(!_inFlightIntvl){ _inFlightIntvl = setInterval(_watchInFlight, 50); } // handle sync requests //A weakness: async calls in flight //could have their handlers called as part of the //_watchInFlight call, before the sync's callbacks // are called. if(args.sync){ _watchInFlight(); }";s:7:"summary";s:65:"watches the io request represented by dfd to see if it completes.";s:7:"private";b:1;}s:21:"dojo._ioAddQueryToUrl";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:6:"ioArgs";a:1:{s:4:"type";s:21:"dojo.__IoCallbackArgs";}}s:6:"source";s:133:" if(ioArgs.query.length){ ioArgs.url += (ioArgs.url.indexOf("?") == -1 ? "?" : "&") + ioArgs.query; ioArgs.query = null; } ";s:7:"summary";s:146:"Adds query params discovered by the io deferred construction to the URL. Only use this for operations which are fundamentally GET-type operations.";s:7:"private";b:1;}s:8:"dojo.xhr";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:3:{s:6:"method";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:77:"HTTP method to be used, such as GET, POST, PUT, DELETE. Should be uppercase.";}s:4:"args";a:1:{s:4:"type";s:14:"dojo.__XhrArgs";}s:7:"hasBody";a:2:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";}}s:6:"source";s:22294:"dojo.provide("dojo._base.xhr"); dojo.require("dojo._base.Deferred"); dojo.require("dojo._base.json"); dojo.require("dojo._base.lang"); dojo.require("dojo._base.query"); //>>excludeStart("webkitMobile", kwArgs.webkitMobile); (function(){ //>>excludeEnd("webkitMobile"); var _d = dojo; function setValue(/*Object*/obj, /*String*/name, /*String*/value){ //summary: // For the named property in object, set the value. If a value // already exists and it is a string, convert the value to be an // array of values. var val = obj[name]; if(_d.isString(val)){ obj[name] = [val, value]; }else if(_d.isArray(val)){ val.push(value); }else{ obj[name] = value; } } dojo.formToObject = function(/*DOMNode||String*/ formNode){ // summary: // dojo.formToObject returns the values encoded in an HTML form as // string properties in an object which it then returns. Disabled form // elements, buttons, and other non-value form elements are skipped. // Multi-select elements are returned as an array of string values. // description: // This form: // // |
// | // | // | // | // |
// // yields this object structure as the result of a call to // formToObject(): // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object } dojo.objectToQuery = function(/*Object*/ map){ // summary: // takes a name/value mapping object and returns a string representing // a URL-encoded version of that object. // example: // this object: // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; // // yields the following query string: // // | "blah=blah&multi=thud&multi=thonk" // FIXME: need to implement encodeAscii!! var enc = encodeURIComponent; var pairs = []; var backstop = {}; for(var name in map){ var value = map[name]; if(value != backstop[name]){ var assign = enc(name) + "="; if(_d.isArray(value)){ for(var i=0; i < value.length; i++){ pairs.push(assign + enc(value[i])); } }else{ pairs.push(assign + enc(value)); } } } return pairs.join("&"); // String } dojo.formToQuery = function(/*DOMNode||String*/ formNode){ // summary: // Returns a URL-encoded string representing the form passed as either a // node or string ID identifying the form to serialize return _d.objectToQuery(_d.formToObject(formNode)); // String } dojo.formToJson = function(/*DOMNode||String*/ formNode, /*Boolean?*/prettyPrint){ // summary: // return a serialized JSON string from a form node or string // ID identifying the form to serialize return _d.toJson(_d.formToObject(formNode), prettyPrint); // String } dojo.queryToObject = function(/*String*/ str){ // summary: // returns an object representing a de-serialized query section of a // URL. Query keys with multiple values are returned in an array. // description: // This string: // // | "foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&" // // results in this object structure: // // | { // | foo: [ "bar", "baz" ], // | thinger: " spaces =blah", // | zonk: "blarg" // | } // // Note that spaces and other urlencoded entities are correctly // handled. // FIXME: should we grab the URL string if we're not passed one? var ret = {}; var qp = str.split("&"); var dec = decodeURIComponent; _d.forEach(qp, function(item){ if(item.length){ var parts = item.split("="); var name = dec(parts.shift()); var val = dec(parts.join("=")); if(_d.isString(ret[name])){ ret[name] = [ret[name]]; } if(_d.isArray(ret[name])){ ret[name].push(val); }else{ ret[name] = val; } } }); return ret; // Object } /* from refactor.txt: all bind() replacement APIs take the following argument structure: { url: "blah.html", // all below are optional, but must be supported in some form by // every IO API timeout: 1000, // milliseconds handleAs: "text", // replaces the always-wrong "mimetype" content: { key: "value" }, // browser-specific, MAY be unsupported sync: true, // defaults to false form: dojo.byId("someForm") } */ // need to block async callbacks from snatching this thread as the result // of an async callback might call another sync XHR, this hangs khtml forever // must checked by watchInFlight() dojo._blockAsync = false; dojo._contentHandlers = { text: function(xhr){ return xhr.responseText; }, json: function(xhr){ return _d.fromJson(xhr.responseText || null); }, "json-comment-filtered": function(xhr){ // NOTE: the json-comment-filtered option was implemented to prevent // "JavaScript Hijacking", but it is less secure than standard JSON. Use // standard JSON instead. JSON prefixing can be used to subvert hijacking. if(!dojo.config.useCommentedJson){ console.warn("Consider using the standard mimetype:application/json." + " json-commenting can introduce security issues. To" + " decrease the chances of hijacking, use the standard the 'json' handler and" + " prefix your json with: {}&&\n" + "Use djConfig.useCommentedJson=true to turn off this message."); } var value = xhr.responseText; var cStartIdx = value.indexOf("\/*"); var cEndIdx = value.lastIndexOf("*\/"); if(cStartIdx == -1 || cEndIdx == -1){ throw new Error("JSON was not comment filtered"); } return _d.fromJson(value.substring(cStartIdx+2, cEndIdx)); }, javascript: function(xhr){ // FIXME: try Moz and IE specific eval variants? return _d.eval(xhr.responseText); }, xml: function(xhr){ var result = xhr.responseXML; //>>excludeStart("webkitMobile", kwArgs.webkitMobile); if(_d.isIE && (!result || !result.documentElement)){ var ms = function(n){ return "MSXML" + n + ".DOMDocument"; } var dp = ["Microsoft.XMLDOM", ms(6), ms(4), ms(3), ms(2)]; _d.some(dp, function(p){ try{ var dom = new ActiveXObject(p); dom.async = false; dom.loadXML(xhr.responseText); result = dom; }catch(e){ return false; } return true; }); } //>>excludeEnd("webkitMobile"); return result; // DOMDocument } }; dojo._contentHandlers["json-comment-optional"] = function(xhr){ var handlers = _d._contentHandlers; if(xhr.responseText && xhr.responseText.indexOf("\/*") != -1){ return handlers["json-comment-filtered"](xhr); }else{ return handlers["json"](xhr); } }; dojo.__IoArgs = function(){ // url: String // URL to server endpoint. // content: Object? // Contains properties with string values. These // properties will be serialized as name1=value2 and // passed in the request. // timeout: Integer? // Milliseconds to wait for the response. If this time // passes, the then error callbacks are called. // form: DOMNode? // DOM node for a form. Used to extract the form values // and send to the server. // preventCache: Boolean? // Default is false. If true, then a // "dojo.preventCache" parameter is sent in the request // with a value that changes with each request // (timestamp). Useful only with GET-type requests. // handleAs: String? // Acceptable values depend on the type of IO // transport (see specific IO calls for more information). // load: Function? // function(response, ioArgs){} response is of type Object, ioArgs // is of type dojo.__IoCallbackArgs. This function will be // called on a successful HTTP response code. // error: Function? // function(response, ioArgs){} response is of type Object, ioArgs // is of type dojo.__IoCallbackArgs. This function will // be called when the request fails due to a network or server error, the url // is invalid, etc. It will also be called if the load or handle callback throws an // exception, unless djConfig.debugAtAllCosts is true. This allows deployed applications // to continue to run even when a logic error happens in the callback, while making // it easier to troubleshoot while in debug mode. // handle: Function? // function(response, ioArgs){} response is of type Object, ioArgs // is of type dojo.__IoCallbackArgs. This function will // be called at the end of every request, whether or not an error occurs. this.url = url; this.content = content; this.timeout = timeout; this.form = form; this.preventCache = preventCache; this.handleAs = handleAs; this.load = load; this.error = error; this.handle = handle; } dojo.__IoCallbackArgs = function(args, xhr, url, query, handleAs, id, canDelete, json){ // args: Object // the original object argument to the IO call. // xhr: XMLHttpRequest // For XMLHttpRequest calls only, the // XMLHttpRequest object that was used for the // request. // url: String // The final URL used for the call. Many times it // will be different than the original args.url // value. // query: String // For non-GET requests, the // name1=value1&name2=value2 parameters sent up in // the request. // handleAs: String // The final indicator on how the response will be // handled. // id: String // For dojo.io.script calls only, the internal // script ID used for the request. // canDelete: Boolean // For dojo.io.script calls only, indicates // whether the script tag that represents the // request can be deleted after callbacks have // been called. Used internally to know when // cleanup can happen on JSONP-type requests. // json: Object // For dojo.io.script calls only: holds the JSON // response for JSONP-type requests. Used // internally to hold on to the JSON responses. // You should not need to access it directly -- // the same object should be passed to the success // callbacks directly. this.args = args; this.xhr = xhr; this.url = url; this.query = query; this.handleAs = handleAs; this.id = id; this.canDelete = canDelete; this.json = json; } dojo._ioSetArgs = function(/*dojo.__IoArgs*/args, /*Function*/canceller, /*Function*/okHandler, /*Function*/errHandler){ // summary: // sets up the Deferred and ioArgs property on the Deferred so it // can be used in an io call. // args: // The args object passed into the public io call. Recognized properties on // the args object are: // canceller: // The canceller function used for the Deferred object. The function // will receive one argument, the Deferred object that is related to the // canceller. // okHandler: // The first OK callback to be registered with Deferred. It has the opportunity // to transform the OK response. It will receive one argument -- the Deferred // object returned from this function. // errHandler: // The first error callback to be registered with Deferred. It has the opportunity // to do cleanup on an error. It will receive two arguments: error (the // Error object) and dfd, the Deferred object returned from this function. var ioArgs = {args: args, url: args.url}; //Get values from form if requestd. var formObject = null; if(args.form){ var form = _d.byId(args.form); //IE requires going through getAttributeNode instead of just getAttribute in some form cases, //so use it for all. See #2844 var actnNode = form.getAttributeNode("action"); ioArgs.url = ioArgs.url || (actnNode ? actnNode.value : null); formObject = _d.formToObject(form); } // set up the query params var miArgs = [{}]; if(formObject){ // potentially over-ride url-provided params w/ form values miArgs.push(formObject); } if(args.content){ // stuff in content over-rides what's set by form miArgs.push(args.content); } if(args.preventCache){ miArgs.push({"dojo.preventCache": new Date().valueOf()}); } ioArgs.query = _d.objectToQuery(_d.mixin.apply(null, miArgs)); // .. and the real work of getting the deferred in order, etc. ioArgs.handleAs = args.handleAs || "text"; var d = new _d.Deferred(canceller); d.addCallbacks(okHandler, function(error){ return errHandler(error, d); }); //Support specifying load, error and handle callback functions from the args. //For those callbacks, the "this" object will be the args object. //The callbacks will get the deferred result value as the //first argument and the ioArgs object as the second argument. var ld = args.load; if(ld && _d.isFunction(ld)){ d.addCallback(function(value){ return ld.call(args, value, ioArgs); }); } var err = args.error; if(err && _d.isFunction(err)){ d.addErrback(function(value){ return err.call(args, value, ioArgs); }); } var handle = args.handle; if(handle && _d.isFunction(handle)){ d.addBoth(function(value){ return handle.call(args, value, ioArgs); }); } d.ioArgs = ioArgs; // FIXME: need to wire up the xhr object's abort method to something // analagous in the Deferred return d; } var _deferredCancel = function(/*Deferred*/dfd){ //summary: canceller function for dojo._ioSetArgs call. dfd.canceled = true; var xhr = dfd.ioArgs.xhr; var _at = typeof xhr.abort; if(_at == "function" || _at == "object" || _at == "unknown"){ xhr.abort(); } var err = dfd.ioArgs.error; if(!err){ err = new Error("xhr cancelled"); err.dojoType="cancel"; } return err; } var _deferredOk = function(/*Deferred*/dfd){ //summary: okHandler function for dojo._ioSetArgs call. var ret = _d._contentHandlers[dfd.ioArgs.handleAs](dfd.ioArgs.xhr); return ret === undefined ? null : ret; } var _deferError = function(/*Error*/error, /*Deferred*/dfd){ //summary: errHandler function for dojo._ioSetArgs call. console.error(error); return error; } // avoid setting a timer per request. It degrades performance on IE // something fierece if we don't use unified loops. var _inFlightIntvl = null; var _inFlight = []; var _watchInFlight = function(){ //summary: // internal method that checks each inflight XMLHttpRequest to see // if it has completed or if the timeout situation applies. var now = (new Date()).getTime(); // make sure sync calls stay thread safe, if this callback is called // during a sync call and this results in another sync call before the // first sync call ends the browser hangs if(!_d._blockAsync){ // we need manual loop because we often modify _inFlight (and therefore 'i') while iterating // note: the second clause is an assigment on purpose, lint may complain for(var i = 0, tif; i < _inFlight.length && (tif = _inFlight[i]); i++){ var dfd = tif.dfd; var func = function(){ if(!dfd || dfd.canceled || !tif.validCheck(dfd)){ _inFlight.splice(i--, 1); }else if(tif.ioCheck(dfd)){ _inFlight.splice(i--, 1); tif.resHandle(dfd); }else if(dfd.startTime){ //did we timeout? if(dfd.startTime + (dfd.ioArgs.args.timeout || 0) < now){ _inFlight.splice(i--, 1); var err = new Error("timeout exceeded"); err.dojoType = "timeout"; dfd.errback(err); //Cancel the request so the io module can do appropriate cleanup. dfd.cancel(); } } }; if(dojo.config.debugAtAllCosts){ func.call(this); }else{ try{ func.call(this); }catch(e){ dfd.errback(e); } } } } if(!_inFlight.length){ clearInterval(_inFlightIntvl); _inFlightIntvl = null; return; } } dojo._ioCancelAll = function(){ //summary: Cancels all pending IO requests, regardless of IO type //(xhr, script, iframe). try{ _d.forEach(_inFlight, function(i){ try{ i.dfd.cancel(); }catch(e){/*squelch*/} }); }catch(e){/*squelch*/} } //Automatically call cancel all io calls on unload //in IE for trac issue #2357. //>>excludeStart("webkitMobile", kwArgs.webkitMobile); if(_d.isIE){ _d.addOnWindowUnload(_d._ioCancelAll); } //>>excludeEnd("webkitMobile"); _d._ioWatch = function(/*Deferred*/dfd, /*Function*/validCheck, /*Function*/ioCheck, /*Function*/resHandle){ //summary: watches the io request represented by dfd to see if it completes. //dfd: // The Deferred object to watch. //validCheck: // Function used to check if the IO request is still valid. Gets the dfd // object as its only argument. //ioCheck: // Function used to check if basic IO call worked. Gets the dfd // object as its only argument. //resHandle: // Function used to process response. Gets the dfd // object as its only argument. var args = dfd.ioArgs.args; if(args.timeout){ dfd.startTime = (new Date()).getTime(); } _inFlight.push({dfd: dfd, validCheck: validCheck, ioCheck: ioCheck, resHandle: resHandle}); if(!_inFlightIntvl){ _inFlightIntvl = setInterval(_watchInFlight, 50); } // handle sync requests //A weakness: async calls in flight //could have their handlers called as part of the //_watchInFlight call, before the sync's callbacks // are called. if(args.sync){ _watchInFlight(); } } var _defaultContentType = "application/x-www-form-urlencoded"; var _validCheck = function(/*Deferred*/dfd){ return dfd.ioArgs.xhr.readyState; //boolean } var _ioCheck = function(/*Deferred*/dfd){ return 4 == dfd.ioArgs.xhr.readyState; //boolean } var _resHandle = function(/*Deferred*/dfd){ var xhr = dfd.ioArgs.xhr; if(_d._isDocumentOk(xhr)){ dfd.callback(dfd); }else{ var err = new Error("Unable to load " + dfd.ioArgs.url + " status:" + xhr.status); err.status = xhr.status; err.responseText = xhr.responseText; dfd.errback(err); } } dojo._ioAddQueryToUrl = function(/*dojo.__IoCallbackArgs*/ioArgs){ //summary: Adds query params discovered by the io deferred construction to the URL. //Only use this for operations which are fundamentally GET-type operations. if(ioArgs.query.length){ ioArgs.url += (ioArgs.url.indexOf("?") == -1 ? "?" : "&") + ioArgs.query; ioArgs.query = null; } } dojo.declare("dojo.__XhrArgs", dojo.__IoArgs, { constructor: function(){ // summary: // In addition to the properties listed for the dojo._IoArgs type, // the following properties are allowed for dojo.xhr* methods. // handleAs: String? // Acceptable values are: text (default), json, json-comment-optional, // json-comment-filtered, javascript, xml // sync: Boolean? // false is default. Indicates whether the request should // be a synchronous (blocking) request. // headers: Object? // Additional HTTP headers to send in the request. this.handleAs = handleAs; this.sync = sync; this.headers = headers; } }); dojo.xhr = function(/*String*/ method, /*dojo.__XhrArgs*/ args, /*Boolean?*/ hasBody){ // summary: // Sends an HTTP request with the given method. // description: // Sends an HTTP request with the given method. // See also dojo.xhrGet(), xhrPost(), xhrPut() and dojo.xhrDelete() for shortcuts // for those HTTP methods. There are also methods for "raw" PUT and POST methods // via dojo.rawXhrPut() and dojo.rawXhrPost() respectively. // method: // HTTP method to be used, such as GET, POST, PUT, DELETE. Should be uppercase. // hasBody: // If the request has an HTTP body, then pass true for hasBody. //Make the Deferred object for this xhr request. var dfd = _d._ioSetArgs(args, _deferredCancel, _deferredOk, _deferError); //Pass the args to _xhrObj, to allow xhr iframe proxy interceptions. dfd.ioArgs.xhr = _d._xhrObj(dfd.ioArgs.args); if(hasBody){ if("postData" in args){ dfd.ioArgs.query = args.postData; }else if("putData" in args){ dfd.ioArgs.query = args.putData; } }else{ _d._ioAddQueryToUrl(dfd.ioArgs); } // IE 6 is a steaming pile. It won't let you call apply() on the native function (xhr.open). // workaround for IE6's apply() "issues" var ioArgs = dfd.ioArgs; var xhr = ioArgs.xhr; xhr.open(method, ioArgs.url, args.sync !== true, args.user || undefined, args.password || undefined); if(args.headers){ for(var hdr in args.headers){ if(hdr.toLowerCase() === "content-type" && !args.contentType){ args.contentType = args.headers[hdr]; }else{ xhr.setRequestHeader(hdr, args.headers[hdr]); } } } // FIXME: is this appropriate for all content types? xhr.setRequestHeader("Content-Type", args.contentType || _defaultContentType); if(!args.headers || !args.headers["X-Requested-With"]){ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); } // FIXME: set other headers here! if(dojo.config.debugAtAllCosts){ xhr.send(ioArgs.query); }else{ try{ xhr.send(ioArgs.query); }catch(e){ dfd.ioArgs.error = e; dfd.cancel(); } } _d._ioWatch(dfd, _validCheck, _ioCheck, _resHandle); xhr = null; return dfd; // dojo.Deferred";s:7:"summary";s:44:"Sends an HTTP request with the given method.";s:11:"description";s:258:"Sends an HTTP request with the given method. See also dojo.xhrGet(), xhrPost(), xhrPut() and dojo.xhrDelete() for shortcuts for those HTTP methods. There are also methods for "raw" PUT and POST methods via dojo.rawXhrPut() and dojo.rawXhrPost() respectively.";s:7:"returns";s:47:"Object|String|DOMDocument|boolean|dojo.Deferred";}s:11:"dojo.xhrGet";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"args";a:1:{s:4:"type";s:14:"dojo.__XhrArgs";}}s:6:"source";s:46:" return _d.xhr("GET", args); // dojo.Deferred";s:7:"summary";s:40:"Sends an HTTP GET request to the server.";s:7:"returns";s:13:"dojo.Deferred";}s:12:"dojo.xhrPost";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"args";a:1:{s:4:"type";s:14:"dojo.__XhrArgs";}}s:6:"source";s:53:" return _d.xhr("POST", args, true); // dojo.Deferred";s:7:"summary";s:206:"Sends an HTTP POST request to the server. In addtion to the properties listed for the dojo.__XhrArgs type, the following property is allowed: postData: String. Send raw data in the body of the POST request.";s:7:"returns";s:13:"dojo.Deferred";}s:11:"dojo.xhrPut";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"args";a:1:{s:4:"type";s:14:"dojo.__XhrArgs";}}s:6:"source";s:52:" return _d.xhr("PUT", args, true); // dojo.Deferred";s:7:"summary";s:203:"Sends an HTTP PUT request to the server. In addtion to the properties listed for the dojo.__XhrArgs type, the following property is allowed: putData: String. Send raw data in the body of the PUT request.";s:7:"returns";s:13:"dojo.Deferred";}s:14:"dojo.xhrDelete";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:4:"args";a:1:{s:4:"type";s:14:"dojo.__XhrArgs";}}s:6:"source";s:48:" return _d.xhr("DELETE", args); //dojo.Deferred";s:7:"summary";s:43:"Sends an HTTP DELETE request to the server.";s:7:"returns";s:13:"dojo.Deferred";}s:26:"dojo._contentHandlers.text";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"xhr";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:48:" text: function(xhr){ return xhr.responseText; ";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:26:"dojo._contentHandlers.json";a:5:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"xhr";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:48:" return _d.fromJson(xhr.responseText || null);";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:43:"dojo._contentHandlers.json-comment-filtered";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"xhr";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:6786:"dojo.provide("dojo._base.xhr"); dojo.require("dojo._base.Deferred"); dojo.require("dojo._base.json"); dojo.require("dojo._base.lang"); dojo.require("dojo._base.query"); //>>excludeStart("webkitMobile", kwArgs.webkitMobile); (function(){ //>>excludeEnd("webkitMobile"); var _d = dojo; function setValue(/*Object*/obj, /*String*/name, /*String*/value){ //summary: // For the named property in object, set the value. If a value // already exists and it is a string, convert the value to be an // array of values. var val = obj[name]; if(_d.isString(val)){ obj[name] = [val, value]; }else if(_d.isArray(val)){ val.push(value); }else{ obj[name] = value; } } dojo.formToObject = function(/*DOMNode||String*/ formNode){ // summary: // dojo.formToObject returns the values encoded in an HTML form as // string properties in an object which it then returns. Disabled form // elements, buttons, and other non-value form elements are skipped. // Multi-select elements are returned as an array of string values. // description: // This form: // // |
// | // | // | // | // |
// // yields this object structure as the result of a call to // formToObject(): // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object } dojo.objectToQuery = function(/*Object*/ map){ // summary: // takes a name/value mapping object and returns a string representing // a URL-encoded version of that object. // example: // this object: // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; // // yields the following query string: // // | "blah=blah&multi=thud&multi=thonk" // FIXME: need to implement encodeAscii!! var enc = encodeURIComponent; var pairs = []; var backstop = {}; for(var name in map){ var value = map[name]; if(value != backstop[name]){ var assign = enc(name) + "="; if(_d.isArray(value)){ for(var i=0; i < value.length; i++){ pairs.push(assign + enc(value[i])); } }else{ pairs.push(assign + enc(value)); } } } return pairs.join("&"); // String } dojo.formToQuery = function(/*DOMNode||String*/ formNode){ // summary: // Returns a URL-encoded string representing the form passed as either a // node or string ID identifying the form to serialize return _d.objectToQuery(_d.formToObject(formNode)); // String } dojo.formToJson = function(/*DOMNode||String*/ formNode, /*Boolean?*/prettyPrint){ // summary: // return a serialized JSON string from a form node or string // ID identifying the form to serialize return _d.toJson(_d.formToObject(formNode), prettyPrint); // String } dojo.queryToObject = function(/*String*/ str){ // summary: // returns an object representing a de-serialized query section of a // URL. Query keys with multiple values are returned in an array. // description: // This string: // // | "foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&" // // results in this object structure: // // | { // | foo: [ "bar", "baz" ], // | thinger: " spaces =blah", // | zonk: "blarg" // | } // // Note that spaces and other urlencoded entities are correctly // handled. // FIXME: should we grab the URL string if we're not passed one? var ret = {}; var qp = str.split("&"); var dec = decodeURIComponent; _d.forEach(qp, function(item){ if(item.length){ var parts = item.split("="); var name = dec(parts.shift()); var val = dec(parts.join("=")); if(_d.isString(ret[name])){ ret[name] = [ret[name]]; } if(_d.isArray(ret[name])){ ret[name].push(val); }else{ ret[name] = val; } } }); return ret; // Object } /* from refactor.txt: all bind() replacement APIs take the following argument structure: { url: "blah.html", // all below are optional, but must be supported in some form by // every IO API timeout: 1000, // milliseconds handleAs: "text", // replaces the always-wrong "mimetype" content: { key: "value" }, // browser-specific, MAY be unsupported sync: true, // defaults to false form: dojo.byId("someForm") } */ // need to block async callbacks from snatching this thread as the result // of an async callback might call another sync XHR, this hangs khtml forever // must checked by watchInFlight() dojo._blockAsync = false; dojo._contentHandlers = { text: function(xhr){ return xhr.responseText; }, json: function(xhr){ return _d.fromJson(xhr.responseText || null); }, "json-comment-filtered": function(xhr){ // NOTE: the json-comment-filtered option was implemented to prevent // "JavaScript Hijacking", but it is less secure than standard JSON. Use // standard JSON instead. JSON prefixing can be used to subvert hijacking. if(!dojo.config.useCommentedJson){ console.warn("Consider using the standard mimetype:application/json." + " json-commenting can introduce security issues. To" + " decrease the chances of hijacking, use the standard the 'json' handler and" + " prefix your json with: {}&&\n" + "Use djConfig.useCommentedJson=true to turn off this message."); } var value = xhr.responseText; var cStartIdx = value.indexOf("\/*"); var cEndIdx = value.lastIndexOf("*\/"); if(cStartIdx == -1 || cEndIdx == -1){ throw new Error("JSON was not comment filtered"); } return _d.fromJson(value.substring(cStartIdx+2, cEndIdx));";s:7:"returns";s:13:"Object|String";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:32:"dojo._contentHandlers.javascript";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"xhr";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:6910:"dojo.provide("dojo._base.xhr"); dojo.require("dojo._base.Deferred"); dojo.require("dojo._base.json"); dojo.require("dojo._base.lang"); dojo.require("dojo._base.query"); //>>excludeStart("webkitMobile", kwArgs.webkitMobile); (function(){ //>>excludeEnd("webkitMobile"); var _d = dojo; function setValue(/*Object*/obj, /*String*/name, /*String*/value){ //summary: // For the named property in object, set the value. If a value // already exists and it is a string, convert the value to be an // array of values. var val = obj[name]; if(_d.isString(val)){ obj[name] = [val, value]; }else if(_d.isArray(val)){ val.push(value); }else{ obj[name] = value; } } dojo.formToObject = function(/*DOMNode||String*/ formNode){ // summary: // dojo.formToObject returns the values encoded in an HTML form as // string properties in an object which it then returns. Disabled form // elements, buttons, and other non-value form elements are skipped. // Multi-select elements are returned as an array of string values. // description: // This form: // // |
// | // | // | // | // |
// // yields this object structure as the result of a call to // formToObject(): // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; var ret = {}; var exclude = "file|submit|image|reset|button|"; _d.forEach(dojo.byId(formNode).elements, function(item){ var _in = item.name; var type = (item.type||"").toLowerCase(); if(_in && type && exclude.indexOf(type) == -1 && !item.disabled){ if(type == "radio" || type == "checkbox"){ if(item.checked){ setValue(ret, _in, item.value); } }else if(item.multiple){ ret[_in] = []; _d.query("option", item).forEach(function(opt){ if(opt.selected){ setValue(ret, _in, opt.value); } }); }else{ setValue(ret, _in, item.value); if(type == "image"){ ret[_in+".x"] = ret[_in+".y"] = ret[_in].x = ret[_in].y = 0; } } } }); return ret; // Object } dojo.objectToQuery = function(/*Object*/ map){ // summary: // takes a name/value mapping object and returns a string representing // a URL-encoded version of that object. // example: // this object: // // | { // | blah: "blah", // | multi: [ // | "thud", // | "thonk" // | ] // | }; // // yields the following query string: // // | "blah=blah&multi=thud&multi=thonk" // FIXME: need to implement encodeAscii!! var enc = encodeURIComponent; var pairs = []; var backstop = {}; for(var name in map){ var value = map[name]; if(value != backstop[name]){ var assign = enc(name) + "="; if(_d.isArray(value)){ for(var i=0; i < value.length; i++){ pairs.push(assign + enc(value[i])); } }else{ pairs.push(assign + enc(value)); } } } return pairs.join("&"); // String } dojo.formToQuery = function(/*DOMNode||String*/ formNode){ // summary: // Returns a URL-encoded string representing the form passed as either a // node or string ID identifying the form to serialize return _d.objectToQuery(_d.formToObject(formNode)); // String } dojo.formToJson = function(/*DOMNode||String*/ formNode, /*Boolean?*/prettyPrint){ // summary: // return a serialized JSON string from a form node or string // ID identifying the form to serialize return _d.toJson(_d.formToObject(formNode), prettyPrint); // String } dojo.queryToObject = function(/*String*/ str){ // summary: // returns an object representing a de-serialized query section of a // URL. Query keys with multiple values are returned in an array. // description: // This string: // // | "foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&" // // results in this object structure: // // | { // | foo: [ "bar", "baz" ], // | thinger: " spaces =blah", // | zonk: "blarg" // | } // // Note that spaces and other urlencoded entities are correctly // handled. // FIXME: should we grab the URL string if we're not passed one? var ret = {}; var qp = str.split("&"); var dec = decodeURIComponent; _d.forEach(qp, function(item){ if(item.length){ var parts = item.split("="); var name = dec(parts.shift()); var val = dec(parts.join("=")); if(_d.isString(ret[name])){ ret[name] = [ret[name]]; } if(_d.isArray(ret[name])){ ret[name].push(val); }else{ ret[name] = val; } } }); return ret; // Object } /* from refactor.txt: all bind() replacement APIs take the following argument structure: { url: "blah.html", // all below are optional, but must be supported in some form by // every IO API timeout: 1000, // milliseconds handleAs: "text", // replaces the always-wrong "mimetype" content: { key: "value" }, // browser-specific, MAY be unsupported sync: true, // defaults to false form: dojo.byId("someForm") } */ // need to block async callbacks from snatching this thread as the result // of an async callback might call another sync XHR, this hangs khtml forever // must checked by watchInFlight() dojo._blockAsync = false; dojo._contentHandlers = { text: function(xhr){ return xhr.responseText; }, json: function(xhr){ return _d.fromJson(xhr.responseText || null); }, "json-comment-filtered": function(xhr){ // NOTE: the json-comment-filtered option was implemented to prevent // "JavaScript Hijacking", but it is less secure than standard JSON. Use // standard JSON instead. JSON prefixing can be used to subvert hijacking. if(!dojo.config.useCommentedJson){ console.warn("Consider using the standard mimetype:application/json." + " json-commenting can introduce security issues. To" + " decrease the chances of hijacking, use the standard the 'json' handler and" + " prefix your json with: {}&&\n" + "Use djConfig.useCommentedJson=true to turn off this message."); } var value = xhr.responseText; var cStartIdx = value.indexOf("\/*"); var cEndIdx = value.lastIndexOf("*\/"); if(cStartIdx == -1 || cEndIdx == -1){ throw new Error("JSON was not comment filtered"); } return _d.fromJson(value.substring(cStartIdx+2, cEndIdx)); }, javascript: function(xhr){ // FIXME: try Moz and IE specific eval variants? return _d.eval(xhr.responseText);";s:7:"returns";s:13:"Object|String";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:25:"dojo._contentHandlers.xml";a:6:{s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:3:"xhr";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:564:" var result = xhr.responseXML; //>>excludeStart("webkitMobile", kwArgs.webkitMobile); if(_d.isIE && (!result || !result.documentElement)){ var ms = function(n){ return "MSXML" + n + ".DOMDocument"; } var dp = ["Microsoft.XMLDOM", ms(6), ms(4), ms(3), ms(2)]; _d.some(dp, function(p){ try{ var dom = new ActiveXObject(p); dom.async = false; dom.loadXML(xhr.responseText); result = dom; }catch(e){ return false; } return true; }); } //>>excludeEnd("webkitMobile"); return result; // DOMDocument";s:7:"returns";s:11:"DOMDocument";s:14:"private_parent";b:1;s:7:"summary";s:0:"";}s:4:"dojo";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}