Optimisation de requete du serveur avec Ajax

Signaler
-
 abou -
Bonjour,

j'ai une aide pour optimiser de requete du serveur avec Ajax.Merci bien et je reste à votre écoute.

5 réponses

Messages postés
32498
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
17 mai 2021
348
Bonjour,

C'est nous qui restons à ton écoute .......
Pour commencer il faudrait :
- Nous montrer ton code
- Nous indiquer sur quoi tu bloques
- Si tu as des messages d'erreurs nous les préciser.
- Si le souci concerne un problème sur la REQUETE en elle même ... un DUMP des tables concernées ou du moins leur structure.
bonsoir,voici le code qui bloque l'affichage du popup ,normalement après avoir cliqué,je dois avoir une petite fenêtre pour m'indiquer si je veux installer ou telacharger mais ça bloque pendant plusieurs minutes avant l affichage de cette petite fenetre ,pourriez vs me dire comment optimiser le code $ajax pour accelerer la reponse du serveur pourque je puisse en avoir une affichage rapide............

voila mon bout de code:--------------------------


AppScreen.prototype.init = function( p_container ) {

 var scope      = this;
 var showCallBack   = function(e){
  scope.visible.apply(scope, [true]);
  // Permet de récupérer l'url pour télécharger 
  // la publication PublishPaper Library
   var str = window.location.href;
   var ind = str.indexOf("html5");
   var begin = str.indexOf("://");
   var res = "publishpaper";
   for (i = begin; i < ind; i++) {
     res += str[i];
    }
   res += "application.zip";
   var ind = str.indexOf("html5");
   var res1 = "";
   for (i = 0; i < ind; i++) {
     res1 += str[i];
    }
    res1 += "application.zip";
    var descd = document.getElementsByClassName("desc")[0];
    
   // Recherche la présence ou non de la publication sur PublishPaper
   // Affiche le menu adequate
$.ajax({
  url: res1, //or your url
  success: function(data){
   document.getElementsByClassName("descContent")[0].innerHTML = "Cette publication n'est pas disponible en téléchargement pour une lecture sur PublishPaper Library";
 document.getElementsByClassName("descContent")[0].style.paddingTop = "100px";
 document.getElementsByClassName("descContent")[0].style.fontSize = "1.0em";
 document.getElementsByClassName("option1")[0].remove();
 document.getElementsByClassName("option2")[0].remove();
 document.getElementById("dmenu").remove();
 descd.getElementsByTagName("img")[0].style.display = "none";
 descd.style.display = "block";
   
  },
  error: function(data){


 descd.style.display = "block";
 document.getElementById("downloadApp").setAttribute('href', res);
  },
})
 };
  //if( isMobile.iOS() ){
 var image = document.createElement("img");
 image.setAttribute("src","resources/img/ui/app.png");
 image.style.width = "80%";
  image.style.height = "80%";
 image.setAttribute("padding-top", "0");
 //}
 var hideCallBack   = function(e){scope.visible.apply(scope, [false]);};

 this.signal      = new Signal();
 this._button     = document.getElementById("appButton");

 //if( isMobile.iOS() ){
 this._button.appendChild(image);
 this._button   = this._button.getElementsByTagName("img")[0];
 //}

 this._popup     = document.getElementById("appPopup");
 this._container    = this._popup.getElementsByClassName("content")[0];
 this._close     = this._popup.getElementsByClassName("btnClose")[0];

 this._button.onclick = showCallBack;
 this._close.onclick = hideCallBack;

 this._popup.style.left = ( ( Utils.getInnerWidth() - 520 ) * 0.5 ) + 'px';

 this._popup.addEventListener("touchmove", this.cancelHandler );
 this._initGestureHandler();

}; //END FUNCTION

AppScreen.prototype.onDoubleTap = function(event) {
 event.preventDefault();
 event.stopPropagation();
}; //END FUNCTION

AppScreen.prototype._initGestureHandler = function() {
 var scope = this;
 var callBackDoubleTap = function(event){ scope.onDoubleTap.apply( scope, [event] ); };
 this._gesture = new GestureHandler();
 this._gesture.onDoubleTap  = callBackDoubleTap;
 this._gesture.listen(this._container);
}; //END FUNCTION

AppScreen.prototype.cancelHandler = function(event) {
 event.preventDefault();
 event.stopPropagation();
}; //END FUNCTION

AppScreen.prototype.visible = function( value ) {
 closeOther(this._popup);
 if(this._popup.style.display == "block")
 this._popup.style.display = 'none';
 else
 this._popup.style.display = ( value == true ) ? "block" : "none";
}; //END FUNCTION

AppScreen.prototype.resize = function() {
 this._popup.style.top = parseInt( ( Utils.getInnerHeight() - 400 ) * 0.5 )+"px";
 this._popup.style.left = ( ( Utils.getInnerWidth() - 520 ) * 0.5 ) + 'px';
}; //END FUNCTION

Bonjour,comment je vais resoudre ce probleme
Bonjour,

le res1 que vous pensez qu'il a le pb ,puis je ne avoir plus d'explication
pour resoudre mn pb c à d ce que je dois faire merci
Messages postés
32498
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
17 mai 2021
348 > abou
Avant l'appel à AJAX .... tu fais un
 alert(res1);

Ca va te donner l'URL qu'il essaye d'utiliser pour l'ajax....
A partir de là .. tu regardes ce que contient ce fichier (voir même.. tu nous montres son code qu'on puisse regarder aussi).

mais visiblement... il regarde si des fichiers sont présent dans "PublishPaper" .... il se peut que ça soit ça qui soit long ....
Ne connaissant pas "PublishPaper" je ne peux pas t'en dire plus.
merci bien je vais faire comme ça
apres une alerte,voila ce qu'il m'affiche: http://localhost/Original/demoschneider_fr/files/

le fichier:application.rar est à 2390ko
voila tt mon code: publishpaper.js:
______________________________________

// # PublishPaper v.6
// last stable changes: 2013-10-15, unixman
// last stable changes: 2014-12-3, JF Bujoli
// SVN.637

/**
  • ...
  • @author Thot
  • @author Unixman (Radu Ovidiu Ilies)
  • @author JF Bujoli

*
  • /


// Récuperation du cookie créer pour garder
// en mémoire la page avant le changement d'orientation

if (readCookie('currpage')){
var cookietemp = readCookie('currpage');
cookietemp = parseInt(cookietemp);
}
$(window).bind('orientationchange', function () {
//alert('Orientation Change');
self.location = self.location;

});
var zdex = 200;
//createCookie('cookietemp', readCookie('currpage'), 0);



/* POO Simulation*/
/* Utils*/

//------------------------------------------------
//----------------------Observer--------------------
//------------------------------------------------
//------------------------------------------------

function Observer() {
this._listeners = new Array();
} //END FUNCTION


Observer.prototype._listeners = null;


Observer.prototype.destroy = function() {
this._listeners = null;
}; //END FUNCTION

Observer.prototype.addListener = function( p_eventType, p_callback, p_context ) {
this._listeners.push( { type:p_eventType, callback:p_callback, context:p_context } );
}; //END FUNCTION

Observer.prototype.removeListener = function( p_eventType, p_callback, p_context ) {
var listeners = new Array();
var max = this._listeners.length;
var listener = null;
for(var i = 0; i < max; i++) {
listener = this._listeners[i];
if( listener.type == p_eventType && listener.callback == p_callback && listener.context == p_context ) {
continue;
} //end if
listeners.push( listener );
} //end for
this._listeners = listeners;
}; //END FUNCTION

Observer.prototype.dispatchEvent = function( p_eventType, p_params ) {
var params = p_params || null;
var max = this._listeners.length;
var listener = null;
var calls = new Array();
for(var i = 0; i < max; i++) {
listener = this._listeners[i];
if(listener.type == p_eventType) {
calls.push(listener);
} //end if
} //end for
max = calls.length;
for(var i = 0; i < max; i++) {
listener = calls[i];
listener.callback.apply( listener.context, [p_eventType,params] );
} //end for
}; //END FUNCTION

/* Utils*/
/*MVC patterns implementations*/


//------------------------------------------------
//--------------------FACADE----------------------
//------------------------------------------------
//------------------------------------------------


function Facade() {
} //END FUNCTION

// static
Facade._instance = null;

Facade.getInstance = function() {
Facade._instance = Facade._instance || new Facade();
return Facade._instance;
}; //END FUNCTION

// private
Facade.prototype._controller = null;
Facade.prototype._model = null;
Facade.prototype._view = null;

// public
Facade.prototype.init = function() {
this._controller = Controller.getInstance();
this._model = Model.getInstance();
this._view = View.getInstance();
this._controller.facade = this;
this._model.facade = this;
this._view.facade = this;
}; //END FUNCTION

Facade.prototype.registerCommand = function( p_notificationType, p_commandClass ) {
this._controller.registerCommand( p_notificationType, p_commandClass );
}; //END FUNCTION

Facade.prototype.removeCommand = function( p_notificationType ) {
this._controller.removeCommand( p_notificationType );
}; //END FUNCTION

Facade.prototype.registerProxy = function( p_name, p_proxy ) {
this._model.registerProxy( p_name, p_proxy );
}; //END FUNCTION

Facade.prototype.removeProxy = function( p_name ) {
this._model.removeProxy( p_name );
}; //END FUNCTION

Facade.prototype.getProxy = function( p_name ) {
return this._model.getProxy( p_name );
}; //END FUNCTION

Facade.prototype.registerMediator = function( p_name, p_proxy ) {
this._view.registerMediator( p_name, p_proxy );
}; //END FUNCTION

Facade.prototype.removeMediator = function( p_name ) {
this._view.removeMediator( p_name );
}; //END FUNCTION

Facade.prototype.getMediator = function( p_name ) {
return this._view.getMediator( p_name );
}; //END FUNCTION

Facade.prototype.sendNotification = function( p_notificationType, p_notification ) {
this._controller.notify( p_notificationType, p_notification );
this._model.notify( p_notificationType, p_notification );
this._view.notify( p_notificationType, p_notification );
}; //END FUNCTION



//------------------------------------------------
//--------------------CONTROLLER--------------------
//------------------------------------------------
//------------------------------------------------


function Controller() {
this._map = new Object();
this.facade = null;
} //END FUNCTION

// static
Controller._instance = null;

Controller.getInstance = function() {
Controller._instance = Controller._instance || new Controller();
return Controller._instance;
}; //END FUNCTION

// private
Controller.prototype._map = null;

// public
Controller.prototype.facade = null;

Controller.prototype.registerCommand = function( p_flag, p_class ) {
this._map[p_flag] = p_class;
}; //END FUNCTION

Controller.prototype.removeCommand = function( p_flag ) {
delete this._map[p_flag];
}; //END FUNCTION

Controller.prototype.notify = function( p_event, p_data ) {
if( this._map[p_event] == null || this._map[p_event] == undefined ) {
return;
} //end if
var instance = new this._map[p_event]();
instance.execute( p_event, p_data );
}; //END FUNCTION



//------------------------------------------------
//--------------------MODEL--------------------
//------------------------------------------------
//------------------------------------------------

function Model() {
this._map = new Object();
this.observer = new Observer();
this.facade = null;
} //END FUNCTION

// static
Model._instance = null;

Model.getInstance = function() {
Model._instance = Model._instance || new Model();
return Model._instance;
}; //END FUNCTION

// private
Model.prototype._map = null;

// public
Model.prototype.observer = null;
Model.prototype.facade = null;

Model.prototype.registerProxy = function( p_flag, p_data ) {
this._map[p_flag] = p_data;
}; //END FUNCTION

Model.prototype.removeProxy = function( p_flag ) {
delete this._map[p_flag];
}; //END FUNCTION

Model.prototype.getProxy = function( p_flag ) {
return this._map[p_flag];
}; //END FUNCTION

Model.prototype.notify = function( p_event, p_data ) {
this.observer.dispatchEvent( p_event, p_data );
}; //END FUNCTION



//------------------------------------------------
//--------------------VIEW--------------------
//------------------------------------------------
//------------------------------------------------

function View() {
this._map = new Object();
this.observer = new Observer();
this.facade = null;
} //END FUNCTION

// static
View._instance = null;
View.getInstance = function() {
View._instance = View._instance || new View();
return View._instance;
}; //END FUNCTION

// private
View.prototype._map = null;

// public
View.prototype.observer = null;
View.prototype.facade = null;

View.prototype.registerMediator = function( p_flag, p_data ) {
this._map[p_flag] = p_data;
}; //END FUNCTION

View.prototype.removeMediator = function( p_flag ) {
delete this._map[p_flag];
}; //END FUNCTION

View.prototype.getMediator = function( p_flag ) {
return this._map[p_flag];
}; //END FUNCTION

View.prototype.notify = function( p_event, p_data ) {
this.observer.dispatchEvent( p_event, p_data );
}; //END FUNCTION



/*PATTERNS*/

///////////////////////////////
///////////////////////////////
/////////////COMMAND///////////
///////////////////////////////
//////////////////////////////


function Command() {
} //END FUNCTION

Command.prototype.execute = function( p_notificationType, p_data ){};



///////////////////////////////
///////////////////////////////
/////////////MACROCOMMAND///////////
///////////////////////////////
//////////////////////////////

function MacroCommand() {
} //END FUNCTION

//private
MacroCommand.prototype._commands = null;

//public
MacroCommand.prototype.addSubCommand = function( p_command ) {
this._commands = this._commands || new Array();
this._commands.push( p_command );
}; //END FUNCTION

MacroCommand.prototype.removeSubCommand = function( p_command ) {
this._commands = this._commands || new Array();
var index = this._commands.indexOf( p_command );
if( index > -1 ) {
this._commands.splice( index, 1 );
} //end if
}; //END FUNCTION


MacroCommand.prototype.execute = function( p_notificationType, p_data ) {
var i = 0;
var max = 0;
var command = null;
this._commands = this._commands || new Array();
max = this._commands.length;
for( i = 0; i < max; i++ ) {
command = new this._commands[i]();
command.execute( p_notificationType, p_data );
} //end for
}; //END FUNCTION


///////////////////////////////
///////////////////////////////
/////////////PROXY///////////
///////////////////////////////
//////////////////////////////


function Proxy() {
} //END FUNCTION

// private
Proxy.prototype._data = null;
Proxy.prototype.name = "";

// public
Proxy.prototype.init = function( p_name, p_data ) {
this.name = p_name;
this._data = p_data;
}; //END FUNCTION

Proxy.prototype.addNotificationListener = function( p_notificationType ) {
Model.getInstance().observer.addListener( p_notificationType, this.onNotification, this );
}; //END FUNCTION

Proxy.prototype.removeNotificationListener = function( p_notificationType ) {
Model.getInstance().observer.removeListener( p_notificationType, this.onNotification, this );
}; //END FUNCTION

Proxy.prototype.onNotification = function( p_notificationType, p_data ) {
}; //END FUNCTION

Proxy.prototype.getData = function() {
return this._data;
}; //END FUNCTION

Proxy.prototype.getFacade = function() {
return Model.getInstance().facade;
}; //END FUNCTION


///////////////////////////////
///////////////////////////////
/////////////MEDIATOR///////////
///////////////////////////////
//////////////////////////////



function Mediator() {
} //END FUNCTION

// private
Mediator.prototype._data = null;
Mediator.prototype.name = null;

// public
Mediator.prototype.init = function( p_name, p_data ) {
this._data = p_data;
this.name = p_name;
}; //END FUNCTION

Mediator.prototype.addNotificationListener = function( p_notificationType ) {
View.getInstance().observer.addListener( p_notificationType, this.onNotification, this );
}; //END FUNCTION

Mediator.prototype.removeNotificationListener = function( p_notificationType ) {
View.getInstance().observer.removeListener( p_notificationType, this.onNotification, this );
}; //END FUNCTION

Mediator.prototype.onNotification = function( p_notificationType, p_data ) {
}; //END FUNCTION

Mediator.prototype.getViewComponent = function() {
return this._data;
}; //END FUNCTION

Mediator.prototype.getFacade = function() {
return View.getInstance().facade;
}; //END FUNCTION


//****************************************************


function Back() {
} //END FUNCTION

Back.easeIn = function ( p_t , p_b, p_c , p_d ) {
return p_c * ( p_t /= p_d ) * p_t * ( 2.70158 * p_t - 1.70158 ) + p_b;
}; //END FUNCTION

Back.easeOut = function (p_t, p_b, p_c, p_d) {
return p_c * ( ( p_t = p_t / p_d - 1) * p_t * ( 2.70158 * p_t + 1.70158) + 1 ) + p_b;
}; //END FUNCTION

Back.easeInOut = function( p_t, p_b, p_c, p_d ) {
if ( ( p_t /= p_d * 0.5 ) < 1 ) {
return p_c * 0.5 * ( p_t * p_t * ( ( 1.70158 * 1.525 + 1 ) * p_t - 1.70158 ) ) + p_b;
} else {
return p_c / 2 * ( ( ( p_t -= 2 ) * p_t * ( 1.70158 * 1.525 + 1 ) * p_t + 1.70158 ) + 2 ) + p_b;
} //end if else
}; //END FUNCTION


//****************************************************


function Bounce() {
} //END FUNCTION

Bounce.easeIn = function ( t , b, c , d ) {
return c - easeOut(d-t, 0, c, d) + b;
}; //END FUNCTION

Bounce.easeOut = function (t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
} //end if else
}; //END FUNCTION

Bounce.easeInOut = function( t, b, c, d ) {
if (t < d*0.5) {
return Bounce.easeIn (t*2, 0, c, d) * .5 + b;
} else {
return Bounce.easeOut (t*2-d, 0, c, d) * .5 + c*.5 + b;
} //end if else
}; //END FUNCTION


//****************************************************


function Circ(){
} //END FUNCTION

Circ.easeIn = function(t, b, c, d) {
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
}; //END FUNCTION

Circ.easeOut = function(t, b, c, d) {
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
}; //END FUNCTION

Circ.easeInOut = function(t, b, c, d) {
if ((t/=d*0.5) < 1) return -c*0.5 * (Math.sqrt(1 - t*t) - 1) + b;
return c*0.5 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
}; //END FUNCTION


//****************************************************


function Cubic() {
} //END FUNCTION

Cubic.easeIn = function(t, b, c, d) {
return c*(t/=d)*t*t + b;
}; //END FUNCTION

Cubic.easeOut = function(t, b, c, d) {
return c*((t=t/d-1)*t*t + 1) + b;
}; //END FUNCTION

Cubic.easeInOut = function(t, b, c, d) {
if ((t/=d*0.5) < 1) return c*0.5*t*t*t + b;
return c*0.5*((t-=2)*t*t + 2) + b;
}; //END FUNCTION


//****************************************************


function Elastic() {
} //END FUNCTION

