function Application(XMLproperties) { this.name = XMLproperties.getElementsByTagName("name")[0].firstChild.data; this.dir = XMLproperties.getElementsByTagName("dir")[0].firstChild.data; if (XMLproperties.getElementsByTagName("description")[0]) this.description = XMLproperties.getElementsByTagName("description")[0].firstChild.data; else this.description = null; this.etatAvancement = XMLproperties.getElementsByTagName("etatAvancement")[0].firstChild.data; this.version = XMLproperties.getElementsByTagName("version")[0].firstChild.data; if (XMLproperties.getElementsByTagName("lang")[0]) this.lang = XMLproperties.getElementsByTagName("lang")[0].firstChild.data; else this.lang = null; if (XMLproperties.getElementsByTagName("developpeur")[0]) this.developpeur = XMLproperties.getElementsByTagName("developpeur")[0].firstChild.data; else this.developpeur = null; if (XMLproperties.getElementsByTagName("corps")[0]) this.corps = XMLproperties.getElementsByTagName("corps")[0].firstChild.data; else this.corps = "corps"; this.menu = null; } Application.prototype.getHomeElt = function() { var app = document.createElement("dl"); app.className = "application " + this.etatAvancement; var appTitle = document.createElement("dt"); appTitle.innerHTML = this.name; var appDescription = document.createElement("dd"); appDescription.innerHTML = this.description; app.observe('click', this.load.bind(this)); app.appendChild(appTitle); app.appendChild(appDescription); return app; } Application.prototype.load = function() { printEtat(6); var test = new Ajax.Request( 'ajax.php', { method: 'get', parameters: {d: "display", a: this.dir}, onSuccess: this.loaded.bind(this), onFailure: function() { printEtat(3); } } ); } Application.prototype.loaded = function(transport, json) { clearScreen(); var display = transport.responseXML.documentElement.getElementsByTagName("display")[0]; var property = transport.responseXML.documentElement.getElementsByTagName("property")[0]; if (display.getElementsByTagName("titre")[0]) $('titre').src = imgTitres_dir + display.getElementsByTagName("titre")[0].firstChild.data; if (display.getElementsByTagName("css")) { //On supprime le style par défaut if ($("main_thm")) document.getElementsByTagName('head')[0].removeChild($("main_thm")); var styles = display.getElementsByTagName("css"); for (i = styles.length - 1; i >= 0; i--) { var css_file = document.createElement("link"); css_file.type = 'text/css'; css_file.rel = 'stylesheet'; css_file.className = 'app'; if (styles[i].getAttribute("media")) css_file.media = styles[i].getAttribute("media"); css_file.href = "applications/" + this.dir + "/" + styles[i].firstChild.data; document.getElementsByTagName('head')[0].appendChild(css_file); } } if (display.getElementsByTagName("script")) { var scripts = display.getElementsByTagName("script"); for (i = scripts.length - 1; i >= 0; i--) { js_file = document.createElement("script"); js_file.type = 'text/javascript'; js_file.className = 'app'; js_file.src = "applications/" + this.dir + "/" + scripts[i].firstChild.data; js_file.defer = true; document.getElementsByTagName('head')[0].appendChild(js_file); } } if (display.getElementsByTagName("background").length > 0) $('body').style.backgroundImage = "url(" + display.getElementsByTagName("background")[0].firstChild.data + ")"; var etat; if (property.getElementsByTagName("etatAvancement").length > 0) etat = property.getElementsByTagName("etatAvancement")[0].firstChild.data; else etat = ""; if (etat == "En construction" || etat == "en construction" || etat == "enconstruction" || etat == "construction" || etat == "c") $('etatAvance').src = "images/etats/construction.png"; else if (etat == "Alpha" || etat == "alpha" || etat == "a") $('etatAvance').src = "images/etats/alpha.png"; else if (etat == "Beta" || etat == "beta" || etat == "Béta" || etat == "béta" || etat == "b") $('etatAvance').src = "images/etats/beta.png"; else $('etatAvance').src = "images/etats/final.png"; //On affiche la page if (display.getElementsByTagName('body')[0]) $('corps').innerHTML = display.getElementsByTagName('body')[0].firstChild.data; //On prépare le menu if (property.getElementsByTagName("menu").length > 0) this.menu = eval(property.getElementsByTagName("menu")[0].firstChild.data); this.genMenu(username != ""); //On lance l'application if (display.getElementsByTagName("js")[0]) { var scripts = display.getElementsByTagName("js"); for (i = scripts.length - 1; i >= 0; i--) eval(scripts[i].firstChild.data); runApplication(property, display, json); } else setTimeout("runApplication" + this.dir + "(" + property + ", " + display + ", " + json + ");", 1); // setTimeout("alert('test')", 0); printEtat(0); } Application.prototype.genMenu = function(online) { //On supprime tous les éléments du menu actuel clearNode($('menu')); //On ajoute le titre var item = document.createElement("li"); item.innerHTML = this.name; item.id = "nameApp"; $('menu').appendChild(item); //Lien vers la page d'accueil var item = document.createElement("li"); item.onclick = function() { hideShownMenu(); firstLoad(); }; item.innerHTML = "Accueil"; if (online) item.className = "item"; else item.className = "item hr"; $('menu').appendChild(item); //Lien de déconnexion if (online) { var item = document.createElement("li"); item.onclick = function() { hideShownMenu(); deconnexion(); }; item.innerHTML = "Déconnexion"; item.className = "item hr"; $('menu').appendChild(item); } //On insère les éléments de l'app if (this.menu) { for (var i = this.menu.length - 1; i >= 0; i--) addMenuItem(this.menu[i]["text"], this.menu[i]["eventClick"]); } //On insère le about app var item = document.createElement("li"); item.observe('click', this.about.bind(this)); item.innerHTML = "À propos de ..."; item.className = "item hr"; $('menu').appendChild(item); //Lien vers la page à propos du site var item = document.createElement("li"); item.onclick = function() { hideShownMenu(); loadPage('aproposdusite'); }; item.innerHTML = "À propos du site"; item.className = "item"; $('menu').appendChild(item); } Application.prototype.about = function() { hideShownMenu(); $(this.corps).innerHTML = ""; //Texte correspondant à l'état de l'app var txtEtat = ""; if (this.etatAvancement == "En construction" || this.etatAvancement == "en construction" || this.etatAvancement == "enconstruction" || this.etatAvancement == "construction" || this.etatAvancement == "c") txtEtat = "En construction"; else if (this.etatAvancement == "Béta" || this.etatAvancement == "Beta" || this.etatAvancement == "beta" || this.etatAvancement == "béta" || this.etatAvancement == "b") txtEtat = "Béta"; else if (this.etatAvancement == "Alpha" || this.etatAvancement == "alpha" || this.etatAvancement == "a") txtEtat = "Alpha"; var titre = document.createElement("h2"); titre.innerHTML = "A propos de " + this.name + " pour Pommultimedia for Home"; $(this.corps).appendChild(titre); titre = document.createElement("h3"); titre.innerHTML = this.name + "
Version " + this.version + " " + txtEtat; $(this.corps).appendChild(titre); if (this.description != null) { titre = document.createElement("h4"); titre.innerHTML = "Description : " + this.description; $(this.corps).appendChild(titre); } if (this.lang != null) { titre = document.createElement("h4"); titre.innerHTML = "Langue : " + this.lang; $(this.corps).appendChild(titre); } titre = document.createElement("h4"); titre.innerHTML = "Nom court : " + this.dir; $(this.corps).appendChild(titre); if (this.developpeur != null) { titre = document.createElement("h4"); titre.innerHTML = "Développeur : " + this.developpeur; $(this.corps).appendChild(titre); } }