// rendering the chart that is panned or zoomed).
// Used with .current.global_pan_sync_time
- last_resized: new Date().getTime(), // the timestamp of the last resize request
+ last_resized: Date.now(), // the timestamp of the last resize request
last_page_scroll: 0, // the timestamp the last time the page was scrolled
console.log('welcome to NETDATA');
NETDATA.onresize = function() {
- NETDATA.options.last_resized = new Date().getTime();
+ NETDATA.options.last_resized = Date.now();
NETDATA.onscroll();
};
NETDATA.onscroll_updater = function() {
NETDATA.onscroll_updater_running = true;
NETDATA.onscroll_updater_count++;
- var start = new Date().getTime();
+ var start = Date.now();
var targets = NETDATA.options.targets;
var len = targets.length;
targets[len].isVisible();
}
- var end = new Date().getTime();
+ var end = Date.now();
// console.log('scroll No ' + NETDATA.onscroll_updater_count + ' calculation took ' + (end - start).toString() + ' ms');
if(NETDATA.options.current.async_on_scroll === false) {
NETDATA.onscroll = function() {
// console.log('onscroll');
- NETDATA.options.last_page_scroll = new Date().getTime();
+ NETDATA.options.last_page_scroll = Date.now();
NETDATA.options.auto_refresher_stop_until = 0;
if(NETDATA.options.targets === null) return;
NETDATA.error = function(code, msg) {
NETDATA.errorLast.code = code;
NETDATA.errorLast.message = msg;
- NETDATA.errorLast.datetime = new Date().getTime();
+ NETDATA.errorLast.datetime = Date.now();
console.log("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
if(this.master !== null && this.master !== state)
this.master.resetChart(true, true);
- var now = new Date().getTime();
+ var now = Date.now();
this.master = state;
this.seq = now;
this.force_after_ms = after;
if(NETDATA.chartDefaults.min_width !== null)
$(that.element).css('min-width', NETDATA.chartDefaults.min_width);
- that.tm.last_dom_created = new Date().getTime();
+ that.tm.last_dom_created = Date.now();
showLoading();
};
that.data_before = 0; // milliseconds - the last timestamp of the data
that.data_update_every = 0; // milliseconds - the frequency to update the data
- that.tm.last_initialized = new Date().getTime();
+ that.tm.last_initialized = Date.now();
createDOM();
that.setMode('auto');
showRendering();
that.element_chart.style.display = 'none';
if(that.element_legend !== null) that.element_legend.style.display = 'none';
- that.tm.last_hidden = new Date().getTime();
+ that.tm.last_hidden = Date.now();
// de-allocate data
// This works, but I not sure there are no corner cases somewhere
init();
}
else {
- that.tm.last_unhidden = new Date().getTime();
+ that.tm.last_unhidden = Date.now();
that.element_chart.style.display = '';
if(that.element_legend !== null) that.element_legend.style.display = '';
resizeChart();
maxMessageFontSize();
}
- that.tm.last_resized = new Date().getTime();
+ that.tm.last_resized = Date.now();
}
};
if(that.settings_id !== null)
NETDATA.localStorageSet('chart_heights.' + that.settings_id, h);
- var now = new Date().getTime();
+ var now = Date.now();
NETDATA.options.last_page_scroll = now;
NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.stop_updates_while_resizing;
this.event_resize.chart_last_w = this.element.clientWidth;
this.event_resize.chart_last_h = this.element.clientHeight;
- var now = new Date().getTime();
+ var now = Date.now();
if(now - this.event_resize.last <= NETDATA.options.current.double_click_speed) {
// double click / double tap event
var noDataToShow = function() {
showMessageIcon('<i class="fa fa-warning"></i> empty');
that.legendUpdateDOM();
- that.tm.last_autorefreshed = new Date().getTime();
+ that.tm.last_autorefreshed = Date.now();
// that.data_update_every = 30 * 1000;
//that.element_chart.style.display = 'none';
//if(that.element_legend !== null) that.element_legend.style.display = 'none';
this.current.force_before_ms = null;
this.current.force_after_ms = null;
- this.tm.last_mode_switch = new Date().getTime();
+ this.tm.last_mode_switch = Date.now();
};
// ----------------------------------------------------------------------------------------------------------------
return;
if(typeof ms === 'number')
- NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + ms;
+ NETDATA.globalSelectionSync.dont_sync_before = Date.now() + ms;
else
- NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
+ NETDATA.globalSelectionSync.dont_sync_before = Date.now() + NETDATA.options.current.sync_selection_delay;
};
// can we globally apply selection sync?
if(NETDATA.options.current.sync_selection === false)
return false;
- if(NETDATA.globalSelectionSync.dont_sync_before > new Date().getTime())
+ if(NETDATA.globalSelectionSync.dont_sync_before > Date.now())
return false;
return true;
if(this.debug === true)
this.log(logme + 'ACCEPTING UPDATE: current/min duration: ' + (current_duration / 1000).toString() + '/' + (this.fixed_min_duration / 1000).toString() + ', wanted duration: ' + (wanted_duration / 1000).toString() + ', duration diff: ' + (Math.round(Math.abs(current_duration - wanted_duration) / 1000)).toString() + ', movement: ' + (movement / 1000).toString() + ', tolerance: ' + (tolerance / 1000).toString() + ', returning: ' + ret);
- this.current.force_update_at = new Date().getTime() + NETDATA.options.current.pan_and_zoom_delay;
+ this.current.force_update_at = Date.now() + NETDATA.options.current.pan_and_zoom_delay;
this.current.force_after_ms = after;
this.current.force_before_ms = before;
NETDATA.globalPanAndZoom.setMaster(this, after, before);
this.updates_since_last_unhide++;
this.updates_since_last_creation++;
- var started = new Date().getTime();
+ var started = Date.now();
// if the result is JSON, find the latest update-every
this.data_update_every = data.view_update_every * 1000;
NETDATA.globalSelectionSync.stop();
// update the performance counters
- var now = new Date().getTime();
+ var now = Date.now();
this.tm.last_updated = now;
// don't update last_autorefreshed if this chart is
if(nocache === false && this.tm.last_visible_check > NETDATA.options.last_page_scroll)
return this.___isVisible___;
- this.tm.last_visible_check = new Date().getTime();
+ this.tm.last_visible_check = Date.now();
var wh = window.innerHeight;
var x = this.element.getBoundingClientRect();
};
this.canBeAutoRefreshed = function() {
- var now = new Date().getTime();
+ var now = Date.now();
if(this.running === true) {
if(this.debug === true)
this.chart_url = chart.url;
this.data_update_every = chart.update_every * 1000;
this.data_points = Math.round(this.chartWidth() / this.chartPixelsPerPoint());
- this.tm.last_info_downloaded = new Date().getTime();
+ this.tm.last_info_downloaded = Date.now();
if(this.title === null)
this.title = chart.title;
};
NETDATA.parseDom = function(callback) {
- NETDATA.options.last_page_scroll = new Date().getTime();
+ NETDATA.options.last_page_scroll = Date.now();
NETDATA.options.updated_dom = false;
var targets = $('div[data-netdata]'); //.filter(':visible');
dygraph.updateOptions(options);
}
- state.dygraph_last_rendered = new Date().getTime();
+ state.dygraph_last_rendered = Date.now();
return true;
};
// the internal default of dygraphs
context.touchDirections = { x: true, y: false };
- state.dygraph_last_touch_start = new Date().getTime();
+ state.dygraph_last_touch_start = Date.now();
state.dygraph_last_touch_move = 0;
if(typeof event.touches[0].pageX === 'number')
state.dygraph_user_action = true;
Dygraph.defaultInteractionModel.touchmove(event, dygraph, context);
- state.dygraph_last_touch_move = new Date().getTime();
+ state.dygraph_last_touch_move = Date.now();
},
touchend: function(event, dygraph, context) {
if(NETDATA.options.debug.dygraph === true || state.debug === true)
}
// if it was double tap within double click time, reset the charts
- var now = new Date().getTime();
+ var now = Date.now();
if(typeof state.dygraph_last_touch_end !== 'undefined') {
if(state.dygraph_last_touch_move === 0) {
var dt = now - state.dygraph_last_touch_end;
state.dygraph_force_zoom = false;
state.dygraph_user_action = false;
- state.dygraph_last_rendered = new Date().getTime();
+ state.dygraph_last_rendered = Date.now();
if(typeof state.dygraph_instance.axes_[0].extremeRange !== 'undefined') {
state.__commonMin = self.data('common-min') || null;
NETDATA.registry.machines = {};
NETDATA.registry.machines_array = new Array();
- var now = new Date().getTime();
+ var now = Date.now();
var apu = person_urls;
var i = apu.length;
while(i--) {
}
// is it too soon for a refresh?
- var now = new Date().getTime();
+ var now = Date.now();
if((now - mainchart.hiddenchart.last_updated) < (mainchart.update_every * 10 * 1000) || (now - mainchart.hiddenchart.last_updated) < (mainchart.hiddenchart.group * mainchart.hiddenchart.update_every * 1000)) {
if(typeof doNext == "function") doNext();
return;
}
mainchart.dashboard.draw(mainchart.control_data);
- mainchart.hiddenchart.last_updated = new Date().getTime();
+ mainchart.hiddenchart.last_updated = Date.now();
mainchart.hiddenchart.refreshCount++;
})
.always(function() {
$('.global_play_button').button('play');
// check if the thread died due to a javascript error
- var now = new Date().getTime();
+ var now = Date.now();
if((now - last_refresh) > 60000) {
// it died or never started
//mylog('It seems the refresh thread died. Restarting it.');
return;
}
- var now = new Date().getTime();
+ var now = Date.now();
if(now - last_refresh > 60000) {
mylog('Refresh thread died. Restarting it.');
renderChartCallback();
// never call it directly, or new javascript threads will be spawn
var timeout = null;
function renderChartCallback() {
- last_refresh = new Date().getTime();
+ last_refresh = Date.now();
if(!page_is_visible) {
timeout = setTimeout(triggerRefresh, CHARTS_CHECK_NO_FOCUS);
}
if(last_user_scroll) {
- var now = new Date().getTime();
+ var now = Date.now();
if((now - last_user_scroll) >= CHARTS_SCROLL_IDLE) {
last_user_scroll = 0;
mylog('Scrolling: resuming refresh...');
//mylog('triggerRefresh()');
if(!page_is_visible || (refresh_mode == REFRESH_PAUSED && mode != MODE_MAIN)) {
- last_refresh = new Date().getTime();
+ last_refresh = Date.now();
timeout = setTimeout(triggerRefresh, CHARTS_REFRESH_IDLE);
return;
}
var height = TARGET_THUMB_GRAPH_HEIGHT;
window.onscroll = function (e) {
- last_user_scroll = new Date().getTime();
+ last_user_scroll = Date.now();
mylog('Scrolling: detected');
}