From afa89f38fa66c616f9c7884678fecb3edcbce392 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 21 May 2014 03:49:55 -0400 Subject: [PATCH] feature(rest) read: add optional dataType --- lib/client.js | 2 +- lib/client/rest.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index d5c5a235..088f5b13 100644 --- a/lib/client.js +++ b/lib/client.js @@ -395,7 +395,7 @@ var Util, DOM, CloudFunc; if (!isRefresh && json) CloudCmd.createFileTable(obj, panel); else - RESTful.read(cleanPath, function(json) { + RESTful.read(cleanPath, 'json', function(json) { CloudCmd.createFileTable(json, panel); Storage.set(cleanPath, json); }); diff --git a/lib/client/rest.js b/lib/client/rest.js index 6502588c..da6526b6 100644 --- a/lib/client/rest.js +++ b/lib/client/rest.js @@ -36,15 +36,21 @@ var Util, DOM, CloudFunc; }); }; - this.read = function(url, callback) { - var isQuery = Util.isContainStr(url, '?'); + this.read = function(url, dataType, callback) { + var isQuery = Util.isContainStr(url, '?'), + isFunc = Util.isFunction(dataType); + + if (!callback && isFunc) { + callback = dataType; + dataType = 'text'; + } sendRequest({ method : 'GET', url : CloudFunc.FS + url, callback : callback, notLog : !isQuery, - dataType : 'text' + dataType : dataType }); };