Commit 77ddcfa2 authored by François Billioud's avatar François Billioud

Try to rewrite bad coded elements and fix asynchronism problem.

There is an infinity loop in with the user profile load and save. It should be fixed
parent 6e643eb0
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
* loadContentFromDocument : display the content of the specified document in the editor * loadContentFromDocument : display the content of the specified document in the editor
*/ */
SVGEditor = function() { SVGEditor = function() {
this.name = "svg-editor"; this.name = "svg-edit"; // name to use in dialog boxes
this.objectName = "SVGEditor" // name of the object reference
this.load = function() {$("#svgframe").attr("src", "svg-edit/svg-editor.html");} this.load = function() {$("#svgframe").attr("src", "svg-edit/svg-editor.html");}
this.saveEdition = function() { this.saveEdition = function() {
...@@ -26,39 +27,20 @@ SVGEditor = function() { ...@@ -26,39 +27,20 @@ SVGEditor = function() {
/** /**
* SVG documents * SVG documents
* *
* editable documents must implements the following arguments and methods * editable documents must override the following arguments and methods of JSONDocument prototype
* type : a unique type ID * type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes * saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page * setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*
* @param arg : a json JSONTextDocument object to load
*/ */
var JSONIllustrationDocument = function(arg) {
JSONDocument.call(this,arg);//inherits properties from JSONDocument
if(arg) {this.load(arg);}
else {
this.type = "illustration";
}
}
JSONIllustrationDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
JSONIllustrationDocument.prototype.saveEdition = function(content) { JSONDocument.prototype.type = "text";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName()); this.setLastUser(getCurrentUser().getName());
this.setContent(content); this.setContent(content);
this.setLastModification(getCurrentTime()); this.setLastModification(getCurrentTime());
this.setAsCurrentDocument(); this.setAsCurrentDocument();
} }
JSONIllustrationDocument.prototype.setAsCurrentDocument = function() { JSONDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentTitle(this); getCurrentPage().displayDocumentInformation(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayLastUserName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this); setCurrentDocument(this);
} }
getCurrentDocument = function() {
return new JSONIllustrationDocument(JSON.parse(localStorage.getItem("currentDocument")));
}
...@@ -21,9 +21,9 @@ function logIntoDav(wallet) { ...@@ -21,9 +21,9 @@ function logIntoDav(wallet) {
function initStorage(wallet) { function initStorage(wallet) {
if(!wallet.provider) {//local storage if(!wallet.provider) {//local storage
setCurrentStorage(new LocalStorage(wallet.userName)); Storage.currentStorage = new LocalStorage(wallet.userName);
} else { } else {
setCurrentStorage(new JIOStorage(wallet)); Storage.currentStorage = new JIOStorage(wallet);
} }
} }
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
* loadContentFromDocument : display the content of the specified document in the editor * loadContentFromDocument : display the content of the specified document in the editor
*/ */
var Xinha = function() { var Xinha = function() {
this.name = "Xinha"; this.name = "Xinha"; // name to use in dialog boxes
this.objectName = "Xinha" // name of the object reference
this.load = function() { this.load = function() {
_editor_url = "xinha/"; _editor_url = "xinha/";
getCurrentPage().include("xinha/XinhaCore.js","script"); getCurrentPage().include("xinha/XinhaCore.js","script");
...@@ -28,7 +29,8 @@ var Xinha = function() { ...@@ -28,7 +29,8 @@ var Xinha = function() {
} }
var AlohaInterface = function() { var AlohaInterface = function() {
this.name = "Aloha"; this.name = "Aloha"; // name to use in dialog boxes
this.objectName = "AlohaInterface" // name of the object reference
this.load = function() { this.load = function() {
GENTICS_Aloha_base="aloha/aloha/"; GENTICS_Aloha_base="aloha/aloha/";
loadFile("aloha/aloha/aloha.js", "script", function(data) { loadFile("aloha/aloha/aloha.js", "script", function(data) {
...@@ -53,7 +55,8 @@ var AlohaInterface = function() { ...@@ -53,7 +55,8 @@ var AlohaInterface = function() {
} }
var NicEdit = function() { var NicEdit = function() {
this.name = "NicEdit"; this.name = "NicEdit"; // name to use in dialog boxes
this.objectName = "NicEdit" // name of the object reference
this.instance = null; this.instance = null;
this.load = function() { this.load = function() {
var nic = this; var nic = this;
...@@ -75,7 +78,8 @@ var NicEdit = function() { ...@@ -75,7 +78,8 @@ var NicEdit = function() {
var TinyEdit = function() { var TinyEdit = function() {
this.name = "TinyEdit"; this.name = "Tiny"; // name to use in dialog boxes
this.objectName = "TinyEdit" // name of the object reference
this.load = function() { this.load = function() {
loadFile("tinyEdit/tinyEdit.js","script",function(data) { loadFile("tinyEdit/tinyEdit.js","script",function(data) {
eval(data); eval(data);
...@@ -114,41 +118,20 @@ var TinyEdit = function() { ...@@ -114,41 +118,20 @@ var TinyEdit = function() {
/** /**
* Text documents * Text documents
* *
* editable documents must implements the following arguments and methods * editable documents must override the following arguments and methods of JSONDocument prototype
* type : a unique type ID * type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes * saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page * setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
/**
* class JSONTextDocument
* @param arg : a json JSONTextDocument object to load
*/ */
var JSONTextDocument = function(arg) {
JSONDocument.call(this,arg);//inherits properties from JSONDocument
if(arg) {this.load(arg);}
else {
this.type = "text";
}
}
JSONTextDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
JSONTextDocument.prototype.saveEdition = function(content) { JSONDocument.prototype.type = "text";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName()); this.setLastUser(getCurrentUser().getName());
this.setContent(content); this.setContent(content);
this.setLastModification(getCurrentTime()); this.setLastModification(getCurrentTime());
this.setAsCurrentDocument(); this.setAsCurrentDocument();
} }
JSONTextDocument.prototype.setAsCurrentDocument = function() { JSONDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentTitle(this); getCurrentPage().displayDocumentInformation(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayLastUserName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this); setCurrentDocument(this);
} }
getCurrentDocument = function() {
return new JSONTextDocument(JSON.parse(localStorage.getItem("currentDocument")));
}
This diff is collapsed.
...@@ -29,7 +29,8 @@ UngObject.prototype.load = function(data) { ...@@ -29,7 +29,8 @@ UngObject.prototype.load = function(data) {
}; };
/* Load methods from a class to another class */ /* Load methods from a class to another class */
UngObject.prototype.inherits = function(superClass) { UngObject.prototype.inherits = function(superClass,arg) {
superClass.call(this,arg);//or this.load(new superClass(arg));
this.prototype.load(superClass.prototype); this.prototype.load(superClass.prototype);
} }
...@@ -44,7 +45,7 @@ UngObject.prototype.equals = function(object) { ...@@ -44,7 +45,7 @@ UngObject.prototype.equals = function(object) {
return true; return true;
} }
/* return a copy of the current object */ /* return a deep copy of the current object */
UngObject.prototype.copy = function() { UngObject.prototype.copy = function() {
var copied = new Object(); var copied = new Object();
for (var property in this) { for (var property in this) {
...@@ -53,123 +54,17 @@ UngObject.prototype.copy = function() { ...@@ -53,123 +54,17 @@ UngObject.prototype.copy = function() {
return copied; return copied;
} }
/** /**
* Class List * convert an object into an array easier to manipulate
* this class provides usual API to manipulate list structure * @param object : the object to convert
* @param arg : a json list object
* @param contentType : the type of the elements of the list
*/ */
var List = function(arg, contentType) { toArray = function(object) {
if(arg && arg.headElement) { var array = [];
if(contentType) { for(var element in object) {
this.headElement=new contentType(arg.headElement); if(typeof element != "function") array.push(object[element]);
} else {
this.headElement = arg.headElement;
}
this.length = arg.length;
this.previous = new List(arg.previous, contentType);
}
else {
this.nullElement();
} }
return array
} }
List.prototype = new UngObject();
List.prototype.load({
nullElement: function() {
this.headElement = null;
this.previous = undefined;
this.length = 0;
},
size: function() {return this.length;},
head: function() {return this.headElement;},
tail: function() {return this.previous;},
isEmpty: function() {return this.head()===null;},
equals: function(list) {
return this.head().equals(list.head()) && this.tail().equals(list.tail());
},
add: function(value) {
var t = new List();
t.load(this);
this.headElement = value;
this.previous = t;
this.length = t.size()+1;
},
get: function(i) {
if(i>=this.size()) {return null;}
if(i==0) {return this.head();}
return this.tail().get(i-1);
},
set: function(i,element) {
if(i>=this.size()) {errorMessage("set out of bounds, "+i+" : "+this.size(),this);return}
if(i==0) {
this.headElement=element;
} else {
this.tail().set(i-1,element);
}
},
remove: function(i) {
if(i>=this.size()) {errorMessage("remove out of bounds, "+i+" : "+this.size(),this);return}//particular case
if(i==0) {this.pop();return}//particular case
if(i==1) {//init
this.previous = this.tail().tail();
} else {//recursion
this.tail().remove(i-1);
}
this.length--;
},
pop: function() {
if(this.isEmpty()) {errorMessage("pop on empty list",this);return null;}
var h = this.head();
this.load(this.tail())
return h;
},
find: function(object) {
if(this.isEmpty()) {return -1}//init-false
var elt = this.head();
if(object.equals) {//init-true
if(object.equals(this.head())) {return 0;}//with an adapted comparator
} else {
if(object===this.head()) {return 0;}//with usual comparator
}
var recursiveResult = this.tail().find(object);//recursion
return recursiveResult>=0 ? this.tail().find(object)+1 : recursiveResult;
},
contains: function(object) {if(this.isEmpty()) {return false} else {return object===this.head() ? true : this.tail().contains(object)}},
insert: function(element,i) {
if(i>this.size()) {errorMessage("insert out of bounds, "+i+" : "+this.size(),this);return}//particular case
if(i==0) {//init
this.add(element);
} else {//recursion
this.tail().insert(element,i-1);
this.length++;
}
},
replace: function(oldElement,newElement) {
if(this.isEmpty()) {errorMessage("<<element not found>> when trying to replace",this);return}//init-false
if(oldElement===this.head()) {
this.set(0,newElement);//init-true
} else {
this.tail().replace(oldElement,newElement);//recursion
}
},
removeElement: function(element) {//remove each occurence of the element in this list
if(this.isEmpty()) {return}
this.tail().removeElement(element);
if(element.equals) {//init-true
if(element.equals(this.head())) {this.pop();}//with an adapted comparator
} else {
if(element===this.head()) {this.pop();}//with usual comparator
}
},
concat: function(list) {
if(list.size()==0) {return this}
var l1 = this.copy();
var l2 = list.copy();
l1.add(l2.get(l2.size()-1));
return l2;
}
});
/** /**
* load a public file with a basic ajax request * load a public file with a basic ajax request
...@@ -184,7 +79,6 @@ loadFile = function(address, type, instruction) { ...@@ -184,7 +79,6 @@ loadFile = function(address, type, instruction) {
dataType: type, dataType: type,
success: instruction, success: instruction,
error: function(type) {alert("Error "+type.status+" : fail while trying to load "+address);} error: function(type) {alert("Error "+type.status+" : fail while trying to load "+address);}
}); });
} }
...@@ -195,14 +89,16 @@ loadFile = function(address, type, instruction) { ...@@ -195,14 +89,16 @@ loadFile = function(address, type, instruction) {
*/ */
waitBeforeSucceed = function(required, func) { waitBeforeSucceed = function(required, func) {
var nb = 2;//avoid to test too much times var nb = 2;//avoid to test too much times
var execute = function() { (function execute() {
try { try {
if(!required.call()) {throw 0;} if(!required.call()) {throw 0;}
func.call();} func.call();}
catch(e) {console.log(e);if(nb<100) {setTimeout(execute,nb*100);}} catch(e) {
nb*=nb; if(console) {console.log(e)}
if(nb<100) {setTimeout(execute,nb*100);}
} }
execute(); nb*=nb;
})()
} }
/* /*
...@@ -211,12 +107,27 @@ waitBeforeSucceed = function(required, func) { ...@@ -211,12 +107,27 @@ waitBeforeSucceed = function(required, func) {
*/ */
tryUntilSucceed = function(func) { tryUntilSucceed = function(func) {
var nb = 2;//avoid to test too much times var nb = 2;//avoid to test too much times
var execute = function() { (function execute() {
try {func.call();} try {func.call();}
catch(e) {if(nb<100) {setTimeout(execute,nb*200);}console.log(e);} catch(e) {
nb*=nb; if(console) {console.log(e)}
if(nb<100) {setTimeout(execute,nb*200);}
} }
execute(); nb*=nb;
})()
}
/**
* call a function periodically. Usefull for checking some stuff regularly
* @param task : function to execute each period
* @param period : time to wait before next execution
* @param firstExecution : (optional) if set to false, the task will not be executed at first call
*/
recursiveTask = function(task,period,firstExecution) {
if(firstExecution!==false) {task.call()}
(function recursion() {
setTimeout(function() {task.call();recursion()},period);
})();
} }
/** /**
...@@ -232,7 +143,7 @@ var resize = function() { ...@@ -232,7 +143,7 @@ var resize = function() {
*/ */
errorMessage = function(message,object) { errorMessage = function(message,object) {
errorObject = object; errorObject = object;
console.log(message); if(console) {console.log(message)}
} }
/** /**
...@@ -241,7 +152,15 @@ errorMessage = function(message,object) { ...@@ -241,7 +152,15 @@ errorMessage = function(message,object) {
function getCurrentTime() {return Date.now();} function getCurrentTime() {return Date.now();}
/** /**
* Paste a toolkit at the mouse position * Paste a toolkit at the mouse position.
* Just add a common css class to your element needing a tooltip, and initialize with :
tooltip = new Tooltip();
$(".myTooltipClass")
.mouseover(function() {tooltip.show("my tooltip text")})
.mouseout(function() {tooltip.hide();})
.mousemove(function(event) {tooltip.move(event);});
*/ */
Tooltip = function() { Tooltip = function() {
this.visible=false; this.visible=false;
......
...@@ -15,32 +15,38 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen ...@@ -15,32 +15,38 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen
* @param documentList : documents information loaded from the storage * @param documentList : documents information loaded from the storage
*/ */
var DocumentList = function(documentList) { var DocumentList = function(documentList) {
if(sessionStorage.documentList) {//load from sessionStorage this.detailedList = {}
this.load(JSON.parse(sessionStorage.documentList));
}
else {
if(documentList) { if(documentList) {
for(var doc in documentList) { for(var doc in documentList) {
this.documentList[doc] = new JSONDocument(documentList[doc]); this.detailedList[doc] = new JSONDocument(documentList[doc]);
}
} }
} else {this.documentList = {}}
this.list = getCurrentStorage().getDocumentList();
this.displayInformation = {}; this.displayInformation = {};
this.displayInformation.page = 1; this.displayInformation.page = 1;
this.selectionList = []; this.selectionList = [];
//check the user document list on the remote storage every 10 seconds
var list = this;
var updateDocumentList = function () {
JIO.getDocumentList({
success: function(data) {
list.detailedList = data;
} }
});
}
recursiveTask(function() {if(JIO.isReady()){updateDocumentList()}},10000);
} }
DocumentList.prototype = new UngObject(); DocumentList.prototype = new UngObject();
DocumentList.prototype.load({ DocumentList.prototype.load({
removeDocument: function(fileName) { removeDocument: function(fileName) {
getCurrentStorage().remove(fileName)//delete the file getCurrentStorage().remove(fileName)//delete the file
delete this.list[fileName];//remove from the list
delete this.detailedList[fileName];// delete this.detailedList[fileName];//
this.save();//save changes this.save();//save changes
}, },
getList: function() {return this.list}, get: function(fileName) {return this.getDetailedList()[fileName]},
getList: function() {return getCurrentStorage().getDocumentList();},
getDetailedList: function() {return this.detailedList}, getDetailedList: function() {return this.detailedList},
getSelectionList: function() {return this.selectionList;}, getSelectionList: function() {return this.selectionList;},
resetSelectionList: function() { resetSelectionList: function() {
...@@ -70,7 +76,7 @@ DocumentList.prototype.load({ ...@@ -70,7 +76,7 @@ DocumentList.prototype.load({
for(i=this.getDisplayInformation().first-1; i<this.getDisplayInformation().last; i++) { for(i=this.getDisplayInformation().first-1; i<this.getDisplayInformation().last; i++) {
$("tr td.listbox-table-select-cell input#"+i).attr("checked",true);//check $("tr td.listbox-table-select-cell input#"+i).attr("checked",true);//check
} }
$("span#selected_row_number a").html(this.size());//display the selected row number $("span#selected_row_number a").html(list.length);//display the selected row number
}, },
addToSelection: function(fileName) { addToSelection: function(fileName) {
this.getSelectionList().push(fileName); this.getSelectionList().push(fileName);
...@@ -108,27 +114,35 @@ DocumentList.prototype.load({ ...@@ -108,27 +114,35 @@ DocumentList.prototype.load({
}, },
/* display the list of documents in the web page */ /* display the list of documents in the web page */
displayContent: function() {//display the list of document itself displayContent: function(list) {//display the list of document itself
$("table.listbox tbody").html("");//empty the previous displayed list $("table.listbox tbody").html("");//empty the previous displayed list
var list = toArray(this.getList());
var detailedList = this.getDetailedList(); var detailedList = this.getDetailedList();
for(var i=this.getDisplayInformation().first-1;i<this.getDisplayInformation().last;i++) { for(var i=this.getDisplayInformation().first-1;i<this.getDisplayInformation().last;i++) {
var fileName = list[i].fileName; var fileName = list[i].fileName;
if(!detailedList[fileName] || new Date(detailedList[fileName].lastModification+1000)<new Date(list[i].lastModify)) {updateDocumentInformation(fileName)} var doc = detailedList[fileName];
var line = new Line(doc,i); var documentList = this;
(function tryToDisplay(j) {//update document information before displaying
if(!doc || new Date(detailedList[fileName].lastModification+1000)<new Date(list[j].lastModify)) {
documentList.updateDocumentInformation(fileName);
setTimeout(function(){tryToDisplay.call(this,j)},500);
} else {
var line = new Line(doc,j);
line.updateHTML(); line.updateHTML();
line.display(); line.display();
if(this.getSelectionList().indexOf(doc.fileName)) {line.setSelected(true);}//check the box if selected if(this.getSelectionList().indexOf(doc.fileName)) {line.setSelected(true);}//check the box if selected
} }
})(i)
}
}, },
displayListInformation: function() {//display number of records, first displayed document, last displayed document... displayListInformation: function(list) {//display number of records, first displayed document, last displayed document...
if(this.size()>0) { if(list.length>0) {
$("div.listbox-number-of-records").css("display","inline"); $("div.listbox-number-of-records").css("display","inline");
$("span#page_start_number").html(this.getDisplayInformation().first); $("span#page_start_number").html(this.getDisplayInformation().first);
$("span#page_stop_number").html(this.getDisplayInformation().last); $("span#page_stop_number").html(this.getDisplayInformation().last);
$("span#total_row_number a").html(this.size()); $("span#total_row_number a").html(list.length);
$("span#selected_row_number a").html(this.getSelectionList().size()); $("span#selected_row_number a").html(this.getSelectionList().length);
} }
else {$("div.listbox-number-of-records").css("display","none");} else {$("div.listbox-number-of-records").css("display","none");}
}, },
...@@ -149,9 +163,10 @@ DocumentList.prototype.load({ ...@@ -149,9 +163,10 @@ DocumentList.prototype.load({
} }
}, },
display: function() { display: function() {
this.updateDisplayInformation(); var list = toArray(this.getList());
this.displayContent(); this.updateDisplayInformation(list);
this.displayListInformation(); this.displayContent(list);
this.displayListInformation(list);
this.displayNavigationElements(); this.displayNavigationElements();
}, },
...@@ -165,12 +180,12 @@ DocumentList.prototype.load({ ...@@ -165,12 +180,12 @@ DocumentList.prototype.load({
}); });
}, },
/* update the document to be displayed */ /* update the document to be displayed */
updateDisplayInformation: function() { updateDisplayInformation: function(list) {
var infos = this.getDisplayInformation(); var infos = this.getDisplayInformation();
infos.step = getCurrentUser().getSetting("displayPreferences"),//documents per page infos.step = getCurrentUser().getSetting("displayPreferences"),//documents per page
infos.first = (infos.page-1)*infos.step + 1,//number of the first displayed document infos.first = (infos.page-1)*infos.step + 1,//number of the first displayed document
infos.last = (this.size()<(infos.first+infos.step)) ? this.size() : infos.first+infos.step-1//number of the last displayed document infos.last = list.length<(infos.first+infos.step) ? list.length : (infos.first+infos.step-1);//number of the last displayed document
infos.lastPage = Math.ceil(this.size()/infos.step); infos.lastPage = Math.ceil(list.length/infos.step);
}, },
setAsCurrentDocumentList: function() { setAsCurrentDocumentList: function() {
...@@ -182,6 +197,8 @@ getDocumentList = function() { ...@@ -182,6 +197,8 @@ getDocumentList = function() {
} }
/** /**
* create a line representing a document in the main table * create a line representing a document in the main table
* @param doc : document to represent * @param doc : document to represent
...@@ -228,11 +245,11 @@ Line.prototype = { ...@@ -228,11 +245,11 @@ Line.prototype = {
.find("td.listbox-table-data-cell") .find("td.listbox-table-data-cell")
.click(function() {//clic on a line .click(function() {//clic on a line
setCurrentDocumentID(line.getID()); setCurrentDocumentID(line.getID());
startDocumentEdition(line.getDocument()) Document.startDocumentEdition(line.getDocument())
}) })
.find("a.listbox-document-icon") .find("a.listbox-document-icon")
.find("img") .find("img")
.attr("src",supportedDocuments[this.getType()].icon)//icon .attr("src",Document.supportedDocuments[this.getType()].icon)//icon
.end() .end()
.end() .end()
.find("a.listbox-document-title").html(this.getDocument().getTitle()).end() .find("a.listbox-document-title").html(this.getDocument().getTitle()).end()
...@@ -243,9 +260,12 @@ Line.prototype = { ...@@ -243,9 +260,12 @@ Line.prototype = {
/* add the line in the table */ /* add the line in the table */
display: function() {$("table.listbox tbody").append($(this.getHTML()));} display: function() {$("table.listbox tbody").append($(this.getHTML()));}
} }
/* load the html code of a default line */ /* load the html code of a default line and execute the callback */
Line.loadHTML = function() { Line.loadHTML = function(callback) {
loadFile("xml/xmlElements.xml", "html", function(data) {Line.originalHTML = $(data).find("line table tbody").html();}); loadFile("xml/xmlElements.xml", "html", function(data) {
Line.originalHTML = $(data).find("line table tbody").html();
callback(Line.getOriginalHTML());
});
return Line.originalHTML; return Line.originalHTML;
} }
/* return the html code of a default line */ /* return the html code of a default line */
...@@ -262,10 +282,11 @@ Line.getOriginalHTML = function() {return Line.originalHTML;} ...@@ -262,10 +282,11 @@ Line.getOriginalHTML = function() {return Line.originalHTML;}
var createNewDocument = function(type) { var createNewDocument = function(type) {
var newDocument = new JSONDocument(); var newDocument = new JSONDocument();
newDocument.setType(type); newDocument.setType(type);
var fileName = DOcument.getAddress(newDocument);
newDocument.save(function() { newDocument.save(function() {
getDocumentList().add(newDocument); getDocumentList()[fileName]=newDocument;
getCurrentStorage().save(); getCurrentStorage().save();
startDocumentEdition(newDocument); Document.startDocumentEdition(newDocument);
}); });
} }
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