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

fix user and document initialization

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