Commit 0e1f692e authored by Marc Duez's avatar Marc Duez
Browse files

model.js: catch error while parsing data file from url

parent 6ec0f991
...@@ -153,24 +153,18 @@ Model.prototype = { ...@@ -153,24 +153,18 @@ Model.prototype = {
.files[0]; .files[0];
oFReader.readAsText(oFile); oFReader.readAsText(oFile);
oFReader.onload = function (oFREvent) { oFReader.onload = function (oFREvent) {
try { try {
var data = JSON.parse(oFREvent.target.result); var data = jQuery.parseJSON(oFREvent.target.result)
} catch (e) { } catch (e) {
myConsole.popupMsg(myConsole.msg.file_error); myConsole.popupMsg(myConsole.msg.file_error);
return 0 return 0
} }
if ((typeof (data.vidjil_json_version) == 'undefined') || (data.vidjil_json_version < VIDJIL_JSON_VERSION)) {
myConsole.popupMsg(myConsole.msg.version_error);
return 0;
}
self.reset()
self.dataFileName = document.getElementById(id)
.files[0].name;
self.parseJsonData(data, limit) self.parseJsonData(data, limit)
.loadGermline() .loadGermline()
.loadAnalysis(analysis); .loadAnalysis(analysis);
self.dataFileName = document.getElementById(id)
.files[0].name;
self.initClones() self.initClones()
} }
...@@ -188,10 +182,8 @@ Model.prototype = { ...@@ -188,10 +182,8 @@ Model.prototype = {
crossDomain: true, crossDomain: true,
url: url, url: url,
success: function (result) { success: function (result) {
json = jQuery.parseJSON(result) self.parseJsonData(result, 100)
self.reset(); self.loadGermline();
self.parseJsonData(json, 100)
.loadGermline();
self.initClones() self.initClones()
self.dataFileName = url_split[url_split.length-1] self.dataFileName = url_split[url_split.length-1]
self.loadAnalysisUrl(url) self.loadAnalysisUrl(url)
...@@ -232,6 +224,13 @@ Model.prototype = { ...@@ -232,6 +224,13 @@ Model.prototype = {
this.dataCluster = [] this.dataCluster = []
this.clusters = [] this.clusters = []
console.log(data)
if ((typeof (data.vidjil_json_version) == 'undefined') || (data.vidjil_json_version < VIDJIL_JSON_VERSION)) {
myConsole.popupMsg(myConsole.msg.version_error);
return 0;
}
self.reset();
//copy .data file in model //copy .data file in model
for (var key in data){ for (var key in data){
if (key != "clusters") self[key] = data[key] if (key != "clusters") self[key] = data[key]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment