/* * markerStats v1.1 mootools * * USAGE : * utiliser "isensStats.watchLinks();" pour metter à jour l'écoute des liens. * * */ var markerStats = new Class ({ Implements: [ Options ], options: { version: 1, page: 'Erreur', debug: false }, initialize: function(options) { this.setOptions(options); // variable stats this.stats = { version: this.options.version, page: this.options.page, lang: (navigator.systemLanguage) ? navigator.systemLanguage : navigator.language, ref: encodeURIComponent(document.referrer) }; var params = this.returnParams(this.stats); new Request.HTML({url: '/isens_marker.php'}).get(params); this.watchLinks(); }, watchLinks: function() { $$('a').each ( function(link) { if( link.retrieve('watched') ) return; var href = link.href; var domain = document.location.host; var file = href.split('/')[href.split('/').length-1]; var ext = ( file.split('.').length > 1 ) ? file.split('.')[file.split('.').length-1] : null; // files if( (ext && ext.length<5) || (!href.match('javascript') && !href.match(domain)) ) { link.addEvents ({ 'mousedown': function(e) { var params = this.returnParams(this.stats); var t = new Date().getTime(); var _href = ( href.split('mailto:').length > 1 ) ? href.split('mailto:')[1] : href; params += '&externe=1&page='+encodeURIComponent(_href)+'&time='+t; new Request.HTML({url: '/isens_marker.php'}).get(params); } .bind(this), 'keydown': function(e) { if(e && e.key == 'enter ') link.fireEvent('mousedown'); } .bind(this) }); } if( this.options.debug ) { link.addEvents ({ 'mouseenter': function() { // if lien contient javascript if( href.match('javascript') ) { console.log('script'); } // if lien externe else if(! href.match(domain) ) { console.log('external'); } // if fichier téléchargeable else if( ext && ext.length < 5 ) { console.log('file'); } // sinon else { console.log('internal'); } } }); } link.store('watched', true); } .bind(this) ); }, returnParams: function(stats) { var params = ''; Object.keys(stats).each ( function(key, index) { if( index > 0 ) params += '&'; params += key + '=' + stats[key]; } .bind(this) ); params += '&screen=' + screen.width + 'x' + screen.height + 'x' + screen.colorDepth; return params; } }); // variable globale isensStats var isensStats; // lanceur des stats window.addEvent('domready', function() { isensStats = new markerStats({ version: '1', page: 'ABYSS%20ANIMATION%20ET%20SERVICE' }); });