--- ../../www.virgule.info/linuxfr/1.0-beta2/toolbar.js 2005-07-29 02:35:18.000000000 +0200 +++ toolbar.js 2005-06-22 16:28:13.000000000 +0200 @@ -74,7 +74,7 @@ a.setAttribute('onclick', 'comments[' + this.index + '].toggleDisplay(); return false;'); this.display = x; - this.node.className = "comment " + (x ? "deplie" : "replie"); + this.node.className = "u-" + this.user + " comment " + (x ? "deplie" : "replie"); a.replaceChild(document.createTextNode((x ? '[-]' : '[+]')), a.firstChild); if (!h1.hasAttribute('ondblclick')) h1.setAttribute('ondblclick', 'comments[' + this.index + @@ -94,10 +94,10 @@ { // on choppe le

correspondant au commentaire var h1 = this.node.getPreviousElement(); - if (this.display) + if (1 /*this.display*/) { // on ne compte que les nouveaux commentaires au dessus du pallier, - // les autres ne sont meme pas considérés comme nouveeaux par la + // les autres ne sont meme pas considérés comme nouveaux par la // toolbar totalnew++; this.isnew = x; @@ -126,10 +126,11 @@ // Vu comment le markup est changeant par ici, on va perdre un peu en performances // et aller chercher le ala mano. Ca devrait pas etre si long - // que ca. - // Pour le futur, prévoir un truc du genre . + // que ca, vu que ca commence par la fin, et qu'il n'est pas bien loin + // TODO: optimiser ca, ou ptet prévoir un truc du genre . + // qui aurait le désavantage de demander une modif du code généré par linuxfr. - for (var i = 0; i < len; i++) + for (var i = len - 1; i >= 0; i--) { if (tmp[i].nodeType == Node.ELEMENT_NODE && tmp[i].nodeName.toLowerCase() == 'i') { @@ -185,8 +186,10 @@ comment.setScoreFromNode(); comment.setUserFromNode(); comment.setDisplay((comment.score >= threshold)); - comment.setIsNew((ts_array[outArray.length] >= gl_timestamp)); - + if (typeof ts_array != 'undefined') + comment.setIsNew((ts_array[outArray.length] >= gl_timestamp)); + else + comment.setIsNew(true); outArray.push(comment); return outArray; } @@ -300,8 +303,8 @@ // Faut le chemin en argument parceque ca peut etre appelle a differents endroits dans linuxfr function DLFPToolbar(cssPath) { - a = new Date(); - + var start = new Date(); + var end; var enableToolbar; var cssFile; var textToSet; @@ -309,7 +312,7 @@ function changeStylesheet(e) { cssFile = prompt('URL de la feuille de style?'); - if (cssFile) + if (cssFile != null && cssFile != '') applyStylesheet(cssFile, 1); return false; } @@ -317,7 +320,7 @@ function changeThreshold(e) { var newThreshold = prompt('Seuil a appliquer?'); - if (newThreshold !== false) + if (newThreshold != null && newThreshold != '') applyThreshold(newThreshold, true); return false; } @@ -363,16 +366,21 @@ var properties = getCookie('properties', '1|1|kaiska.css').split('|'); if (properties.length == 3) { - var cour = document.getElementById('csscourante'); - - if (cour) + if (cssFile) { - textToSet = cssFile; - if (textToSet.length > 20) - textToSet = '...' + textToSet.substring(textToSet.length - 20); - cour.firstChild.data = textToSet; + var cour; + + properties[2] = cssFile; + + cour = document.getElementById('csscourante'); + if (cour && cour.firstChild && cour.firstChild.data) + { + textToSet = cssFile; + if (textToSet.length > 20) + textToSet = '...' + textToSet.substring(textToSet.length - 20); + cour.firstChild.data = textToSet; + } } - properties[2] = cssFile; setCookie('properties', properties[0] + '|' + properties[1] + '|' + properties[2]); } } @@ -483,17 +491,18 @@ generateToolbar(true, true, true); // FIXME: faire des prefs pour ces 3 trucs } } - b = new Date(); - displayBenchMark(b - a); + end = new Date(); + displayBenchMark(start, end); } -function displayBenchMark(duration) +function displayBenchMark(start, end) { var span = document.getElementById('generation'); - var text = ' La toolbar a necéssité ' + duration / 100 + ' secondes pour faire son travail.'; + var text = ' La toolbar a necéssité ' + (end - start) / 1000 + ' secondes pour faire son travail.'; if (span) span.appendChild(document.createTextNode(text)); else alert(text); + } \ No newline at end of file