Elastic._2PI = Math.PI * 2;

Elastic.easeIn = function(t, b, c, d, a, p) {
var s;
a = a || 0;
p = p || 0;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
else s = p/Elastic._2PI * Math.asin (c/a);
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*Elastic._2PI/p )) + b;
}; //END FUNCTION

Elastic.easeOut = function(t, b, c, d, a, p ) {
var s;
a = a || 0;
p = p || 0;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
else s = p/Elastic._2PI * Math.asin (c/a);
return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*Elastic._2PI/p ) + c + b);
}; //END FUNCTION

Elastic.easeInOut = function (t, b, c, d, a, p) {
var s;
a = a || 0;
p = p || 0;
if (t==0) return b; if ((t/=d*0.5)==2) return b+c; if (!p) p=d*(.3*1.5);
if (!a || (c > 0 && a < c) || (c < 0 && a < -c)) { a=c; s = p/4; }
else s = p/Elastic._2PI * Math.asin (c/a);
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*Elastic._2PI/p )) + b;
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*Elastic._2PI/p )*.5 + c + b;
}; //END FUNCTION


//****************************************************

?
function Expo (){
}

Expo.easeIn = function(t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b - c * 0.001;
}; //END FUNCTION

Expo.easeOut = function(t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
}; //END FUNCTION

Expo.easeInOut = function(t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d*0.5) < 1) return c*0.5 * Math.pow(2, 10 * (t - 1)) + b;
return c*0.5 * (-Math.pow(2, -10 * --t) + 2) + b;
}; //END FUNCTION


//****************************************************


function Linear() {
} //END FUNCTION

Linear.power = 0;

Linear.easeNone = function(t, b, c, d) {
return c*t/d + b;
}; //END FUNCTION

Linear.easeIn = function(t, b, c, d) {
return c*t/d + b;
}; //END FUNCTION

Linear.easeOut = function(t, b, c, d) {
return c*t/d + b;
}; //END FUNCTION

Linear.easeInOut = function(t, b, c, d) {
return c*t/d + b;
}; //END FUNCTION


//****************************************************


function Quad(){
} //END FUNCTION

Quad.easeIn = function(t, b, c, d) {
return c*(t/=d)*t + b;
}; //END FUNCTION

Quad.easeOut = function(t, b, c, d) {
return -c *(t/=d)*(t-2) + b;
}; //END FUNCTION

Quad.easeInOut = function( t, b, c, d) {
if ((t/=d*0.5) < 1) return c*0.5*t*t + b;
return -c*0.5 * ((--t)*(t-2) - 1) + b;
}; //END FUNCTION


//****************************************************


function Quart(){
} //END FUNCTION

Quart.easeIn = function(t, b, c, d) {
return c*(t/=d)*t*t*t + b;
}; //END FUNCTION

Quart.easeOut = function(t, b, c, d) {
return -c * ((t=t/d-1)*t*t*t - 1) + b;
}; //END FUNCTION

Quart.easeInOut = function(t, b, c, d) {
if ((t/=d*0.5) < 1) return c*0.5*t*t*t*t + b;
return -c*0.5 * ((t-=2)*t*t*t - 2) + b;
}; //END FUNCTION


//****************************************************


function Quint() {
} //END FUNCTION

Quint.easeIn = function(t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
}; //END FUNCTION

Quint.easeOut = function(t, b, c, d) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
}; //END FUNCTION

Quint.easeInOut = function(t, b, c, d) {
if ((t/=d*0.5) < 1) return c*0.5*t*t*t*t*t + b;
return c*0.5*((t-=2)*t*t*t*t + 2) + b;
}; //END FUNCTION


//****************************************************


function Sine(){
} //END FUNCTION

Sine._HALF_PI = Math.PI * 0.5;

Sine.easeIn = function(t, b, c, d) {
return -c * Math.cos(t/d * _HALF_PI) + c + b;
}; //END FUNCTION

Sine.easeOut = function(t, b, c, d) {
return c * Math.sin(t/d * _HALF_PI) + b;
}; //END FUNCTION

Sine.easeInOut = function(t, b, c, d) {
return -c*0.5 * (Math.cos(Math.PI*t/d) - 1) + b;
}; //END FUNCTION


//****************************************************

?
function Strong() {
} //END FUNCTION

Strong.easeIn = function(t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
}; //END FUNCTION

Strong.easeOut = function(t, b, c, d) {
return c*((t=t/d-1)*t*t*t*t + 1) + b;
}; //END FUNCTION

Strong.easeInOut = function(t, b, c, d) {
if ((t/=d*0.5) < 1) return c*0.5*t*t*t*t*t + b;
return c*0.5*((t-=2)*t*t*t*t + 2) + b;
}; //END FUNCTION


//****************************************************

// static members
TweenNano._started = false;
TweenNano._masterList = new Array();

TweenNano._render = function() {
var i = TweenNano._masterList.length;
var tw = null;
while( --i > -1 ) {
tw = TweenNano._masterList[i];
tw.update();
} //end while
}; //END FUNCTION

TweenNano.addTween = function( p_tween ) {
TweenNano._masterList.push(p_tween);
}; //END FUNCTION

TweenNano.getTweenByTarget = function(p_target) {
var i = TweenNano._masterList.length;
var tw = null;
while( --i > -1 ) {
tw = TweenNano._masterList[i];
if( tw.target == p_target ) {
return tw;
} //end if
} //end while
return null;
}; //END FUNCTION

TweenNano.removeTween = function( p_tween ) {
var index = TweenNano._masterList.indexOf(p_tween);
if( index != -1 ) {
this._masterList.splice(index,1);
} //end if
}; //END FUNCTION

// start the renderer
TweenNano._start = function() {
if( TweenNano._started == false ) {
TweenNano._started = true;
FrameManager.getInstance().addFrameListener( TweenNano._render, TweenNano );
} //end if
}; //END FUNCTION

/* static methods */
TweenNano.kill = function( p_target, p_complete ) {
p_complete = ( p_complete == true ) ? true : false;
var tw = TweenNano.getTweenByTarget(p_target);
if( tw != null ) {
tw.complete( p_complete );
} //end if
}; //END FUNCTION

TweenNano.killAll = function( p_target, p_complete ) {
var i = TweenNano._masterList.length;
p_complete = ( p_complete == true ) ? true : false;
while( --i > -1 ) {
TweenNano._masterList[i].complete( p_complete );
} //end while
}; //END FUNCTION

TweenNano.to = function( p_target, p_duration , p_vars, p_cadency ) {
return new TweenNano( p_target, p_duration, p_vars, p_cadency );
}; //END FUNCTION

TweenNano.delayer = function( p_delay, p_target, p_duration, p_vars, p_cadency ) {
setTimeout( function(){ TweenNano.to( p_target, p_duration, p_vars, p_cadency ); }, p_delay );
}; //END FUNCTION


TweenNano.delayedCall = function( p_delay, p_onComplete, p_onCompleteParams, p_useFrames ) {
return new TweenNano( p_onComplete, 0, { delay: p_delay, onComplete: p_onComplete, onCompleteParams: p_onCompleteParams, useFrames: p_useFrames, overwrite:false } );
}; //END FUNCTION

function TweenNano ( p_target, p_duration, p_vars, p_cadency ) {

TweenNano._start();

var _public = this;

// private
_public._cadency = 100;
_public._time = 0;

// public
_public.duration = p_duration;
_public.vars = new Object();
_public.startTime = 0;
_public.target = new Object();
_public.active = false;
_public.gc = false;
_public.useFrames = false;
_public.ratio = 0;

// protected
_public._ease = _public.defaultEaseOut;
_public._propTweens = new Array();
_public.reservedProperties = ["ease","delay","useFrames","overwrite","onComplete","onCompleteParams","runBackwards","immediateRender","onUpdate","onUpdateParams"];

_public._construct = function( p_target, p_duration, p_vars, p_cadency ) {

TweenNano.kill(p_target,false);
TweenNano.addTween(this);

_public._time = new Date().getTime();

_public.vars = p_vars;
_public.duration = p_duration;
_public.target = p_target;

_public._ease = ( typeof( _public.vars.ease ) == "function" ) ? _public.vars.ease : _public.defaultEaseOut;
_public._cadency = ( p_cadency == undefined ) ? 100 : p_cadency;

_public._propTweens = new Array();

_public.useFrames = false;
_public.delay = ( typeof( _public.vars.delay ) == "undefined" ) ? 0 : new Number( _public.vars.delay );

_public.startTime = _public._time + _public.delay;
_public.renderTime(0);

_public.init();

}; //END FUNCTION

_public.defaultEaseOut = function( p_t, p_b, p_c, p_d ) {
return ( -1 * ( p_t /= p_d ) * ( p_t - 2 ) );
}; //END FUNCTION

_public.renderTime = function( p_time ) {

var l_prop = new Array();
var i = _public._propTweens.length;

if ( p_time >= _public.duration ) {
p_time = _public.duration;
_public.ratio = 1;
} else if ( p_time <= 0 ) {
_public.ratio = 0;
} else {
_public.ratio = _public._ease( p_time, 0, 1, _public.duration );
} //end if else

while(--i > -1) {
l_prop = _public._propTweens[i];
_public.target[ l_prop[0] ] = l_prop[1] + ( _public.ratio * l_prop[2] );
//alert( _public.target[ l_prop[0] ]+", "+_public.ratio+","+l_prop[0]+","+l_prop[1]+","+l_prop[2] );
} //end while

if(typeof(_public.vars.onUpdate) == "function") {
_public.vars.onUpdate.apply( _public.target, _public.vars.onUpdateParams );
} //end if

if( p_time >= _public.duration && !_public.gc ) {
_public.complete(true);
} //end if

}; //END FUNCTION

_public.init = function() {
var l_prop;
var i = 0;
for ( l_prop in _public.vars) {
if( _public.reservedProperties.indexOf(l_prop) == -1 ) {
_public._propTweens[i] = [l_prop, _public.target[l_prop], new Number( _public.vars[l_prop] - _public.target[l_prop] ) ];
i++;
} //end if
} //end for
}; //END FUNCTION

_public.complete = function( p_complete ) {
if ( p_complete && !_public.gc ) {
_public.gc = true;
_public.renderTime( _public.duration );
} //end if
_public.kill();
if (_public.vars.onComplete) {
_public.vars.onComplete.apply( null, _public.vars.onCompleteParams );
} //end if
}; //END FUNCTION

_public.kill = function() {
TweenNano.removeTween(this);
}; //END FUNCTION

_public.update = function() {
_public._time = new Date().getTime();
_public.renderTime( _public._time - _public.startTime);
}; //END FUNCTION

_public._construct( p_target, p_duration, p_vars, p_cadency );

} //END FUNCTION


