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) {
//define as current page
currentPage = this;
this.loadXML("xml/"+page+".xml");
if(page!=undefined) {this.loadXML("xml/"+page+".xml");}
}
Page.prototype = {
setXML: function(data) {
......@@ -61,6 +61,7 @@ Page.prototype = {
case "text-editor":
editor = new Xinha();
doc=new JSONTextDocument();
saveAdresse = "dav/temp.json";
break;
case "table-editor":
editor = new SheetEditor();
......@@ -69,6 +70,7 @@ Page.prototype = {
case "image-editor":
editor = new SVGEditor();
doc=new JSONIllustrationDocument();
saveAdresse = "dav/temp2.json";
break;
default://renvoie à la page d'accueil
window.location = "ung.html";
......@@ -76,7 +78,7 @@ Page.prototype = {
break;
}
doc.load(getCurrentDocument());
if(getCurrentDocument()) {doc.load(getCurrentDocument());}
this.setEditor(editor);
doc.setAsCurrentDocument();
......@@ -113,37 +115,28 @@ Page.prototype = {
for (var i = 0; i<languages.length; 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 {
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
displayAuthorName: function(doc) {this.getHTML().getElementById("author").innerHTML = doc.getAuthor();},
displayLastModification: function(doc) {this.getHTML().getElementById("last_update").innerHTML = doc.getLastModification();},
displayDocumentTitle: function(doc) {this.getHTML().getElementById("document_title").innerHTML = doc.getTitle();},
displayAuthorName: function(doc) {$("a#author").html(doc.getAuthor());},
displayLastModification: function(doc) {$("a#last_update").html(doc.getLastModification());},
displayDocumentTitle: function(doc) {$("a#document_title").html(doc.getTitle());},
displayDocumentContent: function(doc) {this.getEditor().loadContentFromDocument(doc);},
displayDocumentState: function(doc) {
var stateArea = this.getHTML().getElementById("document_state");
stateArea.innerHTML = doc.getState()[getCurrentUser().getLanguage()];
},
displayDocumentState: function(doc) {$("a#document_state").html(doc.getState()[getCurrentUser().getLanguage()]);},
//web page information
displayPageTitle: function() {
var pageTitle = this.getHTML().getElementById("page_title");
pageTitle.innerHTML = this.getTitle();
},
displayPageContent: function() {
var pageContent = this.getHTML().getElementById("page_content");
pageContent.innerHTML = this.getContent();
}
displayPageTitle: function() {$("title#page_title").html(this.getTitle());},
displayPageContent: function() {$("div#page_content").html(this.getContent());}
}
getCurrentPage = function() {return currentPage;}
setCurrentPage = function(page) {currentPage = new Page(page);}
setCurrentPage = function(page) {currentPage = page;}
/*
* User Class
......@@ -151,9 +144,10 @@ setCurrentPage = function(page) {currentPage = new Page(page);}
*/
var User = function(details) {
this.name = "unknown";
this.language = "en";
this.language = "fr";
this.storage = "http://www.unhosted-dav.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.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;},
getIdentityProvider: function() {return this.identityProvider;},
setIdentityProvider: function(IDProv) {this.identityProvider = IDProv;},
getDisplayPreferences: function() {return this.displayPreferences;},
setDisplayPreferences: function(n) {this.displayPreferences = n;},
setAsCurrentUser: function() {
getCurrentPage().displayUserName(this);
......@@ -277,10 +273,11 @@ editDocumentSettings = function() {
modal: true,
buttons: {
"Save": function(){
getCurrentDocument().setTitle($(getCurrentDocument()).find("#name").attr("value"));
getCurrentDocument().setLanguage($(getCurrentDocument()).find("#language").attr("value"));
getCurrentDocument().setVersion($(getCurrentDocument()).find("#version").attr("value"));
getCurrentDocument().setAsCurrentDocument();//diplay modifications
var doc = getCurrentDocument();
doc.setTitle($(this).find("#name").attr("value"));
doc.setLanguage($(getCurrentDocument()).find("#language").attr("value"));
doc.setVersion($(getCurrentDocument()).find("#version").attr("value"));
doc.setAsCurrentDocument();//diplay modifications
$(this).dialog("close");
},
Cancel: function() {
......@@ -293,7 +290,7 @@ editDocumentSettings = function() {
saveCurrentDocument = function() {
getCurrentPage().getEditor().saveEdition();
saveXHR(addressOfTestDocument);
saveXHR(saveAdresse);
//saveJIO(); : JIO function
}
......
......@@ -31,11 +31,8 @@
<script type="text/javascript">
// initialize
addressOfTestDocument = "http://sidunhosted.com/ungdav/test.json";
var initPage = function() {
var pageIWantToTest = "editor";
// addressOfTestDocument = "dav/temp2.json";
setCurrentPage(pageIWantToTest);
setCurrentPage(new Page(supportedDocuments[getCurrentDocument().getType()].editorPage));
}
var initUser = function() {
......@@ -44,14 +41,9 @@
user.setAsCurrentUser();
}
var initDocument = function() {
loadXHR(addressOfTestDocument);
}
var init = function() {
initPage();
waitBeforeSucceed(function() {return getCurrentPage().getXML();},initUser);
waitBeforeSucceed(function() {return getCurrentPage().getEditor();},initDocument);
}
$(document).ready(init);
</script>
......@@ -80,7 +72,7 @@
<div class="input"><div >
<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>
</div></div>
......@@ -152,7 +144,7 @@
<label>search_bar</label>
<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"/>
</a>
......@@ -160,33 +152,6 @@
<a id="document_title" name="document_title" onclick="javascript:editDocumentSettings()">Untitled</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>
......@@ -257,9 +222,9 @@
</div>
</div>
</div>
<div class="main">
<div class="document">
......@@ -279,11 +244,8 @@
</fieldset>
</div>
</div>
<p class="clear"></p>
</div>
</div>
</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