From aec152d7933d83fa39d9a76f4edd05f931d57376 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 5 Jun 2015 08:19:43 -0400 Subject: [PATCH] feature(dom) Images.show.error: jqXHR -> text --- lib/client/dom.js | 27 +++------------------------ lib/client/load.js | 3 +-- lib/client/rest.js | 12 +++++++++++- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 4fa1d614..de5113a2 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -109,34 +109,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return image; } - function error(jqXHR, isQuiet) { - var isStr = Util.type.string(jqXHR), - image = Images.error(), - response = '', - statusText = '', - status = 0, - text = ''; - - if (jqXHR) - if (isStr) { - text = jqXHR; - } else { - response = jqXHR.responseText; - statusText = jqXHR.statusText; - status = jqXHR.status; - text = status === 404 ? response : statusText; - } + function error(text) { + var image = Images.error(); DOM.show(image); image.title = text; - if (text) - setTimeout(function() { - if (!isQuiet) - Dialog.alert(text); - - CloudCmd.log(text); - }, 100); + CloudCmd.log(text); return image; } diff --git a/lib/client/load.js b/lib/client/load.js index 3a56a737..8e0ebb29 100644 --- a/lib/client/load.js +++ b/lib/client/load.js @@ -52,7 +52,6 @@ var Util, DOM; funcError = function() { var callback, template = 'file {{ src }} could not be loaded', - isQuit = true, msg = rendy(template, { src: p.src }), @@ -64,7 +63,7 @@ var Util, DOM; parent.removeChild(element); - Images.show.error(msg, isQuit); + Images.show.error(msg); Util.exec(callback, error); }; diff --git a/lib/client/rest.js b/lib/client/rest.js index dd2cc795..7a54b615 100644 --- a/lib/client/rest.js +++ b/lib/client/rest.js @@ -187,7 +187,17 @@ var Util, DOM, CloudFunc, CloudCmd; url : p.url, data : p.data, dataType : p.dataType, - error : Images.show.error, + error : function(jqXHR) { + var response = jqXHR.responseText, + statusText = jqXHR.statusText, + status = jqXHR.status, + text = status === 404 ? response : statusText; + + Images.show.error(text); + setTimeout(function() { + DOM.Dialog.alert(text); + }, 100); + }, success : function(data) { Images.hide();