minor optimizations
Costa Tsaousis (ktsaou) committed
Dec 16, 2015 at 21:41 UTC
c4fabf403db511ba237767eeb9d569838faf947e
1 file changed
+322
-157
web/dashboard.js
+322
-157
@@ -207,20 +207,21 @@
207
},
208
209
debug: {
210
- show_boxes: 0,
211
- main_loop: 0,
212
- focus: 0,
213
- visibility: 0,
214
- chart_data_url: 0,
215
- chart_errors: 1,
216
- chart_timing: 0,
217
- chart_calls: 0,
218
- libraries: 0,
219
- dygraph: 0
210
+ show_boxes: false,
211
+ main_loop: false,
212
+ focus: false,
213
+ visibility: false,
214
+ chart_data_url: false,
215
+ chart_errors: true,
216
+ chart_timing: false,
217
+ chart_calls: false,
218
+ libraries: false,
219
+ dygraph: false
220
}
221
}
222
223
- if(NETDATA.options.debug.main_loop) console.log('welcome to NETDATA');
223
+ if(NETDATA.options.debug.main_loop === true)
224
+ console.log('welcome to NETDATA');
225
226
window.onresize = function(event) {
227
NETDATA.options.last_page_scroll = new Date().getTime();
@@ -364,7 +365,8 @@
365
366
// set a new master
367
setMaster: function(state, after, before) {
367
- if(!NETDATA.options.current.sync_pan_and_zoom) return;
368
+ if(NETDATA.options.current.sync_pan_and_zoom === false)
369
+ return;
370
371
if(this.master !== null && this.master !== state)
372
this.master.resetChart();
@@ -379,7 +381,8 @@
381
382
// clear the master
383
clearMaster: function() {
382
- if(!NETDATA.options.current.sync_pan_and_zoom) return;
384
+ if(NETDATA.options.current.sync_pan_and_zoom === false)
385
+ return;
386
387
if(this.master !== null) {
388
var state = this.master;
@@ -508,6 +511,8 @@
511
last_resized: 0, // the time the chart was resized
512
last_hidden: 0, // the time the chart was hidden
513
last_unhidden: 0, // the time the chart was unhidden
514
+
515
+ last_autorefreshed: 0 // the time the chart was last refreshed
516
},
517
518
current: null, // auto, pan, zoom
@@ -517,7 +522,6 @@
522
name: 'auto',
523
autorefresh: true,
524
url: 'invalid://', // string - the last url used to update the chart
520
- last_autorefreshed: 0, // milliseconds - the timestamp of last automatic refresh
525
view_update_every: 0, // milliseconds - the minimum acceptable refresh duration
526
after_ms: 0, // milliseconds - the first timestamp of the data
527
before_ms: 0, // milliseconds - the last timestamp of the data
@@ -535,7 +539,6 @@
539
name: 'pan',
540
autorefresh: false,
541
url: 'invalid://', // string - the last url used to update the chart
538
- last_autorefreshed: 0, // milliseconds - the timestamp of last refresh
542
view_update_every: 0, // milliseconds - the minimum acceptable refresh duration
543
after_ms: 0, // milliseconds - the first timestamp of the data
544
before_ms: 0, // milliseconds - the last timestamp of the data
@@ -553,7 +556,6 @@
556
name: 'zoom',
557
autorefresh: false,
558
url: 'invalid://', // string - the last url used to update the chart
556
- last_autorefreshed: 0, // milliseconds - the timestamp of last refresh
559
view_update_every: 0, // milliseconds - the minimum acceptable refresh duration
560
after_ms: 0, // milliseconds - the first timestamp of the data
561
before_ms: 0, // milliseconds - the last timestamp of the data
@@ -587,7 +589,9 @@
589
590
// prevent to global selection sync for some time
591
chartState.prototype.globalSelectionSyncDelay = function(ms) {
590
- if(!NETDATA.options.current.sync_selection) return;
592
+ if(NETDATA.options.current.sync_selection === false)
593
+ return;
594
+
595
if(typeof ms === 'number')
596
NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + ms;
597
else
@@ -596,7 +600,9 @@
600
601
// can we globally apply selection sync?
602
chartState.prototype.globalSelectionSyncAbility = function() {
599
- if(!NETDATA.options.current.sync_selection) return false;
603
+ if(NETDATA.options.current.sync_selection === false)
604
+ return false;
605
+
606
if(NETDATA.globalSelectionSync.dont_sync_before > new Date().getTime()) return false;
607
return true;
608
}
@@ -612,17 +618,23 @@
618
chartState.prototype.globalSelectionSyncBeMaster = function() {
619
// am I the master?
620
if(this.globalSelectionSyncIsMaster()) {
615
- if(this.debug) this.log('sync: I am the master already.');
621
+ if(this.debug === true)
622
+ this.log('sync: I am the master already.');
623
+
624
return;
625
}
626
627
if(NETDATA.globalSelectionSync.state) {
620
- if(this.debug) this.log('sync: I am not the sync master. Resetting global sync.');
628
+ if(this.debug === true)
629
+ this.log('sync: I am not the sync master. Resetting global sync.');
630
+
631
this.globalSelectionSyncStop();
632
}
633
634
// become the master
625
- if(this.debug) this.log('sync: becoming sync master.');
635
+ if(this.debug === true)
636
+ this.log('sync: becoming sync master.');
637
+
638
this.selected = true;
639
NETDATA.globalSelectionSync.state = this;
640
@@ -633,10 +645,13 @@
645
st = targets[len];
646
647
if(st === this) {
636
- if(this.debug) st.log('sync: not adding me to sync');
648
+ if(this.debug === true)
649
+ st.log('sync: not adding me to sync');
650
}
651
else if(st.globalSelectionSyncIsEligible()) {
639
- if(this.debug) st.log('sync: adding to sync as slave');
652
+ if(this.debug === true)
653
+ st.log('sync: adding to sync as slave');
654
+
655
st.globalSelectionSyncBeSlave();
656
}
657
}
@@ -660,17 +675,23 @@
675
// sync all the visible charts to the given time
676
// this is to be called from the chart libraries
677
chartState.prototype.globalSelectionSync = function(t) {
663
- if(!this.globalSelectionSyncAbility()) {
664
- if(this.debug) this.log('sync: cannot sync (yet?).');
678
+ if(this.globalSelectionSyncAbility() === false) {
679
+ if(this.debug === true)
680
+ this.log('sync: cannot sync (yet?).');
681
+
682
return;
683
}
684
668
- if(!this.globalSelectionSyncIsMaster()) {
669
- if(this.debug) this.log('sync: trying to be sync master.');
685
+ if(this.globalSelectionSyncIsMaster() === false) {
686
+ if(this.debug === true)
687
+ this.log('sync: trying to be sync master.');
688
+
689
this.globalSelectionSyncBeMaster();
690
672
- if(!this.globalSelectionSyncAbility()) {
673
- if(this.debug) this.log('sync: cannot sync (yet?).');
691
+ if(this.globalSelectionSyncAbility() === false) {
692
+ if(this.debug === true)
693
+ this.log('sync: cannot sync (yet?).');
694
+
695
return;
696
}
697
}
@@ -690,14 +711,19 @@
711
// stop syncing all charts to the given time
712
chartState.prototype.globalSelectionSyncStop = function() {
713
if(NETDATA.globalSelectionSync.slaves.length) {
693
- if(this.debug) this.log('sync: cleaning up...');
714
+ if(this.debug === true)
715
+ this.log('sync: cleaning up...');
716
+
717
var self = this;
718
$.each(NETDATA.globalSelectionSync.slaves, function(i, st) {
719
if(st === self) {
697
- if(self.debug) st.log('sync: not adding me to sync stop');
720
+ if(self.debug === true)
721
+ st.log('sync: not adding me to sync stop');
722
}
723
else {
700
- if(self.debug) st.log('sync: removed slave from sync');
724
+ if(self.debug === true)
725
+ st.log('sync: removed slave from sync');
726
+
727
st.clearSelection();
728
}
729
});
@@ -713,29 +739,31 @@
739
740
chartState.prototype.setSelection = function(t) {
741
if(typeof this.library.setSelection === 'function') {
716
- if(this.library.setSelection(this, t))
742
+ if(this.library.setSelection(this, t) === true)
743
this.selected = true;
744
else
745
this.selected = false;
746
}
747
else this.selected = true;
748
723
- if(this.selected && this.debug) this.log('selection set to ' + t.toString());
749
+ if(this.selected === true && this.debug === true)
750
+ this.log('selection set to ' + t.toString());
751
752
return this.selected;
753
}
754
755
chartState.prototype.clearSelection = function() {
729
- if(this.selected) {
756
+ if(this.selected === true) {
757
if(typeof this.library.clearSelection === 'function') {
731
- if(this.library.clearSelection(this))
758
+ if(this.library.clearSelection(this) === true)
759
this.selected = false;
760
else
761
this.selected = true;
762
}
763
else this.selected = false;
764
738
- if(!this.selected && this.debug) this.log('selection cleared');
765
+ if(this.selected === false && this.debug === true)
766
+ this.log('selection cleared');
767
}
768
769
this.legendReset();
@@ -750,7 +778,7 @@
778
},
779
780
chartState.prototype.calculateRowForTime = function(t) {
753
- if(!this.timeIsVisible(t)) return -1;
781
+ if(this.timeIsVisible(t) === false) return -1;
782
return Math.floor((t - this.current.after_ms) / this.current.view_update_every);
783
}
784
@@ -762,15 +790,19 @@
790
}
791
792
chartState.prototype.pauseChart = function() {
765
- if(!this.paused) {
766
- if(this.debug) this.log('paused');
793
+ if(this.paused === false) {
794
+ if(this.debug === true)
795
+ this.log('paused');
796
+
797
this.paused = true;
798
}
799
}
800
801
chartState.prototype.unpauseChart = function() {
802
if(this.paused) {
773
- if(this.debug) this.log('unpaused');
803
+ if(this.debug === true)
804
+ this.log('unpaused');
805
+
806
this.paused = false;
807
}
808
}
@@ -787,7 +819,7 @@
819
this.current.force_update_at = 0;
820
this.current.force_before_ms = null;
821
this.current.force_after_ms = null;
790
- this.current.last_autorefreshed = 0;
822
+ this.tm.last_autorefreshed = 0;
823
this.paused = false;
824
this.selected = false;
825
this.enabled = true;
@@ -797,7 +829,7 @@
829
// or the chart will flip-flop when it is the master
830
// of a selection sync and another chart becomes
831
// the new master
800
- if(!NETDATA.options.current.sync_pan_and_zoom && this.isVisible())
832
+ if(NETDATA.options.current.sync_pan_and_zoom === false && this.isVisible() === true)
833
state.updateChart();
834
}
835
@@ -806,7 +838,6 @@
838
if(this.current.name === m) return;
839
840
this[m].url = this.current.url;
809
- this[m].last_autorefreshed = this.current.last_autorefreshed;
841
this[m].view_update_every = this.current.view_update_every;
842
this[m].after_ms = this.current.after_ms;
843
this[m].before_ms = this.current.before_ms;
@@ -831,7 +862,8 @@
862
this.current.force_before_ms = null;
863
this.current.force_after_ms = null;
864
834
- if(this.debug) this.log('mode set to ' + this.current.name);
865
+ if(this.debug === true)
866
+ this.log('mode set to ' + this.current.name);
867
}
868
869
chartState.prototype._minPanOrZoomStep = function() {
@@ -850,16 +882,22 @@
882
883
var min_step = this._minPanOrZoomStep();
884
if(new_range < old_range && new_range / this.chartWidth() < 100) {
853
- if(this.debug) this.log('_shouldBeMoved(' + (new_after / 1000).toString() + ' - ' + (new_before / 1000).toString() + '): minimum point size: 0.10, wanted point size: ' + (new_range / this.chartWidth() / 1000).toString() + ': TOO SMALL RANGE');
885
+ if(this.debug === true)
886
+ this.log('_shouldBeMoved(' + (new_after / 1000).toString() + ' - ' + (new_before / 1000).toString() + '): minimum point size: 0.10, wanted point size: ' + (new_range / this.chartWidth() / 1000).toString() + ': TOO SMALL RANGE');
887
+
888
return false;
889
}
890
891
if(step >= min_step) {
858
- if(this.debug) this.log('_shouldBeMoved(' + (new_after / 1000).toString() + ' - ' + (new_before / 1000).toString() + '): minimum step: ' + (min_step / 1000).toString() + ', this step: ' + (step / 1000).toString() + ': YES');
892
+ if(this.debug === true)
893
+ this.log('_shouldBeMoved(' + (new_after / 1000).toString() + ' - ' + (new_before / 1000).toString() + '): minimum step: ' + (min_step / 1000).toString() + ', this step: ' + (step / 1000).toString() + ': YES');
894
+
895
return true;
896
}
897
else {
862
- if(this.debug) this.log('_shouldBeMoved(' + (new_after / 1000).toString() + ' - ' + (new_before / 1000).toString() + '): minimum step: ' + (min_step / 1000).toString() + ', this step: ' + (step / 1000).toString() + ': NO');
898
+ if(this.debug === true)
899
+ this.log('_shouldBeMoved(' + (new_after / 1000).toString() + ' - ' + (new_before / 1000).toString() + '): minimum step: ' + (min_step / 1000).toString() + ', this step: ' + (step / 1000).toString() + ': NO');
900
+
901
return false;
902
}
903
}
@@ -868,20 +906,28 @@
906
var move = false;
907
908
if(this.current.name === 'auto') {
871
- if(this.debug) this.log('updateChartPanOrZoom(): caller did not set proper mode');
909
+ if(this.debug === true)
910
+ this.log('updateChartPanOrZoom(): caller did not set proper mode');
911
+
912
this.setMode('pan');
913
}
914
875
- if(!this.current.force_after_ms || !this.current.force_before_ms) {
876
- if(this.debug) this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): INIT');
915
+ if(this.current.force_after_ms === null || this.current.force_before_ms === null) {
916
+ if(this.debug === true)
917
+ this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): INIT');
918
+
919
move = true;
920
}
921
else if(this._shouldBeMoved(this.current.force_after_ms, this.current.force_before_ms, after, before) && this._shouldBeMoved(this.current.after_ms, this.current.before_ms, after, before)) {
880
- if(this.debug) this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): FORCE CHANGE from ' + (this.current.force_after_ms / 1000).toString() + ' - ' + (this.current.force_before_ms / 1000).toString());
922
+ if(this.debug === true)
923
+ this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): FORCE CHANGE from ' + (this.current.force_after_ms / 1000).toString() + ' - ' + (this.current.force_before_ms / 1000).toString());
924
+
925
move = true;
926
}
927
else if(this._shouldBeMoved(this.current.requested_after_ms, this.current.requested_before_ms, after, before) && this._shouldBeMoved(this.current.after_ms, this.current.before_ms, after, before)) {
884
- if(this.debug) this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): REQUESTED CHANGE from ' + (this.current.requested_after_ms / 1000).toString() + ' - ' + (this.current.requested_before_ms / 1000).toString());
928
+ if(this.debug === true)
929
+ this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): REQUESTED CHANGE from ' + (this.current.requested_after_ms / 1000).toString() + ' - ' + (this.current.requested_before_ms / 1000).toString());
930
+
931
move = true;
932
}
933
@@ -893,7 +939,9 @@
939
return true;
940
}
941
896
- if(this.debug) this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): IGNORE');
942
+ if(this.debug === true)
943
+ this.log('updateChartPanOrZoom(' + (after / 1000).toString() + ' - ' + (before / 1000).toString() + '): IGNORE');
944
+
945
return false;
946
}
947
@@ -1012,10 +1060,13 @@
1060
}
1061
1062
this.colors_assigned[label] = this.colors_available.shift();
1015
- if(this.debug) this.log('label "' + label + '" got color "' + this.colors_assigned[label]);
1063
+
1064
+ if(this.debug === true)
1065
+ this.log('label "' + label + '" got color "' + this.colors_assigned[label]);
1066
}
1067
else {
1018
- if(this.debug) this.log('label "' + label + '" already has color "' + this.colors_assigned[label] + '"');
1068
+ if(this.debug === true)
1069
+ this.log('label "' + label + '" already has color "' + this.colors_assigned[label] + '"');
1070
}
1071
1072
this.colors.push(this.colors_assigned[label]);
@@ -1069,18 +1120,22 @@
1120
var labels = this.current.data.dimension_names.toString();
1121
if(labels !== this.element_legend_childs.series.labels_key) {
1122
needed = true;
1072
- if(this.debug) this.log('NEW LABELS: "' + labels + '" NOT EQUAL OLD LABELS: "' + this.element_legend_childs.series.labels_key + '"');
1123
+
1124
+ if(this.debug === true)
1125
+ this.log('NEW LABELS: "' + labels + '" NOT EQUAL OLD LABELS: "' + this.element_legend_childs.series.labels_key + '"');
1126
}
1127
}
1128
1076
- if(!needed) {
1129
+ if(needed === false) {
1130
// make sure there are colors available
1131
if(this.colors === null) this.colors = NETDATA.colors;
1132
1133
// do we have to update the current values?
1134
// we do this, only when the visible chart is current
1135
if(Math.abs(this.current.data.last_entry_t - this.current.data.before) <= this.current.data.view_update_every) {
1083
- if(this.debug) this.log('chart in running... updating values on legend...');
1136
+ if(this.debug === true)
1137
+ this.log('chart in running... updating values on legend...');
1138
+
1139
var labels = this.current.data.dimension_names;
1140
var i = labels.length;
1141
while(i--)
@@ -1098,7 +1153,8 @@
1153
// we will re-generate the colors for the chart
1154
this.colors = null;
1155
1101
- if(this.debug) this.log('updating Legend DOM');
1156
+ if(this.debug === true)
1157
+ this.log('updating Legend DOM');
1158
1159
self = $(this.element);
1160
var genLabel = function(state, parent, name, count) {
@@ -1203,7 +1259,8 @@
1259
1260
if(this.current.data) {
1261
this.element_legend_childs.series.labels_key = this.current.data.dimension_names.toString();
1206
- if(this.debug) this.log('SET DATA LABELS: "' + this.element_legend_childs.series.labels_key + '"');
1262
+ if(this.debug === true)
1263
+ this.log('labels from data: "' + this.element_legend_childs.series.labels_key + '"');
1264
1265
for(var i = 0, len = this.current.data.dimension_names.length; i < len ;i++) {
1266
genLabel(this, content, this.current.data.dimension_names[i], i);
@@ -1216,7 +1273,8 @@
1273
genLabel(this, content, this.chart.dimensions[dim].name, i);
1274
}
1275
this.element_legend_childs.series.labels_key = tmp.toString();
1219
- if(this.debug) this.log('SET DEFAULT LABELS: "' + this.element_legend_childs.series.labels_key + '"');
1276
+ if(this.debug === true)
1277
+ this.log('labels from chart: "' + this.element_legend_childs.series.labels_key + '"');
1278
}
1279
1280
// create a hidden div to be used for hidding
@@ -1235,7 +1293,8 @@
1293
}
1294
1295
chartState.prototype.createChartDOM = function() {
1238
- if(this.debug) this.log('creating DOM');
1296
+ if(this.debug === true)
1297
+ this.log('creating DOM');
1298
1299
this.element_chart_id = this.library_name + '-' + this.uuid + '-chart';
1300
this.element_chart = document.createElement('div');
@@ -1251,8 +1310,11 @@
1310
this.element_legend.className += ' netdata-' + this.library_name + '-legend';
1311
this.element_legend.id = this.element_legend_id;
1312
$(this.element_legend).data('netdata-state-object', this);
1254
- if(!this.hasLegend()) this.element_legend.style.display = 'none';
1255
- else this.element.appendChild(this.element_legend);
1313
+
1314
+ if(this.hasLegend() === false)
1315
+ this.element_legend.style.display = 'none';
1316
+ else
1317
+ this.element.appendChild(this.element_legend);
1318
1319
this.element_legend_childs.series = null;
1320
this.legendUpdateDOM();
@@ -1311,7 +1373,9 @@
1373
1374
chartState.prototype.resizeChart = function() {
1375
if(this.needsResize()) {
1314
- if(this.debug) this.log('forcing re-generation due to window resize.');
1376
+ if(this.debug === true)
1377
+ this.log('forcing re-generation due to window resize.');
1378
+
1379
this.tm.last_created = 0;
1380
this.tm.last_resized = new Date().getTime();
1381
}
@@ -1356,11 +1420,14 @@
1420
if(this.dimensions)
1421
this.current.url += "&dimensions=" + this.dimensions;
1422
1359
- if(NETDATA.options.debug.chart_data_url || this.debug) this.log('chartURL(): ' + this.current.url + ' WxH:' + this.chartWidth() + 'x' + this.chartHeight() + ' points: ' + this.current.points + ' library: ' + this.library_name);
1423
+ if(NETDATA.options.debug.chart_data_url === true || this.debug === true)
1424
+ this.log('chartURL(): ' + this.current.url + ' WxH:' + this.chartWidth() + 'x' + this.chartHeight() + ' points: ' + this.current.points + ' library: ' + this.library_name);
1425
}
1426
1427
chartState.prototype.updateChartWithData = function(data) {
1363
- if(this.debug) this.log('got data from netdata server');
1428
+ if(this.debug === true)
1429
+ this.log('got data from netdata server');
1430
+
1431
this.current.data = data;
1432
this.updates_counter++;
1433
@@ -1390,7 +1457,7 @@
1457
data.state = this;
1458
}
1459
1393
- if(this.debug) {
1460
+ if(this.debug === true) {
1461
this.log('UPDATE No ' + this.updates_counter + ' COMPLETED');
1462
1463
if(this.current.force_after_ms)
@@ -1412,18 +1479,21 @@
1479
this.resizeChart();
1480
1481
if(this.updates_since_last_creation >= this.library.max_updates_to_recreate()) {
1415
- if(this.debug) this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.');
1482
+ if(this.debug === true)
1483
+ this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.');
1484
+
1485
this.tm.last_created = 0;
1486
}
1487
1488
if(this.tm.last_created > 0 && typeof this.library.update === 'function') {
1420
- if(this.debug) this.log('updating chart...');
1489
+ if(this.debug === true)
1490
+ this.log('updating chart...');
1491
1492
// check and update the legend
1493
this.legendUpdateDOM();
1494
1495
this.updates_since_last_creation++;
1426
- if(NETDATA.options.debug.chart_errors) {
1496
+ if(NETDATA.options.debug.chart_errors === true) {
1497
this.library.update(this, data);
1498
}
1499
else {
@@ -1436,12 +1506,13 @@
1506
}
1507
}
1508
else {
1439
- if(this.debug) this.log('creating chart...');
1509
+ if(this.debug === true)
1510
+ this.log('creating chart...');
1511
1512
this.createChartDOM();
1513
this.updates_since_last_creation = 0;
1514
1444
- if(NETDATA.options.debug.chart_errors) {
1515
+ if(NETDATA.options.debug.chart_errors === true) {
1516
this.library.create(this, data);
1517
this.tm.last_created = new Date().getTime();
1518
}
@@ -1463,12 +1534,12 @@
1534
// don't update last_autorefreshed if this chart is
1535
// forced to be updated with global PanAndZoom
1536
if(NETDATA.globalPanAndZoom.isActive())
1466
- this.current.last_autorefreshed = 0;
1537
+ this.tm.last_autorefreshed = 0;
1538
else {
1539
//if(NETDATA.options.current.parallel_refresher === true)
1469
- // this.current.last_autorefreshed = Math.round(now / 1000) * 1000;
1540
+ // this.tm.last_autorefreshed = Math.round(now / 1000) * 1000;
1541
//else
1471
- this.current.last_autorefreshed = now;
1542
+ this.tm.last_autorefreshed = now;
1543
}
1544
1545
this.refresh_dt_ms = now - started;
@@ -1482,7 +1553,9 @@
1553
// due to late initialization of charts and libraries
1554
// we need to check this too
1555
if(this.enabled === false) {
1485
- if(this.debug) this.log('I am not enabled');
1556
+ if(this.debug === true)
1557
+ this.log('I am not enabled');
1558
+
1559
if(typeof callback === 'function') callback();
1560
return false;
1561
}
@@ -1509,7 +1582,9 @@
1582
this.clearSelection();
1583
this.chartURL();
1584
this.showLoading();
1512
- if(this.debug) this.log('updating from ' + this.current.url);
1585
+
1586
+ if(this.debug === true)
1587
+ this.log('updating from ' + this.current.url);
1588
1589
var self = this;
1590
this.xhr = $.ajax( {
@@ -1520,7 +1595,10 @@
1595
})
1596
.success(function(data) {
1597
self.hideLoading();
1523
- if(self.debug) self.log('data received. updating chart.');
1598
+
1599
+ if(self.debug === true)
1600
+ self.log('data received. updating chart.');
1601
+
1602
self.updateChartWithData(data);
1603
})
1604
.fail(function() {
@@ -1534,9 +1612,10 @@
1612
}
1613
1614
chartState.prototype.destroyChart = function() {
1537
- if(this.debug === true) this.log('destroying chart');
1615
+ if(this.debug === true)
1616
+ this.log('destroying chart');
1617
1539
- this.current.last_autorefreshed = new Date().getTime();
1618
+ this.tm.last_autorefreshed = new Date().getTime();
1619
1620
if(this.element_message !== null) {
1621
this.element_message.innerHTML = '';
@@ -1581,9 +1660,9 @@
1660
this.tm.last_visible_check = 0;
1661
this.tm.last_hidden = 0;
1662
this.tm.last_unhidden = 0;
1663
+ this.tm.last_autorefreshed = 0;
1664
1665
if(this.current !== null) {
1586
- this.current.last_autorefreshed = 0;
1666
this.current.view_update_every = 0;
1667
this.current.after_ms = 0;
1668
this.current.before_ms = 0;
@@ -1602,7 +1681,8 @@
1681
1682
chartState.prototype.unhideChart = function() {
1683
if(typeof this.___isHidden___ !== 'undefined' && this.enabled === true) {
1605
- if(this.debug === true) this.log('unhiding chart');
1684
+ if(this.debug === true)
1685
+ this.log('unhiding chart');
1686
1687
this.element_message.style.display = 'none';
1688
if(this.element_chart !== null) this.element_chart.style.display = 'inline-block';
@@ -1624,7 +1704,9 @@
1704
if(NETDATA.options.current.destroy_on_hide === true)
1705
this.destroyChart();
1706
1627
- if(this.debug === true) this.log('hiding chart');
1707
+ if(this.debug === true)
1708
+ this.log('hiding chart');
1709
+
1710
this.element_message.style.display = 'inline-block';
1711
if(this.element_chart !== null) this.element_chart.style.display = 'none';
1712
if(this.element_legend !== null) this.element_legend.style.display = 'none';
@@ -1638,7 +1720,8 @@
1720
1721
chartState.prototype.hideLoading = function() {
1722
if(typeof this.___showsLoading___ !== 'undefined' && this.enabled === true) {
1641
- if(this.debug === true) this.log('hide loading...');
1723
+ if(this.debug === true)
1724
+ this.log('hide loading...');
1725
1726
this.element_message.style.display = 'none';
1727
if(this.element_chart !== null) this.element_chart.style.display = 'inline-block';
@@ -1652,7 +1735,8 @@
1735
1736
chartState.prototype.showLoading = function() {
1737
if(typeof this.___showsLoading___ === 'undefined' && this.tm.last_created === 0 && this.enabled === true) {
1655
- if(this.debug === true) this.log('show loading...');
1738
+ if(this.debug === true)
1739
+ this.log('show loading...');
1740
1741
this.element_message.style.display = 'none';
1742
if(this.element_chart !== null) this.element_chart.style.display = 'none';
@@ -1668,7 +1752,9 @@
1752
chartState.prototype.isVisible = function() {
1753
// this.log('last_visible_check: ' + this.tm.last_visible_check + ', last_page_scroll: ' + NETDATA.options.last_page_scroll);
1754
if(this.tm.last_visible_check > NETDATA.options.last_page_scroll) {
1671
- if(this.debug === true) this.log('isVisible: ' + this.___isVisible___);
1755
+ if(this.debug === true)
1756
+ this.log('isVisible: ' + this.___isVisible___);
1757
+
1758
return this.___isVisible___;
1759
}
1760
@@ -1692,14 +1778,20 @@
1778
// the chart is too far
1779
this.___isVisible___ = false;
1780
if(this.tm.last_created !== 0) this.hideChart();
1695
- if(this.debug === true) this.log('isVisible: ' + this.___isVisible___);
1781
+
1782
+ if(this.debug === true)
1783
+ this.log('isVisible: ' + this.___isVisible___);
1784
+
1785
return this.___isVisible___;
1786
}
1787
else {
1788
// the chart is inside or very close
1789
this.___isVisible___ = true;
1790
this.unhideChart();
1702
- if(this.debug === true) this.log('isVisible: ' + this.___isVisible___);
1791
+
1792
+ if(this.debug === true)
1793
+ this.log('isVisible: ' + this.___isVisible___);
1794
+
1795
return this.___isVisible___;
1796
}
1797
}
@@ -1712,31 +1804,41 @@
1804
now = new Date().getTime();
1805
1806
if(this.enabled === false) {
1715
- if(this.debug) this.log('I am not enabled');
1807
+ if(this.debug === true)
1808
+ this.log('I am not enabled');
1809
+
1810
return false;
1811
}
1812
1813
if(this.library === null || this.library.enabled === false) {
1814
this.error('charting library "' + this.library_name + '" is not available');
1721
- if(this.debug) this.log('My chart library ' + this.library_name + ' is not available');
1815
+ if(this.debug === true)
1816
+ this.log('My chart library ' + this.library_name + ' is not available');
1817
+
1818
return false;
1819
}
1820
1821
if(this.isVisible() === false) {
1726
- if(NETDATA.options.debug.visibility || this.debug) this.log('I am not visible');
1727
- return;
1822
+ if(NETDATA.options.debug.visibility === true || this.debug === true)
1823
+ this.log('I am not visible');
1824
+
1825
+ return false;
1826
}
1827
1828
if(this.current.force_update_at !== 0 && this.current.force_update_at < now) {
1731
- if(this.debug) this.log('timed force update detecting - allowing this update');
1829
+ if(this.debug === true)
1830
+ this.log('timed force update detected - allowing this update');
1831
+
1832
this.current.force_update_at = 0;
1833
return true;
1834
}
1835
1736
- if(this.isAutoRefreshed()) {
1836
+ if(this.isAutoRefreshed() === true) {
1837
// allow the first update, even if the page is not visible
1838
if(this.updates_counter && !NETDATA.options.page_is_visible) {
1739
- if(NETDATA.options.debug.focus || this.debug) this.log('canBeAutoRefreshed(): page does not have focus');
1839
+ if(NETDATA.options.debug.focus === true || this.debug === true)
1840
+ this.log('canBeAutoRefreshed(): page does not have focus');
1841
+
1842
return false;
1843
}
1844
@@ -1744,27 +1846,37 @@
1846
if(NETDATA.options.auto_refresher_stop_until === 0 || NETDATA.options.auto_refresher_stop_until < now) {
1847
if(NETDATA.globalPanAndZoom.isActive()) {
1848
if(NETDATA.globalPanAndZoom.shouldBeAutoRefreshed(this)) {
1747
- if(this.debug) this.log('canBeAutoRefreshed(): global panning: I need an update.');
1849
+ if(this.debug === true)
1850
+ this.log('canBeAutoRefreshed(): global panning: I need an update.');
1851
+
1852
return true;
1853
}
1854
else {
1751
- if(this.debug) this.log('canBeAutoRefreshed(): global panning: I am already up to date.');
1855
+ if(this.debug === true)
1856
+ this.log('canBeAutoRefreshed(): global panning: I am already up to date.');
1857
+
1858
return false;
1859
}
1860
}
1861
1756
- if(this.selected) {
1757
- if(this.debug) this.log('canBeAutoRefreshed(): I have a selection in place.');
1862
+ if(this.selected === true) {
1863
+ if(this.debug === true)
1864
+ this.log('canBeAutoRefreshed(): I have a selection in place.');
1865
+
1866
return false;
1867
}
1868
1761
- if(this.paused) {
1762
- if(this.debug) this.log('canBeAutoRefreshed(): I am paused.');
1869
+ if(this.paused === true) {
1870
+ if(this.debug === true)
1871
+ this.log('canBeAutoRefreshed(): I am paused.');
1872
+
1873
return false;
1874
}
1875
1766
- if(now - this.current.last_autorefreshed > this.current.view_update_every) {
1767
- if(this.debug) this.log('canBeAutoRefreshed(): It is time to update me.');
1876
+ if(now - this.tm.last_autorefreshed > this.current.view_update_every) {
1877
+ if(this.debug === true)
1878
+ this.log('canBeAutoRefreshed(): It is time to update me.');
1879
+
1880
return true;
1881
}
1882
}
@@ -1774,7 +1886,7 @@
1886
}
1887
1888
chartState.prototype.autoRefresh = function(callback) {
1777
- if(this.canBeAutoRefreshed()) {
1889
+ if(this.canBeAutoRefreshed() === true) {
1890
this.updateChart(callback);
1891
}
1892
else {
@@ -1800,7 +1912,10 @@
1912
}
1913
else {
1914
this.chart_url = this.host + "/api/v1/chart?chart=" + this.id;
1803
- if(this.debug) this.log('downloading ' + this.chart_url);
1915
+
1916
+ if(this.debug === true)
1917
+ this.log('downloading ' + this.chart_url);
1918
+
1919
var self = this;
1920
1921
$.ajax( {
@@ -1830,15 +1945,16 @@
1945
chartState.prototype.sizeChart = function() {
1946
this.element.className += " netdata-container";
1947
1833
- if(this.debug) this.log('sizing element');
1948
+ if(this.debug === true)
1949
+ this.log('sizing element');
1950
1835
- if(this.width)
1951
+ if(this.width !== 0)
1952
$(this.element).css('width', this.width);
1953
1838
- if(this.height)
1954
+ if(this.height !== 0)
1955
$(this.element).css('height', this.height);
1956
1841
- if(NETDATA.chartDefaults.min_width)
1957
+ if(NETDATA.chartDefaults.min_width !== null)
1958
$(this.element).css('min-width', NETDATA.chartDefaults.min_width);
1959
}
1960
@@ -1848,7 +1964,7 @@
1964
this.tm.last_created = new Date().getTime();
1965
}
1966
1851
- this.current.last_autorefreshed = new Date().getTime();
1967
+ this.tm.last_autorefreshed = new Date().getTime();
1968
this.current.view_update_every = 30 * 1000;
1969
}
1970
@@ -1856,7 +1972,9 @@
1972
chartState.prototype.message = function(type, msg) {
1973
this.hideChart();
1974
this.element_message.innerHTML = msg;
1859
- if(this.debug) this.log(msg);
1975
+
1976
+ if(this.debug === null)
1977
+ this.log(msg);
1978
}
1979
1980
// show an error on the chart and stop it forever
@@ -1881,7 +1999,9 @@
1999
this.element_loading.className += ' netdata-chart-is-loading';
2000
this.element.appendChild(this.element_loading);
2001
1884
- if(this.debug) this.log('created');
2002
+ if(this.debug === null)
2003
+ this.log('created');
2004
+
2005
this.sizeChart();
2006
2007
// make sure the host does not end with /
@@ -1896,7 +2016,7 @@
2016
NETDATA.error(402, this.library_name);
2017
this.error('chart library "' + this.library_name + '" is not found');
2018
}
1899
- else if(!NETDATA.chartLibraries[this.library_name].enabled) {
2019
+ else if(NETDATA.chartLibraries[this.library_name].enabled === false) {
2020
NETDATA.error(403, this.library_name);
2021
this.error('chart library "' + this.library_name + '" is not enabled');
2022
}
@@ -1915,7 +2035,7 @@
2035
// get or create a chart state, given a DOM element
2036
NETDATA.chartState = function(element) {
2037
var state = $(element).data('netdata-state-object') || null;
1918
- if(!state) {
2038
+ if(state === null) {
2039
state = new chartState(element);
2040
$(element).data('netdata-state-object', state);
2041
}
@@ -1929,7 +2049,8 @@
2049
// This is used to load jquery - after it is loaded, we use jquery
2050
NETDATA._loadjQuery = function(callback) {
2051
if(typeof jQuery === 'undefined') {
1932
- if(NETDATA.options.debug.main_loop) console.log('loading ' + NETDATA.jQuery);
2052
+ if(NETDATA.options.debug.main_loop === true)
2053
+ console.log('loading ' + NETDATA.jQuery);
2054
2055
var script = document.createElement('script');
2056
script.type = 'text/javascript';
@@ -2036,7 +2157,8 @@
2157
// this is purely sequencial charts refresher
2158
// it is meant to be autonomous
2159
NETDATA.chartRefresherNoParallel = function(index) {
2039
- if(NETDATA.options.debug.mail_loop) console.log('NETDATA.chartRefresherNoParallel(' + index + ')');
2160
+ if(NETDATA.options.debug.mail_loop === true)
2161
+ console.log('NETDATA.chartRefresherNoParallel(' + index + ')');
2162
2163
if(NETDATA.options.updated_dom === true) {
2164
// the dom has been updated
@@ -2045,25 +2167,28 @@
2167
return;
2168
}
2169
if(index >= NETDATA.options.targets.length) {
2048
- if(NETDATA.options.debug.main_loop) console.log('waiting to restart main loop...');
2049
- NETDATA.options.auto_refresher_fast_weight = 0;
2170
+ if(NETDATA.options.debug.main_loop === true)
2171
+ console.log('waiting to restart main loop...');
2172
2051
- setTimeout(function() {
2052
- NETDATA.chartRefresher();
2053
- }, NETDATA.options.current.idle_between_loops);
2054
- }
2173
+ NETDATA.options.auto_refresher_fast_weight = 0;
2174
+
2175
+ setTimeout(function() {
2176
+ NETDATA.chartRefresher();
2177
+ }, NETDATA.options.current.idle_between_loops);
2178
+ }
2179
else {
2180
var state = NETDATA.options.targets[index];
2181
2182
if(NETDATA.options.auto_refresher_fast_weight < NETDATA.options.current.fast_render_timeframe) {
2059
- if(NETDATA.options.debug.main_loop) console.log('fast rendering...');
2183
+ if(NETDATA.options.debug.main_loop === true)
2184
+ console.log('fast rendering...');
2185
2186
state.autoRefresh(function() {
2187
NETDATA.chartRefresherNoParallel(++index);
2188
});
2189
}
2190
else {
2066
- if(NETDATA.options.debug.main_loop) console.log('waiting for next refresh...');
2191
+ if(NETDATA.options.debug.main_loop === true) console.log('waiting for next refresh...');
2192
NETDATA.options.auto_refresher_fast_weight = 0;
2193
2194
setTimeout(function() {
@@ -2142,7 +2267,8 @@
2267
var targets = NETDATA.options.targets;
2268
var len = targets.length;
2269
while(len--) {
2145
- if(!targets[len].isVisible()) continue;
2270
+ if(targets[len].isVisible() === false)
2271
+ continue;
2272
2273
var state = targets[len];
2274
if(state.library.initialized === false) {
@@ -2186,7 +2312,7 @@
2312
2313
var targets = $('div[data-netdata]').filter(':visible');
2314
2189
- if(NETDATA.options.debug.main_loop)
2315
+ if(NETDATA.options.debug.main_loop === true)
2316
console.log('DOM updated - there are ' + targets.length + ' charts on page.');
2317
2318
NETDATA.options.targets = new Array();
@@ -2208,17 +2334,20 @@
2334
2335
$(window).blur(function() {
2336
NETDATA.options.page_is_visible = false;
2211
- if(NETDATA.options.debug.focus) console.log('Lost Focus!');
2337
+ if(NETDATA.options.debug.focus === true)
2338
+ console.log('Lost Focus!');
2339
});
2340
2341
$(window).focus(function() {
2342
NETDATA.options.page_is_visible = true;
2216
- if(NETDATA.options.debug.focus) console.log('Focus restored!');
2343
+ if(NETDATA.options.debug.focus === true)
2344
+ console.log('Focus restored!');
2345
});
2346
2347
if(typeof document.hasFocus === 'function' && !document.hasFocus()) {
2348
NETDATA.options.page_is_visible = false;
2221
- if(NETDATA.options.debug.focus) console.log('Document has no focus!');
2349
+ if(NETDATA.options.debug.focus === true)
2350
+ console.log('Document has no focus!');
2351
}
2352
2353
NETDATA.parseDom(NETDATA.chartRefresher);
@@ -2509,7 +2638,9 @@
2638
dygraph.resize();
2639
2640
if(state.current.name === 'pan') {
2512
- if(NETDATA.options.debug.dygraph || state.debug) state.log('dygraphChartUpdate() loose update');
2641
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2642
+ state.log('dygraphChartUpdate() loose update');
2643
+
2644
dygraph.updateOptions({
2645
file: data.result.data,
2646
colors: state.chartColors(),
@@ -2518,7 +2649,9 @@
2649
});
2650
}
2651
else {
2521
- if(NETDATA.options.debug.dygraph || state.debug) state.log('dygraphChartUpdate() strict update');
2652
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2653
+ state.log('dygraphChartUpdate() strict update');
2654
+
2655
dygraph.updateOptions({
2656
file: data.result.data,
2657
colors: state.chartColors(),
@@ -2533,7 +2666,8 @@
2666
};
2667
2668
NETDATA.dygraphChartCreate = function(state, data) {
2536
- if(NETDATA.options.debug.dygraph || state.debug) state.log('dygraphChartCreate()');
2669
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2670
+ state.log('dygraphChartCreate()');
2671
2672
var self = $(state.element);
2673
@@ -2544,7 +2678,7 @@
2678
var smooth = (chart_type === 'line' && !NETDATA.chartLibraries.dygraph.isSparkline(state))?true:false;
2679
smooth = self.data('dygraph-smooth') || smooth;
2680
2547
- if(!NETDATA.dygraph.smooth)
2681
+ if(NETDATA.dygraph.smooth === false)
2682
smooth = false;
2683
2684
var strokeWidth = (chart_type === 'stacked')?0.0:((smooth)?1.5:1.0)
@@ -2677,7 +2811,8 @@
2811
},
2812
drawCallback: function(dygraph, is_initial) {
2813
if(state.current.name !== 'auto') {
2680
- if(NETDATA.options.debug.dygraph) state.log('dygraphDrawCallback()');
2814
+ if(NETDATA.options.debug.dygraph === true)
2815
+ state.log('dygraphDrawCallback()');
2816
2817
var x_range = dygraph.xAxisRange();
2818
var after = Math.round(x_range[0]);
@@ -2687,13 +2822,17 @@
2822
}
2823
},
2824
zoomCallback: function(minDate, maxDate, yRanges) {
2690
- if(NETDATA.options.debug.dygraph) state.log('dygraphZoomCallback()');
2825
+ if(NETDATA.options.debug.dygraph === true)
2826
+ state.log('dygraphZoomCallback()');
2827
+
2828
state.globalSelectionSyncStop();
2829
state.globalSelectionSyncDelay();
2830
state.updateChartPanOrZoom(minDate, maxDate);
2831
},
2832
highlightCallback: function(event, x, points, row, seriesName) {
2696
- if(NETDATA.options.debug.dygraph || state.debug) state.log('dygraphHighlightCallback()');
2833
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2834
+ state.log('dygraphHighlightCallback()');
2835
+
2836
state.pauseChart();
2837
2838
// there is a bug in dygraph when the chart is zoomed enough
@@ -2710,16 +2849,21 @@
2849
// state.dygraph_instance.plugins_[0].plugin.legend_div_.style.zIndex = 10000;
2850
},
2851
unhighlightCallback: function(event) {
2713
- if(NETDATA.options.debug.dygraph || state.debug) state.log('dygraphUnhighlightCallback()');
2852
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2853
+ state.log('dygraphUnhighlightCallback()');
2854
+
2855
state.unpauseChart();
2856
state.globalSelectionSyncStop();
2857
},
2858
interactionModel : {
2859
mousedown: function(event, dygraph, context) {
2719
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.mousedown()');
2860
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2861
+ state.log('interactionModel.mousedown()');
2862
+
2863
state.globalSelectionSyncStop();
2864
2722
- if(NETDATA.options.debug.dygraph) state.log('dygraphMouseDown()');
2865
+ if(NETDATA.options.debug.dygraph === true)
2866
+ state.log('dygraphMouseDown()');
2867
2868
// Right-click should not initiate a zoom.
2869
if(event.button && event.button === 2) return;
@@ -2752,7 +2896,8 @@
2896
}
2897
},
2898
mousemove: function(event, dygraph, context) {
2755
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.mousemove()');
2899
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2900
+ state.log('interactionModel.mousemove()');
2901
2902
if(context.isPanning) {
2903
state.globalSelectionSyncStop();
@@ -2768,7 +2913,8 @@
2913
}
2914
},
2915
mouseup: function(event, dygraph, context) {
2771
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.mouseup()');
2916
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2917
+ state.log('interactionModel.mouseup()');
2918
2919
if (context.isPanning) {
2920
state.globalSelectionSyncDelay();
@@ -2780,17 +2926,21 @@
2926
}
2927
},
2928
click: function(event, dygraph, context) {
2783
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.click()');
2929
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2930
+ state.log('interactionModel.click()');
2931
/*Dygraph.cancelEvent(event);*/
2932
},
2933
dblclick: function(event, dygraph, context) {
2787
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.dblclick()');
2934
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2935
+ state.log('interactionModel.dblclick()');
2936
+
2937
state.globalSelectionSyncStop();
2938
NETDATA.globalPanAndZoom.clearMaster();
2939
state.resetChart();
2940
},
2941
mousewheel: function(event, dygraph, context) {
2793
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.mousewheel()');
2942
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2943
+ state.log('interactionModel.mousewheel()');
2944
2945
if(event.altKey || event.shiftKey) {
2946
state.globalSelectionSyncStop();
@@ -2810,14 +2960,17 @@
2960
var before = before_old - dt;
2961
var after = after_old + dt;
2962
2813
- if(NETDATA.options.debug.dygraph) state.log('percent: ' + percentage + ' from ' + after_old + ' - ' + before_old + ' to ' + after + ' - ' + before + ', range from ' + (before_old - after_old).toString() + ' to ' + (before - after).toString());
2963
+ if(NETDATA.options.debug.dygraph === true)
2964
+ state.log('percent: ' + percentage + ' from ' + after_old + ' - ' + before_old + ' to ' + after + ' - ' + before + ', range from ' + (before_old - after_old).toString() + ' to ' + (before - after).toString());
2965
2966
state.setMode('zoom');
2967
state.updateChartPanOrZoom(after, before);
2968
}
2969
},
2970
touchstart: function(event, dygraph, context) {
2820
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.touchstart()');
2971
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2972
+ state.log('interactionModel.touchstart()');
2973
+
2974
state.globalSelectionSyncStop();
2975
state.globalSelectionSyncDelay();
2976
Dygraph.Interaction.startTouch(event, dygraph, context);
@@ -2825,13 +2978,17 @@
2978
state.setMode('zoom');
2979
},
2980
touchmove: function(event, dygraph, context) {
2828
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.touchmove()');
2981
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2982
+ state.log('interactionModel.touchmove()');
2983
+
2984
//Dygraph.cancelEvent(event);
2985
state.globalSelectionSyncStop();
2986
Dygraph.Interaction.moveTouch(event, dygraph, context);
2987
},
2988
touchend: function(event, dygraph, context) {
2834
- if(NETDATA.options.debug.dygraph || state.debug) state.log('interactionModel.touchend()');
2989
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
2990
+ state.log('interactionModel.touchend()');
2991
+
2992
Dygraph.Interaction.endTouch(event, dygraph, context);
2993
}
2994
}
@@ -3176,7 +3333,7 @@
3333
format: function(state) { return 'json'; },
3334
options: function(state) { return 'ms|flip'; },
3335
legend: function(state) {
3179
- if(!this.isSparkline(state))
3336
+ if(this.isSparkline(state) === false)
3337
return 'right-side';
3338
else
3339
return null;
@@ -3185,7 +3342,7 @@
3342
max_updates_to_recreate: function(state) { return 5000; },
3343
track_colors: function(state) { return true; },
3344
pixels_per_point: function(state) {
3188
- if(!this.isSparkline(state))
3345
+ if(this.isSparkline(state) === false)
3346
return 3;
3347
else
3348
return 2;
@@ -3301,7 +3458,7 @@
3458
};
3459
3460
NETDATA.registerChartLibrary = function(library, url) {
3304
- if(NETDATA.options.debug.libraries)
3461
+ if(NETDATA.options.debug.libraries === true)
3462
console.log("registering chart library: " + library);
3463
3464
NETDATA.chartLibraries[library].url = url;
@@ -3360,14 +3517,18 @@
3517
return;
3518
}
3519
3363
- if(NETDATA.options.debug.main_loop) console.log('loading ' + NETDATA.requiredJs[index].url);
3520
+ if(NETDATA.options.debug.main_loop === true)
3521
+ console.log('loading ' + NETDATA.requiredJs[index].url);
3522
+
3523
$.ajax({
3524
url: NETDATA.requiredJs[index].url,
3525
cache: true,
3526
dataType: "script"
3527
})
3528
.success(function() {
3370
- if(NETDATA.options.debug.main_loop) console.log('loaded ' + NETDATA.requiredJs[index].url);
3529
+ if(NETDATA.options.debug.main_loop === true)
3530
+ console.log('loaded ' + NETDATA.requiredJs[index].url);
3531
+
3532
NETDATA.loadRequiredJs(++index, callback);
3533
})
3534
.fail(function() {
@@ -3384,7 +3545,9 @@
3545
return;
3546
}
3547
3387
- if(NETDATA.options.debug.main_loop) console.log('loading ' + NETDATA.requiredCSS[index].url);
3548
+ if(NETDATA.options.debug.main_loop === true)
3549
+ console.log('loading ' + NETDATA.requiredCSS[index].url);
3550
+
3551
NETDATA._loadCSS(NETDATA.requiredCSS[index].url);
3552
NETDATA.loadRequiredCSS(++index);
3553
}
@@ -3395,7 +3558,9 @@
3558
NETDATA._loadjQuery(function() {
3559
NETDATA.loadRequiredJs(0, function() {
3560
if(typeof netdataDontStart === 'undefined' || !netdataDontStart) {
3398
- if(NETDATA.options.debug.main_loop) console.log('starting chart refresh thread');
3561
+ if(NETDATA.options.debug.main_loop === true)
3562
+ console.log('starting chart refresh thread');
3563
+
3564
NETDATA.start();
3565
}
3566