1
0
Fork 0
zutil-php/JsPHP.php
2008-11-14 16:38:36 +00:00

110 lines
No EOL
2.7 KiB
PHP

<?php
//created by Ziver koc. Nice hu
// Too make this work you must have echoed out html and the body tags
//********* GLOBAL **********************
$progressInit = false;
$progressNextId = 0;
//**************************************
// Example of use
echo"<html><body><center>";
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-life.gif");
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-mana.gif");
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-life.gif");
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-mana.gif");
for($i=0;$i<=100;$i+=2){
sleep(1);
progressSetValue($i);
progressSetText($i."%");
progressSetValue($i/2,1);
progressSetText(($i/2)."%",1);
progressSetValue($i/4,2);
progressSetText(($i/4)."%",2);
progressSetValue($i/3,3);
progressSetText(($i/3)."%",3);
//echo $i."% > ";
}
echo"</center></body></html>";
redirect("http://google.com");
function progressBarInit($width, $height, $imgBar, $imgProggress){
GLOBAL $progressInit, $progressNextId;
if(!$progressInit){
echo"
<script type='text/javascript'>
<!--
function setValue(id,value){
document.getElementById('progressValue'+id).style.width = value+'%';
}
function setText(id,text){
document.getElementById('progressText'+id).innerHTML = text;
}
//-->
</script>";
$progressInit = true;
}
$id = $progressNextId;
$progressNextId++;
echo"
<style type='text/css'>
.progress".$id."{
background: transparent url(".$imgBar.") repeat-x scroll 0%;
border: 1px solid black;
color: white;
height: ".$height."px;
margin: 5pt;
padding: 0pt;
position: relative;
text-align: center;
width: ".$width."px;
border-collapse: collapse;
}
#progressValue".$id."{
background: transparent url(".$imgProggress.") repeat-x scroll 0%;
float: left;
height: ".$height."px;
margin: 0pt;
padding: 0pt;
font-size: 11px;
}
</style>
<div class='progress".$id."'>
<div id='progressValue".$id."' style='width: 0%' >
<span id='progressText".$id."'></span>
</div>
</div>
";
flush();
return $id;
}
function progressSetValue($value,$id=0){
echo"
<script type='text/javascript'>
<!--
setValue(".$id.",".$value.");
//-->
</script>
";
flush();
}
function progressSetText($text,$id=0){
echo"
<script type='text/javascript'>
<!--
setText(".$id.",'".$text."');
//-->
</script>
";
flush();
}
function redirect($url){
echo"
<script type='text/javascript'>
<!--
window.location = '".$url."';
//-->
</script>
";
flush();
}
?>