From e7b3cbb56f3d93e991a790c5c3965e280d877bdb Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 19 Apr 2012 09:19:43 +0000 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20du=20javascript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/views/scripts/index/index.phtml | 15 +++++--- public/scripts/enrichissement.js | 41 ++++++++++++++------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml index 3196d72c..e276ccef 100644 --- a/application/views/scripts/index/index.phtml +++ b/application/views/scripts/index/index.phtml @@ -54,12 +54,15 @@ fileEnCours as $file) {?> -fichier?> -dateAdded?> -nbLigneT?> -nbLigne?> -error?> -Remise à zéro et redémarrage + fichier?> + dateAdded?> + nbLigneT?> + nbLigne?> + error?> + + Remise à zéro et redémarrage + + diff --git a/public/scripts/enrichissement.js b/public/scripts/enrichissement.js index 37c5017f..0144c957 100644 --- a/public/scripts/enrichissement.js +++ b/public/scripts/enrichissement.js @@ -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); } - }); - }); -} \ No newline at end of file