Revision e38ba356
Added by Steve Beaver almost 8 years ago
src/usr/local/www/widgets/widgets/system_information.widget.php | ||
---|---|---|
51 | 51 |
'disk_usage' => gettext('Disk Usage') |
52 | 52 |
); |
53 | 53 |
|
54 |
// Declared here so that JavaScript cann access it |
|
55 |
$updtext = sprintf(gettext("Obtaining update status %s"), "<i class='fa fa-cog fa-spin'></i>"); |
|
56 |
|
|
54 | 57 |
if ($_REQUEST['getupdatestatus']) { |
55 | 58 |
require_once("pkg-utils.inc"); |
56 | 59 |
|
... | ... | |
108 | 111 |
<div> |
109 | 112 |
<?printf("%s %s", gettext("Version information updated at"), |
110 | 113 |
date("Y-m-d H:i", filemtime($cache_file)));?> |
114 |
|
|
115 |
<a id="updver" href="#" class="fa fa-refresh"></a> |
|
111 | 116 |
</div> |
112 | 117 |
<?php |
113 | 118 |
endif; |
... | ... | |
228 | 233 |
<?php endif; ?> |
229 | 234 |
<?php if (!isset($config['system']['firmware']['disablecheck'])): ?> |
230 | 235 |
<br /><br /> |
231 |
<div id='updatestatus'><?php echo gettext("Obtaining update status "); ?><i class="fa fa-cog fa-spin"></i></div>
|
|
236 |
<div id='updatestatus'><?=$updtext?></div>
|
|
232 | 237 |
<?php endif; ?> |
233 | 238 |
</td> |
234 | 239 |
</tr> |
... | ... | |
633 | 638 |
} |
634 | 639 |
} |
635 | 640 |
|
641 |
|
|
636 | 642 |
<?php endif; // $widget_first_instance ?> |
637 | 643 |
|
638 | 644 |
events.push(function(){ |
645 |
|
|
639 | 646 |
// --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ |
640 | 647 |
|
641 | 648 |
// Callback function called by refresh system when data is retrieved |
... | ... | |
664 | 671 |
// Callback function called by refresh system when data is retrieved |
665 | 672 |
function version_callback(s) { |
666 | 673 |
$('[id^=widget-system_information] #updatestatus').html(s); |
674 |
|
|
675 |
// The click handler has to be attached after the div is updated |
|
676 |
$('#updver').click(function() { |
|
677 |
updver_ajax(); |
|
678 |
}); |
|
667 | 679 |
} |
668 | 680 |
|
669 | 681 |
// POST data to send via AJAX |
... | ... | |
686 | 698 |
// --------------------------------------------------------------------------------------------------- |
687 | 699 |
|
688 | 700 |
set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); |
701 |
|
|
702 |
|
|
703 |
// AJAX function to update the version display with non-cached data |
|
704 |
function updver_ajax() { |
|
705 |
|
|
706 |
// Display the "updating" message |
|
707 |
$('[id^=widget-system_information] #updatestatus').html("<?=$updtext?>"); // <?=$updtext?>"); |
|
708 |
|
|
709 |
$.ajax({ |
|
710 |
type: 'POST', |
|
711 |
url: "/widgets/widgets/system_information.widget.php", |
|
712 |
dataType: 'html', |
|
713 |
data: { |
|
714 |
ajax: "ajax", |
|
715 |
getupdatestatus: "2" |
|
716 |
}, |
|
717 |
|
|
718 |
success: function(data){ |
|
719 |
// Display the returned data |
|
720 |
$('[id^=widget-system_information] #updatestatus').html(data); |
|
721 |
// Re-attach the click handler |
|
722 |
|
|
723 |
$('#updver').click(function() { |
|
724 |
updver_ajax(); |
|
725 |
}); |
|
726 |
}, |
|
727 |
|
|
728 |
error: function(e){ |
|
729 |
} |
|
730 |
}); |
|
731 |
} |
|
689 | 732 |
}); |
690 | 733 |
//]]> |
691 | 734 |
</script> |
Also available in: Unified diff
Add AJAX version check