Newer
Older
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
// jshint esversion: 6
const doorNaming = {};
let doorInterval = false;
function doorInit() {
fetch((conf.doorSrcUrl+'&machine='+machine).replace('?&','?'), {cache: "no-store"})
.then((response) => {return response.json();})
.then((doorList) => {
for (let facility in doorList) {
doorNaming[facility] = [];
for (let d=0; d<doorList[facility].length; d++) {
if (doorNaming[facility][d] == "") continue;
doorNaming[facility][d] = doorList[facility][d];
const id = doorNaming[facility][d].replace('.', '_');
$('#'+id).css('fill', 'gray');
$('#'+id).css('stroke', 'gray');
// console.log('doorNaming', facility, doorNaming[facility], d, id);
}
}
doorInterval = setInterval(doorRead, 1000);
});
}
function doorMenu(menuParams) {
// console.log('doorMenu', menuParams, (conf.doorSrcUrl+'&machine='+machine).replace('?&','?'));
menuParams.door = document.location.search.indexOf('door')>-1;
gui.add(menuParams, 'door').name('doors').onChange(function() {doorSwitch(menuParams);});
if (menuParams.door) {
doorInit();
}
}
function door2d(lattice, menuParams) {
console.log('door2d',lattice, menuParams);
$('.doorpss').css('fill', 'gray');
$('.doorpss').css('stroke', 'gray');
doorMenu(menuParams);
}
function doorSwitch(menuParams) {
console.log('doorSwitch()',menuParams, menuParams.door);
if (doorInterval !== false) {
clearInterval(doorInterval);
}
doorInterval = false;
if (menuParams.door==false) {
for (let facility in doorNaming) {
for (let d=0; d<doorNaming[facility].length; d++) {
const id = doorNaming[facility][d].replace('.', '_');
$('#'+id).css('fill', 'gray');
$('#'+id).css('stroke', 'gray');
// console.log('doorNaming', facility, doorNaming[facility], d, id);
}
}
}
else {
if ($.isEmptyObject(doorNaming)) doorInit();
else {
doorRead();
doorInterval = setInterval(doorRead, 1000);
}
}
}
function doorRender(val) {
for (let facility in val) {
for (let d=0; d<val[facility].door.length; d++) {
if (typeof doorNaming[facility][d]=='undefined') continue;
const id = doorNaming[facility][d].replace('.', '_');
$('#'+id).css('fill', val[facility].door[d]!=1? '#00000000': (val[facility].hold[d]==1 != facility=='sr'? 'yellow': 'white'));
$('#'+id).css('stroke', val[facility].door[d]!=1? 'red': '#00000000');
// console.log('doorNaming', facility, doorNaming[facility], d, id);
}
}
}
function doorRead() {
fetch((conf.doorUrl+'&machine='+machine).replace('?&','?'), {cache: "no-store"})
.then((response) => {return response.json();})
.then((eventData) => {
// console.log('fetch()',(conf.doorUrl+'&machine='+machine).replace('?&','?'), eventData);
doorRender(eventData);
});
}