-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.js
1093 lines (963 loc) · 30.6 KB
/
data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Enter your complete Firebase database name. The sub-folder is created from the Powershell script, so just match those.
var url = "https://xxx-xxx-xxx.firebaseio.com/Company%20Name"
// This is only to prettify the output of the meter counts
function thousands_separator(num) {
if (num == null) {
return 0;
} else {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}
}
// Main function that pulls all data and displays it
function get_machine_data() {
// Manual user input
// (need to remove get_machine_data() from after the block for this to work)
asset = document.getElementById("u_input").value;
// Automatic User Input (requires get_machine_data() to be run at the end of the block)
//
//var urlParams = new URLSearchParams(window.location.search);
//if (document.getElementById("u_input").value == "" && urlParams.has('asset') == true) {
// asset = urlParams.get('asset');
// console.log("urlParams.get('asset'): " + asset);
//} else {
// urlParams.delete('asset');
// asset = document.getElementById("u_input").value;
// console.log("u_input: " + asset);
//}
//if (urlParams.has('asset') == true) {
// asset = urlParams.get('asset');
//}
// Retrieve ipaddr (identifier)
//
// The way I've found it can work efficiently is to have a section which maps
// equipment IDs to their IP address, only using hyphens (i.e. "xxx-xxx-xxx-xxx"), since
// Firebase doesn't like "." in names. This allows the ipaddr identifier to be used in
// other locations and keep ambiguity to a minimum.
//
// The main reason is when the scan is happening, you don't know what the "Asset Number"
// actually is at the start, as the machines are scanned by IP and the asset number is
// written after the fact, so the only readily available identifier is the IP Address.
//
fetch(url + "/asset/" + asset + ".json")
.then(function (response) {
return response.json();
})
.then(function (data) {
//console.log(JSON.stringify(data));
ipaddr = data;
// Retrieve model
fetch(url + "/machines/" + ipaddr + ".json")
.then(function (response) {
return response.json();
})
.then(function (data) {
// Retrieve model
model = data["Model"];
document.getElementById("model_output").innerHTML = model;
// Retrieve serial
serial = data["Serial Number"];
document.getElementById("serial_output").innerHTML = serial;
// Retrieve asset
asset = data["Asset Number"];
document.getElementById("asset_output").innerHTML = asset;
// Retrieve ip address
ip = data["IP Address"];
document.getElementById("ip_output").innerHTML = ip;
// Retrieve mac address
mac = data["Hardware Address"];
document.getElementById("mac_output").innerHTML = mac;
// Retrieve firmware
firmware = data["Firmware Version"];
document.getElementById("firmware_output").innerHTML = firmware;
// Retrieve location
loc = data["Location"];
document.getElementById("loc_output").innerHTML = loc;
// Retrieve Shipped data
shipped = data["Shipped"];
if (shipped == null) {
console.log("shipped is empty");
} else {
if (shipped["Black"] === 1) {
document.getElementById("tkc").checked = true;
} else {
document.getElementById("tkc").checked = false;
}
if (shipped["Cyan"] === 1) {
document.getElementById("tcc").checked = true;
} else {
document.getElementById("tcc").checked = false;
}
if (shipped["Magenta"] === 1) {
document.getElementById("tmc").checked = true;
} else {
document.getElementById("tmc").checked = false;
}
if (shipped["Yellow"] === 1) {
document.getElementById("tyc").checked = true;
} else {
document.getElementById("tyc").checked = false;
}
if (shipped["Waste"] === 1) {
document.getElementById("wbc").checked = true;
} else {
document.getElementById("wbc").checked = false;
}
}
// Retrieve latest scan
scan = data["Latest Scan"];
document.getElementById("scan_output").innerHTML = scan;
// Data for graphs
fetch(url + "/scans/" + ipaddr + ".json")
// This used to work, but no longer does
//fetch(url + "/scans/" + ipaddr + ".json" + encodeURIComponent('?orderBy="$key"&limitToLast=30'))
// Correct form for pulling only a few of the scans
//fetch(url + "/scans/" + ipaddr + ".json" + '?orderBy="$key"&limitToLast=300')
.then(function (response) {
return response.json();
})
.then(function (data) {
// This runs all plots with all data retrieved
toner_plot(data);
developer_plot(data);
drum_plot(data);
maint_plot(data);
total_plot(data);
// Added to show toner install date
var elements = [];
for (date in data) {
elements.push(date);
}
// /* You are not expected to understand this. */
//
// Setting up variables in order to have the dates shown for toner out/replaced
var el_length = elements.length;
// Black Toner Near End date
for (let i = 1; i < el_length; i++) {
tk_value = data[elements[el_length - i]]["Black Toner"];
tk_value_prev = data[elements[el_length - (i + 1)]]["Black Toner"];
k_date_value = data[elements[el_length - i]]["Date"];
if (tk_value <= 0 && tk_value_prev > 10) {
k_ne_date_value = k_date_value;
document.getElementById("tk_ne_date_val").innerHTML = k_ne_date_value;
break;
} else {
document.getElementById("tk_ne_date_val").innerHTML = "Not reached";
}
}
// Black Toner Replaced date
for (let i = 1; i < el_length; i++) {
tk_value = data[elements[el_length - i]]["Black Toner"];
tk_value_prev = data[elements[el_length - (i + 1)]]["Black Toner"];
k_date_value = data[elements[el_length - i]]["Date"];
if (tk_value > 90 && tk_value_prev <= 15) {
tk_date_value = k_date_value;
document.getElementById("tk_date_val").innerHTML = k_date_value;
break;
} else {
if (tk_value_prev <= 0 && tk_value <= 0) {
document.getElementById("tk_date_val").innerHTML = "Not replaced yet";
break;
} else {
document.getElementById("tk_date_val").innerHTML = "Not replaced yet";
}
}
}
// Cyan Toner Near End date
for (let i = 1; i < el_length; i++) {
tc_value = data[elements[el_length - i]]["Cyan Toner"];
tc_value_prev = data[elements[el_length - (i + 1)]]["Cyan Toner"];
c_date_value = data[elements[el_length - i]]["Date"];
if (tc_value <= 0 && tc_value_prev > 10) {
c_ne_date_value = c_date_value;
document.getElementById("tc_ne_date_val").innerHTML = c_ne_date_value;
break;
} else {
document.getElementById("tc_ne_date_val").innerHTML = "Not reached";
}
}
// Cyan Toner replaced date
for (let i = 1; i < el_length; i++) {
tc_value = data[elements[el_length - i]]["Cyan Toner"];
tc_value_prev = data[elements[el_length - (i + 1)]]["Cyan Toner"];
c_date_value = data[elements[el_length - i]]["Date"];
if (tc_value > 90 && tc_value_prev <= 15) {
tc_date_value = c_date_value;
document.getElementById("tc_date_val").innerHTML = c_date_value;
break;
} else {
if (tc_value_prev <= 0 && tc_value <= 0) {
document.getElementById("tc_date_val").innerHTML = "Not replaced yet";
break;
} else {
document.getElementById("tc_date_val").innerHTML = "Not replaced yet";
}
}
}
// Magenta Toner Near End date
for (let i = 1; i < el_length; i++) {
tm_value = data[elements[el_length - i]]["Magenta Toner"];
tm_value_prev = data[elements[el_length - (i + 1)]]["Magenta Toner"];
m_date_value = data[elements[el_length - i]]["Date"];
if (tm_value <= 0 && tm_value_prev > 10) {
m_ne_date_value = m_date_value;
document.getElementById("tm_ne_date_val").innerHTML = m_ne_date_value;
break;
} else {
document.getElementById("tm_ne_date_val").innerHTML = "Not reached";
}
}
// Magenta Toner replaced date
for (let i = 1; i < el_length; i++) {
tm_value = data[elements[el_length - i]]["Magenta Toner"];
tm_value_prev = data[elements[el_length - (i + 1)]]["Magenta Toner"];
m_date_value = data[elements[el_length - i]]["Date"];
if (tm_value > 90 && tm_value_prev <= 15) {
tm_date_value = m_date_value;
document.getElementById("tm_date_val").innerHTML = m_date_value;
break;
} else {
if (tm_value_prev <= 0 && tm_value <= 0) {
document.getElementById("tm_date_val").innerHTML = "Not replaced yet";
break;
} else {
document.getElementById("tm_date_val").innerHTML = "Not replaced yet";
}
}
}
// Yellow Toner Near End date
for (let i = 1; i < el_length; i++) {
ty_value = data[elements[el_length - i]]["Yellow Toner"];
ty_value_prev = data[elements[el_length - (i + 1)]]["Yellow Toner"];
y_date_value = data[elements[el_length - i]]["Date"];
if (ty_value <= 0 && ty_value_prev > 10) {
y_ne_date_value = y_date_value;
document.getElementById("ty_ne_date_val").innerHTML = y_ne_date_value;
break;
} else {
document.getElementById("ty_ne_date_val").innerHTML = "Not reached";
}
}
// Yellow Toner replaced date
for (let i = 1; i < el_length; i++) {
ty_value = data[elements[el_length - i]]["Yellow Toner"];
ty_value_prev = data[elements[el_length - (i + 1)]]["Yellow Toner"];
y_date_value = data[elements[el_length - i]]["Date"];
if (ty_value > 90 && ty_value_prev <= 15) {
ty_date_value = y_date_value;
document.getElementById("ty_date_val").innerHTML = y_date_value;
break;
} else {
if (ty_value_prev <= 0 && ty_value <= 0) {
document.getElementById("ty_date_val").innerHTML = "Not replaced yet";
break;
} else {
document.getElementById("ty_date_val").innerHTML = "Not replaced yet";
}
}
}
// Waste Toner Near End date
for (let i = 1; i < el_length; i++) {
wb_value = data[elements[el_length - i]]["Waste Toner"];
wb_value_prev = data[elements[el_length - (i + 1)]]["Waste Toner"];
w_date_value = data[elements[el_length - i]]["Date"];
if (wb_value <= 0 && wb_value_prev > 10) {
w_ne_date_value = w_date_value;
document.getElementById("wb_ne_date_val").innerHTML = w_ne_date_value;
break;
} else {
document.getElementById("wb_ne_date_val").innerHTML = "Not reached";
}
}
// Waste Toner replaced date
for (let i = 1; i < el_length; i++) {
wb_value = data[elements[el_length - i]]["Waste Toner"];
wb_value_prev = data[elements[el_length - (i + 1)]]["Waste Toner"];
w_date_value = data[elements[el_length - i]]["Date"];
if (wb_value == 100 && (wb_value_prev == 0 || wb_value_prev == -3)) {
document.getElementById("wb_date_val").innerHTML = w_date_value;
break;
} else {
document.getElementById("wb_date_val").innerHTML = "Not replaced yet";
}
}
})
// Retrieve all current supply data
fetch(url + "/scans/" + ipaddr + "/" + scan + ".json")
.then(function (response) {
return response.json();
})
.then(function (data) {
// Total count
count = thousands_separator(data["Total Count"]);
document.getElementById("total_count").innerHTML = count;
if (count == null) {
document.getElementById("total_count").innerHTML = count;
}
// Color total
color_total = thousands_separator(data["Full Color Total Count"]);
document.getElementById("color_total").innerHTML = color_total;
if (color_total == null) {
document.getElementById("color_total").innerHTML = color_total;
}
// Black and white total
black_total = thousands_separator(data["Black & White Total Count"]);
document.getElementById("black_total").innerHTML = black_total;
// Black Toner
black_toner = data["Black Toner"];
if (black_toner == "-3") {
black_toner = "Near End";
document.getElementById("black_bar").setAttribute("style", "width: 99.75%; background-color: red; color: white;");
} else {
document.getElementById("black_bar").setAttribute("style", "color: white; width:" + black_toner + "%");
}
// This is for the numerical display
document.getElementById("black_toner").innerHTML = black_toner;
// Cyan Toner
cyan_toner = data["Cyan Toner"];
if (cyan_toner == "-3") {
cyan_toner = "Near End";
document.getElementById("cyan_bar").setAttribute("style", "width: 99.75%; background-color: red; color: white;");
} else {
document.getElementById("cyan_bar").setAttribute("style", "width:" + cyan_toner + "%");
}
// This is for the numerical display
document.getElementById("cyan_toner").innerHTML = cyan_toner;
// if machine is mono
if (cyan_toner == null) {
document.getElementById("cyan_bar").setAttribute("style", "height: 0px; border: 0px; color: #000000;");
}
if (cyan_toner == null && black_toner == "Near End") {
document.getElementById("cyan_bar").setAttribute("style", "height: 0px; border: 0px; color: red;");
}
// Magenta toner
magenta_toner = data["Magenta Toner"];
if (magenta_toner == "-3") {
magenta_toner = "Near End";
document.getElementById("magenta_bar").setAttribute("style", "width: 99.75%; background-color: red; color: white;");
} else {
document.getElementById("magenta_bar").setAttribute("style", "width:" + magenta_toner + "%");
}
// This is for the numerical display
document.getElementById("magenta_toner").innerHTML = magenta_toner;
if (magenta_toner == null) {
document.getElementById("magenta_bar").setAttribute("style", "height: 0px; border: 0px; color: #000000;");
}
if (magenta_toner == null && black_toner == "Near End") {
document.getElementById("magenta_bar").setAttribute("style", "height: 0px; border: 0px; color: red;");
}
// Yellow toner
yellow_toner = data["Yellow Toner"];
if (yellow_toner == "-3") {
yellow_toner = "Near End";
document.getElementById("yellow_bar").setAttribute("style", "width: 99.75%; background-color: red; color: white;");
} else {
document.getElementById("yellow_bar").setAttribute("style", "width:" + yellow_toner + "%");
}
// This is for the numerical display
document.getElementById("yellow_toner").innerHTML = yellow_toner;
if (yellow_toner == null) {
document.getElementById("yellow_bar").setAttribute("style", "height: 0px; border: 0px; color: #000000;");
}
if (yellow_toner == null && black_toner == "Near End") {
document.getElementById("yellow_bar").setAttribute("style", "height: 0px; border: 0px; color: red;");
}
// Waste toner
waste = data["Waste Toner"];
//document.getElementById("waste_toner").innerHTML = waste;
document.getElementById("waste_bar").setAttribute("style", "width: 99.75%;");
if (waste == null) {
document.getElementById("waste_bar").setAttribute("style", "height: 0px; border: 0px; color: #dddddd;");
}
// Fusing unit
fusing_unit = data["Fusing Unit"];
if (fusing_unit == "-2") {
fusing_unit = "No data";
document.getElementById("fusing_unit_bar").setAttribute("style", "width: 99.75%;");
}
//document.getElementById("fusing_unit").innerHTML = fusing_unit;
if (fusing_unit == null) {
document.getElementById("fusing_unit_bar").setAttribute("style", "height: 0px; border: 0px; color: #dddddd;");
}
// Black Developer
black_dev = data["Black Developer"];
if (black_dev == "-3") {
black_dev = "Near End";
document.getElementById("black_dev").innerHTML = black_dev;
document.getElementById("black_dev_bar").setAttribute("style", "width: 99.75%");
}
// This is for the numerical display
document.getElementById("black_dev").innerHTML = black_dev;
if (black_dev == null) {
document.getElementById("black_dev_bar").setAttribute("style", "height: 0px; border: 0px; color: #dddddd;");
} else {
document.getElementById("black_dev_bar").setAttribute("style", "color: white; width:" + black_dev + "%");
}
// Cyan Developer
cyan_dev = data["Cyan Developer"];
if (cyan_dev == "-3") {
cyan_dev = "Near End";
document.getElementById("cyan_dev").innerHTML = cyan_dev;
document.getElementById("cyan_dev_bar").setAttribute("style", "width: 99.75%");
}
// This is for the numerical display
document.getElementById("cyan_dev").innerHTML = cyan_dev;
if (cyan_dev == null) {
document.getElementById("cyan_dev").innerHTML = null;
document.getElementById("cyan_dev_bar").setAttribute("style", "height: 0px; border: 0px; color: black;");
} else {
document.getElementById("cyan_dev_bar").setAttribute("style", "color: black; width:" + cyan_dev + "%");
}
// Magenta Developer
magenta_dev = data["Magenta Developer"];
if (magenta_dev == "-3") {
magenta_dev = "Near End";
document.getElementById("magenta_dev").innerHTML = magenta_dev;
document.getElementById("magenta_dev_bar").setAttribute("style", "width: 99.75%");
}
// This is for the numerical display
document.getElementById("magenta_dev").innerHTML = magenta_dev;
if (magenta_dev == null) {
document.getElementById("magenta_dev_bar").setAttribute("style", "height: 0px; border: 0px; color: black;");
} else {
document.getElementById("magenta_dev_bar").setAttribute("style", "color: black; width:" + magenta_dev + "%");
}
// Yellow Developer
yellow_dev = data["Yellow Developer"];
if (yellow_dev == "-3") {
yellow_dev = "Near End";
document.getElementById("yellow_dev").innerHTML = yellow_dev;
document.getElementById("yellow_dev_bar").setAttribute("style", "width: 99.75%");
}
// This is for the numerical display
document.getElementById("yellow_dev").innerHTML = yellow_dev;
if (yellow_dev == null) {
document.getElementById("yellow_dev_bar").setAttribute("style", "height: 0px; border: 0px; color: black;");
} else {
document.getElementById("yellow_dev_bar").setAttribute("style", "color: black; width:" + yellow_dev + "%");
}
// Black Drum
black_drum = data["Black Drum"];
if (black_drum == "-3") {
black_drum = "Near End";
document.getElementById("black_drum").innerHTML = black_drum;
document.getElementById("black_drum_bar").setAttribute("style", "width: 99.75%");
}
// This is for the numerical display
document.getElementById("black_drum").innerHTML = black_drum;
if (black_drum == null) {
document.getElementById("black_drum_bar").setAttribute("style", "height: 0px; border: 0px; color: black;");
} else {
document.getElementById("black_drum_bar").setAttribute("style", "color: white; width:" + black_drum + "%");
}
// Cyan Drum
cyan_drum = data["Cyan Drum"];
if (cyan_drum == "-3") {
cyan_drum = "Near End";
document.getElementById("cyan_drum").innerHTML = cyan_drum;
document.getElementById("cyan_drum_bar").setAttribute("style", "width: 99.75%");
} else {
//document.getElementById("cyan_drum").innerHTML = cyan_drum;
document.getElementById("cyan_drum_bar").setAttribute("style", "width:" + cyan_drum + "%");
}
document.getElementById("cyan_drum").innerHTML = cyan_drum;
if (cyan_drum == null) {
document.getElementById("cyan_drum_bar").setAttribute("style", "height: 0px; border: 0px; color: black;")
} else {
document.getElementById("cyan_drum_bar").setAttribute("style", "color: black; width:" + cyan_drum + "%");
}
// Magenta Drum
magenta_drum = data["Magenta Drum"];
if (magenta_drum == "-3") {
magenta_drum = "Near End";
document.getElementById("magenta_drum").innerHTML = magenta_drum;
document.getElementById("magenta_drum_bar").setAttribute("style", "width: 99.75%");
}
document.getElementById("magenta_drum").innerHTML = magenta_drum;
if (magenta_drum == null) {
document.getElementById("magenta_drum_bar").setAttribute("style", "height: 0px; border: 0px; color: black;");
} else {
document.getElementById("magenta_drum_bar").setAttribute("style", "color: black; width:" + magenta_drum + "%");
}
// Yellow Drum
yellow_drum = data["Yellow Drum"];
if (yellow_drum == "-3") {
yellow_drum = "Near End";
document.getElementById("yellow_drum").innerHTML = yellow_drum;
document.getElementById("yellow_drum_bar").setAttribute("style", "width: 99.75%");
}
document.getElementById("yellow_drum").innerHTML = yellow_drum;
if (yellow_drum == null) {
document.getElementById("yellow_drum_bar").setAttribute("style", "height: 0px; border: 0px; color: black;");
} else {
document.getElementById("yellow_drum_bar").setAttribute("style", "color: black;");
document.getElementById("yellow_drum_bar").setAttribute("style", "width:" + yellow_drum + "%");
}
})
})
})
}
// This is necessary when using "Automatic User Input, otherwise the page will not populate
//get_machine_data();
// Plot element variables
var linewidth = 3;
var mode = "lines";
var gaps = true;
// Toner usage graph
function toner_plot(data) {
var key_array = Object.keys(data);
//range
N = 50;
var toner_c = [];
var toner_m = [];
var toner_y = [];
var toner_k = [];
var dates = key_array;
for (var i = 0; i < key_array.length; i++) {
toner_c.push(data[key_array[i]]["Cyan Toner"]);
toner_m.push(data[key_array[i]]["Magenta Toner"]);
toner_y.push(data[key_array[i]]["Yellow Toner"]);
toner_k.push(data[key_array[i]]["Black Toner"]);
}
var plot_c = {
mode: mode,
connectgaps: true,
x: dates,
y: toner_c,
name: "Cyan Toner",
line: {
color: "#0066CC",
width: linewidth
}
};
var plot_m = {
mode: mode,
connectgaps: true,
x: dates,
y: toner_m,
name: "Magenta Toner",
line: {
color: "#FF3366",
width: linewidth
}
};
var plot_y = {
mode: mode,
connectgaps: true,
x: dates,
y: toner_y,
name: "Yellow Toner",
line: {
color: "#FFFF00",
width: linewidth
}
};
var plot_k = {
mode: mode,
connectgaps: true,
x: dates,
y: toner_k,
name: "Black Toner",
line: {
color: "#333333",
width: linewidth
}
};
data = [plot_k, plot_c, plot_m, plot_y];
var layout = {
title: "Toner",
autosize: false,
displaymodebar: false,
displaylogo: false,
dragmode: 'pan',
height: 300,
width: 600,
zeroline: true,
margin: {
autoexpand: false,
l: 25,
r: 25,
t: 50
},
xaxis: {
fixedrange: false
},
yaxis: {
fixedrange: true,
// we want the -3 or 100 to stay on the plot and not get trimmed at the bounds, so pad by 4
range: [-7, 104]
},
showlegend: false
};
// scrollZoom adds the ability to select a range and zoom in on it
Plotly.newPlot("toner", data, layout, {
scrollZoom: true
});
}
// Developer usage graph
function developer_plot(data) {
var key_array = Object.keys(data);
var dev_c = [];
var dev_m = [];
var dev_y = [];
var dev_k = [];
var dates = key_array;
for (var i = 0; i < key_array.length; i++) {
dev_c.push(data[key_array[i]]["Cyan Developer"]);
dev_m.push(data[key_array[i]]["Magenta Developer"]);
dev_y.push(data[key_array[i]]["Yellow Developer"]);
dev_k.push(data[key_array[i]]["Black Developer"]);
}
var plot_c = {
mode: mode,
connectgaps: true,
x: dates,
y: dev_c,
name: "Cyan Developer",
line: {
color: "#0066CC",
width: linewidth
}
};
var plot_m = {
mode: mode,
connectgaps: true,
x: dates,
y: dev_m,
name: "Magenta Developer",
line: {
color: "#FF3366",
width: linewidth
}
};
var plot_y = {
mode: mode,
connectgaps: true,
x: dates,
y: dev_y,
name: "Yellow Developer",
line: {
color: "#FFFF00",
width: linewidth
}
};
var plot_k = {
mode: mode,
connectgaps: true,
x: dates,
y: dev_k,
name: "Black Developer",
line: {
color: "#333333",
width: linewidth
}
};
data = [plot_k, plot_c, plot_m, plot_y];
var layout = {
title: "Developer",
autosize: false,
displaymodebar: false,
displaylogo: false,
dragmode: 'pan',
height: 300,
width: 600,
zeroline: true,
margin: {
autoexpand: false,
l: 25,
r: 25,
t: 25
},
xaxis: {
fixedrange: false
},
yaxis: {
fixedrange: true,
// we want the -3 or 100 to stay on the plot and not get trimmed at the bounds, so pad by 4
range: [-7, 104]
},
showlegend: false
};
Plotly.newPlot("dev", data, layout, {
scrollZoom: true
});
}
// Drum usage graph
function drum_plot(data) {
var key_array = Object.keys(data);
var drum_c = [];
var drum_m = [];
var drum_y = [];
var drum_k = [];
var dates = key_array;
for (var i = 0; i < key_array.length; i++) {
drum_c.push(data[key_array[i]]["Cyan Drum"]);
drum_m.push(data[key_array[i]]["Magenta Drum"]);
drum_y.push(data[key_array[i]]["Yellow Drum"]);
drum_k.push(data[key_array[i]]["Black Drum"]);
}
var plot_c = {
mode: mode,
connectgaps: true,
x: dates,
y: drum_c,
name: "Cyan Drum",
line: {
color: "#0066CC",
width: linewidth
}
};
var plot_m = {
mode: mode,
connectgaps: true,
x: dates,
y: drum_m,
name: "Magenta Drum",
line: {
color: "#FF3366",
width: linewidth
}
};
var plot_y = {
mode: mode,
connectgaps: true,
x: dates,
y: drum_y,
name: "Yellow Drum",
line: {
color: "#FFFF00",
width: linewidth
}
};
var plot_k = {
mode: mode,
connectgaps: true,
x: dates,
y: drum_k,
name: "Black Drum",
line: {
color: "#333333",
width: linewidth
}
};
data = [plot_k, plot_c, plot_m, plot_y];
var layout = {
title: "Drum",
autosize: false,
displaymodebar: false,
displaylogo: false,
dragmode: 'pan',
height: 300,
width: 600,
zeroline: true,
margin: {
autoexpand: false,
l: 25,
r: 25,
t: 25
},
xaxis: {
fixedrange: false
},
yaxis: {
fixedrange: true,
// we want the -3 or 100 to stay on the plot and not get trimmed at the bounds, so pad by 4
range: [-7, 104]
},
showlegend: false
};
Plotly.newPlot("drum", data, layout, {
scrollZoom: true
});
}
// Waste Container and Fuser usage graph
function maint_plot(data) {
var key_array = Object.keys(data);
var waste_toner = [];
var fusing_unit = [];
var dates = key_array;
for (var i = 0; i < key_array.length; i++) {
waste_toner.push(data[key_array[i]]["Waste Toner"]);
fusing_unit.push(data[key_array[i]]["Fusing Unit"]);
}
var plot_w = {
mode: mode,
connectgaps: true,
x: dates,
y: waste_toner,
name: "Waste Toner",
line: {
color: "#999999",
width: linewidth
}
};
var plot_f = {
mode: mode,
connectgaps: true,
x: dates,
y: fusing_unit,
name: "Fusing Unit",
line: {
color: "#FF8800",
width: linewidth
}
};
data = [plot_w, plot_f];
var layout = {
title: "Waste Toner and Fusing Unit",
autosize: false,
displaymodebar: false,
displaylogo: false,
dragmode: 'pan',
height: 300,
width: 600,
zeroline: true,
margin: {
autoexpand: false,
l: 25,
r: 25,
t: 25
},
xaxis: {
fixedrange: false
},
yaxis: {
fixedrange: true,
// we want the -3 or 100 to stay on the plot and not get trimmed at the bounds, so pad by 4
range: [-7, 104]
},
showlegend: false
};
Plotly.newPlot("maint", data, layout, {
scrollZoom: true
});
}
// Page count totals graph
function total_plot(data) {
var key_array = Object.keys(data);
//range
N = 50;
var totalc = [];
var mono = [];
var color = [];
var dates = key_array;
for (var i = 0; i < key_array.length; i++) {
totalc.push(data[key_array[i]]["Total Count"]);
mono.push(data[key_array[i]]["Black & White Total Count"]);
color.push(data[key_array[i]]["Full Color Total Count"]);
}
var plot_totalc = {
mode: mode,
connectgaps: true,
x: dates,
y: totalc,
name: "Total Count",
line: {
color: "#00FF00",
width: 1
}
};
var plot_mono = {
mode: mode,
connectgaps: true,
x: dates,
y: mono,
fill: 'tonexty',
stackgroup: 'one',
name: "Black & White",
line: {
color: "#000000",
width: 1
}
};
var plot_color = {
mode: mode,
connectgaps: true,
x: dates,
y: color,
fill: 'tonexty',
stackgroup: 'one',
name: "Full Color",
line: {
color: "#0000FF",