X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=js%2Feuphorik.js;h=fafa85418db926b6fc86883a58fe56f2b412e3d6;hb=cded85bdaf899cef1ba38d2ee6fd24c67f2abc52;hp=9dd3357430bc42ef212ad0f18cc23ea77bd945d5;hpb=de3bc0dbc72f81a21e14c421c7fb5a96bdeb057f;p=euphorik.git
diff --git a/js/euphorik.js b/js/euphorik.js
index 9dd3357..fafa854 100755
--- a/js/euphorik.js
+++ b/js/euphorik.js
@@ -128,7 +128,11 @@ Util.prototype.creerDocumentXMLAction = function()
{
if (document.implementation && document.implementation.createDocument)
{
- return document.implementation.createDocument("", "action", null)
+ // var doc = document.implementation.createDocument("", "action", null)
+ var parser = new DOMParser();
+ var doc = parser.parseFromString("\n", "text/xml")
+ //alert(this.serializeXML(doc))
+ return doc
}
else if (window.ActiveXObject)
{
@@ -143,32 +147,9 @@ Util.prototype.creerDocumentXMLAction = function()
Util.prototype.xmlVersAction = function(xml)
{
- return {action: this.to_utf8(this.serializeXML(xml /*, "UTF-8"*/))}
+ //return {action: this.to_utf8(this.serializeXML(xml /*, "UTF-8"*/))}
+ return {action: this.serializeXML(xml)}
}
-
-// voir : http://homepage3.nifty.com/aokura/jscript/utf8.html
-// et : http://www1.tip.nl/~t876506/utf8tbl.html
-Util.prototype.to_utf8 = function(s)
-{
- if (!s) return ""
-
- var c, d = ""
- for (var i = 0; i < s.length; i++)
- {
- c = s.charCodeAt(i);
- if (c <= 0x7f) {
- d += s.charAt(i);
- } else if (c >= 0x80 && c <= 0x7ff) {
- d += String.fromCharCode(((c >> 6) & 0x1f) | 0xc0);
- d += String.fromCharCode((c & 0x3f) | 0x80);
- } else {
- d += String.fromCharCode((c >> 12) | 0xe0);
- d += String.fromCharCode(((c >> 6) & 0x3f) | 0x80);
- d += String.fromCharCode((c & 0x3f) | 0x80);
- }
- }
- return d;
-}
Util.prototype.md5 = function(chaine)
{
@@ -430,7 +411,12 @@ Client.prototype.resetDonneesPersonnelles = function()
this.login = ""
this.password = ""
this.email = ""
- this.css = jQuery("link#cssPrincipale").attr("href")
+ this.css = jQuery("link#cssPrincipale").attr("href")
+
+ // les conversations, une conversation est un objet possédant les attributs suivants :
+ // - racine (entier)
+ // - page (entier)
+ this.conversations = new Array()
}
Client.prototype.setCss = function(css)
@@ -441,14 +427,20 @@ Client.prototype.setCss = function(css)
this.css = css
jQuery("link#cssPrincipale").attr("href", this.css)
this.majMenu()
-
- /* enregistement automatique..
- if (!this.identifie())
- if (!this.enregistrement())
- return
- */
+
if (this.identifie())
this.flush()
+}
+
+/**
+ * Ajoute une conversation à la vue de l'utilisateur.
+ * Le profile de l'utilisateur est directement sauvegardé sur le serveur.
+ * @param racines la racine de la conversation
+ */
+Client.prototype.ajouterConversation = function(racine)
+{
+ this.conversations.push({racine : racine, page : 1})
+ this.flush()
}
Client.prototype.getXMLlogin = function(login, password)
@@ -550,6 +542,26 @@ Client.prototype.getXMLProfile = function()
nodeCSS.appendChild(XMLDocument.createTextNode(this.css))
XMLDocument.documentElement.appendChild(nodeCSS)
+ // mémorise les conversations affichées
+ if (this.conversations.length > 0)
+ {
+ var nodeConversations = XMLDocument.createElement("conversations")
+ XMLDocument.documentElement.appendChild(nodeConversations)
+ for (var i = 0; i < this.conversations.length; i++)
+ {
+ var nodeConv = XMLDocument.createElement("conversation")
+ nodeConversations.appendChild(nodeConv)
+
+ var nodeRacine = XMLDocument.createElement("racine")
+ nodeRacine.appendChild(XMLDocument.createTextNode(this.conversations[i].racine))
+ nodeConv.appendChild(nodeRacine)
+
+ var nodePage = XMLDocument.createElement("page")
+ nodePage.appendChild(XMLDocument.createTextNode(this.conversations[i].page))
+ nodeConv.appendChild(nodePage)
+ }
+ }
+
return XMLDocument
}
@@ -722,7 +734,7 @@ Client.prototype.chargerDonnees = function(data)
Client.prototype.flush = function()
{
thisClient = this
- //thisClient.util.log(this.util.xmlVersAction(this.getXMLProfile()).action)
+ //thisClient.util.log(this.util.xmlVersAction(this.getXMLProfile()).action)
jQuery.ajax(
{
async: true,
@@ -775,6 +787,12 @@ jQuery.noConflict()
jQuery(document).ready(
function()
{
+ /* FIXME : ce code pose problème sur konqueror, voir : http://www.kde-forum.org/thread.php?threadid=17993
+ var p = new DOMParser();
+ var doc = p.parseFromString("\n", "text/xml")
+ var s = new XMLSerializer()
+ alert(s.serializeToString(doc)) */
+
var util = new Util()
var client = new Client(util)
var pages = new Pages()