Popup notifications when there are Parsing exceptions or when requests Fail instead...
authorStephan Reichholf <sreichholf@users.schwerkraft.elitedvb.net>
Fri, 26 Feb 2010 16:38:26 +0000 (16:38 +0000)
committerStephan Reichholf <sreichholf@users.schwerkraft.elitedvb.net>
Fri, 26 Feb 2010 16:38:26 +0000 (16:38 +0000)
This should help users to see when something went wrong!

webinterface/src/web-data/objects.js
webinterface/src/web-data/tools.js

index 89204eb..87bb63f 100644 (file)
@@ -152,7 +152,9 @@ function EPGList(xml){
        // parsing values from xml-element
        try{
                this.xmlitems = xml.getElementsByTagName("e2eventlist").item(0).getElementsByTagName("e2event");
-       } catch (e) { debug("[EPGList] parsing Error");}
+       } catch (e) {
+               notify("Error Parsing EPG: " + e, false);
+       }
        
        this.getArray = function(sortbytime){
                debug("[EPGList] Sort by time "+sortbytime);
@@ -604,7 +606,7 @@ function DeviceInfo(xml){
                                        'model' : model
                        };                                      
                } catch (e) {
-                       debug("[incomingDeviceInfo] error parsing NIM data: " + e);
+                       notify("Error parsing frontend data: " + e);
                }
        }
        
@@ -624,7 +626,7 @@ function DeviceInfo(xml){
                                        'free'          : free
                        };
                } catch(e){
-                       debug("[incomingDeviceInfo] error parsing HDD data: " + e);
+                       notify("Error parsing HDD data: " + e, false);                  
                }
        }
        
@@ -649,7 +651,7 @@ function DeviceInfo(xml){
                                        'netmask' : netmask
                        };
                } catch (e) {
-                       debug("[incomingDeviceInfo] error parsing NIC data: " + e);
+                       notify("Error parsing NIC data: " + e, false);                  
                }
        }
        
@@ -662,7 +664,7 @@ function DeviceInfo(xml){
                                'webifversion': xml.getElementsByTagName('e2webifversion').item(0).firstChild.data                      
                };
        } catch (e) {
-               debug("[incomingDeviceInfo] parsing Error" + e);
+               notify("Error parsing deviceinfo data: " + e, false);           
        }
        
        this.json = {
@@ -682,7 +684,7 @@ function SimpleXMLResult(xml){
        try{
                this.xmlitems = xml.getElementsByTagName("e2simplexmlresult").item(0);
        } catch (e) {
-               debug("[SimpleXMLResult] parsing e2simplexmlresult" + e);
+               notify("Error parsing e2simplexmlresult: " + e, false);
        }
 
        this.state = getNodeContent(this.xmlitems, 'e2state', 'False');
@@ -708,8 +710,9 @@ function SimpleXMLList(xml, tagname){
        try{
                this.xmlitems = xml.getElementsByTagName(tagname);
        } catch (e) {
-               debug("[SimpleXMLList] parsing e2simplexmllist"+e);
+               notify("Error parsing SimpleXMLList: " + e, false);     
        }
+       
        this.xmllist = [];
        
        this.getList = function(){
@@ -748,8 +751,9 @@ function Settings(xml){
                this.xmlitems = xml.getElementsByTagName("e2settings").item(0).getElementsByTagName("e2setting");
                debug("[Settings] Number of items: " + this.xmlitems);
        } catch (e) {
-               debug("[Settings] parsing Error");
+               notify("Error parsing Settings: " + e, false);  
        }       
+       
        this.settings = [];
        
        this.getArray = function(){
@@ -771,7 +775,7 @@ function FileList(xml){
        try{
                this.xmlitems = xml.getElementsByTagName("e2filelist").item(0).getElementsByTagName("e2file");
        } catch (e) {
-               debug("[FileList] parsing Error");
+               notify("Error parsing FileList: " + e, false);
        }
        this.filelist = [];
 
index 7d8fff6..dc0f4b2 100644 (file)
@@ -130,7 +130,7 @@ function notify(text, state){
 
                set('notification', "<div>"+text+"</div>");
                notif.appear({duration : 0.5, to: 0.9 });
-               hideNotifierTimeout = setTimeout(hideNotifier, 7500);
+               hideNotifierTimeout = setTimeout(hideNotifier, 10000);
        }
 }
 
@@ -437,6 +437,11 @@ function openDebug(){
        debugWin = openPopupPage("Debug", uri, 500, 300);
 }
 
+function requestFailed(transport){
+       var notifText = "Request failed for:  " + transport.request.url + "<br>Status: " + transport.status + " " + transport.statusText;
+       notify(notifText, false);
+}
+
 function doRequest(url, readyFunction){
        requestStarted();
        var request = '';
@@ -446,16 +451,19 @@ function doRequest(url, readyFunction){
                try{
                        request = new Ajax.Request(url,
                                        {
-                               asynchronous: true,
-                               method: 'GET',
-                               requestHeaders: ['Pragma', 'no-cache', 'Cache-Control', 'no-cache,no-store', 'Expires', '-1'],
-                               onException: function(o,e){ throw(e); },                                
-                               onSuccess: function (transport, json) {                                         
-                                       if(typeof(readyFunction) != "undefined"){
-                                               readyFunction(transport);
-                                       }
-                               },
-                               onComplete: requestFinished 
+                                               asynchronous: true,
+                                               method: 'GET',
+                                               requestHeaders: ['Cache-Control', 'no-cache,no-store', 'Expires', '-1'],
+                                               onException: function(o,e){ throw(e); },                                
+                                               onSuccess: function (transport, json) {                                         
+                                                       if(typeof(readyFunction) != "undefined"){
+                                                               readyFunction(transport);
+                                                       }
+                                               },
+                                               onFailure: function(transport){
+                                                       requestFailed(transport);
+                                               },
+                                               onComplete: requestFinished 
                                        });
                } catch(e) {}
        } else { //we're on gears!
@@ -463,17 +471,18 @@ function doRequest(url, readyFunction){
                        request = google.gears.factory.create('beta.httprequest');
                        request.open('GET', url);
 
-                       if( typeof(readyFunction) != "undefined" ){
-                               request.onreadystatechange = function(){                                
-                                       if(request.readyState == 4){
-                                               if(request.status == 200){                      
+
+                       request.onreadystatechange = function(){                                
+                               if(request.readyState == 4){
+                                       if(request.status == 200){
+                                               if( typeof(readyFunction) != "undefined" ){
                                                        readyFunction(request);
-                                               } else {
-                                                       //we COULD do some error handling here
                                                }
+                                       } else {
+                                               requestFailed(transport);
                                        }
-                               };
-                       }
+                               }
+                       };
                        request.send();
                } catch(e) {}
        }