From 70e7dec0ac14321a2eef912ade2b5f0df374f154 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sun, 14 Sep 2014 21:40:03 -0400 Subject: [PATCH] remove redundant code --- mithril.js | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/mithril.js b/mithril.js index e6e9e333..1946fd77 100644 --- a/mithril.js +++ b/mithril.js @@ -787,36 +787,6 @@ Mithril = m = new function app(window, undefined) { } function identity(value) {return value} - function serializeArray(array, prefix){ - var idx, out = [] - for (idx in array) { - var formatted = (prefix ? prefix : "") + "[]" - if (prefix && typeof array[idx] === "object") formatted = formatted.replace(/\[\]$/i, "[" + idx + "]") - if (typeof array[idx] === "object" && JSON.stringify(array[idx]) === "{}") continue - if (array[idx] instanceof Array) out.push(serializeArray(array[idx], formatted)) - else if(typeof array[idx] === "object") out.push(serializeObject(array[idx], formatted)) - else out.push(encodeURIComponent(formatted) + "=" + encodeURIComponent(array[idx])) - } - return out.join("&") - } - - function serializeObject(obj, prefix) { - var key, out = [] - for (key in obj) { - var formatted = prefix ? prefix + "[" + key + "]" : key - if (obj[key] instanceof Array) { - if(obj[key].length < 1) continue - out.push(serializeArray(obj[key], formatted)) - } - else if(typeof obj[key] === "object") { - if(JSON.stringify(obj[key]) === "{}") continue - out.push(serializeObject(obj[key], formatted)) - } - else out.push(encodeURIComponent(formatted) + "=" + encodeURIComponent(obj[key])) - } - return out.join("&") - } - function ajax(options) { if (options.dataType && options.dataType.toLowerCase() === "jsonp") { var callbackKey = "mithril_callback_" + new Date().getTime() + "_" + (Math.round(Math.random() * 1e16)).toString(36) @@ -857,7 +827,7 @@ Mithril = m = new function app(window, undefined) { + (options.url.indexOf("?") > 0 ? "&" : "?") + (options.callbackKey ? options.callbackKey : "callback") + "=" + callbackKey - + "&" + serializeObject(options.data || {}) + + "&" + buildQueryString(options.data || {}) window.document.body.appendChild(script) } else {