summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www/index.php')
-rw-r--r--src/usr/local/www/index.php69
1 files changed, 67 insertions, 2 deletions
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php
index 51adbae..a9d58e7 100644
--- a/src/usr/local/www/index.php
+++ b/src/usr/local/www/index.php
@@ -121,6 +121,7 @@ foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) {
if (!is_array($config['widgets'])) {
$config['widgets'] = array();
}
+
if (!is_array($user_settings['widgets'])) {
$user_settings['widgets'] = array();
}
@@ -385,7 +386,7 @@ foreach ($available as $widgetkey => $widgetconfig):
?>
<div class="col-sm-3"><a href="#" id="btnadd-<?=$widgetconfig['basename']?>"><i class="fa fa-plus"></i> <?=$widgetconfig['title']?></a></div>
<?php endif; ?>
-<?php
+<?php
endforeach;
?>
</div>
@@ -566,8 +567,20 @@ function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) {
});
}
-events.push(function() {
+// --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
+// These need to live outsie of the events.push() function to enable the widgets to see them
+var ajaxspecs = new Array(); // Array to hold widget refresh specifications (objects )
+var ajaxidx = 0;
+var ajaxmutex = false;
+var ajaxcntr = 0;
+// Add a widget refresh object to the array list
+function register_ajax(ws) {
+ ajaxspecs.push(ws);
+}
+// ---------------------------------------------------------------------------------------------------
+
+events.push(function() {
// Make panels destroyable
$('.container .panel-heading a[data-toggle="close"]').each(function (idx, el) {
$(el).on('click', function(e) {
@@ -622,9 +635,61 @@ events.push(function() {
$('#btnstore').removeClass("invisible");
}
});
+
+ // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
+ function make_ajax_call(wd) {
+ ajaxmutex = true;
+
+ $.ajax({
+ type: 'POST',
+ url: wd.url,
+ dataType: 'html',
+ data: wd.parms,
+
+ success: function(data){
+ wd.callback(data);
+ ajaxmutex = false;
+ },
+
+ error: function(e){
+// alert("Error: " + e);
+ ajaxmutex = false;
+ }
+ });
+ }
+
+ // Loop through each AJAX widget refresh object, make the AJAX call and pass the
+ // results back to the widget's callback function
+ function executewidget() {
+ if (ajaxspecs.length > 0) {
+ var freq = ajaxspecs[ajaxidx].freq; // widget can specifify it should be called freq times around hte loop
+
+ if (!ajaxmutex) {
+ if (((ajaxcntr % freq) === 0) && (typeof ajaxspecs[ajaxidx].callback === "function" )) {
+ make_ajax_call(ajaxspecs[ajaxidx]);
+ }
+
+ if (++ajaxidx >= ajaxspecs.length) {
+ ajaxidx = 0;
+
+ if (++ajaxcntr >= 4096) {
+ ajaxcntr = 0;
+ }
+ }
+ }
+
+ setTimeout(function() { executewidget(); }, 1000);
+ }
+ }
+
+ // Kick it off
+ executewidget();
+
+ //----------------------------------------------------------------------------------------------------
});
//]]>
</script>
+
<?php
//build list of javascript include files
foreach (glob('widgets/javascript/*.js') as $file) {
OpenPOWER on IntegriCloud