Aca esta el 'backend'
Código PHP:
<?php
class Backend_Controller extends BM_Controller
{
public function index()
{
set_time_limit(0);
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
flush();
$this->__header();
while(1) :
$time2 = date("h:i:s");
echo "<script type=\"text/javascript\">";
echo "tsf.time('{$time2}');";
echo "</script>";
sleep(1);
flush();
endwhile;
$this->__footer();
die();
}
private function __header()
{
$config = BM_Config::singleton();
$url = $config->read('url');
echo '<head>
<title>Backend</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML");
if (is_khtml)
{
var prototypejs = document.createElement("script");
prototypejs.setAttribute("type","text/javascript");
prototypejs.setAttribute("src","javascript/prototype.js");
var head = document.getElementsByTagName("head");
head[0].appendChild(prototypejs);
}
var tsf = window.parent.tsf;
</script>';
}
private function __footer()
{
echo "
</body>
</html>";
}
}
?>
Código:
var tsf = { time:function(hour) { jQuery("#hour").html(hour); //console.log(hour); } }; var comet = { connection : false, iframediv : false, requestPhp : "index.php?controller=backend", initialize: function() { if (navigator.appVersion.indexOf("MSIE") != -1) { // For internet explorer comet.connection = new ActiveXObject("htmlfile"); comet.connection.open(); comet.connection.write("<html>"); comet.connection.write("<script>document.domain = '"+document.domain+"'"); comet.connection.write("</html>"); comet.connection.close(); comet.iframediv = comet.connection.createElement("div"); comet.connection.appendChild(comet.iframediv); comet.connection.parentWindow.comet = comet; comet.connection.parentWindow.tsf = tsf; comet.iframediv.innerHTML = "<iframe id='comet_iframe' src='" + comet.requestPhp + "'></iframe>"; } else if (navigator.appVersion.indexOf("KHTML") != -1) { // For KHTML browsers comet.connection = document.createElement('iframe'); comet.connection.setAttribute('id', 'comet_iframe'); comet.connection.setAttribute('src', comet.requestPhp); with (comet.connection.style) { position = "absolute"; left = top = "-100px"; height = width = "1px"; visibility = "hidden"; } document.body.appendChild(comet.connection); } else { // Firefox and others comet.connection = document.createElement('iframe'); comet.connection.setAttribute('id', 'comet_iframe'); with (comet.connection.style) { left = top = "-100px"; height = width = "1px"; visibility = "hidden"; display = 'none'; } comet.iframediv = document.createElement('iframe'); comet.iframediv.setAttribute('src', comet.requestPhp); comet.connection.appendChild(comet.iframediv); document.body.appendChild(comet.connection); } }, onUnload: function() { if (comet.connection) { comet.connection = false; } } };
Código:
<body> <script type="text/javascript"> Event.observe(window, "load", comet.initialize); Event.observe(window, "unload", comet.onUnload); </script>
O sea todo funciona bien, pero no entiendo porque en chrome siempre queda cargando..