mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
refactor(dom) showError
This commit is contained in:
parent
66647c09c9
commit
2297bb5259
1 changed files with 23 additions and 34 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue