From 996686fd272fa24137e2b39f09dede5b6d6430c4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 13 May 2014 10:39:46 -0400 Subject: [PATCH] refactor(dom) getCurrentFileContent --- lib/client/dom.js | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index c909d6e2..b091ae15 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -971,33 +971,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @callback - callback function or data struct {sucess, error} * @currentFile */ - this.getCurrentFileContent = function(pParams, currentFile) { - var ret, - current = currentFile || this.getCurrentFile(), - lParams = pParams ? pParams : {}, - lPath = this.getCurrentPath(current), - lErrorWas = pParams.error, - lError = function(jqXHR) { - Util.exec(lErrorWas); - Images.showError(jqXHR); - }; + this.getCurrentFileContent = function(callback, currentFile) { + var RESTful = DOM.RESTful, + current = currentFile || this.getCurrentFile(), + isDir = this.isCurrentIsDir(currentFile), + path = this.getCurrentPath(current); - if (Util.isFunction(lParams)) - lParams.success = Util.retExec(pParams); + if (isDir) + path += '?json'; - lParams.error = lError; + RESTful.read(path, callback); - if (this.isCurrentIsDir(currentFile)) - lPath += '?json'; - else if (!lParams.dataType) - lParams.dataType = 'text'; - - if (!lParams.url) - lParams.url = CloudFunc.FS + lPath; - - ret = this.ajax(lParams); - - return ret; + return this; }; /**