Fixed problems with auto-refresh

This commit is contained in:
m-lopez-f 2016-09-08 09:50:13 +02:00
parent 070659e948
commit 18d3f1e7a0
2 changed files with 59 additions and 51 deletions

View File

@ -134,11 +134,13 @@ echo '</div>';
ui_require_jquery_file('countdown'); ui_require_jquery_file('countdown');
ui_require_javascript_file('wz_jsgraphics'); ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console'); ui_require_javascript_file('pandora_visual_console');
$ignored_params['refr'] = '';
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
var refr = <?php echo (int) $refr; ?>; var refr = <?php echo (int) $refr; ?>;
var href = "<?php echo ui_get_url_refresh ($ignored_params); ?>";
var startCountDown = function (duration, cb) { var startCountDown = function (duration, cb) {
$('div.vc-countdown').countdown('destroy'); $('div.vc-countdown').countdown('destroy');
@ -152,42 +154,44 @@ ui_require_javascript_file('pandora_visual_console');
alwaysExpire: true, alwaysExpire: true,
onExpiry: function () { onExpiry: function () {
$('div.vc-countdown').countdown('destroy'); $('div.vc-countdown').countdown('destroy');
cb(); //~ cb();
url = js_html_entity_decode( href ) + duration;
$(document).attr ("location", url);
} }
}); });
} }
var fetchMap = function () { //~ var fetchMap = function () {
$.ajax({ //~ $.ajax({
url: 'public_console.php', //~ url: 'public_console.php',
type: 'GET', //~ type: 'GET',
dataType: 'html', //~ dataType: 'html',
data: { //~ data: {
hash: '<?php echo $hash; ?>', //~ hash: '<?php echo $hash; ?>',
id_layout: <?php echo $id_layout; ?>, //~ id_layout: <?php echo $id_layout; ?>,
graph_javascript: <?php echo (int) $graph_javascript; ?>, //~ graph_javascript: <?php echo (int) $graph_javascript; ?>,
id_user: '<?php echo $config['id_user']; ?>', //~ id_user: '<?php echo $config['id_user']; ?>',
width: $(window).width(), //~ width: $(window).width(),
height: $(window).height(), //~ height: $(window).height(),
xhr: true //~ xhr: true
} //~ }
}) //~ })
.done(function (data, textStatus, xhr) { //~ .done(function (data, textStatus, xhr) {
$('div#vc-container').html(data); //~ $('div#vc-container').html(data);
startCountDown(refr, fetchMap); //~ startCountDown(refr, fetchMap);
}); //~ });
} //~ }
startCountDown(refr, false);
// Auto hide controls // Auto hide controls
var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000); autoHideElement(controls, 1000);
$('select#refr').change(function (event) { $('select#refr').change(function (event) {
refr = Number.parseInt(event.target.value, 10); refr = Number.parseInt(event.target.value, 10);
startCountDown(refr, fetchMap); startCountDown(refr, false);
}); });
// Start the map fetch // Start the map fetch
fetchMap(); //~ fetchMap();
}); });
</script> </script>

View File

@ -209,31 +209,34 @@ else {
ui_require_javascript_file('wz_jsgraphics'); ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console'); ui_require_javascript_file('pandora_visual_console');
$ignored_params['refr'] = '';
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
$(document).ready (function () { $(document).ready (function () {
var refr = <?php echo $refr; ?>; var refr = <?php echo (int)$refr; ?>;
var pure = <?php echo (int) $config['pure']; ?>; var pure = <?php echo (int) $config['pure']; ?>;
var href = "<?php echo ui_get_url_refresh ($ignored_params); ?>";
if (pure) { if (pure) {
//~ var startCountDown = function (duration, cb) { var startCountDown = function (duration, cb) {
//~ $('div.vc-countdown').countdown('destroy'); $('div.vc-countdown').countdown('destroy');
//~ if (!duration) return; if (!duration) return;
//~ var t = new Date(); var t = new Date();
//~ t.setTime(t.getTime() + duration * 1000); t.setTime(t.getTime() + duration * 1000);
//~ $('div.vc-countdown').countdown({ $('div.vc-countdown').countdown({
//~ until: t, until: t,
//~ format: 'MS', format: 'MS',
//~ layout: '(%M%nn%M:%S%nn%S <?php echo __('Until refresh'); ?>) ', layout: '(%M%nn%M:%S%nn%S <?php echo __('Until refresh'); ?>) ',
//~ alwaysExpire: true, alwaysExpire: true,
//~ onExpiry: function () { onExpiry: function () {
//~ $('div.vc-countdown').countdown('destroy'); $('div.vc-countdown').countdown('destroy');
//~ cb(); //cb();
//~ } url = js_html_entity_decode( href ) + duration;
//~ }); $(document).attr ("location", url);
//~ } }
});
}
//~ var fetchMap = function () { //~ var fetchMap = function () {
//~ $.ajax({ //~ $.ajax({
@ -252,17 +255,18 @@ ui_require_javascript_file('pandora_visual_console');
//~ }) //~ })
//~ .done(function (data, textStatus, xhr) { //~ .done(function (data, textStatus, xhr) {
//~ $('div#vc-container').html(data); //~ $('div#vc-container').html(data);
//~ startCountDown(refr, fetchMap); //~ startCountDown(refr, false);
//~ }); //~ });
//~ } //~ }
startCountDown(refr, false);
//~ // Auto hide controls //~ // Auto hide controls
//~ var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');
//~ autoHideElement(controls, 1000); autoHideElement(controls, 1000);
//~ $('select#refr').change(function (event) {
//~ refr = Number.parseInt(event.target.value, 10); $('select#refr').change(function (event) {
//~ startCountDown(refr, fetchMap); refr = Number.parseInt(event.target.value, 10);
//~ }); startCountDown(refr, false);
});
//~ // Start the map fetch //~ // Start the map fetch
//~ fetchMap(); //~ fetchMap();