comparison core.js @ 1443:bbfcb31c37e4

Bug #1502: Any parser XML errors will show the error and halt the rest of the loading.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Fri, 18 Dec 2015 18:28:06 +0000
parents fd22bb563f85
children 8540d153caec
comparison
equal deleted inserted replaced
1442:b11521789253 1443:bbfcb31c37e4
64 //var decode = $.parseXML(response); 64 //var decode = $.parseXML(response);
65 //projectXML = $(decode); 65 //projectXML = $(decode);
66 66
67 var parse = new DOMParser(); 67 var parse = new DOMParser();
68 projectXML = parse.parseFromString(response,'text/xml'); 68 projectXML = parse.parseFromString(response,'text/xml');
69 var errorNode = projectXML.getElementsByTagName('parsererror');
70 if (errorNode.length >= 1)
71 {
72 var msg = document.createElement("h3");
73 msg.textContent = "FATAL ERROR";
74 var span = document.createElement("span");
75 span.textContent = "The XML parser returned the following errors when decoding your XML file";
76 document.getElementsByTagName('body')[0].appendChild(msg);
77 document.getElementsByTagName('body')[0].appendChild(span);
78 document.getElementsByTagName('body')[0].appendChild(errorNode[0]);
79 return;
80 }
69 81
70 // Build the specification 82 // Build the specification
71 specification.decode(projectXML); 83 specification.decode(projectXML);
72 84
73 // Detect the interface to use and load the relevant javascripts. 85 // Detect the interface to use and load the relevant javascripts.
183 } 195 }
184 196
185 function errorSessionDump(msg){ 197 function errorSessionDump(msg){
186 // Create the partial interface XML save 198 // Create the partial interface XML save
187 // Include error node with message on why the dump occured 199 // Include error node with message on why the dump occured
200 popup.showPopup();
201 popup.popupContent.innerHTML = null;
202 var err = document.createElement('error');
203 var parent = document.createElement("div");
204 if (typeof msg === "object")
205 {
206 err.appendChild(msg);
207 popup.popupContent.appendChild(msg);
208
209 } else {
210 err.textContent = msg;
211 popup.popupContent.innerHTML = "ERROR : "+msg;
212 }
188 var xmlDoc = interfaceXMLSave(); 213 var xmlDoc = interfaceXMLSave();
189 var err = document.createElement('error');
190 err.textContent = msg;
191 xmlDoc.appendChild(err); 214 xmlDoc.appendChild(err);
192 var parent = document.createElement("div");
193 parent.appendChild(xmlDoc); 215 parent.appendChild(xmlDoc);
194 var file = [parent.innerHTML]; 216 var file = [parent.innerHTML];
195 var bb = new Blob(file,{type : 'application/xml'}); 217 var bb = new Blob(file,{type : 'application/xml'});
196 var dnlk = window.URL.createObjectURL(bb); 218 var dnlk = window.URL.createObjectURL(bb);
197 var a = document.createElement("a"); 219 var a = document.createElement("a");
198 a.hidden = ''; 220 a.hidden = '';
199 a.href = dnlk; 221 a.href = dnlk;
200 a.download = "save.xml"; 222 a.download = "save.xml";
201 a.textContent = "Save File"; 223 a.textContent = "Save File";
202 224
203 popup.showPopup(); 225
204 popup.popupContent.innerHTML = "ERROR : "+msg; 226
205 popup.popupContent.appendChild(a); 227 popup.popupContent.appendChild(a);
206 } 228 }
207 229
208 // Only other global function which must be defined in the interface class. Determines how to create the XML document. 230 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
209 function interfaceXMLSave(){ 231 function interfaceXMLSave(){