refactor(dom) showError

This commit is contained in:
coderaiser 2014-04-18 10:42:21 -04:00
parent 66647c09c9
commit 2297bb5259

View file

@ -109,44 +109,33 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
* show error image (usualy after error on ajax request)
*/
this.showError = function(jqXHR) {
var func,
lErrorImage = Images.error(),
lResponse = '',
lStatusText = '',
lStatus = 0,
lText = '';
var isStr = Util.isString(jqXHR),
image = Images.error(),
response = '',
statusText = '',
status = 0,
text = '';
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 (jqXHR)
if (isStr) {
text = jqXHR;
} else {
response = jqXHR.responseText;
statusText = jqXHR.statusText;
status = jqXHR.status;
text = status === 404 ? response : statusText;
}
/* если файла не существует*/
if (Util.isContainStr(lText, 'Error: ENOENT, '))
lText = lText.replace('Error: ENOENT, n','N');
DOM.show(image);
image.title = text;
/* если не хватает прав для чтения файла*/
else if (Util.isContainStr(lText, 'Error: EACCES,'))
lText = lText.replace('Error: EACCES, p','P');
if (text)
setTimeout(function() {
Dialog.alert(text);
Util.log(text);
}, 100);
DOM.show(lErrorImage);
lErrorImage.title = lText;
if (lText) {
Util.log(lText);
func = Dialog.alert.bind(null, lText);
setTimeout(func, 100);
}
return lErrorImage;
return image;
};
this.setProgress = function(value, title) {