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
|
<!-- ++ BEGIN ++ Dynamic DNS ++ system_status.htm ++ -->
<script type="text/javascript">//<![CDATA[
// helper to move status data to the relevant
// screen objects
// called by XHR.poll and XHR.get
function _data2elements(x, data) {
var tbl = document.getElementById('ddns_status_table');
// security check
if ( !(tbl) ) { return; }
// clear all rows
while (tbl.firstElementChild !== tbl.lastElementChild)
tbl.removeChild(tbl.lastElementChild);
// variable for Modulo-Division use to set cbi-rowstyle-? (0 or 1)
var i = -1;
var j = 1;
// DDNS Service disabled
if (data[0].enabled == 0) {
var txt = '<strong><font color="red"><%:DDNS Autostart disabled%></font>' ;
var url = '<a href="' + data[0].url_up + '"><%:enable here%></a></strong>' ;
tbl.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format(((j + i) % 2) + 1), [
E('<div class="td">', [ txt," - ", url ])
]));
i++ ;
}
var configuration;
var next_update;
var lookup;
var registered_ip;
var network;
for( j = 1; j < data.length; j++ )
{
// configuration
configuration = data[j].section;
// pid
// data[j].pid ignored here
// last update
// data[j].datelast ignored here
// next update
switch (data[j].datenext) {
case "_empty_":
next_update = '<em><%:Unknown error%></em>';
break;
case "_stopped_":
next_update = '<em><%:Stopped%></em>';
break;
case "_disabled_":
next_update = '<em><%:Disabled%></em>';
break;
case "_noupdate_":
next_update = '<em><%:Update error%></em>';
break;
case "_runonce_":
next_update = '<em><%:Run once%></em>';
break;
case "_verify_":
next_update = '<em><%:Verify%></em>';
break;
default:
next_update = data[j].datenext;
break;
}
// lookup
if (data[j].lookup == "_nolookup_")
lookup = '<em><%:config error%></em>';
else
lookup = data[j].lookup;
// registered IP
switch (data[j].reg_ip) {
case "_nolookup_":
registered_ip = '<em><%:config error%></em>';
break;
case "_nodata_":
registered_ip = '<em><%:No data%></em>';
break;
case "_noipv6_":
registered_ip = '<em><%:IPv6 not supported%></em>';
break;
default:
registered_ip = data[j].reg_ip;
break;
}
// monitored interface
if (data[j].iface == "_nonet_")
network = '<em><%:Config error%></em>';
else
network = data[j].iface;
tbl.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format(((j + i) % 2) + 1), [
E('<div class="td">', [ E('<strong>', configuration) ]),
E('<div class="td">', next_update),
E('<div class="td">', lookup),
E('<div class="td">', registered_ip),
E('<div class="td">', network)
]));
}
if (tbl.firstElementChild === tbl.lastElementChild || (data[0].enabled == 0 && tbl.childNodes.length == 2) ) {
var br = '<br />';
var msg = '<%:There is no service configured.%>';
if (tbl.firstElementChild !== tbl.lastElementChild)
br = '';
msg = br + msg;
tbl.appendChild(E('<div class="tr cbi-section-table-row">', [
E('<div class="td">', [ E('<em>', msg) ])
]));
}
}
// force to immediate show status (not waiting for XHR.poll)
XHR.get('<%=url([[admin]], [[services]], [[ddns]], [[status]])%>', null,
function(x, data) {
if (data) { _data2elements(x, data); }
}
);
XHR.poll(15, '<%=url([[admin]], [[services]], [[ddns]], [[status]])%>', null,
function(x, data) {
if (data) { _data2elements(x, data); }
}
);
//]]></script>
<fieldset class="cbi-section" id="ddns_status_section">
<legend><a href="<%=url([[admin]], [[services]], [[ddns]])%>"><%:Dynamic DNS%></a></legend>
<div class="table cbi-section-table" id="ddns_status_table">
<div class="tr cbi-section-table-titles">
<div class="th cbi-section-table-cell"><%:Configuration%></div>
<div class="th cbi-section-table-cell"><%:Next Update%></div>
<div class="th cbi-section-table-cell"><%:Lookup Hostname%></div>
<div class="th cbi-section-table-cell"><%:Registered IP%></div>
<div class="th cbi-section-table-cell"><%:Network%></div>
</div>
<div class="tr cbi-section-table-row">
<div class="td"><em><br /><%:Collecting data...%></em></div>
</div>
</div>
</fieldset>
<!-- ++ END ++ Dynamic DNS ++ system_status.htm ++ -->
|