From 243e1f12bf1f67267a56ef98efcb8b9aa2ff344b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Jun 2014 07:23:40 -0400 Subject: [PATCH] feature(storage) get: callback(data) -> callback(error, data) --- lib/client.js | 4 ++-- lib/client/dom.js | 7 +++---- lib/client/edit.js | 4 ++-- lib/client/menu.js | 2 +- lib/client/storage.js | 2 +- lib/client/storage/_github.js | 2 +- lib/client/view.js | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/client.js b/lib/client.js index b9c910ca..c5bb3cad 100644 --- a/lib/client.js +++ b/lib/client.js @@ -272,7 +272,7 @@ var Util, DOM, CloudFunc; dirPath = CloudFunc.rmLastSlash(dirPath) || '/'; - Storage.get(dirPath, function(data) { + Storage.get(dirPath, function(error, data) { if (!data) { data = getJSONfromFileTable(); Storage.set(dirPath, data); @@ -380,7 +380,7 @@ var Util, DOM, CloudFunc; Util.log ('reading dir: "' + cleanPath + '";'); - Storage.get(cleanPath, function(json) { + Storage.get(cleanPath, function(error, json) { var RESTful = DOM.RESTful, obj = Util.parseJSON(json), isRefresh = options.refresh, diff --git a/lib/client/dom.js b/lib/client/dom.js index 44604a1e..3b677574 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -790,7 +790,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (hash && length < ONE_MEGABYTE) DOM.saveDataToStorage(path, data, hash); - Util.exec(callback, data); + Util.exec(callback, null, data); }; if (isDir) @@ -1195,8 +1195,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; var Storage = DOM.Storage, nameHash = name + '-hash'; - Storage.get(nameHash, function(storeHash) { - var equal, error, + Storage.get(nameHash, function(error, storeHash) { + var equal, isContain = Util.isContainStr(loadHash, 'error'); if (isContain) @@ -1268,7 +1268,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Storage.get(nameHash, callback); } ], callback); - } }); }; diff --git a/lib/client/edit.js b/lib/client/edit.js index f64ec8bb..e391de73 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -104,7 +104,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI Session.setUndoManager(new UndoManager()); }, function(callback) { - Info.getData(function(data) { + Info.getData(function(error, data) { Value = data; if (isJS && Session.getUseWorker()) @@ -310,7 +310,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI }, function(func) { var path = Info.path; - DOM.getDataFromStorage(path, function(data) { + DOM.getDataFromStorage(path, function(error, data) { if (data) Value = data; diff --git a/lib/client/menu.js b/lib/client/menu.js index 0e21b454..22699702 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -177,7 +177,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; } function uploadTo(nameModule) { - Info.getData(function(data) { + Info.getData(function(error, data) { var name = Info.name; CloudCmd.execFromModule(nameModule, 'uploadFile', { diff --git a/lib/client/storage.js b/lib/client/storage.js index 3e53d8c8..9e02b033 100644 --- a/lib/client/storage.js +++ b/lib/client/storage.js @@ -81,7 +81,7 @@ var Util, DOM; if (Allowed) ret = localStorage.getItem(name); - Util.exec(callback, ret); + Util.exec(callback, null, ret); return this; }, diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 66249ab8..b2a8ab1d 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -52,7 +52,7 @@ var CloudCmd, Util, DOM, CloudFunc, Github, cb; GitHub.autorize = function(callback, code) { - Storage.get('token', function(token) { + Storage.get('token', function(error, token) { var isContain, apiURL = CloudFunc.apiURL, URL = '//' + window.location.host + '/auth/github'; diff --git a/lib/client/view.js b/lib/client/view.js index 42174484..b867cb22 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -112,7 +112,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; switch(type) { default: - Info.getData(function(data) { + Info.getData(function(error, data) { var element = document.createTextNode(data); /* add margin only for view text documents */ Element.css('margin', '2%');