//****************************************************

function ImageLoader() {

var _public = this;
var m_currentId = "";
var m_total = 0;
var m_files = new Array();
var m_data = new Object();

_public.signal = new Signal();

_public.addFile = function( p_file, p_id ) {
m_files.push( {url:p_file, id:p_id} );
}; //END FUNCTION

_public.load = function() {
m_total = m_files.length;
loadNextFile();
}; //END FUNCTION

function loadNextFile() {
var l_img = new Image();
var l_obj;
if( m_files.length == 0 ) {
_public.signal.dispatchEvent(ImageLoader.LOAD_COMPLETE);
} else {
l_img.onload = completeHandler;
l_obj = m_files.shift();
m_currentId = l_obj.id;
l_img.src = l_obj.url;
} //end if else
} //END FUNCTION

function completeHandler(event) {
var l_img = event.target;
m_data[m_currentId] = l_img;
_public.signal.dispatchEvent(ImageLoader.LOAD_PROGRESS);
loadNextFile();
}; //END FUNCTION

_public.getProgression = function() {
return parseInt( ( m_total - m_files.length ) / m_total * 100 );
}; //END FUNCTION

_public.clean = function() {
m_files = new Array();
m_data = new Object();
} //END FUNCTION

_public.getData = function() {
return m_data;
}; //END FUNCTION

_public.getDataById = function( p_id ) {
return m_data[p_id];
}; //END FUNCTION

_public.destroy = function() {
m_files = null;
m_data = null;
} //END FUNCTION

} //END FUNCTION

ImageLoader.signal = null;

ImageLoader.LOAD_COMPLETE = "loadComplete";
ImageLoader.LOAD_PROGRESS = "loadProgress";


//****************************************************


//------------------------------------------------
//---------------------POO EMULATION--------------
//------------------------------------------------
//------------------------------------------------

function POO(){
} //END FUNCTION

// static
POO._extends = new Array();

POO.extend = function( p_child, p_ancestor ) {
POO._extends.push({"child":p_child,"ancestor":p_ancestor});
}; //END FUNCTION

POO.run = function() {
var obj = null;
var i = 0;
var max = POO._extends.length;
var prop = null;
for (i = 0; i < max; i++ ) {
obj = POO._extends[i];
for( prop in obj.ancestor.prototype ) {
if( typeof(obj.child.prototype[prop]) == "undefined" ) {
obj.child.prototype[prop] = obj.ancestor.prototype[prop];
} //end if
obj.child.prototype._super = obj.child.prototype._super || {};
obj.child.prototype._super[prop] = obj.ancestor.prototype[prop];
} //end for
} //end for
} //END FUNCTION


//****************************************************


function Signal() {
this._listeners = new Array();
} //END FUNCTION

Signal.prototype._listeners = null;

Signal.prototype.destroy = function() {
this._listeners = null;
}; //END FUNCTION

Signal.prototype.addListener = function( p_eventType, p_callback, p_context ) {
this._listeners.push( {type:p_eventType, callback:p_callback, context:p_context} );
}; //END FUNCTION

Signal.prototype.removeListener = function( p_eventType, p_callback, p_context ) {
var listeners = new Array();
var max = this._listeners.length;
var listener = null;
var i = 0;
for( i = 0; i < max; i++ ) {
listener = this._listeners[i];
if( listener.type == p_eventType && listener.callback == p_callback && listener.context == p_context ) {
continue;
} //end if
listeners.push( listener );
} //end for
this._listeners = listeners;
}; //END FUNCTION

Signal.prototype.dispatchEvent = function( p_eventType, p_params ) {
var params = p_params || null;
var max = this._listeners.length;
var listener = null;
var calls = new Array();
var i = 0;
for( i = 0; i < max; i++ ) {
listener = this._listeners[i];
if( listener.type == p_eventType ) {
calls.push(listener);
} //end if
} //end for
max = calls.length;
for( i = 0; i < max; i++ ) {
listener = calls[i];
listener.callback.apply( listener.context, params );
} //end for
}; //END FUNCTION


//****************************************************


MouseTracker.MOUSE_UP = "mouseUp";
MouseTracker.MOUSE_DOWN = "mouseDown";
MouseTracker.DOUBLE_CLICK = "doubleClick";

function MouseTracker( p_element ) {

var m_element = p_element || document;
var _public = this;
var _lastTime = 0;

this.down = false;
this.lastX = 0;
this.lastY = 0;
this.mouseX = 0;
this.mouseY = 0;
this.skip = 0;
this.signal = new Signal();

function touchHandler(event) {

var l_time = new Date().getTime();
var l_touches = event.changedTouches;

if( event.type == "touchstart" ) {

event.preventDefault();

if( l_time - _lastTime < 500 ) {
_public.signal.dispatchEvent( MouseTracker.DOUBLE_CLICK );
} //end if

_public.down = true;
_public.lastX = l_touches[0].pageX;
_public.lastY = l_touches[0].pageY;
_public.signal.dispatchEvent( MouseTracker.MOUSE_DOWN );

_lastTime = l_time;

} else if( event.type == "touchend" ) {

_public.down = false;
_public.lastX = l_touches[0].pageX;
_public.lastY = l_touches[0].pageY;
_public.signal.dispatchEvent( MouseTracker.MOUSE_UP );

} else {

event.preventDefault();
this.skip = ( this.skip + 1 ) % 4;
if( this.skip < 3 ) {
return;
} //end if

} //end if else

_public.mouseX = l_touches[0].pageX;
_public.mouseY = l_touches[0].pageY;

} //END FUNCTION

function mouseHandler(event) {

var l_time = new Date().getTime();
var l_touches = event.changedTouches;

if( event.type == "mousedown" ) {

event.preventDefault();

if( l_time - _lastTime < 500 ) {
_public.signal.dispatchEvent( MouseTracker.DOUBLE_CLICK );
} //end if

_public.down = true;
_public.lastX = event.pageX;
_public.lastY = event.pageY;
_public.signal.dispatchEvent( MouseTracker.MOUSE_DOWN );

_lastTime = l_time;

} else if( event.type == "mouseup" ) {

_public.down = false;
_public.lastX = event.pageX;
_public.lastY = event.pageY;
_public.signal.dispatchEvent( MouseTracker.MOUSE_UP );

} else {

this.skip = ( this.skip + 1 ) % 5;
if( this.skip < 4 ) {
return;
} //end if

} //end if else

_public.mouseX = event.pageX;
_public.mouseY = event.pageY;

} //END FUNCTION

m_element.addEventListener( "touchmove", touchHandler );
m_element.addEventListener( "touchstart", touchHandler );
m_element.addEventListener( "touchend", touchHandler );

m_element.addEventListener("mousemove", mouseHandler );
m_element.addEventListener("mouseup", mouseHandler );
m_element.addEventListener("mousedown", mouseHandler );

} //END FUNCTION


//****************************************************


ResizeTracker.RESIZE = "resize";

function ResizeTracker() {

this.signal = new Signal();
var _public = this;

function resizeHandler(event) {
//-- unixman bug fix orientationchange
//_public.signal.dispatchEvent( ResizeTracker.RESIZE, [event] );
//--
} //END FUNCTION

//window.addEventListener("resize", resizeHandler);
//window.addEventListener("orientationchange", resizeHandler);

} //END FUNCTION


//****************************************************

function FrameManager() {

this.signal = new Signal();
var _this = this;

function render() {
_this.signal.dispatchEvent( FrameManager.ENTER_FRAME );
window.requestAnimationFrame( render );
} //END FUNCTION

render();

} //END FUNCTION

// static
FrameManager.ENTER_FRAME = "enterFrame";
FrameManager._instance = null;

FrameManager.getInstance = function() {
if( FrameManager._instance == null ) {
FrameManager._instance = new FrameManager();
} //end if
return FrameManager._instance;
}; //END FUNCTION

// public
FrameManager.prototype.signal = null;

FrameManager.prototype.addFrameListener = function( p_callback, p_context ) {
this.signal.addListener( FrameManager.ENTER_FRAME, p_callback, p_context );
};

FrameManager.prototype.removeFrameListener = function( p_callback, p_context ) {
this.signal.removeListener( FrameManager.ENTER_FRAME, p_callback, p_context );
};


//****************************************************


// DOM utilities

