salve ho un problema in questa pagina:
http://merkinball.altervista.org/new.../song_machine/
si tratta di un sistema di rating in cui i risulati vengono visualizzati in una finestra di popup quando si clicca sul link "results"... io vorrei includere tali risultati in una tabella della home, cioe in modo che tali risultati vengano visualizzati al caricamento della pagina e non al click...
Lo script si compone di un file js e di uno php;
la finestra di popup si apre con un link del genere:
<br><a href="#" onClick="javascript :topsongs('y')" >Top Songs</a>
nella head c č:
<script language="javascript" type="text/javascript" src="js/chromeless_35.js"></script>
questo č il file .js:
/*
CHROMELESS WINDOWS v.35.1 [ 8.1K ]
Licensed under GNU LGPL (www.gnu.org )
(c) Gabriel Suchowolski,2000 >> www.microbians.com
Thanks to Gustavo Ponce >> www.urbanlove.org (resize addon)
*/
function chromeless(u,n,W,H,X,Y,cU,cO,cL,mU,mO,xU,xO,rU,rO, tH,tW,wB,wBs,wBG,wBGs,wNS,fSO,brd,max,min,res,tsz) {
var c=(document.all&&navigator.userAgent.index Of("Win")!=-1)?1:0
var v=navigator.appVersion.substring(navigator.appVers ion.indexOf("MSIE ")+5,navigator.appVersion.indexOf("MSIE ")+
min=(v>=5.5?min:false);
var w=window.screen.width; var h=window.screen.height
var W=W||w; W=(typeof(W)=='string'?Math.ceil(parseInt(W)*w/100):W); W+=(brd*2+2)*c
var H=H||h; H=(typeof(H)=='string'?Math.ceil(parseInt(H)*h/100):H); H+=(tsz+brd+2)*c
var X=X||Math.ceil((w-W)/2)
var Y=Y||Math.ceil((h-H)/2)
var s=",width="+W+",height="+H
if(c){
var cTIT='\n'+
'<html><head><META HTTP-EQUIV="imagetoolbar" CONTENT="no">\n'+
'<script>\n'+
'var IcU=new Image();IcU.src="'+cU+'";var IcO=new Image();IcO.src="'+cO+'";var IcL=new Image();IcL.src="'+cL+'";var IxU=new Image();IxU.src="'+xU+'";var IxO=new Image();IxO.src="'+xO+'";var IrU=new Image();IrU.src="'+rU+'";var IrO=new Image();IrO.src="'+rO+'";var ImU=new Image();ImU.src="'+mU+'";var ImO=new Image();ImO.src="'+mO+'"\n'+
'document.onmousemove=document.onselectstart=docum ent.ondragstart=document.oncontextmenu=new Function("wMOV();return false");\n'+
'b=-1\n'+
'wLOA=function(){if(top.ok&&document.body) {'+(min?'bMIN.style.visibility="visible";':'')+'bL OA.style.visibility="hidden";wRSZ()}else setTimeout("wLOA()",500)};wLOA()\n'+
'wRSZ=function(){var dw=document.body.clientWidth;bCLO.style.pixelLeft= dw-22;bMIN.style.pixelLeft=bLOA.style.pixelLeft=dw-62;bFUL.style.pixelLeft=bRES.style.pixelLeft=dw-42}\n'+
'wMAX=function(m){top.mod=m;if(m){top.mT(0,0);top. rT('+w+','+h+');bFUL.style.visibility="hidden";bRE S.style.visibility="visible"}else{top.mT(top.px,to p.py);top.rT(top.sW,top.sH);bFUL.style.visibility= "visible";bRES.style.visibility="hidden"}}\n'+
'wDBL=function(){if(!top.mod)wMAX(1);else wMAX(0)}\n'+
'wMIN=function(){top.window.moveTo(0,-4000);if(top.opener&&!top.opener.closed){t op.opener.window.focus()};top.window.blur()}\n'+
'wMOV=function(){\n'+
'if(b==0){top.bCOL("'+wBG+'","'+wB+'");b=-1}\n'+
'if(b==2&&!top.mod){top.px=event.screenX-ofx-1;top.py=event.screenY-ofy-1;top.mT(top.px,top.py)}\n'+
'if(b==1){top.bCOL("'+wBGs+'","'+wBs+'");ofx=event .x;ofy=event.y;b=2}\n'+
'}</script></head>\n'+
'<body onresize="wRSZ()" bgcolor='+wBG+'>\n'+
'<div style="position:absolute;left:5px;top:4px;width:20 00px">'+tH+'</div>\n'+
'<img id=bMOV style="position:absolute;left:-50px;top:-50px" '+(max?'ondblclick="wDBL()"':'')+' onmousemove="wMOV()" onmousedown="b=1;wMOV()" onmouseup="b=0;wMOV()" border=0 src="" width=2000 height=2000>\n'+
'<img id=bFUL style="position:absolute;top:4px;left:'+(W-42)+'px;'+(max?'':'display:none')+'" src="'+xU+'" border=0 width=11 height=11 onmouseover="this.src=IxO.src" onmouseout="this.src=IxU.src" onmouseup="this.src=IxU.src" onmousedown="this.src=IxU.src" onclick="wMAX(1)">\n'+
'<img id=bRES style="position:absolute;top:4px;left:'+(W-42)+'px;visibility:hidden" src="'+rU+'" border=0 width=11 height=11 onmouseover="this.src=IrO.src" onmouseout="this.src=IrU.src" onmouseup="this.src=IrU.src" onmousedown="this.src=IrU.src" onclick="wMAX(0)">\n'+
'<img id=bCLO style="position:absolute;top:4px;left:'+(W-22)+'px;" src="'+cU+'" border=0 width=11 height=11 onmouseover="this.src=IcO.src" onmouseout="this.src=IcU.src" onmouseup="this.src=IcU.src" onmousedown="this.src=IcU.src" onclick="top.window.close()">\n'+
'<img id=bLOA style="position:absolute;top:4px;left:'+(W-62)+'px;" src="'+cL+'" border=0 width=11 height=11>\n'+
'<img id=bMIN style="position:absolute;top:4px;left:'+(W-62)+'px;visibility:hidden" src="'+mU+'" border=0 width=11 height=11 onmouseover="this.src=ImO.src" onmouseout="this.src=ImU.src" onmouseup="this.src=ImU.src" onmousedown="this.src=ImU.src" onclick="wMIN()">\n'+
'</body>\n'+
'</html>'
cTIT=cTIT.replace(/\//g,"\\\/").replace(/\"/g,"\\\"").replace(/\n/g,"\\n")
cRES=function(b,s){
var tmp='\n'+
'<html><head><META HTTP-EQUIV="imagetoolbar" CONTENT="no">\n'+
'<script>\n'+
'document.onmousemove=document.onselectstart=docum ent.ondragstart=document.oncontextmenu=new Function("wMOV();return false");\n'+
'b=-1\n'+
'wMOV=function(){if(!top.mod){\n'+
'if(b==0){top.sH=top.fH;top.sW=top.fW;b=-1}\n'+
'if(b==2&&(1=='+b+'||4=='+b+'||5=='+b+')){ tmp=event.screenY-oH;if(top.sH+tmp>100){top.fH=top.sH+tmp}}\n'+
'if(b==2&&(2=='+b+'||4=='+b+')){tmp=event. screenX-oW;if(top.sW-tmp>100){top.fW=top.sW-tmp;top.px=event.screenX-ofx-1}}\n'+
'if(b==2&&(3=='+b+'||5=='+b+')){tmp=event. screenX-oW;top.fW=top.sW+tmp}\n'+
'if(b==2){setTimeout("top.rT(top.fW,top.fH);top.mT (top.px,top.py);",10)}\n'+
'if(b==1){ofx=event.x;oH=event.screenY;oW=event.sc reenX;b=2}\n'+
'}}</script></head>\n'+
'<body bgcolor='+wBG+'>\n'+
'<img style="cursor:'+s+'-resize" id=bMOV style="position:absolute;left:-50px;top:-50px" onmousemove="wMOV()" onmousedown="b=1;wMOV()" onmouseup="b=0;wMOV()" border=0 src="" width=3000 height=2000>\n'+
'</body>\n'+
'</html>'
return tmp.replace(/\//g,"\\\/").replace(/\"/g,"\\\"").replace(/\n/g,"\\n")
}
var cRESd=cRES(1,'s'),cRESl=cRES(2,'w'),cRESr=cRES(3,' e'),cRESbl=cRES(4,'sw'),cRESbr=cRES(5,'se')
var cFRM='<HTML><HEAD><TITLE>'+tW+'& lt;/TITLE>\n'+
'<script>\n'+
'ok=0;mod=0;sH=fH='+(H)+';sW=fW='+(W)+';px='+(X)+' ;py='+(Y)+'\n'+
'bCOL=function(c1,c2){fT.document.bgColor=n0.docum ent.bgColor=n1.document.bgColor=n2.document.bgColo r=n3.document.bgColor=n4.document.bgColor=c1;bL.do cument.bgColor=bT.document.bgColor=bR.document.bgC olor=bB.document.bgColor=c2}\n'+
'mTIT=function(){if(frames.length>8){fT.documen t.write("'+cTIT+'");fT.document.close();if ('+res+'){n2.document.write("'+cRESd+'");n2.docume nt.close();n1.document.write("'+cRESr+'");n1.docum ent.close();n0.document.write("'+cRESl+'");n0.docu ment.close();n3.document.write("'+cRESbl+'");n3.do cument.close();n4.document.write("'+cRESbr+'");n4. document.close()};top.bCOL("'+wBG+'","'+wB+'")}els e{setTimeout("mTIT()",20)}}\n'+
'mT=function(x,y){top.window.moveTo(x,y)}\n'+
'rT=function(w,h){top.window.resizeTo(w,h)}\n'+
'top.rT(fW,fH);top.mT(px,py)\n'+
'mTIT()\n'+
'</script></HEAD>\n'+
'<frameset onselectstart="return false" onload="top.ok=1" onfocus="if (top.ok&&fT&&fT.wMAX) fT.wMAX(top.mod)" border=0 framespacing=0 frameborder=0 rows="'+tsz+',100%,'+brd+'">\n'+
' <frame name=fT src="about :blank" scrolling=no noresize>\n'+
' <frameset border=0 framespacing=0 frameborder=0 cols="'+brd+',1,100%,1,'+brd+'">\n'+
' <frame name=n0 src="about :blank" scrolling=no noresize>\n'+
' <frame name=bL src="about :blank" scrolling=no noresize>\n'+
' <frameset border=0 framespacing=0 frameborder=0 rows="1,100%,1">\n'+
' <frame name=bT src="about :blank" scrolling=no noresize>\n'+
' <frame name=main src="'+u+'" '+fSO+'>\n'+
' <frame name=bB src="about :blank" scrolling=no noresize>\n'+
' </frameset>\n'+
' <frame name=bR src="about :blank" scrolling=no noresize>\n'+
' <frame name=n1 src="about :blank" scrolling=no noresize>\n'+
' </frameset>\n'+
' <frameset border=0 framespacing=0 frameborder=0 cols="'+brd+',100%,'+brd+'">\n'+
' <frame name=n3 src="about :blank" scrolling=no noresize>\n'+
' <frame name=n2 src="about :blank" scrolling=no noresize>\n'+
' <frame name=n4 src="about :blank" scrolling=no noresize>\n'+
' </frameset>\n'+
'</frameset>\n'+
'</HTML>'
var CWIN=window.open("",n,"fullscreen=1"+s)
CWIN.moveTo(5000,0)
CWIN.ft=true
CWIN.document.write(cFRM)
CWIN.document.close()
} else {
var CWIN=window.open(u,n,wNS+s,true)
CWIN.moveTo(X,Y)
}
CWIN.focus()
CWIN.setURL=function(u) { if (this && !this.closed) { if (this.frames.main) this.frames.main.location.href=u; else this.location.href=u } }
CWIN.closeIT=function() { if (this && !this.closed) this.close() }
return CWIN
}
function openIT(u,W,H,X,Y,n,b,x,m,r,t) {
var cU ='http://www.merkinball.com/cgi-bin/rate/img/close_up.gif'
var cO ='http://www.merkinball.com/cgi-bin/rate/img/close_ovr.gif'
var cL ='http://www.merkinball.com/cgi-bin/rate/img/clock.gif'
var mU ='http://www.merkinball.com/cgi-bin/rate/img/min_up.gif'
var mO ='http://www.merkinball.com/cgi-bin/rate/img/min_ovr.gif'
var xU ='http://www.merkinball.com/cgi-bin/rate/img/max_up.gif'
var xO ='http://www.merkinball.com/cgi-bin/rate/img/max_ovr.gif'
var rU ='http://www.merkinball.com/cgi-bin/rate/img/res_up.gif'
var rO ='http://www.merkinball.com/cgi-bin/rate/img/res_ovr.gif'
var tH ='<font face=verdana size=1>&nbsp;&nbsp;'+t+'</font>'
var tW ='&nbsp;&nbsp;'+t
var wB ='#000000'
var wBs ='#ebebeb'
var wBG ='#ebe0e0'
var wBGs='#ebebeb'
var wNS ='toolbar=0,location=0,directories=0,status=0,menu bar=0,scrollbars=0,resizable=0'
var fSO ='scrolling=no noresize'
var brd =b||0;
var max =x||false;
var min =m||false;
var res =r||false;
var tsz =20;
return chromeless(u,n,W,H,X,Y,cU,cO,cL,mU,mO,xU,xO,rU,rO, tH,tW,wB,wBs,wBG,wBGs,wNS,fSO,brd,max,min,res,tsz)
}
function vote(song) {
openIT('http://www.merkinball.com/cgi-bin/rate/votea.php?song='+song,260,270,null,null,'vote',0,t rue,false,false,'Vote');
vote.focus();
return(false);
}
function topsongs(type) {
openIT('http://www.merkinball.com/cgi-bin/rate/votea.php?classifica='+type,250,280,null,null,'top songs',0,true,false,false,'Top Songs');
topsongs.focus();
return(false);
}
################################################
################################################
questo č il file php:
<HTML>
<BODY BGCOLOR="#EBEBEB" onload="top.window.focus()" >
<HEAD><TITLE>Vote.php script by lx</TITLE></HEAD>
<center>
<?php
// Necessary Variables:
$graph = true;
// Visualizza il grafico dei voti. (true/false)
$db = "no";
if ($db == "yes") {
$dbname = "";
$dbpass = "";
$tabname = "";
}
$RESULT_FILE_NAME = "/membri/merkinball/new/english/album_machine/poll_data.txt";
// Absolute path and name to file contain poll data.
$QUESTION = "Rate This Song:";
// Question Text.
$ANSWER = array( "4", "5", "6", "7", "8", "9", "10");
// All answer.
$PASS = "password"; //password for the addsong action
$addallow = true; //allow to add songs through the script
// End Necessary Variables section
/************************************************** ****************************/
if ($song) {
if (! $vote ) {
echo "<FORM METHOD=\"POST\">\n";
echo "<TR><TH><strong>$QUESTION&l t;/strong></TH></TR></BR></BR>\n";
echo "<TABLE WIDTH=100% BORDER=0><TR><TD>\n";
while (list($key, $val) = each($ANSWER)) {
echo "<TD align=\"center\"><strong><font=\"Verda na\" size=\"1\"><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val</font></strong></TD>\n";
}
echo "</TABLE></TD></TR>";
echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Rate \" onclick=\"onmouseout=''\"></TD></TR>\n";
echo "</FORM></br>";
} else {
$fd = fopen($RESULT_FILE_NAME, "r");
if ($fd) {
while (!feof($fd) && $parts[0] != $song)
{
$buffer = fgets($fd, 4096);
$parts = explode("|",$buffer);
if ($parts[0] == $song) {$exists = "yes";}
// 0 -- 7777 !!!!
}
fclose($fd);
}
if ($exists!="yes") {
echo "<P>Please add this song to the DB.</P>";
die;
}
$answer++;
$parts[$answer]++ ;
$toadd = "$parts[0]|$parts[1]|$parts[2]|$parts[3]|$parts[4]|$parts[5]|$parts[6]|$parts[7]|$parts[8]";
if ($exists=="yes") {
$temp = fopen("../../public/tmp.tmp", "w");
$fd = fopen($RESULT_FILE_NAME, "r");
while (!feof($fd))
{
$buff = fgets($fd, 4096);
if ($buff == $buffer) {
fputs($temp, $toadd);
} else {
fputs($temp, $buff);
}
}
fclose($fd);
fclose($temp);
copy("../../public/tmp.tmp", $RESULT_FILE_NAME);
} else {
$fd = fopen($RESULT_FILE_NAME, "a");
fputs($fd,"$toadd\n");
fclose($fd);
}
$nofvotes = array_sum($parts);
$media = (4*$parts[1] + 5*$parts[2] + 6*$parts[3] + 7*$parts[4] + 8*$parts[5] + 9*$parts[6] + 10*$parts[7]) / $nofvotes;
$media = substr($media, 0, 4);
if ($graph) {
echo "<TABLE BORDER=0 HEIGHT=120><TR valign=bottom>\n";
for ($prot=1;$prot<8;$prot++) {
$percent = $parts[$prot] * 100 / $nofvotes;
$percent_int = floor($percent);
$w = 30;
$h = (86/100*$percent_int)+20;
if ($h==20) {$h=2;}
if ($graph) {echo "<TD><IMG src=cyl.gif WIDTH=$w HEIGHT=$h></TD>\n";}
}
echo "</TR><TR><FONT size=-4>\n";
for ($prot=1;$prot<8;$prot++) {
$percent = $parts[$prot] * 100 / $nofvotes;
$percent_int = floor($percent);
if ($graph) {echo "<TD><FONT size=-4>$percent_int%</FONT></TD>\n";}
}
echo "</FONT></TR></TABLE>\n";
}
echo "<TH valign=bottom></br><strong>Total votes: $nofvotes</strong></br>";
echo "<strong>Average is: $media</strong></br>";
echo "<INPUT TYPE=\"Button\" VALUE=\"Thanks\" onClick=\"top.window.close()\"></TH>";
}
}
elseif ($classifica) {
if (! $n ) {$n = 20;}
$fd = fopen($RESULT_FILE_NAME, "r");
if ($fd) {
$buffer = fgets($fd, 4096);
$i=0;
while (!feof($fd))
{
$parts = explode("|",$buffer);
$media[$i]["title"] = $parts[8];
$nofvotes = $parts[1]+$parts[2]+$parts[3]+$parts[4]+$parts[5]+$parts[6]+$parts[7];
if ($nofvotes>0) {
$med = (4*$parts[1] + 5*$parts[2] + 6*$parts[3] + 7*$parts[4] + 8*$parts[5] + 9*$parts[6] + 10*$parts[7]) / $nofvotes;
$med = substr($med, 0, 4);
} else {$med=0;}
$media[$i]["media"] = $med;
$i++;
$buffer = fgets($fd, 4096);
// 0 -- 7777 !!!!
}
fclose($fd);
function cmp ($a, $b) {
if ($a["media"] == $b["media"]) return 0;
return ($a["media"] > $b["media"]) ? -1 : 1;
}
usort ($media, "cmp");
if (count($media)<$n) {$n=count($media);}
echo "<BR><TABLE BORDER=1 bordercolor=black cellpadding=0 cellspacing=0>";
echo "<TR><TD><Font=verdana><Stron g>POS</strong></font></TD><TD><font=verdana><strong> TITLE</strong></font></TD><TD><font=verdana><strong> AV.</strong></font></TD></TR>";
for ($i = 1; $i <= $n; $i++) {
$ititle = $media[$i-1]["title"];
$imedia = $media[$i-1]["media"];
echo "<TR><TD ALIGN=\"right\"><font=verdana><strong& gt;$i.</strong></font></TD>";
echo "<TD><font=verdana><strong>$itit le</font></TD>";
echo "<TD><font=verdana><strong>$imed ia</font></TD></TR>";
}
echo "</TABLE></BR>";
echo "<INPUT TYPE=\"Button\" VALUE=\"Close\" onClick=\"top.window.close()\">";
}
}
elseif ($addsong==$PASS && $addallow) {
if (! $add ) {
echo "<FORM METHOD=\"POST\">\n";
echo "<input type=\"hidden\" name=\"addsong\" value=\"$PASS\">";
echo "<TABLE BORDER=0><TR><TD>\n";
echo "Full title:</TD><TD><INPUT TYPE=\"Text\" NAME=\"title\"</TD></TR>";
echo "<TR><TD>Short title:</TD><TD><INPUT TYPE=\"Text\" NAME=\"stitle\"</TD></TR>";
echo "<TR><TD></TD><TD align=\"right\"><INPUT TYPE=\"Submit\" NAME=\"add\" VALUE=\" Add \" onclick=\"onmouseout=''\"></TD></TR>\n";
echo "</TABLE></FORM></br>";
} else {
$toadd = "$stitle|0|0|0|0|0|0|0|$title";
$fd = fopen($RESULT_FILE_NAME, "a");
if ($fd) {
fputs($fd,"$toadd\n");
fclose($fd);
echo "Successfully added $title to $RESULT_FILE_NAME";
} else {echo "Unable to open $RESULT_FILE_NAME for writing";}
echo "<FORM METHOD=\"POST\">\n";
echo "<input type=\"hidden\" name=\"addsong\" value=\"$PASS\">";
echo "<INPUT TYPE=\"Submit\" NAME=\"addmore\" VALUE=\" Add More\" onclick=\"onmouseout=''\">";
echo "<INPUT TYPE=\"Button\" VALUE=\"Close\" onClick=\"top.window.close()\">";
echo "</FORM>";
}
}
?>
</center>
<CENTER><BR><TH valign=bottom>
<FONT FACE="Arial" SIZE=-2>
<EM>2002 lx&copy </EM></FONT><TH>
</CENTER></BODY></HTML>
################################################## ##############################################
Perfavore aiutatemi
aru culu
se ho capito bene vuoi che il popup si apra quando viene visualizzata la finestra e non quando cliccano sul link...
scusa ma non ti basta metterlo nell'onload del body ?
<BODY onload="javascript :topsongs('y')">
Regole di scrittura
Non puoi creare nuove discussioni
Non puoi rispondere ai messaggi
Non puoi inserire allegati.
Non puoi modificare i tuoi messaggi
Regole del forum