Voici mon problème , sur un site ou je suis développeur , j'ai depuis quelques version de firefox un problème récurant pour mes utilisateurs :
C'est un chat multi chanel , mixé entre php et javascript organisé en onglet , le problème , c'est que depuis la version 2.5 ou 3 , la fermeture d'un onglet entraine le plantage du chat ( plus rien d'affiché dans l'onglet restant et il faut refresh la page )
Je tiens à préciser que sur google chrome il ne marche plus du tout et sur IE il marche parfaitement ( les onglets se cloturent sans entrainer de plantage )
voici le code js du chat, merci d'avance :
Code : Tout sélectionner
/* Init of xmlHTTP object */
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
var menu;
var master;
var status;
var onglets;
var form;
var fenetre;
var connectes;
var call_menu;
var call_smiley;
var select;
var textarea;
var message;
var smileys;
var saveBG;
var saveBG2;
var pageTitle;
var debug;
var debugActive=false;
var pict;
var capital;
var nbConn=0;
var nbInvis=0;
/* Layout */
var widthConnect=160;
var HeightTop=25;
var HeightTextArea=50;
var HeightOnglets=25;
var contentPadding=4;
/* Status Vars */
var currentChannel=-255;
var newChannel=-255;
var fullChannel=-255;
var beforeId=0;
var alerts=[];
var currentChannels=[];
currentChannels[0]='0';
var channelCache=[];
var currentDate=[];
var timeOut;
var decoTimeOut;
var autoRecoTime=15000;
var maxRecoAttempt=5;
var updateInterval=2500;
var recoAttempt=0;
var mustSend=false;
var image=[];
/* Content Datas */
var contentCache=[];
var contentInput=[];
var archiveInput=[];
function parch_init(){
pageTitle=document.title;
if (design=="V1"){
connectes=document.getElementById('conn');
smileys=document.getElementById('smileys');
capital=document.getElementById('capital');
var image, spacer;
for (var i=0;i<listSmileys.length;i++){
image=document.createElement('img');
image.src='http://images.projet-ivy.net'+listSmileys[i][1];
image.title=listSmileys[i][0];
image.alt=listSmileys[i][0];
image.style.cursor="pointer";
image.onclick=function(){emoticon(this.title);};
smileys.appendChild(image);
spacer=document.createTextNode(" ");
smileys.appendChild(spacer);
}
/* Debug */
debug=document.createElement("div");
debug.style.width='400px';
debug.onclick=function(){ this.parentNode.removeChild(this); debugActive=false;}
/* Image */
pict=document.createElement('img');
pict.style.width='50px';
fenetre=document.getElementById('parcheminmessages');
textarea=document.getElementById('message');
onglets=document.getElementById('onglets');
message=textarea;
master=document.getElementsByTagName('body')[0];
status=onglets;
createSphereDropDown();
textarea.onkeypress=textAreaKeyPress;
document.onkeydown=giveTextareaFocus;
master.onmouseover=restoreTitle;
}
/* DESIGN V2 */
else if (design=="V2"){
menu=document.getElementById('menuleft');
menu.style.width="150px";
/* Preparing Smileys */
smileys=document.createElement('div');
smileys.style.width="250px";
smileys.className="box";
var image, spacer;
for (var i=0;i<listSmileys.length;i++){
image=document.createElement('img');
image.src='http://images.projet-ivy.net'+listSmileys[i][1];
image.title=listSmileys[i][0];
image.alt=listSmileys[i][0];
image.style.cursor="pointer";
image.onclick=function(){emoticon(this.title);};
image.style.height="18px";
smileys.appendChild(image);
spacer=document.createTextNode(" ");
smileys.appendChild(spacer);
}
/* Cleaning Document */
var body=document.getElementsByTagName('body')[0];
var winWidth, winHeight;
/* Getting Width */
if(typeof window.innerWidth != "undefined") {
winWidth = window.innerWidth;
}
else if(typeof document.documentElement.offsetWidth != "undefined") {
winWidth = document.documentElement.offsetWidth ;
}
else {
winWidth = document.body.offsetWidth ;
}
/* Getting Height */
if(typeof window.innerHeight != "undefined") {
winHeight = window.innerHeight;
}
else if(typeof document.documentElement.offsetHeight != "undefined") {
winHeight = document.documentElement.offsetHeight ;
}
else {
winHeight = document.body.offsetHeight ;
}
document.onkeydown=giveTextareaFocus;
master=document.createElement('div');
body.appendChild(master);
body.style.marginTop="0px";
body.style.marginBottom="0px";
master.style.width=winWidth+"px";
master.style.height=winHeight+"px";
master.className="box";
master.style.border="0px";
master.style.padding="0px";
master.style.margin="0px";
master.onmouseover=restoreTitle;
while (body.childNodes.length>1){
body.removeChild(body.childNodes[0]);
}
/* Image */
pict=document.createElement('img');
pict.style.width='50px';
/* Status Bar */
status=document.createElement('div');
status.style.height=HeightTop + "px";
status.id="parcheminStatus";
status.style.borderBottom="1px solid #000";
master.appendChild(status);
/* Add Float Left MENU */
call_menu=document.createElement('span');
var tmp_content=document.createTextNode('Afficher le menu');
call_menu.appendChild(tmp_content);
call_menu.style.cursor='pointer';
call_menu.onclick=show_menu;
status.appendChild(call_menu);
/* Debug */
debug=document.createElement("div");
debug.style.width='400px';
debug.onclick=function(){ this.parentNode.removeChild(this); debugActive=false;}
/* Menu déroulant sphères */
createSphereDropDown();
/* Connectés */
connectes=document.createElement('div');
connectes.style.height=winHeight - (HeightTop + HeightTextArea + HeightOnglets +3) + "px";
connectes.id="parcheminConnectes";
connectes.style.borderBottom="1px solid #000";
connectes.style.borderLeft="1px solid #000";
connectes.style.width= widthConnect +"px";
connectes.style.overflow="hidden";
connectes.style.position="absolute";
connectes.style.right="0px";
master.appendChild(connectes);
/* Fenetre */
fenetre=document.createElement('div');
fenetre.style.height=winHeight - (HeightTop + HeightTextArea + HeightOnglets + 3 + contentPadding*2) + "px";
fenetre.id="parcheminContent";
fenetre.style.borderBottom="1px solid #000";
fenetre.style.overflow="auto";
fenetre.style.marginRight=(widthConnect + 1)+"px";
fenetre.style.padding=contentPadding + "px";
capital=document.createElement('div');
capital.style.backgroundColor="#800";
capital.style.position="absolute";
capital.style.top=HeightTop+"px";
capital.style.right=(widthConnect + 20)+"px";
capital.style.color="#FFF";
master.appendChild(capital);
master.appendChild(fenetre);
/* Onglets */
onglets=document.createElement('div');
onglets.style.height=HeightOnglets +"px";
onglets.id="parcheminOnglets";
onglets.style.borderBottom="1px solid #000";
master.appendChild(onglets);
/* Add Float Left MENU */
call_smiley=document.createElement('span');
tmp_content=document.createElement('img');
tmp_content.src="http://images.projet-ivy.net/yahoo/yb61.gif";
call_smiley.appendChild(tmp_content);
call_smiley.style.cursor='pointer';
call_smiley.style.border='1px solid';
call_smiley.style.padding='1px';
call_smiley.style.marginLeft='5px';
call_smiley.style.marginRight='10px';
call_smiley.onclick=show_smiley;
onglets.appendChild(call_smiley);
/* Form */
form=document.createElement('div');
form.style.height=HeightTextArea + "px";
form.style.display="inline";
form.id="parcheminForm";
textarea=document.createElement('textarea');
textarea.id="message";
textarea.style.height=(HeightTextArea - 5) +"px";
textarea.style.border="0px";
textarea.style.margin="0px";
textarea.style.padding="0px";
textarea.style.width= "100%";
textarea.style.paddingLeft=contentPadding + "px";
textarea.style.paddingRight=contentPadding + "px";
textarea.style.width= ( winWidth - 2*contentPadding ) +"px";
textarea.onkeypress=textAreaKeyPress;
form.appendChild(textarea);
master.appendChild(form);
window.onresize=resizeWindow;
}/* END DESIGN V2 */
/* Joining Basic Channel */
joinChannel();
update();
giveTextareaFocus();
message=textarea;
if (document.recalc){
document.recalc();
}
}
function showPict(e){
var mX, mY;
if (!window.event) {
mX = e.pageX;
mY = e.pageY;
} else {
mX = window.event.clientX;
mY = window.event.clientY;
}
pict.src="http://micro.projet-ivy.net/"+this.title;
pict.style.position="absolute";
pict.style.top=mY+"px";
if (design=="V2"){
pict.style.right=widthConnect+"px";
} else {
pict.style.left=(mX + 50)+"px";
}
master.appendChild(pict);
this.alt=this.title;
this.title="";
return false;
}
function hidePict(e){
master.removeChild(pict);
this.title=this.alt;
}
function giveTextareaFocus(){
document.title=pageTitle;
textarea.focus();
}
function restoreTitle(){
document.title=pageTitle;
}
function sendParchemin(){
mustSend=false;
window.clearTimeout(timeOut);
var text=textarea.value;
if (text.length<1){
return;
}
var fragment_url="/chat.ajx?";
for (var i=0;i<currentChannels.length;i++){
fragment_url+="sphere[]="+currentChannels[i]+"&";
}
if (newChannel!=-255){
currentChannels.push(newChannel);
fragment_url+="new_sphere="+newChannel;
newChannel=-255;
}
appendDebug(" POST > "+fragment_url);
if (xmlhttp.readyState!=4 && xmlhttp.readyState!=0){
mustSend=true;
return false;
}
xmlhttp.open("POST", fragment_url);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf8');
xmlhttp.onreadystatechange = handleSendParchemin;
decoTimeOut=window.setTimeout("autoReco();",autoRecoTime);
xmlhttp.send("message="+encodeURIComponent(text)+"¤tSphere="+encodeURIComponent(currentChannel));
textarea.value="";
return true;
}
function handleSendParchemin() {
if (xmlhttp.readyState == 4) {
window.clearTimeout(decoTimeOut);
if (xmlhttp.status==200) {
appendDebug(" POST <" + xmlhttp.responseText);
eval(xmlhttp.responseText);
window.clearTimeout(decoTimeOut);
if (mustSend){
sendParchemin();
return;
}
recoAttempt--;
timeOut=window.setTimeout("update();",updateInterval);
return;
}
window.clearTimeout(decoTimeOut);
setError();
}
};
function appendDebug(text){
if (debugActive){
var date=new Date();
var tmp=document.createTextNode(date.toString()+" : "+text);
debug.appendChild(tmp);
debug.appendChild(document.createElement('br'))
debug.scrollTop=1000000;
}
}
function textAreaKeyPress(e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
if (textarea.value=="!debug"){
textarea.value="";
//show_debug();
return false;
} else if (textarea.value=="!clear"){
textarea.value="";
while(debug.childNodes.length>0){
debug.removeChild(debug.firstChild);
}
return false;
} else if (textarea.value=="!pause"){
textarea.value="";
setError();
return false;
} else if (textarea.value=="!reco"){
textarea.value="";
setError();
removeError();
return false;
}
sendParchemin();
return false;
}else
return true;
}
function resizeWindow(){
var winHeight,winWidth;
/* Getting Width */
if(typeof window.innerWidth != "undefined") {
winWidth = window.innerWidth;
}
else if(typeof document.documentElement.offsetWidth != "undefined") {
winWidth = document.documentElement.offsetWidth;
}
else {
winWidth = document.body.offsetWidth;
}
/* Getting Height */
if(typeof window.innerHeight != "undefined") {
winHeight = window.innerHeight;
}
else if(typeof document.documentElement.offsetHeight != "undefined") {
winHeight = document.documentElement.offsetHeight;
}
else {
winHeight = document.body.offsetHeight;
}
master.style.width=winWidth+"px";
master.style.height=winHeight+"px";
textarea.style.width= ( winWidth - 2*contentPadding ) +"px";
fenetre.style.height=winHeight - (HeightTop + HeightTextArea + HeightOnglets + 3 + contentPadding*2) + "px";
connectes.style.height=winHeight - (HeightTop + HeightTextArea + HeightOnglets +3) + "px";
}
function buildPictName(id,pictId,pictExt){
var pictName=id+"_"+pictId+"."+pictExt;
var dirName="/"+pictName.substring(0,1)+"/"+pictName.substring(1,3)+"/";
return dirName+pictName;
}
function preload_pict(pict_name){
var image=new Image();
image.src=pict_name;
}
function listConnectes(){
capital.innerHTML="Capital : "+capitalCourant+" écus ";
capital.innerHTML+=" | Tarif : " + ((currentChannel!=-1)?(basePrice):(basePrice + 2))+ " écus";
while(connectes.childNodes.length>0){
connectes.removeChild(connectes.childNodes[0]);
}
var new_connecte=document.createElement('h4');
var text=document.createTextNode('Connectes');
new_connecte.style.textAlign='center';
new_connecte.appendChild(text);
connectes.appendChild(new_connecte);
nbConn=0;
nbInvis=0;
for (var i=0;i<list_conn.length;i++){
if (list_conn[i][2]==currentChannel){
nbConn++;
if (list_conn[i][3]==1 && !showInvis){
nbInvis++;
}else {
new_connecte=document.createElement('a');
new_connecte.href="fiche.php?id="+list_conn[i][0];
new_connecte.title=buildPictName(list_conn[i][0],list_conn[i][4],list_conn[i][5]);
preload_pict("http://micro.projet-ivy.net/"+new_connecte.title);
new_connecte.onmouseover=showPict;
new_connecte.onmouseout=hidePict;
if (list_conn[i][6]==1){
new_connecte.style.fontStyle='italic';
}
text=document.createTextNode(list_conn[i][1] + " - " + list_conn[i][0]);
new_connecte.appendChild(text);
new_connecte.style.display='block';
new_connecte.style.textAlign='center';
if (list_conn[i][3]==1){
new_connecte.style.fontWeight='bold';
nbInvis++;
}
connectes.appendChild(new_connecte);
}
}
}
new_connecte=document.createElement('h4');
text=document.createTextNode(nbConn+' Connectés - '+nbInvis+' Invis');
new_connecte.style.textAlign='center';
new_connecte.appendChild(text);
connectes.appendChild(new_connecte);
}
function update(){
window.clearTimeout(timeOut);
var multiplicator=1;
var fragment_url="/chat.ajx?";
for (var i=0;i<currentChannels.length;i++){
fragment_url+="sphere[]="+currentChannels[i]+"&";
}
if (fullChannel!=-255){
fragment_url+="new_sphere="+fullChannel+"&full&archive_end="+beforeId;
fullChannel=-255;
multiplicator=10;
}
else if (newChannel!=-255){
currentChannels.push(newChannel);
fragment_url+="new_sphere="+newChannel;
newChannel=-255;
}
appendDebug("GET > "+fragment_url);
if (xmlhttp.readyState!=0 && xmlhttp.readyState!=4){
return;
}
xmlhttp.open("GET", fragment_url);
xmlhttp.onreadystatechange =handleUpdate;
decoTimeOut=window.setTimeout("autoReco();",autoRecoTime * multiplicator);
xmlhttp.send(null);
}
function handleUpdate() {
if (xmlhttp.readyState==4) {
appendDebug(" <"+xmlhttp.responseText);
if (xmlhttp.status==200) {
appendDebug(" <"+xmlhttp.responseText);
eval(xmlhttp.responseText);
window.clearTimeout(decoTimeOut);
timeOut=window.setTimeout("update();",updateInterval);
if (mustSend){
sendParchemin();
}
recoAttempt--;
return;
} else {
window.clearTimeout(decoTimeOut);
setError();
}
}
}
function refreshOnglets(){
var currentId;
for (var i=1;i<onglets.childNodes.length;i++){
if (onglets.childNodes[i].id){
currentId=parseInt(onglets.childNodes[i].id.replace(/[^0-9-]/gi,''));
if (alerts[currentId]){
if (onglets.childNodes[i].style){
onglets.childNodes[i].style.backgroundColor="orange";
}
}
}
}
}
function appendData(){
var working, p;
var nbLines=0;
while (contentCache[currentChannel].length>0 && nbLines<50){
working=contentCache[currentChannel].shift();
p=displayLine(working);
if (design=="V2"){
channelCache[currentChannel].appendChild(p);
} else if (design=="V1"){
channelCache[currentChannel].insertBefore(p,channelCache[currentChannel].firstChild);
}
var y=p.y ? p.y : p.offsetTop;
fenetre.scrollTop=y;
nbLines++;
}
if (contentCache[currentChannel].length>0){
appendDebug('Traitement par Bloc');
window.setTimeout("appendData();",50);
}
}
function displayLine(working){
var p, a, text, time, date, content, b, h4;
var day, month, year, h, m, s, purge;
p=document.createElement('p');
p.id="phrase_" + working[5];
if (working[6]==userId){
p.className="SelfUser";
}
a=document.createElement('a');
a.href="fiche.php?id=" + working[6];
a.style.fontWeight="bold";
text=document.createTextNode(working[1]);
a.appendChild(text);
date=new Date();
date.setTime(working[0]*1000);
day=date.getDate();
month=date.getMonth();
year=date.getFullYear();
h=date.getHours();
m=date.getMinutes();
s=date.getSeconds();
if (currentDate[currentChannel].getDate()!=day || currentDate[currentChannel].getMonth()!=month || currentDate[currentChannel].getFullYear()!=year){
h4=document.createElement('h4');
time=document.createTextNode('Messages du '+day+'/'+(month+1)+'/'+year);
h4.appendChild(time);
if (design=="V2"){
p.appendChild(h4);
} else if (design=="V1"){
p.insertBefore(h4,p.firstChild);
}
h4=document.createElement('hr');
if (design=="V2"){
p.appendChild(h4);
} else if (design=="V1"){
p.insertBefore(h4,p.firstChild);
}
}
currentDate[currentChannel].setFullYear(year,month,day);
time=document.createTextNode(h+(s?(':'+(m<10?("0"+m):m)+':'+(s<10?("0"+s):s)):(':'+(m<10?("0"+m):m))));
content=document.createElement("span");
content.innerHTML=bbcode(" "+working[2]);
if(userId==11927)
{
purge=document.createElement('a');
purge.href="purgeparcho.php?id="+working[5];
text=document.createTextNode("[Purge]");
purge.appendChild(text);
p.appendChild(purge);
}
switch(working[3]){
case 0: /* Normal */
p.appendChild(a);
text=document.createTextNode(" - ");
p.appendChild(text);
p.appendChild(time);
text=document.createTextNode("> ");
p.appendChild(text);
p.appendChild(content);
break;
case 1: /* /me */
text=document.createTextNode(" @ ");
p.appendChild(text);
p.style.fontStyle="italic";
p.appendChild(time);
b=document.createElement("B");
text=document.createTextNode(" * ");
b.appendChild(text);
p.appendChild(b);
b.appendChild(a);
p.appendChild(content);
b=document.createElement("B");
p.appendChild(b);
text=document.createTextNode(" * ");
b.appendChild(text);
break;
case 2: /* WALL */
b=document.createElement("B");
text=document.createTextNode(" [Annonce Globale] : ");
b.appendChild(text);
p.appendChild(b);
p.appendChild(a);
text=document.createTextNode(" - ");
p.appendChild(text);
p.appendChild(time);
text=document.createTextNode("> ");
p.appendChild(text);
p.appendChild(content);
break;
case 3: /* You Got New Mail */
a=document.createElement("a");
a.href="/desktop.php";
b=document.createElement("H4");
b.appendChild(a);
a.appendChild(content);
p.appendChild(b);
break;
case 4: /* /roll */
b=document.createElement("B");
p.appendChild(b);
b.appendChild(a);
text=document.createTextNode(" lance les dés ");
b.appendChild(text);
p.appendChild(content);
b=document.createElement("B");
p.appendChild(b);
break;
}
return p;
}
function prepareTextElements(){
var tmp;
var current_element;
var count=0;
if (tmp_message.length>1){
tmp=tmp_message.pop();
contentInput=contentInput.concat(tmp_message);
tmp_message=[];
}
if (contentInput.length>0){
document.title="Nouveaux Messages";
do{
current_element=contentInput.shift();
if (current_element[4]==0){
current_element[4]=currentChannel;
}
if (current_element[4]!=currentChannel)
{
alerts[current_element[4]]=true;
if (tmp=document.getElementById('onglet_'+current_element[4]))
tmp.style.backgroundColor='orange';
}
contentCache[current_element[4]].push(current_element);
count++;
}while (contentInput.length>1 && count<50)
}
if (contentInput.length>0){
appendDebug('Prepare par Blocs');
window.setTimeout('prepareTextElements();',150);
} else {
appendData();
refreshOnglets();
}
}
function preparePrependTextElements(){
var tmp;
var current_element;
var p;
var count=0;
if (prepend_message.length>1){
tmp=prepend_message.pop();
archiveInput=archiveInput.concat(prepend_message);
prepend_message=[];
}
if (archiveInput.length>0){
document.title="Archives Chargées";
do{
current_element=archiveInput.shift();
if (current_element[4]==0){
current_element[4]=currentChannel;
}
p=displayLine(current_element);
/* Appending */
if (design=="V2"){
channelCache[current_element[4]].insertBefore(p,channelCache[currentChannel].childNodes[1]);
} else if (design=="V1"){
channelCache[current_element[4]].insertBefore(p,channelCache[currentChannel].childNodes[channelCache[currentChannel].childNodes.length-2]);
}
}while (archiveInput.length>1 && count<50)
}
if (archiveInput.length>0){
appendDebug('Prepare Prepend par Blocs');
window.setTimeout('preparePrependTextElements();',150);
} else {
// appendData();
// refreshOnglets();
}
}
function autoReco(){
recoAttempt=Math.max(recoAttempt,0);
appendDebug('Reconnexion automatique');
if (recoAttempt<maxRecoAttempt){
xmlhttp.abort();
recoAttempt++;
update();
} else {
setError();
}
}
function setError(){
var tmp=document.createElement('div');
var tmpText=document.createTextNode('Erreur de connexion, cliquez ici pour vous reconnecter');
appendDebug("Erreur");
xmlhttp.abort();
tmp.id="Error";
tmp.appendChild(tmpText);
tmp.style.position="absolute";
tmp.style.backgroundColor="#DD0000";
tmp.style.top="0px";
tmp.style.right="0px";
tmp.onclick=removeError;
status.appendChild(tmp);
window.clearTimeout(timeOut);
}
function login_timeout(){
setError();
alert("Vous avez été déconnecté d'ivy, veuillez vous reconnecter.");
window.location.href="/login.php";
}
function removeError(){
update();
appendDebug("Reconnexion");
if (this.parentNode){
this.parentNode.removeChild(this);
}else {
var element=document.getElementById('Error');
element.parentNode.removeChild(element);
}
}
function createSphereDropDown(){
select=document.createElement('select');
for (var i=0;i<list_spheres.length;i++){
select.options[select.options.length]=new Option(list_spheres[i][1],list_spheres[i][0]);
if (list_spheres[i][0]==sphere){
select.selectedIndex=select.options.length - 1;
}
}
select.style.cssFloat='right';
select.style.position='absolute';
select.style.right='5px';
select.style.top='2px';
select.onchange=joinChannel;
status.appendChild(select);
}
function joinChannel(){
var channelLabel=select.options[select.selectedIndex].text;
var channelId=select.options[select.selectedIndex].value;
var onglet;
if (onglet=document.getElementById('onglet_'+channelId)){
focusChannel(channelId);
} else {
createChannel(channelId,channelLabel);
newChannel=channelId;
}
}
function createChannel(channelId,channelLabel){
/* Creation Onglet */
var new_onglet=document.createElement('span');
new_onglet.id='onglet_'+channelId;
var close=document.createElement('span');
var text_content=document.createTextNode('x');
close.appendChild(text_content);
close.style.padding='1px';
close.style.border='1px solid';
close.style.cursor='pointer';
close.style.marginLeft='5px';
close.onmouseover=turnRed;
close.onmouseout=restoreBG;
close.onclick=closeChannel;
text_content=document.createTextNode(channelLabel);
new_onglet.appendChild(text_content);
new_onglet.style.width='130px';
new_onglet.style.border='1px solid';
new_onglet.style.cursor='pointer';
new_onglet.style.marginRight='3px';
new_onglet.onclick=ongletFocus;
new_onglet.onmouseover=turnDarkGreen;
new_onglet.onmouseout=restoreBG2;
new_onglet.appendChild(close);
onglets.appendChild(new_onglet);
channelCache[channelId]=document.createElement('div');
var a=document.createElement("a");
text_content=document.createTextNode('afficher les archives (peut prendre du temps)');
a.appendChild(text_content);
a.onclick=needArchive;
channelCache[channelId].appendChild(a);
a=document.createElement('br');
channelCache[channelId].appendChild(a);
currentDate[channelId]=new Date();
currentDate[channelId].setFullYear(1970,1,1);
contentCache[channelId]=[];
/* Fin Creation Onglet */
focusChannel(channelId);
}
function needArchive(){
fullChannel=currentChannel;
for (var i=0;i<channelCache[currentChannel].childNodes.length;i++){
if (design=="V2"){
if (channelCache[currentChannel].childNodes[i].id){
beforeId=parseInt(channelCache[currentChannel].childNodes[i].id.replace(/[^0-9]/gi,''));
break;
}
} else {
if (channelCache[currentChannel].childNodes[channelCache[currentChannel].childNodes.length-i-1].id){
beforeId=parseInt(channelCache[currentChannel].childNodes[channelCache[currentChannel].childNodes.length-i-1].id.replace(/[^0-9]/gi,''));
break;
}
}
}
update();
return false;
}
function turnRed(){
saveBG=this.style.backgroundColor;
this.style.backgroundColor='#800';
}
function turnDarkGreen(){
saveBG2=this.style.backgroundColor;
this.style.backgroundColor='#0B0';
}
function restoreBG(){
this.style.backgroundColor=saveBG;
}
function restoreBG2(){
this.style.backgroundColor=saveBG2;
}
function ongletFocus(){
var channelId=this.id.replace(/[^0-9-]/g,'');
channelId=parseInt(channelId);
focusChannel(channelId);
listConnectes();
}
function focusChannel(channelId){
appendDebug('Focussing Channel '+channelId+' From '+currentChannel);
if (currentChannel!=-255){
fenetre.removeChild(fenetre.firstChild);
}
currentChannel=channelId;
fenetre.appendChild(channelCache[channelId]);
for (var i=1;i<onglets.childNodes.length;i++){
if (onglets.childNodes[i].style){
onglets.childNodes[i].style.backgroundColor="";
}
}
saveBG="";
saveBG2="green";
var onglet=document.getElementById('onglet_'+channelId);
onglet.style.backgroundColor="green";
alerts[channelId]=false;
appendData();
var y=0;
var p;
if (p=channelCache[currentChannel].lastNode)
{
var y=p.y ? p.y : p.offsetTop;
}
fenetre.scrollTop=Math.max(y,1000000);
refreshOnglets();
appendDebug('End Focus Channel');
}
function closeChannel(){
var channelId=this.parentNode.id.replace(/[^0-9-]/g,'');
channelId=parseInt(channelId);
channelCache[channelId]=null;
contentCache[channelId]=[];
var onglet=document.getElementById('onglet_'+channelId);
onglets.removeChild(onglet);
var tmpChannels=[];
for (var i=0;i<currentChannels.length;i++){
if (currentChannels[i]!=channelId){
tmpChannels.push(currentChannels[i]);
}
}
currentChannels=tmpChannels;
if (channelId==currentChannel){
if (onglets.childNodes.length>1){
for (i=1;i<onglets.childNodes.length;i++){
if (onglets.childNodes[i].id){
break;
}
}
channelId=onglets.childNodes[i].id.replace(/[^0-9-]/g,'');
channelId=parseInt(channelId);
focusChannel(channelId);
}
}
if (onglets.childNodes.length==1){
currentChannel=-255;
}
}
function show_menu(){
menu.style.position="absolute";
menu.style.top="15px";
menu.style.left="5px";
master.appendChild(menu);
var tmp_content=document.createTextNode('Masquer le menu');
call_menu.removeChild(call_menu.childNodes[0]);
call_menu.appendChild(tmp_content);
call_menu.onclick=hide_menu;
}
function hide_menu(){
master.removeChild(menu);
var tmp_content=document.createTextNode('Afficher le menu');
call_menu.removeChild(call_menu.childNodes[0]);
call_menu.appendChild(tmp_content);
call_menu.onclick=show_menu;
}
function show_smiley(){
call_smiley.onclick=hide_smiley;
smileys.style.position="absolute";
smileys.style.bottom=(HeightTextArea + HeightOnglets) + "px";
smileys.style.left="5px";
master.appendChild(smileys);
call_smiley.removeChild(call_smiley.childNodes[0]);
tmp_content=document.createElement('img');
tmp_content.src="http://images.projet-ivy.net/yahoo/yb61.gif";
call_smiley.appendChild(tmp_content);
call_smiley.style.cursor="pointer";
}
function hide_smiley(){
call_smiley.onclick=show_smiley;
call_smiley.removeChild(call_smiley.childNodes[0]);
tmp_content=document.createElement('img');
tmp_content.src="http://images.projet-ivy.net/yahoo/yb61.gif";
call_smiley.appendChild(tmp_content);
master.removeChild(smileys);
}
function show_debug(){
debugActive=true;
debug.style.position="absolute";
debug.style.top="15px";
debug.className="box";
debug.style.height="400px";
debug.style.overflow="auto";
debug.style.right="5px";
master.appendChild(debug);
}
function BBWave(message,param){
var size=param.split(":");
var min=Math.max(parseInt(size[0]),5);
var max=Math.min(parseInt(size[1]),32);
if (min==max)
{
return message;
}
if (min>max){
var tmp=min;
min=max;
max=tmp;
}
var out="";
var size=min;
var mounting=true;
var curChar;
for (i=0;i<message.length;i++){
if (message.substr(i,1)=='&'){
curChar=message.substr(i,1);
i++;
while (message.substr(i,1)!=';'){
curChar+=message.substr(i,1)
i++;
}
} else {
curChar=message.substr(i,1);
}
out+="<span style='font-size:"+size+"px;'>"+curChar+"</span>";
if (mounting){
size++;
}else{
size--;
}
if (size>=max){
size=max;
mounting=false;
}else if (size<=min){
size=min;
mounting=true;
}
}
return out;
}
function BBFade(message,colors){
var color=colors.split(":");
var col=new Array();
for (i in color)
{
col[i]=new Array();
col[i]['r']=parseInt(color[i].substr(0,2),16);
col[i]['g']=parseInt(color[i].substr(2,2),16);
col[i]['b']=parseInt(color[i].substr(4,2),16);
}
var m_l=message.length;
var nb_col=col.length;
var steps=Math.floor(m_l/(nb_col-1));
var nb, r, g, b;
var out="";
for (i=0;i<m_l;i++)
{
if (message.substr(i,1)=='&'){
curChar=message.substr(i,1);
i++;
while (message.substr(i,1)!=';'){
curChar+=message.substr(i,1)
i++;
}
} else {
curChar=message.substr(i,1);
}
if (i>steps*(nb_col-1)) {
nb=nb_col-1;
r=col[nb]['r'];
g=col[nb]['g'];
b=col[nb]['b'];
out+="<span style='color:rgb("+r+","+g+","+b+");'>"+curChar+"</span>";
}
else if (i%steps==0) {
nb=i/steps;
r=col[nb]['r'];
g=col[nb]['g'];
b=col[nb]['b'];
out+="<span style='color:rgb("+r+","+g+","+b+");'>"+curChar+"</span>";
}
else {
nb=Math.ceil(i/steps);
r=Math.round(col[nb-1]['r']-(((col[nb-1]['r']-col[nb]['r'])/steps)*(i%steps)));
g=Math.round(col[nb-1]['g']-(((col[nb-1]['g']-col[nb]['g'])/steps)*(i%steps)));
b=Math.round(col[nb-1]['b']-(((col[nb-1]['b']-col[nb]['b'])/steps)*(i%steps)));
out+="<span style='color:rgb("+r+","+g+","+b+");'>"+curChar+"</span>";
}
}
return out;
}
function bbcode(tmp){
tmp=tmp.replace(/\[wave=([0-9:]+)\](.*)\[\/wave\]/img ,function(str,p1,p2){return BBWave(p2,p1);});
tmp=tmp.replace(/\[fade=([^\]]+)\](.*)\[\/fade\]/img ,function(str,p1,p2){return BBFade(p2,p1);});
appendDebug('BBCode');
return tmp;
}
window.onload=parch_init;
En état de marche :

Si on supprime n'importe quel onglet :