function Utils(){
} //END FUNCTION

Utils.getInnerHeight = function () {
//return document.documentElement.clientHeight;
return window.innerHeight;
//return document.body.offsetHeight;
}; //END FUNCTION

Utils.getInnerWidth = function () {
//return document.documentElement.clientWidth;
return window.innerWidth;
//return document.body.offsetHeight;
}; //END FUNCTION

Utils.extractUrlParams = function() {
var t = location.search.substring(1).split('&');
var f = [];
for (var i=0; i<t.length; i++){
var x = t[ i ].split('=');
f[x[0]]=x[1];
} //end for
return f;
}; //END FUNCTION

Utils.$ = function(p_id) {
return document.getElementById(p_id);
}; //END FUNCTION

Utils.$$ = function(p_tagName) {
return document.getElementsByTagName(p_tagName);
}; //END FUNCTION


//****************************************************


function CallBack(){
} //END FUNCTION

CallBack.create = function( p_func, p_context, p_args ) {
var func = function() {
p_func.apply( p_context, p_args );
}; //END FUNCTION
return func;
}; //END FUNCTION


//****************************************************


function dump( p_obj ) {

var data = "";
var i = 0;
var max = 0;
var props = new Array();

for( var prop in p_obj ) {
props.push(prop);
} //end for

props = props.sort();
max = props.length;

for( i = 0; i < max; i++ ) {
data += props[i]+":"+p_obj[props[i]]+"\n";
} //end for

return data;

}; //END FUNCTION

function Main() {
this.init();
} //END FUNCTION

Main.prototype.init = function() {
ApplicationFacade.getInstance().init();
ApplicationFacade.getInstance().sendNotification( ApplicationNotification.START_APP, getPPConfig() );
}; //END FUNCTION

window.onload = function() {
setFPS(60);
POO.run();
new Main();
}; //END FUNCTION

function setFPS( p_fps ) {
window.requestAnimationFrame = (function () {
return window.requestAnimationFrame || //Chromium
window.webkitRequestAnimationFrame || //Webkit
window.mozRequestAnimationFrame || //Mozilla Geko
window.oRequestAnimationFrame || //Opera Presto
window.msRequestAnimationFrame || //IE Trident?
function (callback, element) {
//Fallback function
window.setTimeout(callback, (1000/p_fps)>>0 );
} //END FUNCTION
})();
} //END FUNCTION


//****************************************************


function ApplicationsLabels(){
} //END FUNCTION

// static
ApplicationsLabels.SUMMARY_LABEL = "lbl1";
ApplicationsLabels.THUMBS_LABEL = "lbl2";
ApplicationsLabels.DOWNLOAD_LABEL = "lbl3";
ApplicationsLabels.SHARE_LABEL = "lbl4";
ApplicationsLabels.ABOUT_LABEL = "lbl5";
ApplicationsLabels.SEARCH_LABEL = "lbl6";
ApplicationsLabels.SEARCH_DEFAULT_INPUT_LABEL = "lbl7";
ApplicationsLabels.SEARCH_RESULTS_LABEL = "lbl8";
ApplicationsLabels.HELP_LABEL = "lbl9";
ApplicationsLabels.HELP_PANEL_1_LABEL = "lbl10";
ApplicationsLabels.HELP_PANEL_2_LABEL = "lbl11";
ApplicationsLabels.HELP_PANEL_3_LABEL = "lbl12";
ApplicationsLabels.HELP_PANEL_4_LABEL = "lbl13";
ApplicationsLabels.HELP_PANEL_5_LABEL = "lbl14";

ApplicationsLabels.SUMMARY_LABEL_ID = "lblId1";
ApplicationsLabels.THUMBS_LABEL_ID = "lblId2";
ApplicationsLabels.DOWNLOAD_LABEL_ID = "lblId3";
ApplicationsLabels.SHARE_LABEL_ID = "lblId4";
ApplicationsLabels.ABOUT_LABEL_ID = "lblId5";
ApplicationsLabels.SEARCH_LABEL_ID = "lblId6";
//ApplicationsLabels.SEARCH_DEFAULT_INPUT_LABEL_ID = "lblId7";// non utilisé
//ApplicationsLabels.SEARCH_RESULTS_LABEL_ID = "lblId8";// non utilisé
ApplicationsLabels.HELP_LABEL_ID = "lblId9";
ApplicationsLabels.HELP_PANEL_1_LABEL_ID = "lblId10";
ApplicationsLabels.HELP_PANEL_2_LABEL_ID = "lblId11";
ApplicationsLabels.HELP_PANEL_3_LABEL_ID = "lblId12";
ApplicationsLabels.HELP_PANEL_4_LABEL_ID = "lblId13";
ApplicationsLabels.HELP_PANEL_5_LABEL_ID = "lblId14";


//****************************************************


function ApplicationNotification(){
} //END FUNCTION

// static
ApplicationNotification.START_APP = "startApp";
ApplicationNotification.APP_READY = "appReady";
ApplicationNotification.INIT_DATA = "initData";
ApplicationNotification.LOAD_NEXT_PAGES = "loadNextPages";
ApplicationNotification.GO_TO_PAGE = "gotopage";
ApplicationNotification.DISPLAY_INTERFACES = "displayInterfaces";
ApplicationNotification.HIDE_INTERFACES = "hideInterfaces";
ApplicationNotification.RESIZE_APP = "resizeApp";
ApplicationNotification.SEARCH_TEXT = "searchText";
ApplicationNotification.SEARCH_RESULT = "searchResult";
ApplicationNotification.ZONE_CLICK = "zoneClick";
ApplicationNotification.DISPLAY_LINK_POPUP = "displayLinkOut";
ApplicationNotification.DISPLAY_MEDIA_POPUP = "displayMedia";
ApplicationNotification.DISPLAY_DIAPO_POPUP = "displayDiapo";
ApplicationNotification.DISPLAY_SHEET_POPUP = "displaySheet";
ApplicationNotification.CLICK_LINK = "clickLink";
ApplicationNotification.DOWNLOAD_PDF = "downloadPDF";
ApplicationNotification.TRANSLATE_APP = "translateApp";


//****************************************************


function ClickLinkCommand(){
}; //END FUNCTION

POO.extend( ClickLinkCommand, Command );

ClickLinkCommand.prototype.execute = function( p_notificationType, p_data ) {
var facade = ApplicationFacade.getInstance();
var proxy = facade.getProxy( ZoneProxy.NAME );
var id = p_data.id;
var vo = proxy.getZoneVOByProp("zoneId",id);
switch( vo.type ) {
case "link_out":
window.open(vo.url,"_blank");
break;
case "link_in":
var body = new Object();
body.numPage = parseInt(vo.target);
facade.sendNotification( ApplicationNotification.LOAD_AND_GO, body );
break;
case "mailto":
window.location.href="mailto:"+vo.target;
break;
}; //end switch
}; //END FUNCTION


//****************************************************

function DownloadPDFCommand() {
}; //END FUNCTION

POO.extend( DownloadPDFCommand, Command );

DownloadPDFCommand.prototype.execute = function( p_notificationType, p_data ) {

var facade = ApplicationFacade.getInstance(),
appProxy = facade.getProxy( ApplicationProxy.NAME ),
URL = appProxy._config.docFolder + appProxy._config.docFilename,
name = "_blank";

//-- unixman (bug fix in the case the PDF document was not defined)
if(typeof appProxy._config.docFolder == "undefined") {
alert('The PDF Folder was not defined in Config !');
return;
} //end if
//--
if(typeof appProxy._config.docFilename == "undefined") {
alert('The PDF File was not defined in Config !');
return;
} //end if
//--

window.open( URL, name );

}; //END FUNCTION


//****************************************************

function InitDataCommand(){
}; //END FUNCTION

POO.extend( InitDataCommand, Command );

InitDataCommand.prototype.execute = function( p_notificationType, p_data ) {

var facade = ApplicationFacade.getInstance();
var applicationProxy = facade.getProxy( ApplicationProxy.NAME );
var summaryProxy = facade.getProxy( SummaryProxy.NAME );
var zoneProxy = facade.getProxy( ZoneProxy.NAME );
var searchEngineProxy = facade.getProxy( SearchEngineProxy.NAME );

var pagesXML = applicationProxy.getPagesXML();
var sumXML = applicationProxy.getSummaryXML();
var srhXML = applicationProxy.getSearchXML();
var labXML = applicationProxy.getLabelsXML();
var configXML = applicationProxy.getConfigurationXML();

applicationProxy.initData(pagesXML, configXML);
summaryProxy.initData(sumXML);
searchEngineProxy.initData(srhXML);
zoneProxy.initData(pagesXML);

Localization.getInstance().initData( labXML );

facade.sendNotification( ApplicationNotification.TRANSLATE_APP, null );
facade.sendNotification( ApplicationNotification.APP_READY, null );

}; //END FUNCTION


//****************************************************

function LoadAndGoCommand(){
}; //END FUNCTION

POO.extend( LoadAndGoCommand, Command );

LoadAndGoCommand.prototype.execute = function( p_notificationType, p_data ) {

var facade = ApplicationFacade.getInstance();
var appProxy = facade.getProxy( ApplicationProxy.NAME );
var body = new Object();
var p_pageNum = p_data.numPage;

p_pageNum = ( p_pageNum >= appProxy.pageEnd ) ? appProxy.pageEnd : p_pageNum;
p_pageNum = ( p_pageNum < appProxy.start ) ? appProxy.start : p_pageNum;

body.numPage = p_pageNum;
appProxy.currentPage = p_pageNum;

appProxy.minPage = parseInt( p_pageNum / 2 ) * 2;
appProxy.maxPage = appProxy.minPage + appProxy.pageOffset;
facade.sendNotification( ApplicationNotification.LOAD_NEXT_PAGES );

}; //END FUNCTION


