[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 /** 2 ** Main functions for administration of ClickHeat 3 ** 4 ** @author Yvan Taviaud - Labsmedia.com 5 ** @since 01/04/2007 6 **/ 7 8 var currentAlpha = 80; 9 var lastDayOfMonth = 0; 10 var currentDate = [0, 0, 0, 0, 0]; 11 var currentRange = 'd'; 12 var currentWidth = 0; 13 var pleaseWait = ''; 14 var cleanerRunning = ''; 15 var isJsOkay = ''; 16 var jsAdminCookie = ''; 17 var hideIframes = true; 18 var hideFlashes = true; 19 var isPmvModule = false; 20 var scriptPath = ''; 21 var scriptIndexPath = ''; 22 23 /** Returns the "top" value of an element */ 24 function getTop(obj) 25 { 26 if (obj.offsetParent != undefined) 27 { 28 return (obj.offsetTop + getTop(obj.offsetParent)); 29 } 30 else 31 { 32 return obj.offsetTop; 33 } 34 } 35 36 /** Resize the div relative to window height and selected screen size */ 37 function resizeDiv() 38 { 39 oD = document.documentElement != undefined && document.documentElement.clientHeight != 0 ? document.documentElement : document.body; 40 iH = oD.innerHeight != undefined ? oD.innerHeight : oD.clientHeight; 41 document.getElementById('overflowDiv').style.height = (iH < 300 ? 400 : iH) - getTop(document.getElementById('overflowDiv')) + 'px'; 42 /** Width of main display */ 43 iW = oD.innerWidth != undefined ? oD.innerWidth : oD.clientWidth; 44 iW = iW < 300 ? 400 : iW; 45 if (document.getElementById('formScreen').value == 0) 46 { 47 currentWidth = iW; 48 } 49 else 50 { 51 currentWidth = document.getElementById('formScreen').value - 5; 52 } 53 document.getElementById('overflowDiv').style.width = currentWidth + 'px'; 54 document.getElementById('webPageFrame').style.width = currentWidth - 25 + 'px'; 55 } 56 57 /** Update calendar selected days */ 58 function updateCalendar(day) 59 { 60 if (day != undefined) 61 { 62 currentDate[0] = day; 63 } 64 currentDate[1] = currentDate[3]; 65 currentDate[2] = currentDate[4]; 66 if (currentRange == 'd') 67 { 68 min = currentDate[0]; 69 max = currentDate[0]; 70 } 71 if (currentRange == 'm') 72 { 73 currentDate[0] = 1; 74 min = 1; 75 max = weekDays.length; 76 } 77 if (currentRange == 'w') 78 { 79 week = weekDays[currentDate[0]]; 80 min = 0; 81 max = 0; 82 for (d = 1; d < weekDays.length; d++) 83 { 84 if (weekDays[d] == week) 85 { 86 if (min == 0) 87 { 88 currentDate[0] = d; 89 min = d; 90 } 91 max = d; 92 } 93 } 94 /** Start was on the previous month */ 95 if (min == 1 && max != 7) 96 { 97 currentDate[0] = lastDayOfMonth - 6 + max; 98 currentDate[1]--; 99 if (currentDate[1] == 0) 100 { 101 currentDate[1] = 12; 102 currentDate[2]--; 103 } 104 } 105 } 106 for (d = 1; d < weekDays.length; d++) 107 { 108 document.getElementById('clickheat-calendar-' + d).className = (d >= min && d <= max ? 'clickheat-calendar-on' : ''); 109 } 110 for (i = 1; i < 7; i++) 111 { 112 if (document.getElementById('clickheat-calendar-10' + i) != undefined) 113 { 114 document.getElementById('clickheat-calendar-10' + i).className = (currentRange == 'w' && weekDays[min] == weekDays[1] ? 'clickheat-calendar-on' : ''); 115 } 116 if (document.getElementById('clickheat-calendar-11' + i) != undefined) 117 { 118 document.getElementById('clickheat-calendar-11' + i).className = (currentRange == 'w' && weekDays[max] == weekDays[weekDays.length - 1] ? 'clickheat-calendar-on' : ''); 119 } 120 } 121 document.getElementById('clickheat-calendar-d').className = (currentRange == 'd' ? 'clickheat-calendar-on' : ''); 122 document.getElementById('clickheat-calendar-w').className = (currentRange == 'w' ? 'clickheat-calendar-on' : ''); 123 document.getElementById('clickheat-calendar-m').className = (currentRange == 'm' ? 'clickheat-calendar-on' : ''); 124 updateHeatmap(); 125 } 126 127 /** Ajax object */ 128 function getXmlHttp() 129 { 130 var xmlhttp = false; 131 try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 132 catch (e) 133 { 134 try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 135 catch (oc) { xmlhttp = null; } 136 } 137 if (!xmlhttp && typeof XMLHttpRequest != undefined) xmlhttp = new XMLHttpRequest(); 138 return xmlhttp; 139 } 140 141 /** Ajax request to update PNGs */ 142 function updateHeatmap() 143 { 144 var xmlhttp; 145 document.getElementById('pngDiv').innerHTML = ' <div style="line-height:20px"><span class="error">' + pleaseWait + '</span></div>'; 146 xmlhttp = getXmlHttp(); 147 var screen = 0; 148 if (document.getElementById('formScreen').value == 0) 149 { 150 screen = -1 * currentWidth + 25; 151 } 152 else 153 { 154 screen = document.getElementById('formScreen').value; 155 } 156 xmlhttp.open('GET', scriptIndexPath + 'action=generate&group=' + document.getElementById('formGroup').value + '&screen=' + screen + '&browser=' + document.getElementById('formBrowser').value + '&date=' + currentDate[2] + '-' + currentDate[1] + '-' + currentDate[0] + '&range=' + currentRange + '&heatmap=' + (document.getElementById('formHeatmap').checked ? '1' : '0') + '&rand=' + Date(), true); 157 xmlhttp.onreadystatechange = function() 158 { 159 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 160 { 161 document.getElementById('pngDiv').innerHTML = xmlhttp.responseText.replace(/_JAVASCRIPT_/, isJsOkay); 162 document.getElementById('webPageFrame').height = document.getElementById('pngDiv').offsetHeight; 163 changeAlpha(currentAlpha); 164 } 165 } 166 xmlhttp.send(null); 167 } 168 169 /** Ajax request to show group layout */ 170 function showGroupLayout() 171 { 172 var xmlhttp; 173 xmlhttp = getXmlHttp(); 174 xmlhttp.open('GET', scriptIndexPath + 'action=layout&group=' + document.getElementById('formGroup').value + '&rand=' + Date(), true); 175 xmlhttp.onreadystatechange = function() 176 { 177 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 178 { 179 document.getElementById('layoutDiv').innerHTML = xmlhttp.responseText; 180 document.getElementById('layoutDiv').style.display = 'block'; 181 showRadioLayout(); 182 } 183 } 184 xmlhttp.send(null); 185 } 186 187 /** Ajax request to show javascript code */ 188 function showJsCode() 189 { 190 var xmlhttp; 191 xmlhttp = getXmlHttp(); 192 xmlhttp.open('GET', scriptIndexPath + 'action=javascript&rand=' + Date(), true); 193 xmlhttp.onreadystatechange = function() 194 { 195 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 196 { 197 document.getElementById('layoutDiv').innerHTML = xmlhttp.responseText; 198 document.getElementById('layoutDiv').style.display = 'block'; 199 updateJs(); 200 } 201 } 202 xmlhttp.send(null); 203 } 204 205 /** Hide group layout */ 206 function hideGroupLayout() 207 { 208 document.getElementById('layoutDiv').style.display = 'none'; 209 document.getElementById('layoutDiv').innerHTML = ''; 210 } 211 212 /** Update JS code in display */ 213 function updateJs() 214 { 215 var str = ''; 216 var language = (navigator.language !== undefined && navigator.language == 'fr' ? 'fr' : 'com'); 217 var addReturn = document.getElementById('jsShort').checked ? '' : '<br />'; 218 str += '<script type="text/javascript" src="'; 219 str += scriptPath + 'js/clickheat.js"></script>' + addReturn; 220 if (language == 'fr') 221 { 222 linkList = ['<a href="http://www.labsmedia.fr/clickheat/index.html">Analyse de trafic</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Analyse comportementale des internautes</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Analyse comportement internautes</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Outils d\'analyse d\'audience</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Carte température page web</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Analyse des clics</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Optimisation de l\'ergonomie</a>', '<a href="http://www.labsmedia.fr/clickheat/index.html">Optimisation ergonimique</a>', '<a href="http://www.labsmedia.fr/index.html">Outils marketing</a>', '<a href="http://www.labsmedia.fr/index.html">Outils webmaster</a>', '<a href="http://www.labsmedia.fr/index.html">Outils référencement</a>', '<a href="http://www.labsmedia.fr/index.html">Monétisation de contenu</a>', '<a href="http://www.labsmedia.fr/index.html">Optimisation de site</a>', '<a href="http://www.labsmedia.fr/index.html">Optimisation de trafic</a>', '<a href="http://www.labsmedia.fr/index.html">Marketing web</a>', '<a href="http://www.labsmedia.fr/index.html">Outils seo</a>', '<a href="http://www.labsmedia.fr/index.html">Outils open source</a>', '<a href="http://www.labsmedia.fr/index.html">Outils webmaster gratuits</a>', '<a href="http://www.labsmedia.fr/index.html">Outils gratuits webmaster</a>']; 223 } 224 else 225 { 226 linkList = ['<a href="http://www.labsmedia.com/clickheat/index.html">Traffic analysis</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Click analysis</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Surfer navigation analysis</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Navigational analysis</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Landing page optimization</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Ergonomy optimization</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Web design optimisation</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Heat map generator</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Open source heat map</a>', '<a href="http://www.labsmedia.com/clickheat/index.html">Open source traffic analysis</a>', '<a href="http://www.labsmedia.com/index.html">Open source tools</a>', '<a href="http://www.labsmedia.com/index.html">Webmaster tools</a>', '<a href="http://www.labsmedia.com/index.html">Marketing tools</a>', '<a href="http://www.labsmedia.com/index.html">Free marketing tools</a>', '<a href="http://www.labsmedia.com/index.html">Open source marketing tools</a>', '<a href="http://www.labsmedia.com/index.html">Seo tools</a>', '<a href="http://www.labsmedia.com/index.html">Traffic optimization</a>', '<a href="http://www.labsmedia.com/index.html">Traffic monetization</a>']; 227 } 228 if (document.getElementById('jsShowImage').checked) 229 { 230 str += '<a href="http://www.labsmedia.' + language + '/clickheat/index.html" title="ClickHeat: clicks heatmap"><img src="' + scriptPath + 'images/logo.png" width="80" height="15" border="0" alt="ClickHeat : track clicks" /></a>' + addReturn; 231 } 232 else 233 { 234 rand = Math.floor(Math.random() * linkList.length); 235 str += '<noscript>' + linkList[rand] + '</noscript>' + addReturn; 236 } 237 str += '<script type="text/javascript"><!--<br />'; 238 str += 'clickHeatSite = '; 239 /** PMV form */ 240 if (document.getElementById('form_site') != undefined) 241 { 242 str += document.getElementById('form_site').site.value.replace(/[^a-z0-9\-_\.]+/gi, '.'); 243 } 244 else 245 { 246 str += '\'<span class="error">' + document.getElementById('jsSite').value.replace(/[^a-z0-9\-_\.]+/gi, '.') + '</span>\''; 247 } 248 str += ';' + addReturn + 'clickHeatGroup = '; 249 if (document.getElementById('jsGroup1').checked) 250 { 251 str += '\'<span class="error">' + document.getElementById('jsGroup').value.replace(/[^a-z0-9\-_\.]+/gi, '.') + '</span>\''; 252 } 253 if (document.getElementById('jsGroup2').checked) 254 { 255 str += 'document.title'; 256 } 257 if (document.getElementById('jsGroup3').checked) 258 { 259 str += 'window.location.pathname'; 260 } 261 str += ';' + addReturn; 262 if (document.getElementById('jsQuota').value != 0) 263 { 264 str += 'clickHeatQuota = <span class="error">' + document.getElementById('jsQuota').value.replace(/[^0-9]*/g, '') + '</span>;' + addReturn; 265 } 266 str += 'clickHeatServer = \'' + scriptPath + 'click' + (isPmvModule == true ? 'pmv' : '') + '.php\';' + addReturn; 267 str += 'initClickHeat(); //--><br />'; 268 str += '</script>'; 269 document.getElementById('clickheat-js').innerHTML = str; 270 } 271 272 /** Show layout's parameters */ 273 function showRadioLayout() 274 { 275 for (i = 0; i < 7; i++) 276 { 277 document.getElementById('layout-span-' + i).style.display = (document.getElementById('layout-radio-' + i).checked ? 'block' : 'none'); 278 } 279 } 280 281 /** Show layout's parameters */ 282 function saveGroupLayout() 283 { 284 for (i = 0; i < 7; i++) 285 { 286 if (document.getElementById('layout-radio-' + i).checked) 287 { 288 break; 289 } 290 } 291 if (i == 7) 292 { 293 alert('Error'); 294 return false; 295 } 296 var xmlhttp; 297 xmlhttp = getXmlHttp(); 298 xmlhttp.open('GET', scriptIndexPath + 'action=layoutupdate&group=' + document.getElementById('formGroup').value + '&url=' + document.getElementById('formUrl').value + '&left=' + document.getElementById('layout-left-' + i).value + '&right=' + document.getElementById('layout-right-' + i).value + '¢er=' + document.getElementById('layout-center-' + i).value + '&rand=' + Date(), true); 299 xmlhttp.onreadystatechange = function() 300 { 301 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 302 { 303 if (xmlhttp.responseText != 'OK') 304 { 305 alert(xmlhttp.responseText); 306 } 307 hideGroupLayout(); 308 loadIframe(); 309 } 310 } 311 xmlhttp.send(null); 312 } 313 314 /** Ajax request to get associated group in iframe */ 315 function loadIframe() 316 { 317 var xmlhttp; 318 xmlhttp = getXmlHttp(); 319 xmlhttp.open('GET', scriptIndexPath + 'action=iframe&group=' + document.getElementById('formGroup').value + '&rand=' + Date(), true); 320 xmlhttp.onreadystatechange = function() 321 { 322 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 323 { 324 if (document.getElementById('webPageFrame').src.search(/clickempty\.html$/) != -1) 325 { 326 document.getElementById('webPageFrame').src = xmlhttp.responseText; 327 updateCalendar(); 328 } 329 else 330 { 331 document.getElementById('webPageFrame').src = xmlhttp.responseText; 332 updateHeatmap(); 333 } 334 } 335 } 336 xmlhttp.send(null); 337 } 338 339 /** Hide iframe's flashes and iframes */ 340 function cleanIframe() 341 { 342 if (document.getElementById('webPageFrame').src.search(/clickempty\.html$/) != -1) 343 { 344 return true; 345 } 346 if (hideIframes == false && hideFlashes == false) 347 { 348 return true; 349 } 350 try 351 { 352 var currentIframe = document.getElementById('webPageFrame'); 353 if (currentIframe.contentDocument) 354 { 355 currentIframeContent = currentIframe.contentDocument; 356 } 357 else if (currentIframe.Document) 358 { 359 currentIframeContent = currentIframe.Document; 360 } 361 /** Hide iframes and flashes content */ 362 if (currentIframeContent == undefined) 363 { 364 return false; 365 } 366 newContent = currentIframeContent.body.innerHTML; 367 oldPos = 0; 368 if (hideIframes == false) 369 { 370 reg = 'object'; 371 } 372 else 373 { 374 if (hideFlashes == false) 375 { 376 reg = 'iframe'; 377 } 378 else 379 { 380 reg = 'object|iframe'; 381 } 382 } 383 startReg = new RegExp('<(' + reg + ')', 'i'); 384 endReg = new RegExp('<\/(' + reg + ')', 'i'); 385 while (true) 386 { 387 pos = newContent.search(startReg); 388 pos2 = newContent.search(endReg); 389 if (pos == -1 || pos2 == -1 || pos == oldPos || pos > pos2) break; 390 pos2 += 9; 391 found = newContent.substring(pos, pos2); 392 width = found.match(/width=[^0-9]*(\d+)/); 393 if (width == null) width = [0, 300]; 394 height = found.match(/height=[^0-9]*(\d+)/); 395 if (height == null) height = [0, 150]; 396 newContent = newContent.substring(0, pos) + '<span style="margin:0; padding:' + Math.ceil(height[1] / 2) + 'px ' + Math.ceil(width[1] / 2) + 'px; line-height:' + (height[1] * 1 + 10) + 'px; border:1px solid #f00; background-color:#faa; font-size:0;"> </span> test' + newContent.substring(pos2, newContent.length); 397 oldPos = pos; 398 } 399 currentIframeContent.body.innerHTML = newContent; 400 } 401 catch(e) {} 402 } 403 404 /** Draw alpha selector */ 405 function drawAlphaSelector(obj, max) 406 { 407 var str = ''; 408 for (i = 0; i < max; i++) 409 { 410 grey = 255 - Math.ceil(i * 255 / max); 411 alpha = Math.ceil(i * 100 / max); 412 str += '<a href="#" id="alpha-level-' + alpha + '" onclick="changeAlpha(' + alpha + '); this.blur(); return false;" style="font-size:12px; border-top:1px solid #888; border-bottom:1px solid #888;' + (i == 0 ? ' border-left:1px solid #888;' : '') + '' + (i == max - 1 ? ' border-right:1px solid #888;' : '') + ' text-decoration:none; background-color:rgb(' + grey + ',' + grey + ',' + grey + ');"> </a>'; 413 } 414 document.getElementById(obj).innerHTML = str; 415 /** Check that currentAlpha exists */ 416 while (document.getElementById('alpha-level-' + currentAlpha) == undefined) 417 { 418 currentAlpha--; 419 } 420 } 421 422 /** Change Alpha on heatmap */ 423 function changeAlpha(alpha) 424 { 425 document.getElementById('alpha-level-' + currentAlpha).style.borderTop = '1px solid #888'; 426 document.getElementById('alpha-level-' + currentAlpha).style.borderBottom = '1px solid #888'; 427 currentAlpha = alpha; 428 document.getElementById('alpha-level-' + currentAlpha).style.borderTop = '2px solid #55b'; 429 document.getElementById('alpha-level-' + currentAlpha).style.borderBottom = '2px solid #55b'; 430 for (i = 0; i < document.images.length; i++) 431 { 432 if (document.images[i].id.search(/^heatmap-\d+$/) == 0) 433 { 434 document.images[i].style.opacity = alpha / 100; 435 if (document.body.filters != undefined) 436 { 437 document.images[i].style.filter = 'alpha(opacity:' + alpha + ')'; 438 } 439 } 440 } 441 } 442 443 /** Ajax request to show javascript code */ 444 function runCleaner() 445 { 446 document.getElementById('cleaner').innerHTML = cleanerRunning; 447 var xmlhttp; 448 xmlhttp = getXmlHttp(); 449 xmlhttp.open('GET', scriptIndexPath + 'action=cleaner&rand=' + Date(), true); 450 xmlhttp.onreadystatechange = function() 451 { 452 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 453 { 454 if (xmlhttp.responseText == 'OK') 455 { 456 document.getElementById('cleaner').innerHTML = ''; 457 } 458 else 459 { 460 document.getElementById('cleaner').innerHTML = xmlhttp.responseText; 461 setTimeout("document.getElementById('cleaner').innerHTML = '';", 10000); 462 } 463 } 464 } 465 xmlhttp.send(null); 466 } 467 468 /** Ajax request to show latest available version */ 469 function showLatestVersion() 470 { 471 var xmlhttp; 472 xmlhttp = getXmlHttp(); 473 xmlhttp.open('GET', scriptIndexPath + 'action=latest&rand=' + Date(), true); 474 xmlhttp.onreadystatechange = function() 475 { 476 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 477 { 478 document.getElementById('layoutDiv').innerHTML = xmlhttp.responseText; 479 document.getElementById('layoutDiv').style.display = 'block'; 480 showRadioLayout(); 481 } 482 } 483 xmlhttp.send(null); 484 } 485 486 /** Shows main panel */ 487 function showPanel() 488 { 489 var div = isPmvModule ? 'contenu' : 'adminPanel'; 490 if (document.getElementById(div).style.display != 'none') 491 { 492 return true; 493 } 494 if (isPmvModule) 495 { 496 document.getElementById('loggued').style.display = 'block'; 497 } 498 document.getElementById(div).style.display = 'block'; 499 document.getElementById('divPanel').innerHTML = '<img src="' + scriptPath + 'images/arrow-up.png" width="11" height="6" alt="" />'; 500 resizeDiv(); 501 } 502 /** Hides main panel */ 503 function hidePanel() 504 { 505 var div = isPmvModule ? 'contenu' : 'adminPanel'; 506 if (isPmvModule) 507 { 508 document.getElementById('loggued').style.display = 'none'; 509 } 510 document.getElementById(div).style.display = 'none'; 511 document.getElementById('divPanel').innerHTML = '<img src="' + scriptPath + 'images/arrow-down.png" width="11" height="6" alt="" />'; 512 resizeDiv(); 513 } 514 515 /** Reverse the state of the admin cookie (used not to log the clicks for admin user) */ 516 function adminCookie() 517 { 518 if (confirm(jsAdminCookie)) 519 { 520 document.cookie = 'clickheat-admin=; expires=Fri, 27 Jul 2001 01:00:00 UTC; path=/'; 521 } 522 else 523 { 524 var date = new Date(); 525 date.setTime(date.getTime() + 365 * 86400 * 1000); 526 document.cookie = 'clickheat-admin=1; expires=' + date.toGMTString() + '; path=/'; 527 } 528 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |