Amélioration du javascript

This commit is contained in:
Michael RICOIS 2012-04-19 09:19:43 +00:00
parent 21c7ddff17
commit e7b3cbb56f
2 changed files with 37 additions and 19 deletions

View File

@ -54,12 +54,15 @@
<tbody>
<?php foreach($this->fileEnCours as $file) {?>
<tr id="<?=$file->id?>" class="encours">
<td><?=$file->fichier?></td>
<td><?=$file->dateAdded?></td>
<td class="ligne"><?=$file->nbLigneT?></td>
<td><?=$file->nbLigne?></td>
<td><?=$file->error?></td>
<td><a class="restart" href="<?=$this->url(array('action'=>'restart', 'id'=>$file->id))?>">Remise à zéro et redémarrage</a></td>
<td><?=$file->fichier?></td>
<td><?=$file->dateAdded?></td>
<td class="ligne"><?=$file->nbLigneT?></td>
<td><?=$file->nbLigne?></td>
<td><?=$file->error?></td>
<td>
<a class="restart" href="<?=$this->url(array('action'=>'restart', 'id'=>$file->id))?>">Remise à zéro et redémarrage</a>
</td>
</tr>
<?php }?>
</tbody>

View File

@ -1,3 +1,16 @@
var nbSeconds = 10;
var timer;
function updateInfo()
{
$('tr.encours:first-child').each(function(){
var objet = $(this);
var id = $(this).attr('id');
$.getJSON('/index/getinfo', {id: id}, function(data){
if (data!=''){ objet.find('td.ligne').text(data.nbLigneT); }
});
});
}
$(document).ready(function(){
$("a.setprofil").click(function(e){
@ -10,24 +23,26 @@ $(document).ready(function(){
});
});
$('a.restart').click(function(e){
e.preventDefault();
var href = $(this).attr('href');
if (confirm("Attention en cliquant sur Ok l'enrichissement va être reinitialiser")) {
window.location = href;
}
});
//Focus entrant sur le document, on relance le script
$(document).focusin(function(){
updateInfo();
timer = setInterval(updateInfo, 10000);
timer = setInterval(updateInfo, nbSeconds*100);
});
//Sortie du focus sur le document on arrête le script
$(document).focusout(function(){
clearInterval(timer);
});
timer = setInterval(updateInfo, 10000);
//Démarrage du time
timer = setInterval(updateInfo, nbSeconds*100);
});
var timer;
function updateInfo()
{
$('tr.encours:first-child').each(function(){
var objet = $(this);
var id = $(this).attr('id');
$.getJSON('/index/getinfo', {id: id}, function(data){
if (data!=''){ objet.find('td.ligne').text(data.nbLigneT); }
});
});
}