From fb7deedf71150d8c013ccd1decfa6e328fa2daa0 Mon Sep 17 00:00:00 2001 From: Javier Abadia Date: Sun, 29 Dec 2013 22:44:37 +0100 Subject: [PATCH] better error reporting --- tiles/index.html | 2 +- tiles/main.js | 35 +++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tiles/index.html b/tiles/index.html index 8f47cbb..069b3f8 100644 --- a/tiles/index.html +++ b/tiles/index.html @@ -55,7 +55,7 @@
× - ERROR: Change a few things up and try submitting again.. + ERROR: Change a few things up and try submitting again..
diff --git a/tiles/main.js b/tiles/main.js index caa7ead..0f80bdd 100644 --- a/tiles/main.js +++ b/tiles/main.js @@ -76,8 +76,8 @@ require(["esri/map", } },function(error){ - alert("Sorry, couldn't load webmap! " + dojo.toJson(error)); - console.log("Error loading webmap: ", dojo.toJson(error)); + showAlert('alert-danger',"Sorry, couldn't load webmap: " + error.message); + console.log("Error loading webmap:",error); }); } @@ -143,7 +143,7 @@ require(["esri/map", dojo.byId('show-stored-tiles').disabled = true; esri.hide(dojo.byId('downloading-ui')); - showError("Failed initializing storage, probably your browser doesn't support IndexedDB nor WebSQL"); + showAlert("alert-danger","Failed initializing storage, probably your browser doesn't support IndexedDB nor WebSQL"); } }); @@ -234,9 +234,9 @@ require(["esri/map", console.log("deleteAllTiles():", success,err); if( success ) - alert("All tiles deleted"); + showAlert("alert-info", "All tiles deleted"); else - alert("Can't delete tiles: " + err); + showAlert("alert-danger","Can't delete tiles: " + err); setTimeout(updateOfflineUsage,0); // request execution in the next turn of the event loop }); @@ -282,7 +282,10 @@ require(["esri/map", } function finishedDownloading(cancelled) - { + { + if( cancelled ) + showAlert('alert-warning', 'Cancelled'); + setTimeout(function() { esri.show(dojo.byId('ready-to-download-ui')); @@ -320,14 +323,26 @@ require(["esri/map", } } - function showError(error) + function showAlert(type, msg) { - dojo.byId('error-msg').innerHTML = error; - dojo.query('#error-div .close').onclick(hideError); + dojo.byId('error-msg').innerHTML = msg; + dojo.query('#error-div .close').onclick(hideAlert); + dojo.query('#error-div .alert') + .removeClass('alert-danger') + .removeClass('alert-info') + .removeClass('alert-warning') + .addClass(type); + switch(type) + { + case 'alert-danger': dojo.byId('error-type').innerHTML = "ERROR"; break; + case 'alert-info': dojo.byId('error-type').innerHTML = "INFO"; break; + case 'alert-warning': dojo.byId('error-type').innerHTML = "WARNING"; break; + } esri.show(dojo.byId('error-div')); + window.scrollTo(0,0); } - function hideError() + function hideAlert() { esri.hide(dojo.byId('error-div')); }