Ho scritto un piccolo script per la gestione delle news..:
Codice PHP:
var vDate=new Array();
var vNiuvs=new Array();
vDate[0]="[b]ERR:[/b] NO <strike>DATE</strike> <u>@</u> THIS POS#!";
vDate[1]="[b]Dom[/b] 23 Nov 2003";
vDate[2]="[b]Lun[/b] 24 Nov 2003";
vDate[3]="[b]Mar[/b] 25 Nov 2003";
vNiuvs[0]="[b]ERR:[/b] NO <strike>NEWS</strike> <u>@</u> THIS POS#!";
vNiuvs[1]="Inizio la stesura dello script per la gestione delle NIUVS.";
vNiuvs[2]="Aggiunto orologio in JS sulla sinistra (sotto il menù ). (IFF (00:00:00) e-mail ELSE BREAK; ).";
vNiuvs[3]="Modificato lo script per a gestione delle NIUVS. Modificati i colori di background.";
var mail="
<span class=\"a\" onclick=\"top.location.href='mailform.htm'\">e-mail</span>
"
var DTW1="", DTW2="", DTW3="";
var NTW1="", NTW2="", NTW3="";
var t1="", t2="", t3="";
var i;
function wNEWS(H) {
H=parseInt(H);
if (H>0) {
DTW1=vDate[vDate.length-1]; NTW1=vNiuvs[vNiuvs.length-1];
if (NTW1.length>H) {
for (i=0;i!=(H-3);i++) {
t1=t1+NTW1.charAt(i);
}
t1=t1+"...";
NTW1=t1;
}
DTW2=vDate[vDate.length-2]; NTW2=vNiuvs[vNiuvs.length-2];
if (NTW2.length>H) {
for (i=0;i!=(H-3);i++) {
t2=t2+NTW2.charAt(i);
}
t2=t2+"...";
NTW2=t2;
}
DTW3=vDate[vDate.length-3]; NTW3=vNiuvs[vNiuvs.length-3];
if (NTW3.length>H) {
for (i=0;i!=(H-3);i++) {
t3=t3+NTW3.charAt(i);
}
t3=t3+"...";
NTW3=t3;
}
};
else if (H==-1) {
var tw="";
i=1;
while (i!=vDate[vDate.length-1]) {
tw+="<p class=\"n\">"+vDate[i]+"
"+vNiuvs[i]+"</p>";
i++;
}
ATW=tw;
};
ATW="<p class=\"n\">"+DTW1+"
"+NTW1+"</p><p class=\"n\">"+DTW2+"
"+NTW2+"</p><p class=\"n\">"+DTW3+"
"+NTW3+"</p>";
document.write(ATW);
}
Potreste aiutarmi a capire (o meglio.. potreste dirmi
) perchè mi si inpalla il browser quando H è -1?
Grazie..
Un'altra cosa..
Come posso fare per cercare "e-mail" nelle news e sostituirgli la variabile "mail"?
Può funzionare questo? (L'ho scritto al volo..)
Codice PHP:
if ((t1.indexOf('e-mail'))!=-1) {
var manca=t1.length-(6+(t1.indexOf('e-mail')));
var t1secondo="";
for (i=0;i!=(t1.indexOf('e-mail'));i++) {
t1secondo+=t1.charAt(i);
}
t1secondo+=mail;
for (i=manca;i!=(t1.length);i++) {
t1secondo+=t1.charAt(i);
}
}
Grazie.