Commit 2e404066 authored by François Billioud's avatar François Billioud

prepare JIOStorage for tests

parent ba8bed00
...@@ -171,6 +171,8 @@ User.prototype.load({//add methods thanks to the UngObject.load method ...@@ -171,6 +171,8 @@ User.prototype.load({//add methods thanks to the UngObject.load method
getDocumentList: function() {return this.documentList;}, getDocumentList: function() {return this.documentList;},
setDocumentList: function(list) {this.documentList = list;}, setDocumentList: function(list) {this.documentList = list;},
getIDProvider: function() {return this.IDProvider;},
setAsCurrentUser: function() { setAsCurrentUser: function() {
getCurrentPage().displayUserName(this); getCurrentPage().displayUserName(this);
getCurrentPage().displayLanguages(this); getCurrentPage().displayLanguages(this);
...@@ -222,10 +224,6 @@ Storage.prototype.load({ ...@@ -222,10 +224,6 @@ Storage.prototype.load({
*/ */
var LocalStorage = function(userName) { var LocalStorage = function(userName) {
Storage.call(this,"local", userName); Storage.call(this,"local", userName);
if(this.user) {
//this.user.documents = {}
//this.updateUser();
}
} }
LocalStorage.prototype = new Storage(); LocalStorage.prototype = new Storage();
LocalStorage.prototype.load({ LocalStorage.prototype.load({
...@@ -277,8 +275,9 @@ LocalStorage.prototype.load({ ...@@ -277,8 +275,9 @@ LocalStorage.prototype.load({
* Class JIOStorage * Class JIOStorage
* this class provides usual API to save/load/delete documents on a remote storage * this class provides usual API to save/load/delete documents on a remote storage
*/ */
var JIOStorage = function(userName) { var JIOStorage = function(userName, IDProvider) {
Storage.call(this,"JIO", userName); Storage.call(this,"JIO", userName);
if(this.user) this.user.IDProvider = IDProvider;
} }
JIOStorage.prototype = new Storage(); JIOStorage.prototype = new Storage();
JIOStorage.prototype.load({ JIOStorage.prototype.load({
...@@ -290,6 +289,8 @@ JIOStorage.prototype.load({ ...@@ -290,6 +289,8 @@ JIOStorage.prototype.load({
url: address, url: address,
type: "GET", type: "GET",
dataType: type, dataType: type,
headers: {Authorization: "Basic "+btoa("smik:asdf")},
fields: {withCredentials: "true"},
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);}
}); });
...@@ -450,7 +451,7 @@ supportedDocuments = {"text":{editorPage:"text-editor",icon:"images/icons/docume ...@@ -450,7 +451,7 @@ supportedDocuments = {"text":{editorPage:"text-editor",icon:"images/icons/docume
undefined:{editorPage:null,icon:"images/icons/other.gif"} undefined:{editorPage:null,icon:"images/icons/other.gif"}
} }
getDocumentAddress = function(doc) { getDocumentAddress = function(doc) {
return getCurrentStorage().getType()=="local" ? doc.getCreation() : "http://sidunhosted.com/ungdav/"+doc.getCreation(); return getCurrentStorage().getType()=="local" ? doc.getCreation() : "http://"+getCurrentUser().getIDProvider()+"/ungdav/"+doc.getCreation();
} }
/************************************************* /*************************************************
......
...@@ -166,8 +166,6 @@ loadFile = function(address, type, instruction) { ...@@ -166,8 +166,6 @@ loadFile = function(address, type, instruction) {
url: address, url: address,
type: "GET", type: "GET",
dataType: type, dataType: type,
headers: { Authorization: "Basic "+btoa("smik:asdf")},
fields: { withCredentials: "true" },
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);}
......
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