Commit 3e76914b authored by François Billioud's avatar François Billioud

fix user and document initialization

parent d5b5c39e
......@@ -2,7 +2,7 @@
* global variables
*/
languages = ["fr","en"];
var availableLanguages = window.document.getElementById("available_languages");
var availableLanguages = $("#available_languages");
currentPage = null;
......@@ -131,8 +131,6 @@ var User = function() {
this.language = "en";
this.storage = "http://www.unhosted-dav.com";
this.identityProvider = "http://www.webfinger.com";
this.setAsCurrentUser();
}
User.prototype = {
getName: function() {return this.name;},
......@@ -176,8 +174,6 @@ var JSONDocument = function() {
this.creation=currentTime();
this.lastModification=currentTime();
this.state=Document.states.draft;
this.setAsCurrentDocument();//temp
}
JSONDocument.prototype = {
//type
......@@ -264,6 +260,7 @@ changeLanguage = function(language) {
user.setLanguage(language);
setCurrentUser(user);
getCurrentPage().displayLanguages(user);
window.location.reload();
}
cancel_sharing = function() {alert("cancel");}
translate = function() {alert("translate");}
......
......@@ -33,10 +33,12 @@
// initialize
init = function() {
setCurrentPage("editor");
alert(getCurrentUser());
if(getCurrentUser()==null) {new User();}
doc = new JSONTextDocument();//load the document (it's just for testing)
doc.setAsCurrentDocument();
var user = getCurrentUser();
(user==null) ? (new User()).setAsCurrentDocument() : user.setAsCurrentUser();
var doc = getCurrentDocument();
(doc==null) ? (new JSONTextDocument()).setAsCurrentDocument() : doc.setAsCurrentDocument();
}
$(document).ready(init);
</script>
......
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