1
0
Fork 0
zutil-php/class/PHPProgressBar.php

91 lines
2 KiB
PHP
Raw Permalink Normal View History

2010-02-11 17:50:45 +00:00
<?php
//created by Ziver koc. Nice hu
// Too make this work you must have echoed out html and the body tags
class PHPProgressBar{
//********* STATIC **********************
public static $progressInit = false;
public static $progressNextId = 0;
//**************************************
private $id;
public function __construct($width, $height, $imgBar, $imgProggress){
if(!self::$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>";
self::$progressInit = true;
}
$this->id = self::$progressNextId;
self::$progressNextId++;
echo"
<style type='text/css'>
.progress".$this->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".$this->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".$this->id."'>
<div id='progressValue".$this->id."' style='width: 0%' >
<span id='progressText".$this->id."'></span>
</div>
</div>
";
flush();
}
public function setValue($value){
echo"
<script type='text/javascript'>
<!--
setValue(".$this->id.",".$value.");
//-->
</script>
";
flush();
}
public function setText($text){
echo"
<script type='text/javascript'>
<!--
setText(".$this->id.",'".$text."');
//-->
</script>
";
flush();
}
public function redirect($url){
echo"
<script type='text/javascript'>
<!--
window.location = '".$url."';
//-->
</script>
";
flush();
}
}
?>