//****************************************************

function SearchTextCommand(){
}; //END FUNCTION

POO.extend( SearchTextCommand, Command );

SearchTextCommand.prototype.execute = function( p_notificationType, p_data ) {
var facade = ApplicationFacade.getInstance();
var text = p_data.text;
var searchEngineProxy = facade.getProxy( SearchEngineProxy.NAME );
searchEngineProxy.search(text);
}; //END FUNCTION


//****************************************************

function StartApplicationCommand(){
}; //END FUNCTION

POO.extend( StartApplicationCommand, Command );

StartApplicationCommand.prototype.execute = function( p_notificationType, p_data ) {
var appmediator = new PublishPaperMediator();
var uimediator = new UIMediator();
var appproxy = new ApplicationProxy();
var srhProxy = new SearchEngineProxy();
var sumProxy = new SummaryProxy();
var srhProxy = new SearchEngineProxy();
var zneProxy = new ZoneProxy();
appproxy.loadConfig(p_data);
ApplicationFacade.getInstance().registerMediator( UIMediator.NAME, uimediator );
ApplicationFacade.getInstance().registerMediator( PublishPaperMediator.NAME, appmediator );
ApplicationFacade.getInstance().registerProxy( ApplicationProxy.NAME, appproxy );
ApplicationFacade.getInstance().registerProxy( SummaryProxy.NAME, sumProxy );
ApplicationFacade.getInstance().registerProxy( SearchEngineProxy.NAME, srhProxy );
ApplicationFacade.getInstance().registerProxy( ZoneProxy.NAME, zneProxy );
appproxy.start();
}; //END FUNCTION


//****************************************************

function TranslateApplicationCommand(){
}; //END FUNCTION

POO.extend( TranslateApplicationCommand, Command );

TranslateApplicationCommand.prototype.execute = function( p_notificationType, p_data ) {

var staticsTexts = [

{"label":ApplicationsLabels.SUMMARY_LABEL, "id":ApplicationsLabels.SUMMARY_LABEL_ID },
{"label":ApplicationsLabels.THUMBS_LABEL, "id":ApplicationsLabels.THUMBS_LABEL_ID },
{"label":ApplicationsLabels.DOWNLOAD_LABEL, "id":ApplicationsLabels.DOWNLOAD_LABEL_ID },
{"label":ApplicationsLabels.SHARE_LABEL, "id":ApplicationsLabels.SHARE_LABEL_ID },
{"label":ApplicationsLabels.ABOUT_LABEL, "id":ApplicationsLabels.ABOUT_LABEL_ID },
{"label":ApplicationsLabels.HELP_LABEL, "id":ApplicationsLabels.HELP_LABEL_ID },
{"label":ApplicationsLabels.HELP_PANEL_1_LABEL, "id":ApplicationsLabels.HELP_PANEL_1_LABEL_ID },
{"label":ApplicationsLabels.HELP_PANEL_2_LABEL, "id":ApplicationsLabels.HELP_PANEL_2_LABEL_ID },
{"label":ApplicationsLabels.HELP_PANEL_3_LABEL, "id":ApplicationsLabels.HELP_PANEL_3_LABEL_ID },
{"label":ApplicationsLabels.HELP_PANEL_4_LABEL, "id":ApplicationsLabels.HELP_PANEL_4_LABEL_ID },
{"label":ApplicationsLabels.HELP_PANEL_5_LABEL, "id":ApplicationsLabels.HELP_PANEL_5_LABEL_ID }

]

var i = staticsTexts.length;
var element = null;

while( --i > -1 ) {
element = document.getElementById(staticsTexts[i].id);
if( element ) {
element.innerText = Localization.getInstance().getWord(staticsTexts[i].label);
} //end if
} //end while

}; //END FUNCTION


//****************************************************

function ZoneClickCommand(){
}; //END FUNCTION

POO.extend( ZoneClickCommand, Command );

// unixman (the actions of the active areas)
ZoneClickCommand.prototype.execute = function(p_notificationType, p_data) {
//--
var facade = ApplicationFacade.getInstance();
var proxy = facade.getProxy( ZoneProxy.NAME );
var id = p_data.id;
var vo = proxy.getZoneVOByProp("zoneId",id);
var mediator = facade.getMediator(UIMediator.NAME);
//--

switch(vo.type) {
case "link_out":
case "link_in":
case "mailto":
facade.sendNotification(ApplicationNotification.DISPLAY_LINK_POPUP, {"vo":vo});
break;
case "media":
if(vo.isPopup == true || vo.target.indexOf("dailymotion") != -1 || vo.target.indexOf("vimeo") != -1 || vo.target.indexOf("youtube") != -1 ) {
facade.sendNotification(ApplicationNotification.DISPLAY_MEDIA_POPUP, {"vo":vo});
} //end if
break;
case "sheet":
facade.sendNotification(ApplicationNotification.DISPLAY_SHEET_POPUP, {"vo":vo});
break;
// Nouveau comportement si la zone est de type diaporama
case "diaporama":
if(vo.isPopup == true) {
facade.sendNotification(ApplicationNotification.DISPLAY_DIAPO_POPUP, {"vo":vo});
} //end if
break;

}; //end switch
//--
}; //END FUNCTION


//****************************************************


function ApplicationFacade(){
} //END FUNCTION

POO.extend( ApplicationFacade, Facade );

// static
ApplicationFacade._instance = null;

ApplicationFacade.getInstance = function() {
ApplicationFacade._instance = ApplicationFacade._instance || new ApplicationFacade();
return ApplicationFacade._instance;
}; //END FUNCTION

// public
ApplicationFacade.prototype.init = function() {
this._super.init.apply( this );
this.registerCommand( ApplicationNotification.START_APP, StartApplicationCommand );
this.registerCommand( ApplicationNotification.LOAD_AND_GO, LoadAndGoCommand );
this.registerCommand( ApplicationNotification.INIT_DATA, InitDataCommand );
this.registerCommand( ApplicationNotification.SEARCH_TEXT, SearchTextCommand );
this.registerCommand( ApplicationNotification.ZONE_CLICK, ZoneClickCommand );
this.registerCommand( ApplicationNotification.CLICK_LINK, ClickLinkCommand );
this.registerCommand( ApplicationNotification.DOWNLOAD_PDF, DownloadPDFCommand );
this.registerCommand( ApplicationNotification.TRANSLATE_APP, TranslateApplicationCommand );
//this.registerCommand( ApplicationNotification.LOAD_NEXT_PAGES, LoadNextPagesCommand );
}; //END FUNCTION


//****************************************************


function ApplicationProxy() {
this.init( ApplicationProxy.NAME, new Array() );
} //END FUNCTION

POO.extend( ApplicationProxy, Proxy );

// static
ApplicationProxy.NAME = "ApplicationProxy";
ApplicationProxy.DATA_XML_PATH = "data.xml";
ApplicationProxy.SUMMARY_XML_PATH = "summary.xml";
ApplicationProxy.SEARCH_XML_PATH = "data.xml";
ApplicationProxy.LABELS_XML_PATH = "labels.xml";
ApplicationProxy.CONFIGURATION_XML_PATH = "configuration.xml";

//private
ApplicationProxy.prototype._loader = null;
ApplicationProxy.prototype._dataXML = null;
ApplicationProxy.prototype._summaryXML = null;
ApplicationProxy.prototype._searchXML = null;
ApplicationProxy.prototype._labelsXML = null;
ApplicationProxy.prototype._configurationXML = null;

//public
ApplicationProxy.prototype.currentPage = 0;
ApplicationProxy.prototype.minPage = 0;
ApplicationProxy.prototype.start = 0;
ApplicationProxy.prototype.maxPage = 4;
ApplicationProxy.prototype.pageOffset = 4;
ApplicationProxy.prototype.pageEnd = 0;
ApplicationProxy.prototype._config = null;

ApplicationProxy.prototype.init = function( p_name, p_data )
{
this._super.init.apply( this, [ p_name, p_data ] );
};

ApplicationProxy.prototype.loadConfig = function(config)
{
this._config = config;
};

ApplicationProxy.prototype.getConfig = function(config)
{
return this._config;
};

ApplicationProxy.prototype._loadData = function()
{
this._loader = new Loader();
this._loader.responseType = Loader.RESPONSE_TYPE_XML;

this._loader.addFile(this._config.dataFolder + ApplicationProxy.DATA_XML_PATH);
this._loader.addFile(this._config.dataFolder + ApplicationProxy.SUMMARY_XML_PATH);
this._loader.addFile(this._config.searchEngineFolder + ApplicationProxy.SEARCH_XML_PATH);
this._loader.addFile(this._config.configFolder + ApplicationProxy.LABELS_XML_PATH);
this._loader.addFile(this._config.configFolder + ApplicationProxy.CONFIGURATION_XML_PATH);

this._loader.signal.addListener( Loader.LOAD_COMPLETE, this._loadCompleteHandler, this );
this._loader.load();
};

