Commit c2112947 authored by François Billioud's avatar François Billioud

corrects bugs with the load of document list

parent 275cb9a4
...@@ -33,14 +33,10 @@ SVGEditor = function() { ...@@ -33,14 +33,10 @@ SVGEditor = function() {
* 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
*/ */
JSONDocument.prototype.type = "text"; JSONDocument.prototype.type = "image";
JSONDocument.prototype.saveEdition = function(content) { 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();
}
JSONDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentInformation(this); getCurrentPage().displayDocumentInformation(this);
setCurrentDocument(this);
} }
...@@ -21,9 +21,32 @@ function logIntoDav(wallet) { ...@@ -21,9 +21,32 @@ function logIntoDav(wallet) {
function initStorage(wallet) { function initStorage(wallet) {
if(!wallet.provider) {//local storage if(!wallet.provider) {//local storage
Storage.currentStorage = new LocalStorage(wallet.userName); /**
* load JIO file from a DAV and create and return the JIO object
* This function will be replaced. The aim is to load JIO in more various ways, and use JIO.initialize after
* @param userName : name of the user
* @param location : server location
* @param applicant : (optional) information about the person/application needing this JIO object (allow limited access)
* @return JIO object
*/
(function initializeFromDav(userName, location, applicant) {
//get the user personal JIO file
$.ajax({
url: location+"/dav/"+userName+"/"+applicant.ID+"/"+"jio.json",//we could use userAdress instead...
type: "GET",
async: false,
dataType: "text",
headers: {Authorization: "Basic "+Base64.encode(userName+":"+applicant.password)},
fields: {withCredentials: "true"},
success: function(jioContent){
Storage.create(jioContent);
},
error: function(type) {alert("Error "+type.status+" : fail while trying to load jio.json");}
});
return JIO;
})(wallet.userName, wallet.storageLocation, {"ID":"www.ungproject.com", "password":wallet.applicationPassword});
} else { } else {
Storage.currentStorage = new JIOStorage(wallet); Storage.create('{"type":"local","userName":"'+wallet.userName+'"}');
} }
} }
......
...@@ -129,9 +129,6 @@ JSONDocument.prototype.saveEdition = function(content) { ...@@ -129,9 +129,6 @@ 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();
}
JSONDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentInformation(this); getCurrentPage().displayDocumentInformation(this);
setCurrentDocument(this);
} }
This diff is collapsed.
...@@ -54,6 +54,31 @@ UngObject.prototype.copy = function() { ...@@ -54,6 +54,31 @@ UngObject.prototype.copy = function() {
return copied; return copied;
} }
/*
* add an event handler executed when the fireEvent function is called
* @param handler : function to execute when the event occures
* @param event : the event to consider
* @param once : if set to true, the handler is executed only once
*/
UngObject.prototype.addEventHandler = function (handler, event, once) {
if(!this.listenerList.length) { this.listnerList = [] }
this.listernerList.push({handler:handler,event:event,once:once});
}
/* fire an event through all the listeners of the object */
UngObject.prototype.fireEvent = function (event) {
for (var i=0; i<this.listenerList.length; i++) {
var listener = this.listenerList[i];
if(listener.event == event) {
listener.handler(event);
if(listener.once) { // remove the listener if supposed to been executed only once
this.listenerList.splice(i,1);
i--;
}
}
}
}
/** /**
* convert an object into an array easier to manipulate * convert an object into an array easier to manipulate
* @param object : the object to convert * @param object : the object to convert
......
...@@ -14,7 +14,10 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen ...@@ -14,7 +14,10 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen
* the detailedList object is the synchronized list containing more detailed information about documents * the detailedList object is the synchronized list containing more detailed information about documents
* @param documentList : documents information loaded from the storage * @param documentList : documents information loaded from the storage
*/ */
var DocumentList = function(documentList) { var DocumentList = {
inititalize: function() {
var data = lo
},
this.detailedList = {} this.detailedList = {}
if(documentList) { if(documentList) {
for(var doc in documentList) { for(var doc in documentList) {
...@@ -193,7 +196,7 @@ DocumentList.prototype.load({ ...@@ -193,7 +196,7 @@ DocumentList.prototype.load({
} }
}); });
getDocumentList = function() { getDocumentList = function() {
return getCurrentUser().getDocumentList(); return getCurrentStorage().getDocumentList();
} }
......
This diff is collapsed.
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