(function(win, NOOP, undefined){ // functions from jQuery framework win.GIGA=win.GIGA||{}; GIGA.noop=GIGA.NOOP=NOOP; GIGA.each = function(object, iterator){ var _isFunction=function(obj){ var toString = Object.prototype.toString; return toString.call(obj) === "[object Function]"; } ,name, i = 0, length = object.length, isObj = length === undefined || _isFunction(object); if ( isObj ) { for ( name in object ) { if ( iterator.call( object[ name ], name, object[ name ] ) === false ) { break; } } } else { for ( var value = object[0]; i < length && iterator.call( value, i, value ) !== false; value = object[++i] ) {} } }; // cross-browsers CONSOLE // new release based on console.js (function($w, $c, NOOP){ //**** add global vars & functions var undefined=NOOP() // save native methods , $save = {} // check if myArray can be used in this script; // we check a a method (push) and a propriety (length) // we create a 'clear' method if not exist , _checkArray = function checkArray(myArray){ if (!myArray || !myArray.push || myArray.length == undefined) myArray=[]; myArray.clear = myArray.clear || function(){myArray.length=0; return myArray}; return myArray } // history array can inherite from existing console.history array (if existing) // we also check console.history is OK, otherwise we set an empty array , history = _checkArray( $c['history'] ) // methods that will be wrapped. First item will be the default log method , methods = ['log', 'debug', 'info', 'warn', 'error'] // methods that will be wrapped but remain transparent , nativeMethods =['assert','clear','count','dir','dirxml','exception','group','groupCollapsed','groupEnd','profile','profileEnd','table','time','timeEnd','trace'] // returns GTM time , _time = function timeToGMT(t){ return t.toGMTString() } // returns a timeStamp, in ms, since begining : ts(t) = Date(t) - Date(beginning) , _ts = (function(t0){ return function timeStamp(){ return (new Date().getTime() - t0 ) } })(new Date().getTime()) // default console.log is used when native console.log is not working // default console.log can be decided by user before loading this script. Just set window.defaultLog , _defaultLog = $w['defaultLog'] || NOOP ; // we remove 'public' Array console.history and we return current history Array history.remove = function removeHistory(){ delete $c['history']; delete history.remove; return history }; //**** add new methods to the console object : // 'history' array is exposed to public console.history $c['history'] = history ; // return saved native log methods $c['getNativeMethods'] = function getNativeMethods(){return $save} // return timeStamp $c['ts'] = $c['ts'] || _ts; // callback function : will be called by log console methods $c['callback'] = $c['callback'] || NOOP; //**** wrap all methods in console object (function(defaultLog){ for (var i=0, MAX=methods.length ; i < MAX; i++) { $c[methods[i]]=(function(m, fct){ // save native method $save[m]=$c['__'+m]=function(){ return Function.prototype.apply.call(fct, $c, [].slice.call(arguments)) }; // return new LOG function return function CONSOLE(){ try { var arg = [].slice.call(arguments) // 'log Object' = arguments, call type, timestamp and local GMT time , o = { 'type': m , 'data' : arg , 'log' : arg.join(' ') , 'ts' : $c['ts']() , 'GMT' : _time(new Date()) }; // apply console native function or default log function if ($c['enable']) Function.prototype.apply.call(fct, $c, arg); // stack into history array; protect function try { history.push(o) } catch(e){ defaultLog('error when pushing logs to the history array : ', e) } // callback try { $c['callback'](o) } catch(e){ defaultLog('error when executing console callback function: ', e) } //return value pushed to history return o } catch(e){ defaultLog('error when executing console.'+m,' : ', e) } }; })(methods[i], $c[methods[i]] || defaultLog); } })($c[methods[0]] || _defaultLog); //**** wrap native methods for (var i=0, MAX=nativeMethods.length, method; i < MAX; i++) { method = nativeMethods[i]; $c[method] = $c[method] || function(){ $c['warn']('console.'+method+' is not available on this browser.') }; }; // wrap 'clear' method to clear 'history' when cleaning the browser console // will clear history only if 'true' boolean is passed to the function $c['clear'] = (function(clearConsole){ return function clearCONSOLE(clearHistory){ try{ // first clear Array if (clearHistory === true) history.clear(); // then clear console return clearConsole(); } catch(e){$c['error']('error when executing console.clear() : ', e)} } })($c['clear']); //**** create new console $w['CONSOLE']=$c; $c['enable']=true; $c['log']('wrapped window.console is ready'); }) (win, win['console'] || {}, function(){}); GIGA.CONSOLE=win['CONSOLE']; GIGA._log=GIGA.CONSOLE.log; GIGA._D=GIGA.CONSOLE.info; GIGA._W=GIGA.CONSOLE.warn; var _log=GIGA.CONSOLE, _D=GIGA._D, _W=GIGA._W; GIGA.GigaButton=win.GigaButton = function GigaButton(id, text, click) { if (! this instanceof GigaButton) return new GIGA.GigaButton(id, text, click); // nouvelles fonction v1.8b pour tester une nv mise en forme var BTon=function BTon(e) {BT.className='bouton-ON';/*e.style.backgroundColor='000066'*/;return true} , BToff=function BToff(e) {BT.className='bouton';/*e.style.backgroundColor= 'transparent'*/;return true} , box=GIGA.$(id) , fct , BT; if (! box.id) return false; else { box.className='bouton'; BT=document.createElement('input'); BT.type='button'; BT.value=text; BT.className='bouton'; box.appendChild(BT); if (click!="") fct = new Function(click); this.setFunction=function(f){fct=f;} BT.onmouseover=function(){BTon(box)} BT.onmouseout=function(){BToff(box)} BT.onclick=function(){BT.blur();BToff(box);fct() } this.BT=BT; this.box=box; this.W=function(w){box.style.width=w}; this.S=function(s){BT.style.fontSize=s}; return ; } //function BTon(e) {e.style.backgroundColor= /*"FF6600"*/"F50000";return true} //function BToff(e) {e.style.backgroundColor= "transparent";return true} } GIGA.div_objet=win.div_object=function(name) { var div_element=GIGA.$(name); div_element.style.display='none'; this.Off=function(){div_element.style.display='none'; return this} this.On=function(){div_element.style.display=''; return this} this.Change=function(){div_element.style.display==''?div_element.style.display='none':div_element.style.display=''; return this} this.$=div_element; } GIGA.$ = function(arg){ var elt; if (arg.id) elt = document.getElementById(arg.id) || {}; else elt = document.getElementById(arg) || {}; elt.hide=function(){if (elt && elt.style) elt.style.display='none'; else _log('not able to hide');;return elt} elt.show=function(){if (elt && elt.style) elt.style.display=''; else _log('not able to show');return elt} elt.Visible=function(v){ if (elt && elt.style) { if (v || v==undefined) elt.style.visibility='visible'; else elt.style.visibility='hidden'; } else _log("not able to change visibility"); return elt } elt.id= (elt&&elt.style&&elt.id) ? elt.id : false; return elt } // fonctions pour le menu - DEPRECATED GIGA.init_menu=win.init_menu = function(){ if (PHP_wrong_id) document.getElementById("wrong_id").style.visibility='visible' else document.getElementById("wrong_id").style.visibility='hidden'; if (ID_auth){ // true si le client est authentifie dans la session div_id.style.visibility='hidden'; div_logon.style.display='none'; div_logoff.style.display=''; wrong_id.style.visibility='hidden'; } else { // sinon afficher le menu d'identification div_id.style.visibility='visible'; div_logon.style.display=''; div_logoff.style.display='none'; } return true } GIGA.MenuON=win.MenuON = function(num) { GIGA.$("menu"+(num)).bgColor= "99CCFF"; return true; } GIGA.MenuOFF=win.MenuOFF = function(num) { BgC=GIGA.$("centre_left").bgColor; GIGA.$("menu"+(num)).bgColor=BgC; return true; } GIGA.logon=win.logon = function() { //test de l'identite et du mot de passe. Si ok alors : div_id.style.visibility='hidden'; div_logon.style.display='none'; div_logoff.style.display=''; wrong_id.style.visibility='hidden'; return true; } GIGA.logoff=win.logoff = function(){ div_id.style.visibility='visible'; form_id.reset(); div_logon.style.display=''; div_logoff.style.display='none'; wrong_id.style.visibility='hidden'; return true; } // fonctions pour les boutons GIGA.bgON=win.bgON = function(nom) { //document.getElementById(nom).bgColor= "F50000"; var N=GIGA.$(nom).firstChild; while (N.nodeName!='BUTTON') N=N.nextSibling; N.className='bouton-ON' ; return true; } GIGA.bgOFF=win.bgOFF=function(nom) { //document.getElementById(nom).bgColor=""; var N=GIGA.$(nom).firstChild; while (N.nodeName!='BUTTON') N=N.nextSibling; N.className='bouton' ; return true; } // transforme une date en string GIGA.DateString=win.DateString=function(time_value,format){ time_value_str=""; time_value_str=time_value.toLocaleString(); if (format){ // retravaille le format en enlevant les heures pos=time_value_str.indexOf(':'); if (pos >= 3){ time_value_str=time_value_str.substring(0,pos-3) }; }; return time_value_str } // transforme des octest en Mo GIGA.ToMo=window.ToMo=function(octets,decimale) {return (octets/1024/1024).toFixed(decimale)} GIGA.Str_octets=win.Str_octets = function(octets,decimale) { s=Array("Octets","Ko", "Mo", "Go"); t=new Array(2); i=0; t[i]=octets; while (t[i]>999) { t[i+1]=t[i]/1024 ; if (i