ApplicationProxy.prototype._loadCompleteHandler = function()
{
this._dataXML = this._loader.getData()[this._config.dataFolder + ApplicationProxy.DATA_XML_PATH];
this._summaryXML = this._loader.getData()[this._config.dataFolder + ApplicationProxy.SUMMARY_XML_PATH];
this._searchXML = this._loader.getData()[this._config.searchEngineFolder + ApplicationProxy.SEARCH_XML_PATH];
this._labelsXML = this._loader.getData()[this._config.configFolder + ApplicationProxy.LABELS_XML_PATH];
this._configurationXML = this._loader.getData()[this._config.configFolder + ApplicationProxy.CONFIGURATION_XML_PATH];

this._loader.destroy();
this.getFacade().sendNotification(ApplicationNotification.INIT_DATA);
};

ApplicationProxy.prototype.start = function()
{
this._loadData();
};

ApplicationProxy.prototype.getPages = function()
{
return this._data;
};

ApplicationProxy.prototype.getPageVOByNum = function( p_num )
{
var i = 0;
var max = this._data.length;
var vo = null;

for( i = 0; i < max; i++ )
{
vo = this._data[i];
if( vo.numPage == p_num )
return vo;
}

return null;
};


ApplicationProxy.prototype.getLabelsXML = function()
{
return this._labelsXML;
};

ApplicationProxy.prototype.getPagesXML = function()
{
return this._dataXML;
};

ApplicationProxy.prototype.getSummaryXML = function()
{
return this._summaryXML;
};

ApplicationProxy.prototype.getSearchXML = function()
{
return this._searchXML;
};

ApplicationProxy.prototype.getConfigurationXML = function()
{
return this._configurationXML;
}

// variables permettant de déterminer l'appareil utilisé
var paysage = 0;
var smartphone = 0;

// variables permettant de déterminer les options à afficher dans le menu
var share = 0;
var download = 0;

// parse XML

ApplicationProxy.prototype.initData = function(p_xml, g_xml) {

var objXML = XMLUtils.toObject(p_xml);
var desc = p_xml.getElementsByTagName("description")[0];
var params = Utils.extractUrlParams();

var i = 0;
var vo = null;
var titre = p_xml.getElementsByTagName("title")[0].textContent;

// récupération des options de partage et download du xml configuration.xml
share = parseInt(g_xml.getElementsByTagName("share")[0].textContent);
download = parseInt(g_xml.getElementsByTagName("pdf")[0].textContent[0]);

var pageData = null;
var pages = objXML.children[0].children[4].children;
var max = pages.length;
var startPage = parseInt( desc.getElementsByTagName("start_page")[0].textContent );
var pageWidth = parseInt( desc.getElementsByTagName("width")[0].textContent );
var pageHeight = parseInt( desc.getElementsByTagName("height")[0].textContent );
var thumbWidth = parseInt( desc.getElementsByTagName("thumbnailwidth")[0].textContent );
var thumbWidth = parseInt( desc.getElementsByTagName("thumbnailwidth")[0].textContent );
var thumbHeight = parseInt( desc.getElementsByTagName("thumbnailheight")[0].textContent );
var pagePath = this._config.pageFolder;
var thumbPath = this._config.thumbFolder;
var lastVO = null;

// récupération du titre de la publication
var elmt = document.getElementById("titre");
var but = document.getElementById("summaryButton");

// on modifie son style

//

//tablette ipad
if( isMobile.iOS() ){
if (share == 0 && download == 0)
but.style.paddingLeft = "94px";
else if (download == 0)
but.style.paddingLeft = "4%";
else if (share == 0)
but.style.paddingLeft = "4%";
if(window.innerHeight > window.innerWidth){
elmt.style.paddingRight = "15%";
}
else if(window.innerWidth > window.innerHeight && window.innerWidth < 580 ){
elmt.style.paddingRight = "0%";
}
else if(window.innerWidth > window.innerHeight && window.innerWidth > 580 && window.innerWidth < 1200 ){
elmt.style.paddingRight = "33%";
}
else{
elmt.style.paddingRight = "23%";
}
}
else{

//smartphone portrait
if(window.innerHeight > window.innerWidth && window.innerWidth < 480){
elmt.style.paddingRight = "26%";
share = 0;
download = 0;
smartphone = 1;
}
//tablette portrait
else if(window.innerHeight > window.innerWidth && window.innerWidth > 480){
elmt.style.paddingRight = "24%";

}
//smartphone paysage
else if(window.innerWidth > window.innerHeight && window.innerWidth < 720){
elmt.style.paddingRight = "58%";
share = 0;
download = 0;
smartphone = 1;
paysage = 1;
}
//tablette paysage
else if(window.innerWidth > window.innerHeight && window.innerWidth > 720){
elmt.style.paddingRight = "45%";
}

}

// affichage du titre de la publication

hide();
elmt.style.color = "#FFFFFF";
elmt.style.fontSize = "1.2em";
elmt.style.textAlign = "";
elmt.style.paddingTop = "12px";
document.getElementById('titre').innerHTML = titre;

vo = new PageVO();
vo.name = "page_-1";
vo.numPage = 0;
vo.id = 0;
vo.textureURL = "";
vo.thumbURL = "";
vo.textureId = 0;
vo.width = 1;
vo.height = 1;
vo.fake = true;

this._data.push( vo );

for( i = 0; i < max; i++ ) {
pageData = pages[i];
vo = new PageVO();
vo.name = pageData.children[0].value;
vo.numPage = parseInt(pageData.attributes["id"]);
vo.id = vo.numPage;
vo.textureURL = pagePath + pageData.children[1].value + this._config.pageExt;
vo.thumbURL = thumbPath + pageData.children[1].value + this._config.thumbExt;
vo.textureId = i;
vo.width = pageWidth;
vo.height = pageHeight;
this._data.push( vo );
} //end for

max = this._data[this._data.length-1].numPage;

// add fake page at the end
//if( this._data.length % 2 != 0 ) {
//lastVO = this._data[this._data.length-1];
//vo = new PageVO();
//vo.numPage = lastVO.numPage + 1;
//vo.id = vo.numPage;
//vo.name = "page_"+vo.numPage;
//vo.textureURL = "";
//vo.thumbURL = "";
//vo.textureId = 0;
//vo.width = 1;
//vo.height = 1;
//vo.fake = true;
//this._data.push( vo );
//} //end if

this._data[this._data.length-1].end = true;

var paramPage = parseInt(params["page"]);
this.currentPage = ( this._data.length > 0 ) ? this._data[1].numPage : this.currentPage;
this.currentPage = (isNaN(paramPage)) ? this.currentPage : paramPage;
this.minPage = parseInt( parseInt( this.currentPage / 2 ) * 2 );
this.maxPage = this.minPage + this.pageOffset;
this.pageEnd = max;
this.start = this._data[1].numPage;

}; //END FUNCTION

ApplicationProxy.prototype.onNotification = function( p_notificationType, p_data ) {
}; //END FUNCTION


//****************************************************

function Localization() {
this.init();
} //END FUNCTION

// static
Localization._instance = null;

Localization.getInstance = function() {
if( Localization._instance == null ) {
Localization._instance = new Localization();
} //end if
return Localization._instance;
}; //END FUNCTION

Localization.prototype._data = null;

Localization.prototype.init = function() {
this._data = new Object();
}; //END FUNCTION

Localization.prototype.addWord = function( flag, word ) {
this._data[flag] = word;
}; //END FUNCTION

Localization.prototype.getWord = function( flag ) {
if( this._data[flag] == undefined ) {
return '';
} else {
return this._data[flag];
} //end if
}; //END FUNCTION

Localization.prototype.initData = function(data) {
this.addWord(ApplicationsLabels.SUMMARY_LABEL, "Sommaire");
this.addWord(ApplicationsLabels.DOWNLOAD_LABEL, "Téléchargement");
this.addWord(ApplicationsLabels.SHARE_LABEL, "Partage");
this.addWord(ApplicationsLabels.HELP_LABEL, "Aide");
this.addWord(ApplicationsLabels.ABOUT_LABEL, "A propos");
this.addWord(ApplicationsLabels.SEARCH_LABEL, "Recherche");
this.addWord(ApplicationsLabels.SEARCH_DEFAULT_INPUT_LABEL, "Veuillez renseigner les termes de votre recherche");
this.addWord(ApplicationsLabels.SEARCH_RESULTS_LABEL, "page(s) correspond(ent) à votre recherche");
this.addWord(ApplicationsLabels.HELP_PANEL_1_LABEL, "Accédez au menu de navigation par simple tap");
this.addWord(ApplicationsLabels.HELP_PANEL_2_LABEL, "Le menu de navigation permet des accès rapides");
this.addWord(ApplicationsLabels.HELP_PANEL_3_LABEL, "Pour changer de page, faites glisser votre doigt vers la gauche ou la droite");
this.addWord(ApplicationsLabels.HELP_PANEL_4_LABEL, "Pour zoomer ou dézoomer, pincez la page");
this.addWord(ApplicationsLabels.HELP_PANEL_5_LABEL, "Accédez aux liens externes ou internes par un tap simple sur la zone active");
}; //END FUNCTION


//****************************************************


function SearchEngineProxy() {
this.init( SearchEngineProxy.NAME, null );
} //END FUNCTION

POO.extend( SearchEngineProxy, Proxy );

//static
SearchEngineProxy.NAME = "SearchEngineProxy";

//private
SearchEngineProxy.prototype._data = null;

//public
SearchEngineProxy.prototype.init = function( p_name, p_data ) {
this._super.init.apply( this, [ p_name, p_data ] );
}; //END FUNCTION

