X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=js%2Feuphorik.js;h=e56acde9f6afc2d01a0e4158f4b2c71c77dd4ec0;hb=cb001bf4e6e3ec3064b954b7c5583db8440f3492;hp=433c0bca25454745bab0b483d4bc4eaef60c038d;hpb=6feaef2a51f7226c41d69f9e86f605718b78aa02;p=euphorik.git diff --git a/js/euphorik.js b/js/euphorik.js index 433c0bc..e56acde 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -1,6 +1,8 @@ // coding: utf-8 -/** +/** + * Contient la base javascript pour le site euphorik.ch. + * Chaque page possède son propre fichier js nommé "page.js". * Auteur : GBurri * Date : 6.11.2007 */ @@ -38,15 +40,17 @@ var conf = { String.prototype.trim = function() { - return this.replace(/^\s+|\s+$/g,""); + return this.replace(/^\s+|\s+$/g, ""); } + String.prototype.ltrim = function() { - return this.replace(/^\s+/,""); + return this.replace(/^\s+/, ""); } + String.prototype.rtrim = function() { - return this.replace(/\s+$/,""); + return this.replace(/\s+$/, ""); } String.prototype.dump = function() @@ -60,12 +64,16 @@ String.prototype.dump = function() } /////////////////////////////////////////////////////////////////////////////////////////////////// - -function Util(serializer) + +/** + * Cette classe regroupe des fonctions utilitaires (helpers). + */ +function Util() { if(typeof XMLSerializer != "undefined") this.serializer = new XMLSerializer() - + + // fermeture des dialogues d jQuery("#info .fermer").click(function(){ jQuery("#info").slideUp(50) }) @@ -73,7 +81,10 @@ function Util(serializer) /** * Affiche une boite de dialogue avec un message à l'intérieur. - * + * @param message le message (string) + * @param type voir 'messageType'. par défaut messageType.informatif + * @param les boutons sous la forme d'un objet ou les clefs sont les labels des boutons + * et les valeurs les fonctions executées lorsqu'un bouton est activé. */ Util.prototype.messageDialogue = function(message, type, boutons) { @@ -102,11 +113,9 @@ Util.prototype.messageDialogue = function(message, type, boutons) } var messageType = {informatif: 0, question: 1, erreur: 2} -/* obsolète -Util.prototype.log = function(str) -{ -}*/ - +/** + * Transforme un document XML en string. + */ Util.prototype.serializeXML = function(documentXML) { if (this.serializer) @@ -119,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) { @@ -134,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) { @@ -765,8 +755,13 @@ jQuery.noConflict() // le main 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()