Skip to content

Commit

Permalink
+ Se termina contador hacia atras. En español, en base a un timestap
Browse files Browse the repository at this point in the history
  y un numero de minutos de duracion (conferencia). Entrar a la url
  yourdomain/count.
  • Loading branch information
jorlugaqui committed Apr 26, 2012
1 parent 77e19d0 commit e32033e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
24 changes: 23 additions & 1 deletion app/Controller/CountController.php
Expand Up @@ -4,7 +4,29 @@ class CountController extends Controller {
public function index(){
$helpers = array('Html');
// Aqui se debe traer hasta que fecha-hora va la conferencia.
$this->set("time", "xd");
// Por ahora fecha estatica para simular
$start = "2012-04-26 07:01:20";

// Tiempo en minutos, dato estatico para ser simulado. Se debe traer
// del campo duration.
$duration = 45;
$duration *= 60;

$tmp = explode(" ", $start);
$time = explode(":", $tmp[1]);
$date = explode("-", $tmp[0]);
$start_unix = mktime($time[0], $time[1], $time[2], $date[1], $date[2], $date[0]);
$start_unix += $duration;

$r = array();
$r["year"] = date("Y", $start_unix);
$r["month"] = date("m", $start_unix);
$r["day"] = date("d", $start_unix);
$r["min"] = date("i", $start_unix);
$r["sec"] = date("s", $start_unix);
$r["hour"] = date("H", $start_unix);
//debug($r);
$this->set("data", $r);
$this->render();
}
}
22 changes: 13 additions & 9 deletions app/View/Count/index.ctp
Expand Up @@ -8,13 +8,17 @@

?>
<h2>Test Contador</h2>
<div id="countdown"></div>
<script type="text/javascript" charset="UTF-8">
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
//$('#countdown').countdown($.countdown.regional['es']);
$("#countdown").countdown({until: newYear});
alert("xd");
<div id="countdown_p"></div>
<script type="text/javascript" charset="UTF-8">
var limit = new Date(
<?php echo $data["year"]; ?>,
<?php echo $data["month"]-1; ?>,
<?php echo $data["day"]; ?>,
<?php echo $data["hour"]; ?>,
<?php echo $data["min"]; ?>,
<?php echo $data["sec"]; ?>
);
//$("#countdown_p").countdown($.countdown.regional['es']);
$("#countdown_p").countdown({until: limit});
alert(limit);
</script>


4 changes: 2 additions & 2 deletions app/webroot/css/app.css
Expand Up @@ -9,9 +9,9 @@
padding-left: 60px;
}

div#countdown{
div#countdown_p{
text-align: center;
display: block;
width: 200px;
height: 20px;
height: 60px;
}

0 comments on commit e32033e

Please sign in to comment.