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

Translate some functions into JQuery

parent c8acfa1c
...@@ -24,7 +24,7 @@ var Page = function(page) { ...@@ -24,7 +24,7 @@ var Page = function(page) {
//define as current page //define as current page
currentPage = this; currentPage = this;
this.loadXML("xml/"+page+".xml"); if(page!=undefined) {this.loadXML("xml/"+page+".xml");}
} }
Page.prototype = { Page.prototype = {
setXML: function(data) { setXML: function(data) {
...@@ -61,6 +61,7 @@ Page.prototype = { ...@@ -61,6 +61,7 @@ Page.prototype = {
case "text-editor": case "text-editor":
editor = new Xinha(); editor = new Xinha();
doc=new JSONTextDocument(); doc=new JSONTextDocument();
saveAdresse = "dav/temp.json";
break; break;
case "table-editor": case "table-editor":
editor = new SheetEditor(); editor = new SheetEditor();
...@@ -69,6 +70,7 @@ Page.prototype = { ...@@ -69,6 +70,7 @@ Page.prototype = {
case "image-editor": case "image-editor":
editor = new SVGEditor(); editor = new SVGEditor();
doc=new JSONIllustrationDocument(); doc=new JSONIllustrationDocument();
saveAdresse = "dav/temp2.json";
break; break;
default://renvoie à la page d'accueil default://renvoie à la page d'accueil
window.location = "ung.html"; window.location = "ung.html";
...@@ -76,7 +78,7 @@ Page.prototype = { ...@@ -76,7 +78,7 @@ Page.prototype = {
break; break;
} }
doc.load(getCurrentDocument()); if(getCurrentDocument()) {doc.load(getCurrentDocument());}
this.setEditor(editor); this.setEditor(editor);
doc.setAsCurrentDocument(); doc.setAsCurrentDocument();
...@@ -113,37 +115,28 @@ Page.prototype = { ...@@ -113,37 +115,28 @@ Page.prototype = {
for (var i = 0; i<languages.length; i++) { for (var i = 0; i<languages.length; i++) {
var l = languages[i]; var l = languages[i];
if(l==user.getLanguage()) {this.getHTML().getElementById("current_language").innerHTML = l;} if(l==user.getLanguage()) {$("span#current_language").html(l);}
else { else {
avLang = avLang + "<li><span onclick='changeLanguage(this.innerHTML)' id='" +l+ "'>"+l+"</span></li>\n" avLang = avLang + "<li><span onclick='changeLanguage($(this).html())' id='" +l+ "'>"+l+"</span></li>\n"
} }
} }
this.getHTML().getElementById("available_languages").innerHTML = avLang; $("ul#available_languages").html(avLang);
}, },
displayUserName: function(user) {this.getHTML().getElementById("userName").innerHTML = user.getName();}, displayUserName: function(user) {$("a#userName").html(user.getName());},
//document information //document information
displayAuthorName: function(doc) {this.getHTML().getElementById("author").innerHTML = doc.getAuthor();}, displayAuthorName: function(doc) {$("a#author").html(doc.getAuthor());},
displayLastModification: function(doc) {this.getHTML().getElementById("last_update").innerHTML = doc.getLastModification();}, displayLastModification: function(doc) {$("a#last_update").html(doc.getLastModification());},
displayDocumentTitle: function(doc) {this.getHTML().getElementById("document_title").innerHTML = doc.getTitle();}, displayDocumentTitle: function(doc) {$("a#document_title").html(doc.getTitle());},
displayDocumentContent: function(doc) {this.getEditor().loadContentFromDocument(doc);}, displayDocumentContent: function(doc) {this.getEditor().loadContentFromDocument(doc);},
displayDocumentState: function(doc) { displayDocumentState: function(doc) {$("a#document_state").html(doc.getState()[getCurrentUser().getLanguage()]);},
var stateArea = this.getHTML().getElementById("document_state");
stateArea.innerHTML = doc.getState()[getCurrentUser().getLanguage()];
},
//web page information //web page information
displayPageTitle: function() { displayPageTitle: function() {$("title#page_title").html(this.getTitle());},
var pageTitle = this.getHTML().getElementById("page_title"); displayPageContent: function() {$("div#page_content").html(this.getContent());}
pageTitle.innerHTML = this.getTitle();
},
displayPageContent: function() {
var pageContent = this.getHTML().getElementById("page_content");
pageContent.innerHTML = this.getContent();
}
} }
getCurrentPage = function() {return currentPage;} getCurrentPage = function() {return currentPage;}
setCurrentPage = function(page) {currentPage = new Page(page);} setCurrentPage = function(page) {currentPage = page;}
/* /*
* User Class * User Class
...@@ -151,9 +144,10 @@ setCurrentPage = function(page) {currentPage = new Page(page);} ...@@ -151,9 +144,10 @@ setCurrentPage = function(page) {currentPage = new Page(page);}
*/ */
var User = function(details) { var User = function(details) {
this.name = "unknown"; this.name = "unknown";
this.language = "en"; this.language = "fr";
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.displayPreferences = 15;//number of displayed document in the list
} }
User.prototype = new UngObject();//inherits from UngObject User.prototype = new UngObject();//inherits from UngObject
User.prototype.load({//add methods thanks to the UngObject.load method User.prototype.load({//add methods thanks to the UngObject.load method
...@@ -165,6 +159,8 @@ User.prototype.load({//add methods thanks to the UngObject.load method ...@@ -165,6 +159,8 @@ User.prototype.load({//add methods thanks to the UngObject.load method
setStorageLocation: function(storage) {this.storage = storage;}, setStorageLocation: function(storage) {this.storage = storage;},
getIdentityProvider: function() {return this.identityProvider;}, getIdentityProvider: function() {return this.identityProvider;},
setIdentityProvider: function(IDProv) {this.identityProvider = IDProv;}, setIdentityProvider: function(IDProv) {this.identityProvider = IDProv;},
getDisplayPreferences: function() {return this.displayPreferences;},
setDisplayPreferences: function(n) {this.displayPreferences = n;},
setAsCurrentUser: function() { setAsCurrentUser: function() {
getCurrentPage().displayUserName(this); getCurrentPage().displayUserName(this);
...@@ -277,10 +273,11 @@ editDocumentSettings = function() { ...@@ -277,10 +273,11 @@ editDocumentSettings = function() {
modal: true, modal: true,
buttons: { buttons: {
"Save": function(){ "Save": function(){
getCurrentDocument().setTitle($(getCurrentDocument()).find("#name").attr("value")); var doc = getCurrentDocument();
getCurrentDocument().setLanguage($(getCurrentDocument()).find("#language").attr("value")); doc.setTitle($(this).find("#name").attr("value"));
getCurrentDocument().setVersion($(getCurrentDocument()).find("#version").attr("value")); doc.setLanguage($(getCurrentDocument()).find("#language").attr("value"));
getCurrentDocument().setAsCurrentDocument();//diplay modifications doc.setVersion($(getCurrentDocument()).find("#version").attr("value"));
doc.setAsCurrentDocument();//diplay modifications
$(this).dialog("close"); $(this).dialog("close");
}, },
Cancel: function() { Cancel: function() {
...@@ -293,7 +290,7 @@ editDocumentSettings = function() { ...@@ -293,7 +290,7 @@ editDocumentSettings = function() {
saveCurrentDocument = function() { saveCurrentDocument = function() {
getCurrentPage().getEditor().saveEdition(); getCurrentPage().getEditor().saveEdition();
saveXHR(addressOfTestDocument); saveXHR(saveAdresse);
//saveJIO(); : JIO function //saveJIO(); : JIO function
} }
......
...@@ -31,11 +31,8 @@ ...@@ -31,11 +31,8 @@
<script type="text/javascript"> <script type="text/javascript">
// initialize // initialize
addressOfTestDocument = "http://sidunhosted.com/ungdav/test.json";
var initPage = function() { var initPage = function() {
var pageIWantToTest = "editor"; setCurrentPage(new Page(supportedDocuments[getCurrentDocument().getType()].editorPage));
// addressOfTestDocument = "dav/temp2.json";
setCurrentPage(pageIWantToTest);
} }
var initUser = function() { var initUser = function() {
...@@ -44,14 +41,9 @@ ...@@ -44,14 +41,9 @@
user.setAsCurrentUser(); user.setAsCurrentUser();
} }
var initDocument = function() {
loadXHR(addressOfTestDocument);
}
var init = function() { var init = function() {
initPage(); initPage();
waitBeforeSucceed(function() {return getCurrentPage().getXML();},initUser); waitBeforeSucceed(function() {return getCurrentPage().getXML();},initUser);
waitBeforeSucceed(function() {return getCurrentPage().getEditor();},initDocument);
} }
$(document).ready(init); $(document).ready(init);
</script> </script>
...@@ -80,7 +72,7 @@ ...@@ -80,7 +72,7 @@
<div class="input"><div > <div class="input"><div >
<a class="email" href="ung/mail.html" lang="en">Email</a> <a class="email" href="ung/mail.html" lang="en">Email</a>
<a class="document" href="ung/ung.html" lang="en">Documents</a> <a class="document" href="#" onclick="javascript:window.location.reload()" lang="en">Documents</a>
<a class="calendar" href="ung/calendar.html" lang="en">Calendar</a> <a class="calendar" href="ung/calendar.html" lang="en">Calendar</a>
</div></div> </div></div>
...@@ -152,7 +144,7 @@ ...@@ -152,7 +144,7 @@
<label>search_bar</label> <label>search_bar</label>
<div class="input"><div > <div class="input"><div >
<a class="ung_docs" href="ung/ung.html"> <a class="ung_docs" href="ung.html">
<img src="images/ung/ung-logo.gif" alt="logo"/> <img src="images/ung/ung-logo.gif" alt="logo"/>
</a> </a>
...@@ -160,33 +152,6 @@ ...@@ -160,33 +152,6 @@
<a id="document_title" name="document_title" onclick="javascript:editDocumentSettings()">Untitled</a> <a id="document_title" name="document_title" onclick="javascript:editDocumentSettings()">Untitled</a>
<a id="document_state" name="document_state">...</a> <a id="document_state" name="document_state">...</a>
<div id="edit_document" title="Rename Document">
<form action="#">
<fieldset>
<label for="name">Insert a new name:</label>
<input type="text" class="title" id="name" name="name" value=""/><br/>
<div id="more_property">
<label for="short_title">Short Title:</label>
<input type="text" class="short_title" id="short_title" name="short_title" value=""/><br/>
<label for="version">Version:</label>
<input type="text" class="version" id="version" name="version" value=""/><br/>
<label for="language">Language:</label>
<input type="text" class="language" id="language" name="language" value=""/><br/>
<label for="sort_index">Sort Index:</label>
<input type="text" class="sort_index" id="sort_index" name="sort_index" value=""/><br/>
<label for="keyword_list">Keywords:</label>
<textarea id="keyword_list" rows="2" cols="20" value="">
</textarea>
</div>
<p class="more_properties" id="more_properties">Edit More Properties</p>
<p class="hide_properties" id="hide_properties">Hide Properties</p>
</fieldset>
</form>
</div>
</div></div> </div></div>
</div> </div>
...@@ -257,9 +222,9 @@ ...@@ -257,9 +222,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="main"> <div class="main">
<div class="document"> <div class="document">
...@@ -279,11 +244,8 @@ ...@@ -279,11 +244,8 @@
</fieldset> </fieldset>
</div> </div>
</div> </div>
<p class="clear"></p>
</div> </div>
</div> </div>
</form> </form>
......
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