Fix indentation and coding standard issues
Showing
2 changed files
with
31 additions
and
36 deletions
... | @@ -121,9 +121,9 @@ | ... | @@ -121,9 +121,9 @@ |
121 | * NOTE: we cannot use window.btoa() for some strange reasons here. | 121 | * NOTE: we cannot use window.btoa() for some strange reasons here. |
122 | * | 122 | * |
123 | * @param String url The url to download | 123 | * @param String url The url to download |
124 | * @param String method The method to use, optional: default GET | 124 | * @param String method The method to use, optional: default GET |
125 | * @param String data The data to send, optional | 125 | * @param String data The data to send, optional |
126 | * @return string Base64 encoded result | 126 | * @return string Base64 encoded result |
127 | */ | 127 | */ |
128 | base64encode: function(url,method,data) { | 128 | base64encode: function(url,method,data) { |
129 | return this.evaluate(function(url,method,data) { | 129 | return this.evaluate(function(url,method,data) { | ... | ... |
... | @@ -224,12 +224,12 @@ | ... | @@ -224,12 +224,12 @@ |
224 | * contents. | 224 | * contents. |
225 | * | 225 | * |
226 | * @param String url The resource url | 226 | * @param String url The resource url |
227 | * @param String method The request method, optional | 227 | * @param String method The request method, optional |
228 | * @param Object data The request data, optional | 228 | * @param Object data The request data, optional |
229 | * @return String Base64 contents string | 229 | * @return String Base64 contents string |
230 | */ | 230 | */ |
231 | this.getBase64 = function(url,method,data) { | 231 | this.getBase64 = function(url,method,data) { |
232 | return this.encode(this.getBinary(url,method,data)); | 232 | return this.encode(this.getBinary(url,method,data)); |
233 | }; | 233 | }; |
234 | 234 | ||
235 | /** | 235 | /** |
... | @@ -237,43 +237,38 @@ | ... | @@ -237,43 +237,38 @@ |
237 | * fails but log errors. | 237 | * fails but log errors. |
238 | * | 238 | * |
239 | * @param String url | 239 | * @param String url |
240 | * @param String method | 240 | * @param String method |
241 | * @param Object data | 241 | * @param Object data |
242 | * @return string | 242 | * @return string |
243 | */ | 243 | */ |
244 | this.getBinary = function(url, method, data) { | 244 | this.getBinary = function(url, method, data) { |
245 | try { | 245 | try { |
246 | var xhr = new XMLHttpRequest(); | 246 | var xhr = new XMLHttpRequest(); |
247 | if(method === undefined || ["GET","get","POST","post"].indexOf(method) == -1) | 247 | if (method === undefined || ["GET","get","POST","post"].indexOf(method) == -1) { |
248 | { | 248 | method = "GET"; |
249 | method = "GET"; | 249 | } else { |
250 | }else{ | 250 | method = method.toUpperCase(); |
251 | method = method.toUpperCase(); | 251 | } |
252 | } | ||
253 | 252 | ||
254 | xhr.open(method, url, false); | 253 | xhr.open(method, url, false); |
255 | this.log("Using HTTP method: '" + method + "'", "debug"); | 254 | this.log("using HTTP method: '" + method + "'", "debug"); |
256 | xhr.overrideMimeType("text/plain; charset=x-user-defined"); | 255 | xhr.overrideMimeType("text/plain; charset=x-user-defined"); |
257 | if(method == "POST") | 256 | if (method == "POST") { |
258 | { | 257 | if(data === undefined) { |
259 | if(data === undefined) | 258 | data_str = ""; |
260 | { | 259 | } else { |
261 | data_str = ""; | 260 | data_str = ""; |
262 | }else{ | 261 | for (k in data) { |
263 | data_str = ""; | 262 | if (typeof(k) == "string" && typeof(data[k]) == "string") { |
264 | for(k in data) | 263 | data_str += "&" + escape(k) + "=" + escape(data[k]); |
265 | { | 264 | } |
266 | if(typeof(k) == "string" && typeof(data[k]) == "string") | 265 | } |
267 | { | 266 | data_str = data_str.substring(1); |
268 | data_str += "&" + escape(k) + "=" + escape(data[k]); | 267 | } |
269 | } | 268 | xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
270 | } | 269 | } |
271 | data_str = data_str.substring(1); | 270 | this.log("using request data: '" + data_str + "'", "debug"); |
272 | } | 271 | xhr.send(method == "POST" ? data_str : null); |
273 | xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | ||
274 | } | ||
275 | this.log("Using request data: '" + data_str + "'", "debug"); | ||
276 | xhr.send(method == "POST" ? data_str : null); | ||
277 | return xhr.responseText; | 272 | return xhr.responseText; |
278 | } catch (e) { | 273 | } catch (e) { |
279 | if (e.name === "NETWORK_ERR" && e.code === 101) { | 274 | if (e.name === "NETWORK_ERR" && e.code === 101) { | ... | ... |
-
Please register or sign in to post a comment