From 627f08806f0e5b266e5528db91b139bd1ff57a38 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 13 Sep 2013 10:14:09 +0000 Subject: [PATCH] refactor(dom) Images showError: rm textStatus, errorThrown --- lib/client/dom.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index f0c7ee2a..f410f964 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -73,14 +73,27 @@ var CloudCmd, Util, DOM, CloudFunc; /** * show error image (usualy after error on ajax request) */ - this.showError = function(jqXHR, textStatus, errorThrown) { + this.showError = function(jqXHR) { var lLoadingImage = lImages.loading(), lErrorImage = lImages.error(), - lResponse = jqXHR.responseText, - lStatusText = jqXHR.statusText, - lStatus = jqXHR.status, - lText = (lStatus === 404 ? lResponse : lStatusText); + lResponse = '', + lStatusText = '', + lStatus = 0, + lText = ''; + if (jqXHR) { + lResponse = jqXHR.responseText; + lStatusText = jqXHR.statusText; + lStatus = jqXHR.status; + lText = lStatus === 404 ? lResponse : lStatusText; + + if (!lText) + if (Util.isString(jqXHR)) + lText = jqXHR; + else + lText = ''; + } + /* если файла не существует*/ if ( Util.isContainStr(lText, 'Error: ENOENT, ') ) lText = lText.replace('Error: ENOENT, n','N'); @@ -99,9 +112,10 @@ var CloudCmd, Util, DOM, CloudFunc; DOM.hide(lLoadingImage); - Util.log(lText); - - setTimeout( Util.retExec(alert, lText), 100); + if (lText) { + Util.log(lText); + setTimeout(Util.retExec(alert, lText), 100); + } return lErrorImage; };