[MIT License](https://github.com/marcj/css-element-queries/blob/master/LICENSE)
+- [AVL C Library](http://freecode.com/projects/avl)
+
+ Copyright 2000, Daniel Nagy, Budapest University of Technology and Economics
+ Released under GNU General Public License (GPL) version 2
+
+
- [morris.js](http://morrisjs.github.io/morris.js/)
Copyright 2013, Olly Smith
line: 1.0,
area: 0.2,
stacked: 0.8
- }
+ },
+
+ set_option_callback: function() { ; }
},
debug: {
}
}
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // local storage options
+
+ NETDATA.objectToLocalStorage = function(obj, prefix) {
+ if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
+ for(var i in obj) {
+ if(typeof obj[i] === 'object') {
+ //console.log('object ' + prefix + '.' + i.toString());
+ NETDATA.objectToLocalStorage(obj[i], prefix + '.' + i.toString());
+ continue;
+ }
+
+ var value = localStorage.getItem(prefix + '.' + i.toString());
+ if(value === null) {
+ switch(typeof obj[i]) {
+ case 'boolean':
+ case 'number':
+ //console.log('write ' + prefix + '.' + i.toString() + ' = ' + obj[i].toString());
+ localStorage.setItem(prefix + '.' + i.toString(), obj[i].toString())
+ break;
+ }
+ continue;
+ }
+
+ switch(typeof obj[i]) {
+ case 'boolean':
+ if(value === 'true' || value === 'false') {
+ obj[i] = (value === 'false')?false:true;
+ //console.log('read ' + prefix + '.' + i.toString() + ' = ' + obj[i].toString());
+ }
+ //else console.log('ignoring ' + i.toString());
+ break;
+
+ case 'number':
+ var n = parseInt(value);
+ if(isNaN(n) === false) {
+ obj[i] = n;
+ // console.log('read ' + prefix + '.' + i.toString() + ' = ' + obj[i].toString());
+ }
+ // else console.log('ignoring ' + i.toString());
+ break;
+ }
+ }
+ }
+ }
+
+ NETDATA.setOption = function(key, value) {
+ var ret = false;
+
+ switch(typeof NETDATA.options.current[key]) {
+ case 'boolean':
+ if(value) NETDATA.options.current[key] = true;
+ else NETDATA.options.current[key] = false;
+ localStorage.setItem('options.' + key.toString(), NETDATA.options.current[key].toString());
+ ret = true;
+ break;
+
+ case 'number':
+ if(typeof value === 'number') {
+ NETDATA.options.current[key] = value;
+ localStorage.setItem('options.' + key.toString(), NETDATA.options.current[key].toString());
+ ret = true;
+ }
+ //else
+ // console.log('invalid number given for option key ' + key.toString);
+ break;
+
+ case 'function':
+ if(typeof value === 'function') {
+ NETDATA.options.current[key] = value;
+ ret = true;
+ }
+ //else
+ // console.log('invalid function given for option key ' + key.toString);
+ break;
+
+ default:
+ // console.log('cannot find option key ' + key.toString());
+ break;
+ }
+
+ if(ret === true)
+ NETDATA.options.current.set_option_callback();
+
+ return ret;
+ }
+
+ NETDATA.getOption = function(key) {
+ return NETDATA.options.current[key];
+ }
+
+ NETDATA.resetOptions = function() {
+ // console.log('will reset all');
+ for(var i in NETDATA.options.defaults) {
+ if(i.toString() === 'set_option_callback') continue;
+
+ if(NETDATA.options.current[i] !== NETDATA.options.defaults[i]) {
+ // console.log('reseting ' + i.toString() + ' to ' + NETDATA.options.defaults[i].toString());
+ NETDATA.setOption(i, NETDATA.options.defaults[i]);
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
if(NETDATA.options.debug.main_loop === true)
console.log('welcome to NETDATA');
NETDATA.loadRequiredJs(0, function() {
ElementQueries.init();
+ // keep a copy of the default settings
+ NETDATA.options.defaults = $.extend({}, NETDATA.options.current);
+
+ // read settings from local storage
+ NETDATA.objectToLocalStorage(NETDATA.options.current, 'options');
+
+ // always start with this option enabled.
+ NETDATA.setOption('stop_updates_when_focus_is_lost', true);
+
if(typeof netdataDontStart === 'undefined' || !netdataDontStart) {
if(NETDATA.options.debug.main_loop === true)
console.log('starting chart refresh thread');
<div class="modal-body">
<form id="optionsForm" method="get" class="form-horizontal">
<div class="form-group">
+ <center>
+ <small style="color: #BBBBBB;">Settings take effect immediately and are saved permanently to browser local storage (except the refresh on focus / always option).
+ <br/>
+ To reset all options to their defaults, click <a href="#" onclick="NETDATA.resetOptions(); return false;">here</a>.</small>
+ </center>
+
<table>
<tr class="option-row">
<td class="option-control"><input id="stop_updates_when_focus_is_lost" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="On Focus" data-off="Always" data-width="110px"></td>
document.getElementById('footer').style.display = 'block';
- // default options
- $('#eliminate_zero_dimensions').bootstrapToggle(NETDATA.options.current.eliminate_zero_dimensions?'on':'off');
- $('#destroy_on_hide').bootstrapToggle(NETDATA.options.current.destroy_on_hide?'on':'off');
- $('#parallel_refresher').bootstrapToggle(NETDATA.options.current.parallel_refresher?'on':'off');
- $('#concurrent_refreshes').bootstrapToggle(NETDATA.options.current.concurrent_refreshes?'on':'off');
- $('#sync_selection').bootstrapToggle(NETDATA.options.current.sync_selection?'on':'off');
- $('#sync_pan_and_zoom').bootstrapToggle(NETDATA.options.current.sync_pan_and_zoom?'on':'off');
- $('#stop_updates_when_focus_is_lost').bootstrapToggle(NETDATA.options.current.stop_updates_when_focus_is_lost?'on':'off');
var update_options_visibility = function() {
- if(NETDATA.options.current.parallel_refresher === false) {
+ // console.log('update_options_visibility');
+
+ var sync_option = function(option) {
+ var self = $('#' + option);
+
+ if(self.prop('checked') !== NETDATA.getOption(option)) {
+ // console.log('switching ' + option.toString());
+ self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
+ }
+ }
+
+ sync_option('eliminate_zero_dimensions');
+ sync_option('destroy_on_hide');
+ sync_option('parallel_refresher');
+ sync_option('concurrent_refreshes');
+ sync_option('sync_selection');
+ sync_option('sync_pan_and_zoom');
+ sync_option('stop_updates_when_focus_is_lost');
+
+ if(NETDATA.getOption('parallel_refresher') === false) {
$('#concurrent_refreshes_row').hide();
}
else {
$('#concurrent_refreshes_row').show();
}
};
- update_options_visibility();
+ NETDATA.setOption('set_option_callback', update_options_visibility);
// handle options changes
- $('#eliminate_zero_dimensions').change(function() { NETDATA.options.current.eliminate_zero_dimensions = $(this).prop('checked'); update_options_visibility(); });
- $('#destroy_on_hide').change(function() { NETDATA.options.current.destroy_on_hide = $(this).prop('checked'); update_options_visibility(); });
- $('#parallel_refresher').change(function() { NETDATA.options.current.parallel_refresher = $(this).prop('checked'); update_options_visibility(); });
- $('#concurrent_refreshes').change(function() { NETDATA.options.current.concurrent_refreshes = $(this).prop('checked'); update_options_visibility(); });
- $('#sync_selection').change(function() { NETDATA.options.current.sync_selection = $(this).prop('checked'); update_options_visibility(); });
- $('#sync_pan_and_zoom').change(function() { NETDATA.options.current.sync_pan_and_zoom = $(this).prop('checked'); update_options_visibility(); });
- $('#stop_updates_when_focus_is_lost').change(function() { NETDATA.options.current.stop_updates_when_focus_is_lost = $(this).prop('checked'); update_options_visibility(); });
+ $('#eliminate_zero_dimensions').change(function() { NETDATA.setOption('eliminate_zero_dimensions', $(this).prop('checked')); });
+ $('#destroy_on_hide').change(function() { NETDATA.setOption('destroy_on_hide', $(this).prop('checked')); });
+ $('#parallel_refresher').change(function() { NETDATA.setOption('parallel_refresher', $(this).prop('checked')); });
+ $('#concurrent_refreshes').change(function() { NETDATA.setOption('concurrent_refreshes', $(this).prop('checked')); });
+ $('#sync_selection').change(function() { NETDATA.setOption('sync_selection', $(this).prop('checked')); });
+ $('#sync_pan_and_zoom').change(function() { NETDATA.setOption('sync_pan_and_zoom', $(this).prop('checked')); });
+ $('#stop_updates_when_focus_is_lost').change(function() { NETDATA.setOption('stop_updates_when_focus_is_lost', $(this).prop('checked')); });
if(document.location.hostname === demo_hostname)
setTimeout(function() {