SearchEngineProxy.prototype.initData = function(p_xml) {

var dbSize = 0;
var objXML = XMLUtils.toObject(p_xml);
var pages = objXML.children[0].children;
var i = 0;
var j = 0;
var id = 0;
var max = pages.length;
var content = "";
var datas = new Array();

for(i=0; i<max; i++) {
content = pages[i].value;
id = parseInt( pages[i].attributes["id"] );
dbSize += content.length;
datas.push( {"id":id,"text":content} );
//alert(content); // unixman
} //end for

dbSize *= 4;
i = datas.length;

//if (navigator.userAgent.indexOf("Mozilla") == -1)
this.initDB(dbSize);

while(--i > -1) {
this.insertData(datas[i].id,datas[i].text);
} //end while

}; //END FUNCTION

SearchEngineProxy.prototype.initDB = function(dbSize) {
//--
//alert('DB Size:' + dbSize);
//--
try {
this._data = openDatabase('ppsearchDB', '1.0', 'PP5 searchEngine Checkins', dbSize);
this._data.transaction(
function(tx) {
tx.executeSql(
'CREATE TABLE ppSearchEngine (id INTEGER UNIQUE, text TEXT)', []
);
} //END FUNCTION
);
} catch(e) {
//alert('ERR: ' + e);
alert('Impossible to launch with firefox');
} //end try catch
//--
}; //END FUNCTION

SearchEngineProxy.prototype.insertData = function(id, text) {
if(text == '') {
return;
} //end if
try {
this._data.transaction(
function(tx) {
tx.executeSql(
'INSERT INTO ppSearchEngine (id , text) VALUES (?, ?)', [id, text]
);
} //END FUNCTION
);
} catch(e) {
//alert('ERR: ' + e);
//alert('Notice: Local Storage Object is not accessible ! (2)');
} //end try catch
}; //END FUNCTION

SearchEngineProxy.prototype.search = function(p_text) {

//on ne protège pas des injections SQL... à voir pour implémenter ça + tard

var textsArray = p_text.split(" ");
var cleanTable = new Array();
var processed_data = new Array();
var scope = this;
var query = 'SELECT * FROM ppSearchEngine';
var i = 0;
var max = textsArray.length;
var word = "";

for( i = 0; i < max; i++ ) {
word = textsArray[i];
word = word.replace(" ", "");
word = word.replace("'", "\'");
if( word != "" && word != " " ) {
cleanTable.push(word);
} //end if
} //end for

textsArray = cleanTable;
max = textsArray.length;

for( i = 0; i < max; i++ ) {
word = textsArray[i];
query += ( i==0 ) ? ' WHERE ': ' OR ';
query += "text LIKE '%" + word + "%'";
} //end for

query += " ORDER BY id";

//alert(query); // unixman

try {
this._data.transaction(
function(tx) {
tx.executeSql(
query,
[],
function(tr, data) {
var i, item, reg, match;
for (i=0, item=null; i<data.rows.length; i++) {
item = data.rows.item(i);
item.matches = 0;
item.id = parseInt(item.id) + 1;
//alert(item.id); // unixman
processed_data.push(item);
for(word in textsArray) {
item.matches += item.text.split(new RegExp('' + textsArray[word] + '', 'gi')).length-1;
} //end for
} //end for
scope._searchCompleteHandler(processed_data);
} //END FUNCTION
);
}
);
} catch(e) {
//alert('ERR: ' + e);
//alert('Notice: Local Storage Object is not accessible ! (3)');
} //end try catch

}; //END FUNCTION

SearchEngineProxy.prototype.onNotification = function( p_notificationType, p_data ) {
}; //END FUNCTION

SearchEngineProxy.prototype._resetResultsForPages = function() {
var proxy = this.getFacade().getProxy( ApplicationProxy.NAME );
var pages = proxy.getPages();
var i = parseInt(pages.length); // unixman fix latest
if(i >= 0) { // avoid infinite loop (ASUS)
while( --i > -1 ) {
pages[i].numResults = 0;
} //end while
} //end if
}; //END FUNCTION

SearchEngineProxy.prototype._searchCompleteHandler = function( p_data ) {

var proxy = this.getFacade().getProxy( ApplicationProxy.NAME );
var i = 0;
var index = -1;
var pages = new Array();
var max = p_data.length;
var vo1 = null;
var id = 0;

this._resetResultsForPages();

for( i = 0; i < max; i++ ) {

id = p_data[i].id + 1;
vo1 = proxy.getPageVOByNum(id);

if( id % 2 == 0 ) {
vo2 = proxy.getPageVOByNum(id+1);
} else {
vo2 = proxy.getPageVOByNum(id-1);
} //end if else

if( vo1 == null ) {
continue;
} //end if

index = pages.indexOf(vo1);

if( index == -1 ) {
pages.push(vo1);
} //end if

if( vo2 == null ) {
continue;
} //end if

index = pages.indexOf(vo2);

if( index == -1 ) {
pages.push(vo2);
} //end if

} //end for

pages = pages.sort(this._sortResult);

// add the proper results to vo;

for( i = 0; i < max; i++ ) {
id = p_data[i].id + 1;
vo1 = proxy.getPageVOByNum(id);
if( vo1 == null ) {
continue;
} //end if
vo1.numResults = p_data[i].matches;
} //end for

this.getFacade().sendNotification( ApplicationNotification.SEARCH_RESULT, {"results":pages} );

}; //END FUNCTION

SearchEngineProxy.prototype._sortResult = function( vo1, vo2 ) {
return ( vo1.numPage < vo2.numPage ) ? -1 : 1;
}; //END FUNCTION


//****************************************************


function SummaryProxy() {
this.init( SummaryProxy.NAME, null );
} //END FUNCTION

POO.extend( SummaryProxy, Proxy );

//static
SummaryProxy.NAME = "SummaryProxy";

//private
SummaryProxy.prototype._data = null;

//public
SummaryProxy.prototype.init = function( p_name, p_data ) {
this._super.init.apply( this, [ p_name, p_data ] );
}; //END FUNCTION

SummaryProxy.prototype.initData = function(p_xml) {

this._data = new Array();
var objXML = XMLUtils.toObject(p_xml);

var i = 0;
var vo = null;
var pages = objXML.children[0].children;
var max = pages.length;
//var pages = objXML.children[0].children[4].children;

for(i = 0; i< max; i++) {
vo = new SummaryVO();
vo.numPage = parseInt(pages[i].attributes["id"]);
vo.name = pages[i].children[0].value;
vo.deeplink = pages[i].children[1].value;
this._data.push( vo );
} //end for

}; //END FUNCTION

SummaryProxy.prototype.getSummary = function() {
return this._data;
}; //END FUNCTION

SummaryProxy.prototype.onNotification = function( p_notificationType, p_data ) {
switch( p_notificationType ) {
default:
// nothing
} //end switch
}; //END FUNCTION


//****************************************************


function ZoneProxy() {
this.init( ZoneProxy.NAME, null );
} //END FUNCTION

POO.extend( ZoneProxy, Proxy );

//static
ZoneProxy.NAME = "ZoneProxy";

//private
ZoneProxy.prototype._data = null;

//public
ZoneProxy.prototype.init = function( p_name, p_data ) {
this._super.init.apply( this, [ p_name, p_data ] );
}; //END FUNCTION

ZoneProxy.prototype.initData = function(p_xml) {

this._data = new Array();
var objXML = XMLUtils.toObject(p_xml);

var i = 0;
var vo = null;
var zones = p_xml.getElementsByTagName("zone");
var zoneXML = null;
var childNode = null;
var max = zones.length;
var type = "";

var pageWidth = parseInt( p_xml.getElementsByTagName("description")[0].getElementsByTagName("width")[0].textContent );
var pageHeight = parseInt( p_xml.getElementsByTagName("description")[0].getElementsByTagName("height")[0].textContent );

// unixman: parse zones

for(i=0; i<max; i++) {
//--
zoneXML = zones[i];
type = zoneXML.getElementsByTagName("type")[0].textContent;
//--
switch(type) {
case "link_out":
vo = this._getLinkoutVO(zoneXML);
break;
case "link_in":
vo = this._getLinkinVO(zoneXML);
break;
case "mailto":
vo = this._getMailtoVO(zoneXML);
break;
case "media":
vo = this._getMediaVO(zoneXML);
break;
case "diaporama":
vo = this._getDiapoVO(zoneXML);
break;
case "sheet":
vo = this._getSheetVO(zoneXML);
break;
default:
vo = null;
} //ens switch
//--
if(vo != null) {
//--
vo.type = zoneXML.getElementsByTagName("type")[0].textContent;
vo.id = parseInt(zoneXML.attributes["id"].value);
vo.zoneId = parseInt(zoneXML.attributes["zoneid"].value);
vo.zoomId = parseInt(zoneXML.attributes["zoomid"].value);
vo.numPage = parseInt(zoneXML.attributes["pageNum"].value);
vo.coords = zoneXML.attributes["coords"].value.split(",");
vo.title = zoneXML.getElementsByTagName("title")[0].textContent;
vo.rollid = zoneXML.getElementsByTagName("rollover")[0].attributes["rolloverid"].value;
vo.rolltype = zoneXML.getElementsByTagName("roll
Je dois faire pour optimiser ce code pour en avoir un affichage rapide merci bien
le code qui bloque l'affichage du popup ,normalement après avoir cliqué,je dois avoir une petite fenêtre pour m'indiquer si je veux installer ou telacharger mais ça bloque pendant plusieurs minutes avant l affichage de cette petite fenetre ,pourriez vs me dire comment optimiser ce code svp