Подскажите как сделать.(AJAX)

12
V
На сайте с 31.01.2008
Offline
146
#11


<?php
ob_start();
function jsProgressBar($ratio=0, $status=null, $name='default') {
static $inited = array();
$percents = round(100*$ratio);

if (empty($inited)) {
echo '
<style>
div.progressbar {
border:1px solid #06d;
width: 75%
}
div.progressbar div {
height:1.2em;
line-height:1.2em;
background-color:#03a;
border-right:1px solid #03a;
text-align:right; color:#fff;
width:0;
overflow:hidden;
padding-right: 5px
}
</style>
<body>
';
}

// init current progress bar if needed
if (!in_array($name, $inited)) {
echo '
<div class="progressbar"><div id="progressbar-'.$name.'"></div></div>
<div class="statusbar" id="statusbar-'.$name.'"></div>
';
ob_flush();
flush();

$inited[] = $name;
}

// set current position
if ($status===null) {
$statusScript = '';
} else {
$statusScript = 'document.getElementById("statusbar-'.$name.'").innerHTML = "'.$status.'";';
}

echo '
<script>
var progress = document.getElementById("progressbar-'.$name.'");
var percent = '.$percents.'+"%";
progress.innerHTML = percent;
progress.style.width = percent;
'.$statusScript.'
</script>
';
ob_flush();
flush();
}

for ($n=0; $n<1000; $n++){


jsProgressBar($n/1000);
usleep(2000);
}



ob_end_flush();
?>
12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий