3 Copyright (C) 2006-2010 Jonathan Zarate
4 http://www.polarcloud.com/tomato/
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
10 // -----------------------------------------------------------------------------
12 Array.prototype.find = function(v) {
13 for (var i = 0; i < this.length; ++i)
14 if (this[i] == v) return i;
18 Array.prototype.remove = function(v) {
19 for (var i = 0; i < this.length; ++i) {
28 // -----------------------------------------------------------------------------
30 String.prototype.trim = function() {
31 return this.replace(/^\s+/, '').replace(/\s+$/, '');
34 // -----------------------------------------------------------------------------
36 Number.prototype.pad = function(min) {
37 var s = this.toString();
38 while (s.length < min) s = '0' + s;
42 Number.prototype.hex = function(min)
44 var h = '0123456789ABCDEF';
48 s = h.charAt(n & 15) + s;
50 } while ((--min > 0) || (n > 0));
54 // -----------------------------------------------------------------------------
56 // ---- Element.protoype. doesn't work with all browsers
59 getOffset: function(e) {
60 var r = { x: 0, y: 0 };
62 while (e.offsetParent) {
70 addClass: function(e, name) {
71 if ((e = E(e)) == null) return;
72 var a = e.className.split(/\s+/);
74 for (var i = 1; i < arguments.length; ++i) {
75 if (a.find(arguments[i]) == -1) {
80 if (k) e.className = a.join(' ');
83 removeClass: function(e, name) {
84 if ((e = E(e)) == null) return;
85 var a = e.className.split(/\s+/);
87 for (var i = 1; i < arguments.length; ++i)
88 k |= a.remove(arguments[i]);
89 if (k) e.className = a.join(' ');
93 if ((e = E(e)) != null) e.parentNode.removeChild(e);
96 parentElem: function(e, tagName) {
98 tagName = tagName.toUpperCase();
99 while (e.parentNode) {
101 if (e.tagName == tagName) return e;
106 display: function() {
107 var enable = arguments[arguments.length - 1];
108 for (var i = 0; i < arguments.length - 1; ++i) {
109 E(arguments[i]).style.display = enable ? '' : 'none';
113 isVisible: function(e) {
116 if ((e.style.visibility != 'visible') || (e.style.display == 'none')) return false;
122 setInnerHTML: function(e, html) {
124 if (e.innerHTML != html) e.innerHTML = html; // reduce flickering
128 // -----------------------------------------------------------------------------
131 getViewSize: function() {
132 if (window.innerHeight) {
133 return { width: window.innerWidth, height: window.innerHeight };
135 else if (document.documentElement && document.documentElement.clientHeight) {
136 return { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
138 return { width: document.body.clientWidth, height: document.body.clientHeight };
141 getPageOffset: function()
143 if (typeof(window.pageYOffset) != 'undefined') {
144 return { x: window.pageXOffset, y: window.pageYOffset };
146 else if ((document.documentElement) && (typeof(document.documentElement.scrollTop) != 'undefined')) {
147 return { x: document.documentElement.scrollLeft, y: document.documentElement.scrollTop };
149 return { x: document.body.scrollLeft, y: document.body.scrollTop };
153 // -----------------------------------------------------------------------------
156 getAll: function(e) {
165 for (var i = 0; i < e.childNodes.length; ++i) {
166 a = a.concat(fields.getAll(e.childNodes[i]));
172 disableAll: function(e, d) {
175 if ((typeof(e.tagName) == 'undefined') && (typeof(e) != 'string')) {
176 for (i = e.length - 1; i >= 0; --i) {
181 var a = this.getAll(E(e));
182 for (var i = a.length - 1; i >= 0; --i) {
188 selected: function(e) {
189 for (var i = 0; i < e.length; ++i) {
190 if (e[i].checked) return e[i];
194 find: function(e, value) {
195 for (var i = 0; i < e.length; ++i) {
196 if (e[i].value == value) return e[i];
203 // -----------------------------------------------------------------------------
206 submitHidden: function(url, fields) {
209 fom = document.createElement('FORM');
212 for (var f in fields) {
213 var e = document.createElement('INPUT');
219 body = document.getElementsByTagName('body')[0];
220 fom = body.appendChild(fom);
222 body.removeChild(fom);
225 submit: function(fom, async, url) {
226 var e, v, f, i, wait, msg, sb, cb;
231 this.dump(fom, async, url);
235 if (this.xhttp) return;
237 if ((sb = E('save-button')) != null) sb.disabled = 1;
238 if ((cb = E('cancel-button')) != null) cb.disabled = 1;
240 if ((!async) || (!useAjax())) {
242 if (url) fom.action = url;
249 for (var i = 0; i < fom.elements.length; ++i) {
251 if ((f.disabled) || (f.name == '') || (f.name.substr(0, 2) == 'f_')) continue;
252 if ((f.tagName == 'INPUT') && ((f.type == 'CHECKBOX') || (f.type == 'RADIO')) && (!f.checked)) continue;
253 if (f.name == '_nextwait') {
255 if (isNaN(wait)) wait = 5;
256 else wait = Math.abs(wait);
258 v.push(escapeCGI(f.name) + '=' + escapeCGI(f.value));
261 if ((msg = E('footer-msg')) != null) {
262 msg.innerHTML = 'Saving...';
263 msg.style.visibility = 'visible';
266 this.xhttp = new XmlHttp();
267 this.xhttp.onCompleted = function(text, xml) {
269 if (text.match(/@msg:(.+)/)) msg.innerHTML = escapeHTML(RegExp.$1);
270 else msg.innerHTML = 'Saved';
274 if (sb) sb.disabled = 0;
275 if (cb) cb.disabled = 0;
276 if (msg) msg.style.visibility = 'hidden';
277 if (typeof(submit_complete) != 'undefined') submit_complete();
281 this.xhttp.onError = function(x) {
282 if (url) fom.action = url;
286 this.xhttp.post(url ? url : fom.action, v.join('&'));
289 addId: function(fom) {
292 if (typeof(fom._http_id) == 'undefined') {
293 e = document.createElement('INPUT');
296 e.value = nvram.http_id;
300 fom._http_id.value = nvram.http_id;
304 addIdAction: function(fom) {
305 if (fom.action.indexOf('?') != -1) fom.action += '&_http_id=' + nvram.http_id;
306 else fom.action += '?_http_id=' + nvram.http_id;
309 dump: function(fom, async, url) {
313 // -----------------------------------------------------------------------------
316 set: function(e, message, quiet) {
317 if ((e = E(e)) == null) return;
318 e._error_msg = message;
319 e._error_org = e.title;
321 elem.addClass(e, 'error');
322 if (!quiet) this.show(e);
326 if ((e = E(e)) == null) return;
327 e.title = e._error_org || '';
328 elem.removeClass(e, 'error');
333 clearAll: function(e) {
334 for (var i = 0; i < e.length; ++i)
339 if ((e = E(e)) == null) return;
340 if (!e._error_msg) return;
341 elem.addClass(e, 'error-focused');
344 elem.removeClass(e, 'error-focused');
348 if ((e = E(e)) == null) return 0;
349 return !e._error_msg;
353 // -----------------------------------------------------------------------------
355 function _v_range(e, quiet, min, max, name)
357 if ((e = E(e)) == null) return 0;
359 if ((!v.match(/^ *[-\+]?\d+ *$/)) || (v < min) || (v > max)) {
360 ferror.set(e, 'Invalid ' + name + '. Valid range: ' + min + '-' + max, quiet);
368 function v_range(e, quiet, min, max)
370 return _v_range(e, quiet, min, max, 'number');
373 function v_port(e, quiet)
375 return _v_range(e, quiet, 1, 0xFFFF, 'port');
378 function v_octet(e, quiet)
380 return _v_range(e, quiet, 1, 254, 'address');
383 function v_mins(e, quiet, min, max)
387 if ((e = E(e)) == null) return 0;
388 if (e.value.match(/^\s*(.+?)([mhd])?\s*$/)) {
390 if (RegExp.$2 == 'h') m = 60;
391 else if (RegExp.$2 == 'd') m = 60 * 24;
392 v = Math.round(RegExp.$1 * m);
395 return _v_range(e, quiet, min, max, 'minutes');
398 ferror.set(e, 'Invalid number of minutes.', quiet);
402 function v_macip(e, quiet, bok, ipp)
404 var s, a, b, c, d, i;
406 if ((e = E(e)) == null) return 0;
407 s = e.value.replace(/\s+/g, '');
409 if ((a = fixMAC(s)) != null) {
415 ferror.set(e, 'Invalid MAC or IP address');
426 ferror.set(e, 'Invalid IP address range', quiet);
430 for (i = 0; i < a.length; ++i) {
432 if (b.match(/^\d+$/)) b = ipp + b;
436 ferror.set(e, 'Invalid IP address', quiet);
440 if (b.indexOf(ipp) != 0) {
441 ferror.set(e, 'IP address outside of LAN', quiet);
445 d = (b.split('.'))[3];
447 ferror.set(e, 'Invalid IP address range', quiet);
453 e.value = ipp + a.join('-');
457 function fixIP(ip, x)
462 if (a.length != 4) return null;
463 for (i = 0; i < 4; ++i) {
465 if ((isNaN(n)) || (n < 0) || (n > 255)) return null;
468 if ((x) && ((a[3] == 0) || (a[3] == 255))) return null;
472 function v_ip(e, quiet, x)
476 if ((e = E(e)) == null) return 0;
477 ip = fixIP(e.value, x);
479 ferror.set(e, 'Invalid IP address', quiet);
487 function v_ipz(e, quiet)
489 if ((e = E(e)) == null) return 0;
490 if (e.value == '') e.value = '0.0.0.0';
491 return v_ip(e, quiet);
494 function v_dns(e, quiet)
496 if ((e = E(e)) == null) return 0;
501 var s = e.value.split(':');
505 else if (s.length != 2) {
506 ferror.set(e, 'Invalid IP address or port', quiet);
510 if ((s[0] = fixIP(s[0])) == null) {
511 ferror.set(e, 'Invalid IP address', quiet);
515 if ((s[1] = fixPort(s[1], -1)) == -1) {
516 ferror.set(e, 'Invalid port', quiet);
524 e.value = s.join(':');
536 // ---- this is goofy because << mangles numbers as signed
539 for (i = 0; i < 4; ++i) x += (o[i] * 1).hex(2);
540 return parseInt(x, 16);
545 return ((ip >> 24) & 255) + '.' + ((ip >> 16) & 255) + '.' + ((ip >> 8) & 255) + '.' + (ip & 255);
549 // ---- 1.2.3.4, 1.2.3.4/24, 1.2.3.4/255.255.255.0, 1.2.3.4-1.2.3.5
550 function _v_iptip(e, ip, quiet)
552 var ma, x, y, z, oip;
558 if (ip.match(/^(.*)-(.*)$/)) {
559 a = fixIP(RegExp.$1);
560 b = fixIP(RegExp.$2);
561 if ((a == null) || (b == null)) {
562 ferror.set(e, 'Invalid IP address range - ' + oip, quiet);
567 if (aton(a) > aton(b)) return b + '-' + a;
575 if (ip.match(/^(.*)\/(.*)$/)) {
582 if ((ma == null) || (!_v_netmask(ma))) {
583 ferror.set(e, 'Invalid netmask - ' + oip, quiet);
588 if ((ma < 0) || (ma > 32)) {
589 ferror.set(e, 'Invalid netmask - ' + oip, quiet);
597 ferror.set(e, 'Invalid IP address - ' + oip, quiet);
602 return ip + ((ma != '') ? ('/' + ma) : '');
605 function v_iptip(e, quiet, multi)
609 if ((e = E(e)) == null) return 0;
610 v = e.value.split(',');
612 if (v.length > multi) {
613 ferror.set(e, 'Too many IP addresses', quiet);
619 ferror.set(e, 'Invalid IP address', quiet);
623 for (i = 0; i < v.length; ++i) {
624 if ((v[i] = _v_iptip(e, v[i], quiet)) == null) return 0;
626 e.value = v.join(', ');
631 function fixPort(p, def)
633 if (def == null) def = -1;
634 if (p == null) return def;
636 if ((isNaN(p) || (p < 1) || (p > 65535) || (('' + p).indexOf('.') != -1))) return def;
640 function _v_portrange(e, quiet, v)
642 if (v.match(/^(.*)[-:](.*)$/)) {
648 if ((x == -1) || (y == -1)) {
649 ferror.set(e, 'Invalid port range: ' + v, quiet);
658 if (x == y) return x;
664 ferror.set(e, 'Invalid port', quiet);
672 function v_portrange(e, quiet)
676 if ((e = E(e)) == null) return 0;
677 v = _v_portrange(e, quiet, e.value);
678 if (v == null) return 0;
683 function v_iptport(e, quiet)
687 if ((e = E(e)) == null) return 0;
689 a = e.value.split(/[,\.]/);
692 ferror.set(e, 'Expecting a list of ports or port range.', quiet);
696 ferror.set(e, 'Only 10 ports/range sets are allowed.', quiet);
701 for (i = 0; i < a.length; ++i) {
702 v = _v_portrange(e, quiet, a[i]);
703 if (v == null) return 0;
707 e.value = q.join(',');
712 function _v_netmask(mask)
714 var v = aton(mask) ^ 0xFFFFFFFF;
715 return (((v + 1) & v) == 0);
718 function v_netmask(e, quiet)
722 if ((e = E(e)) == null) return 0;
731 else if (e.value.match(/^\s*\/\s*(\d+)\s*$/)) {
733 if ((b >= 1) && (b <= 32)) {
734 if (b == 32) n = 0xFFFFFFFF; // js quirk
735 else n = (0xFFFFFFFF >>> b) ^ 0xFFFFFFFF;
736 e.value = (n >>> 24) + '.' + ((n >>> 16) & 0xFF) + '.' + ((n >>> 8) & 0xFF) + '.' + (n & 0xFF);
741 ferror.set(e, 'Invalid netmask', quiet);
749 mac = mac.replace(/\s+/g, '').toUpperCase();
750 if (mac.length == 0) {
753 else if (mac.length == 12) {
754 mac = mac.match(/../g);
757 mac = mac.split(/[:\-]/);
758 if (mac.length != 6) return null;
760 for (i = 0; i < 6; ++i) {
762 if (t.search(/^[0-9A-F]+$/) == -1) return null;
763 if ((t = parseInt(t, 16)) > 255) return null;
766 return mac.join(':');
769 function v_mac(e, quiet)
773 if ((e = E(e)) == null) return 0;
774 mac = fixMAC(e.value);
775 if ((!mac) || (isMAC0(mac))) {
776 ferror.set(e, 'Invalid MAC address', quiet);
784 function v_macz(e, quiet)
788 if ((e = E(e)) == null) return 0;
789 mac = fixMAC(e.value);
791 ferror.set(e, 'Invalid MAC address', quiet);
799 function v_length(e, quiet, min, max)
803 if ((e = E(e)) == null) return 0;
806 if (min == undefined) min = 1;
808 ferror.set(e, 'Invalid length. Please enter at least ' + min + ' character' + (min == 1 ? '.' : 's.'), quiet);
811 max = max || e.maxlength;
813 ferror.set(e, 'Invalid length. Please reduce the length to ' + max + ' characters or less.', quiet);
821 function v_domain(e, quiet)
825 if ((e = E(e)) == null) return 0;
826 s = e.value.trim().replace(/\s+/g, ' ');
827 if ((s.length > 0) && (s.search(/^[.a-zA-Z0-9_\- ]+$/) == -1)) {
828 ferror.set(e, "Invalid name. Only characters \"A-Z 0-9 . - _\" are allowed.", quiet);
838 return (mac == '00:00:00:00:00:00');
841 // -----------------------------------------------------------------------------
845 if ((a = fixIP(a)) == null) a = '255.255.255.255';
846 if ((b = fixIP(b)) == null) b = '255.255.255.255';
847 return aton(a) - aton(b);
850 function cmpText(a, b)
852 if (a == '') a = '\xff';
853 if (b == '') b = '\xff';
854 return (a < b) ? -1 : ((a > b) ? 1 : 0);
857 function cmpInt(a, b)
861 return ((isNaN(a)) ? -0x7FFFFFFF : a) - ((isNaN(b)) ? -0x7FFFFFFF : b);
864 function cmpDate(a, b)
866 return b.getTime() - a.getTime();
869 // -----------------------------------------------------------------------------
871 // ---- todo: cleanup this mess
875 return elem.parentElem(e, 'TABLE').gridObj;
878 function tgHideIcons()
881 while ((e = document.getElementById('tg-row-panel')) != null) e.parentNode.removeChild(e);
884 // ---- options = sort, move, delete
885 function TomatoGrid(tb, options, maxAdd, editorFields)
887 this.init(tb, options, maxAdd, editorFields);
891 TomatoGrid.prototype = {
892 init: function(tb, options, maxAdd, editorFields) {
895 this.tb.gridObj = this;
900 if (!options) options = '';
904 this.canSort = options.indexOf('sort') != -1;
905 this.canMove = options.indexOf('move') != -1;
906 this.maxAdd = maxAdd || 140;
907 this.canEdit = (editorFields != null);
908 this.canDelete = this.canEdit || (options.indexOf('delete') != -1);
909 this.editorFields = editorFields;
910 this.sortColumn = -1;
911 this.sortAscending = true;
914 _insert: function(at, cells, escCells) {
918 tr = this.tb.insertRow(at);
919 for (i = 0; i < cells.length; ++i) {
921 if (typeof(c) == 'string') {
922 td = tr.insertCell(i);
923 td.className = 'co' + (i + 1);
924 if (escCells) td.appendChild(document.createTextNode(c));
925 else td.innerHTML = c;
936 headerClick: function(cell) {
938 this.sort(cell.cellN);
942 headerSet: function(cells, escCells) {
945 elem.remove(this.header);
946 this.header = e = this._insert(0, cells, escCells);
947 e.className = 'header';
949 for (i = 0; i < e.cells.length; ++i) {
950 e.cells[i].cellN = i; // cellIndex broken in Safari
951 e.cells[i].onclick = function() { return TGO(this).headerClick(this); };
958 footerClick: function(cell) {
961 footerSet: function(cells, escCells) {
964 elem.remove(this.footer);
965 this.footer = e = this._insert(-1, cells, escCells);
966 e.className = 'footer';
967 for (i = 0; i < e.cells.length; ++i) {
968 e.cells[i].cellN = i;
969 e.cells[i].onclick = function() { TGO(this).footerClick(this) };
980 TGO(e).moving = null;
981 i = e.previousSibling;
982 if (i == this.header) return;
983 e.parentNode.removeChild(e);
984 i.parentNode.insertBefore(e, i);
994 TGO(e).moving = null;
996 if (i == this.footer) return;
997 e.parentNode.removeChild(e);
998 i.parentNode.insertBefore(e, i.nextSibling);
1004 rpMo: function(img, e) {
1009 if (me.moving == e) {
1015 img.style.border = "1px dotted red";
1018 rpDel: function(e) {
1020 TGO(e).moving = null;
1021 e.parentNode.removeChild(e);
1026 rpMouIn: function(evt) {
1027 var e, x, ofs, me, s, n;
1029 if ((evt = checkEvent(evt)) == null) return;
1031 me = TGO(evt.target);
1032 if (me.isEditing()) return;
1033 if (me.moving) return;
1036 e = document.createElement('div');
1039 e.setAttribute('id', 'tg-row-panel');
1044 s = '<img src="rpu.gif" onclick="this.parentNode.tgo.rpUp(this.parentNode.ref)" title="Move Up"><img src="rpd.gif" onclick="this.parentNode.tgo.rpDn(this.parentNode.ref)" title="Move Down"><img src="rpm.gif" onclick="this.parentNode.tgo.rpMo(this,this.parentNode.ref)" title="Move">';
1048 s += '<img src="rpx.gif" onclick="this.parentNode.tgo.rpDel(this.parentNode.ref)" title="Delete">';
1052 x = x.cells[x.cells.length - 1];
1053 ofs = elem.getOffset(x);
1055 e.style.left = (ofs.x + x.offsetWidth - n) + 'px';
1056 e.style.top = ofs.y + 'px';
1057 e.style.width = n + 'px';
1060 document.body.appendChild(e);
1063 rpHide: tgHideIcons,
1067 onClick: function(cell) {
1070 var p = this.moving.parentNode;
1072 if (this.moving != q) {
1073 var v = this.moving.rowIndex > q.rowIndex;
1074 p.removeChild(this.moving);
1075 if (v) p.insertBefore(this.moving, q);
1076 else p.insertBefore(this.moving, q.nextSibling);
1087 insert: function(at, data, cells, escCells) {
1090 if ((this.footer) && (at == -1)) at = this.footer.rowIndex;
1091 e = this._insert(at, cells, escCells);
1092 e.className = (e.rowIndex & 1) ? 'even' : 'odd';
1094 for (i = 0; i < e.cells.length; ++i) {
1095 e.cells[i].onclick = function() { return TGO(this).onClick(this); };
1099 e.getRowData = function() { return this._data; }
1100 e.setRowData = function(data) { this._data = data; }
1102 if ((this.canMove) || (this.canEdit) || (this.canDelete)) {
1103 e.onmouseover = this.rpMouIn;
1104 // ---- e.onmouseout = this.rpMouOut;
1105 if (this.canEdit) e.title = 'Click to edit';
1113 insertData: function(at, data) {
1114 return this.insert(at, data, this.dataToView(data), false);
1117 dataToView: function(data) {
1119 for (var i = 0; i < data.length; ++i) {
1120 var s = escapeHTML('' + data[i]);
1121 if (this.editorFields && this.editorFields.length > i) {
1122 var ef = this.editorFields[i].multi;
1123 if (!ef) ef = [this.editorFields[i]];
1124 var f = (ef && ef.length > 0 ? ef[0] : null);
1125 if (f && f.type == 'password') {
1126 if (!f.peekaboo || get_config('web_pb', '1') != '0')
1127 s = s.replace(/./g, '●');
1135 dataToFieldValues: function(data) {
1139 fieldValuesToData: function(row) {
1143 e = fields.getAll(row);
1144 for (i = 0; i < e.length; ++i) data.push(e[i].value);
1150 edit: function(cell) {
1153 if (this.isEditing()) return;
1156 sr.style.display = 'none';
1157 elem.removeClass(sr, 'hover');
1160 er = this.createEditor('edit', sr.rowIndex, sr);
1161 er.className = 'editor';
1164 c = er.cells[cell.cellIndex || 0];
1165 e = c.getElementsByTagName('input');
1166 if ((e) && (e.length > 0)) {
1174 this.controls = this.createControls('edit', sr.rowIndex);
1176 this.disableNewEditor(true);
1178 this.verifyFields(this.editor, true);
1181 createEditor: function(which, rowIndex, source) {
1184 if (which == 'edit') values = this.dataToFieldValues(source.getRowData());
1186 var row = this.tb.insertRow(rowIndex);
1187 row.className = 'editor';
1189 var common = ' onkeypress="return TGO(this).onKey(\'' + which + '\', event)" onchange="TGO(this).onChange(\'' + which + '\', this)"';
1192 for (var i = 0; i < this.editorFields.length; ++i) {
1194 var ef = this.editorFields[i].multi;
1195 if (!ef) ef = [this.editorFields[i]];
1197 for (var j = 0; j < ef.length; ++j) {
1200 if (f.prefix) s += f.prefix;
1201 var attrib = ' class="fi' + (vi + 1) + '" ' + (f.attrib || '');
1202 var id = (this.tb ? ('_' + this.tb + '_' + (vi + 1)) : null);
1203 if (id) attrib += ' id="' + id + '"';
1207 switch (get_config('web_pb', '1')) {
1215 attrib += ' autocomplete="off"';
1216 if (f.peekaboo && id) attrib += ' onfocus=\'peekaboo("' + id + '",1)\'';
1219 s += '<input type="' + f.type + '" maxlength=' + f.maxlen + common + attrib;
1220 if (which == 'edit') s += ' value="' + escapeHTML('' + values[vi]) + '">';
1224 s += '<select' + common + attrib + '>';
1225 for (var k = 0; k < f.options.length; ++k) {
1227 if (which == 'edit') {
1228 s += '<option value="' + a[0] + '"' + ((a[0] == values[vi]) ? ' selected>' : '>') + a[1] + '</option>';
1231 s += '<option value="' + a[0] + '">' + a[1] + '</option>';
1237 s += '<input type="checkbox"' + common + attrib;
1238 if ((which == 'edit') && (values[vi])) s += ' checked';
1242 s += f.custom.replace(/\$which\$/g, which);
1244 if (f.suffix) s += f.suffix;
1248 var c = row.insertCell(i);
1250 if (this.editorFields[i].vtop) c.vAlign = 'top';
1256 createControls: function(which, rowIndex) {
1259 r = this.tb.insertRow(rowIndex);
1260 r.className = 'controls';
1262 c = r.insertCell(0);
1263 c.colSpan = this.header.cells.length;
1264 if (which == 'edit') {
1266 '<input type=button value="Delete" onclick="TGO(this).onDelete()"> ' +
1267 '<input type=button value="OK" onclick="TGO(this).onOK()"> ' +
1268 '<input type=button value="Cancel" onclick="TGO(this).onCancel()">';
1272 '<input type=button value="Add" onclick="TGO(this).onAdd()">';
1277 removeEditor: function() {
1280 elem.remove(this.editor);
1283 if (this.controls) {
1284 elem.remove(this.controls);
1285 this.controls = null;
1289 showSource: function() {
1291 this.source.style.display = '';
1296 onChange: function(which, cell) {
1297 return this.verifyFields((which == 'new') ? this.newEditor : this.editor, true);
1300 onKey: function(which, ev) {
1301 switch (ev.keyCode) {
1303 if (which == 'edit') this.onCancel();
1306 if (((ev.srcElement) && (ev.srcElement.tagName == 'SELECT')) ||
1307 ((ev.target) && (ev.target.tagName == 'SELECT'))) return true;
1308 if (which == 'edit') this.onOK();
1315 onDelete: function() {
1316 this.removeEditor();
1317 elem.remove(this.source);
1319 this.disableNewEditor(false);
1322 onCancel: function() {
1323 this.removeEditor();
1325 this.disableNewEditor(false);
1331 if (!this.verifyFields(this.editor, false)) return;
1333 data = this.fieldValuesToData(this.editor);
1334 view = this.dataToView(data);
1336 this.source.setRowData(data);
1337 for (i = 0; i < this.source.cells.length; ++i) {
1338 this.source.cells[i].innerHTML = view[i];
1341 this.removeEditor();
1343 this.disableNewEditor(false);
1352 if (!this.verifyFields(this.newEditor, false)) return;
1354 data = this.fieldValuesToData(this.newEditor);
1355 this.insertData(-1, data);
1357 this.disableNewEditor(false);
1358 this.resetNewEditor();
1361 verifyFields: function(row, quiet) {
1365 showNewEditor: function() {
1368 r = this.createEditor('new', -1, null);
1369 this.footer = this.newEditor = r;
1371 r = this.createControls('new', -1);
1372 this.newControls = r;
1374 this.disableNewEditor(false);
1377 disableNewEditor: function(disable) {
1378 if (this.getDataCount() >= this.maxAdd) disable = true;
1379 if (this.newEditor) fields.disableAll(this.newEditor, disable);
1380 if (this.newControls) fields.disableAll(this.newControls, disable);
1383 resetNewEditor: function() {
1386 e = fields.getAll(this.newEditor);
1388 for (i = 0; i < e.length; ++i) {
1390 if (f.selectedIndex) f.selectedIndex = 0;
1393 try { if (e.length) e[0].focus(); } catch (er) { }
1396 getDataCount: function() {
1398 n = this.tb.rows.length;
1399 if (this.footer) n = this.footer.rowIndex;
1400 if (this.header) n -= this.header.rowIndex + 1;
1404 sortCompare: function(a, b) {
1406 var col = obj.sortColumn;
1407 var r = cmpText(a.cells[col].innerHTML, b.cells[col].innerHTML);
1408 return obj.sortAscending ? r : -r;
1411 sort: function(column) {
1412 if (this.editor) return;
1414 if (this.sortColumn >= 0) {
1415 elem.removeClass(this.header.cells[this.sortColumn], 'sortasc', 'sortdes');
1417 if (column == this.sortColumn) {
1418 this.sortAscending = !this.sortAscending;
1421 this.sortAscending = true;
1422 this.sortColumn = column;
1424 elem.addClass(this.header.cells[column], this.sortAscending ? 'sortasc' : 'sortdes');
1429 resort: function() {
1430 if ((this.sortColumn < 0) || (this.getDataCount() == 0) || (this.editor)) return;
1432 var p = this.header.parentNode;
1434 var i, j, max, e, p;
1439 top = this.header ? this.header.rowIndex + 1 : 0;
1440 max = this.footer ? this.footer.rowIndex : this.tb.rows.length;
1441 for (i = top; i < max; ++i) a.push(p.rows[i]);
1442 a.sort(THIS(this, this.sortCompare));
1443 this.removeAllData();
1445 for (i = 0; i < a.length; ++i) {
1446 e = p.insertBefore(a[i], this.footer);
1447 e.className = (j & 1) ? 'even' : 'odd';
1452 recolor: function() {
1455 i = this.header ? this.header.rowIndex + 1 : 0;
1456 e = this.footer ? this.footer.rowIndex : this.tb.rows.length;
1457 for (; i < e; ++i) {
1458 o = this.tb.rows[i];
1459 o.className = (o.rowIndex & 1) ? 'even' : 'odd';
1463 removeAllData: function() {
1466 i = this.header ? this.header.rowIndex + 1 : 0;
1467 count = (this.footer ? this.footer.rowIndex : this.tb.rows.length) - i;
1468 while (count-- > 0) elem.remove(this.tb.rows[i]);
1471 getAllData: function() {
1472 var i, max, data, r;
1475 max = this.footer ? this.footer.rowIndex : this.tb.rows.length;
1476 for (i = this.header ? this.header.rowIndex + 1 : 0; i < max; ++i) {
1477 r = this.tb.rows[i];
1478 if ((r.style.display != 'none') && (r._data)) data.push(r._data);
1483 isEditing: function() {
1484 return (this.editor != null);
1489 // -----------------------------------------------------------------------------
1492 function xmlHttpObj()
1496 ob = new XMLHttpRequest();
1501 ob = new ActiveXObject('Microsoft.XMLHTTP');
1509 var _holdAjax = null;
1513 if (_useAjax == -1) _useAjax = ((_holdAjax = xmlHttpObj()) != null);
1519 if ((!useAjax()) || ((this.xob = xmlHttpObj()) == null)) return null;
1523 XmlHttp.prototype = {
1524 addId: function(vars) {
1525 if (vars) vars += '&';
1527 vars += '_http_id=' + escapeCGI(nvram.http_id);
1531 get: function(url, vars) {
1533 vars = this.addId(vars);
1536 this.xob.onreadystatechange = THIS(this, this.onReadyStateChange);
1537 this.xob.open('GET', url, true);
1538 this.xob.send(null);
1545 post: function(url, vars) {
1547 vars = this.addId(vars);
1549 this.xob.onreadystatechange = THIS(this, this.onReadyStateChange);
1550 this.xob.open('POST', url, true);
1551 this.xob.send(vars);
1560 this.xob.onreadystatechange = function () { }
1567 onReadyStateChange: function() {
1569 if (typeof(E) == 'undefined') return; // oddly late? testing for bug...
1571 if (this.xob.readyState == 4) {
1572 if (this.xob.status == 200) {
1573 this.onCompleted(this.xob.responseText, this.xob.responseXML);
1576 this.onError('' + (this.xob.status || 'unknown'));
1585 onCompleted: function(text, xml) { },
1586 onError: function(ex) { }
1590 // -----------------------------------------------------------------------------
1593 function TomatoTimer(func, ms)
1596 this.onTimer = func;
1597 if (ms) this.start(ms);
1601 TomatoTimer.prototype = {
1602 start: function(ms) {
1604 this.tid = setTimeout(THIS(this, this._onTimer), ms);
1608 clearTimeout(this.tid);
1613 isRunning: function() {
1614 return (this.tid != null);
1617 _onTimer: function() {
1622 onTimer: function() {
1627 // -----------------------------------------------------------------------------
1630 function TomatoRefresh(actionURL, postData, refreshTime, cookieTag)
1632 this.setup(actionURL, postData, refreshTime, cookieTag);
1633 this.timer = new TomatoTimer(THIS(this, this.start));
1636 TomatoRefresh.prototype = {
1639 setup: function(actionURL, postData, refreshTime, cookieTag) {
1642 this.actionURL = actionURL;
1643 this.postData = postData;
1644 this.refreshTime = refreshTime * 1000;
1645 this.cookieTag = cookieTag;
1651 if ((e = E('refresh-time')) != null) {
1652 if (this.cookieTag) cookie.set(this.cookieTag, e.value);
1653 this.refreshTime = e.value * 1000;
1657 this.updateUI('start');
1660 if ((this.http = new XmlHttp()) == null) {
1665 this.http.parent = this;
1667 this.http.onCompleted = function(text, xml) {
1668 var p = this.parent;
1670 if (p.cookieTag) cookie.unset(p.cookieTag + '-error');
1678 if ((p.refreshTime > 0) && (!p.once)) {
1680 p.timer.start(Math.round(p.refreshTime));
1689 this.http.onError = function(ex) {
1690 var p = this.parent;
1691 if ((!p) || (!p.running)) return;
1695 if (++p.errors <= 3) {
1697 p.timer.start(3000);
1702 var e = cookie.get(p.cookieTag + '-error') * 1;
1703 if (isNaN(e)) e = 0;
1705 cookie.unset(p.cookieTag);
1706 cookie.set(p.cookieTag + '-error', e, 1);
1708 alert('XMLHTTP: ' + ex);
1713 setTimeout(reloadPage, 2000);
1717 this.http.post(this.actionURL, this.postData);
1721 if (this.cookieTag) cookie.set(this.cookieTag, -(this.refreshTime / 1000));
1723 this.updateUI('stop');
1726 this.once = undefined;
1729 toggle: function(delay) {
1730 if (this.running) this.stop();
1731 else this.start(delay);
1734 updateUI: function(mode) {
1737 if (typeof(E) == 'undefined') return; // for a bizzare bug...
1739 b = (mode != 'stop') && (this.refreshTime > 0);
1740 if ((e = E('refresh-button')) != null) {
1741 e.value = b ? 'Stop' : 'Refresh';
1742 e.disabled = ((mode == 'start') && (!b));
1744 if ((e = E('refresh-time')) != null) e.disabled = b;
1745 if ((e = E('refresh-spinner')) != null) e.style.visibility = b ? 'visible' : 'hidden';
1748 initPage: function(delay, def) {
1751 e = E('refresh-time');
1752 if (((this.cookieTag) && (e != null)) &&
1753 ((v = cookie.get(this.cookieTag)) != null) && (!isNaN(v *= 1))) {
1754 e.value = Math.abs(v);
1755 if (v > 0) v = (v * 1000) + (delay || 0);
1759 if (e) e.value = def;
1770 this.refreshTime = v;
1771 this.timer.start(v);
1772 this.updateUI('wait');
1777 function genStdTimeList(id, zero, min)
1780 var t = [3,4,5,10,15,30,60,120,180,240,300,10*60,15*60,20*60,30*60];
1784 b.push('<select id="' + id + '"><option value=0>' + zero);
1785 for (i = 0; i < t.length; ++i) {
1787 if (v < min) continue;
1788 b.push('<option value=' + v + '>');
1789 if (v == 60) b.push('1 minute');
1790 else if (v > 60) b.push((v / 60) + ' minutes');
1791 else b.push(v + ' seconds');
1793 b.push('</select> ');
1795 document.write(b.join(''));
1798 function genStdRefresh(spin, min, exec)
1800 W('<div style="text-align:right">');
1801 if (spin) W('<img src="spin.gif" id="refresh-spinner"> ');
1802 genStdTimeList('refresh-time', 'Auto Refresh', min);
1803 W('<input type="button" value="Refresh" onclick="' + (exec ? exec : 'refreshClick()') + '" id="refresh-button"></div>');
1807 // -----------------------------------------------------------------------------
1810 function _tabCreate(tabs)
1813 buf.push('<ul id="tabs">');
1814 for (var i = 0; i < arguments.length; ++i)
1815 buf.push('<li><a href="javascript:tabSelect(\'' + arguments[i][0] + '\')" id="' + arguments[i][0] + '">' + arguments[i][1] + '</a>');
1816 buf.push('</ul><div id="tabs-bottom"></div>');
1817 return buf.join('');
1820 function tabCreate(tabs)
1822 document.write(_tabCreate.apply(this, arguments));
1825 function tabHigh(id)
1827 var a = E('tabs').getElementsByTagName('A');
1828 for (var i = 0; i < a.length; ++i) {
1829 if (id != a[i].id) elem.removeClass(a[i], 'active');
1831 elem.addClass(id, 'active');
1834 // -----------------------------------------------------------------------------
1837 set: function(key, value, days) {
1838 document.cookie = 'tomato_' + key + '=' + value + '; expires=' +
1839 (new Date(new Date().getTime() + ((days ? days : 14) * 86400000))).toUTCString() + '; path=/';
1842 get: function(key) {
1843 var r = ('; ' + document.cookie + ';').match('; tomato_' + key + '=(.*?);');
1844 return r ? r[1] : null;
1847 unset: function(key) {
1848 document.cookie = 'tomato_' + key + '=; expires=' +
1849 (new Date(1)).toUTCString() + '; path=/';
1853 // -----------------------------------------------------------------------------
1855 function checkEvent(evt)
1857 if (typeof(evt) == 'undefined') {
1860 evt.target = evt.srcElement;
1861 evt.relatedTarget = evt.toElement;
1873 return (typeof(e) == 'string') ? document.getElementById(e) : e;
1878 return elem.parentElem(e, 'TR');
1881 function THIS(obj, func)
1883 return function() { return func.apply(obj, arguments); }
1888 return (typeof(v) == 'undefined') ? '' : '' + v;
1891 function escapeHTML(s)
1894 return '&#' + c.charCodeAt(0) + ';';
1896 return s.replace(/[&"'<>\r\n]/g, esc);
1899 function escapeCGI(s)
1901 return escape(s).replace(/\+/g, '%2B'); // escape() doesn't handle +
1907 return '%' + c.charCodeAt(0).hex(2);
1909 return s.replace(/[<>|%]/g, esc);
1912 function ellipsis(s, max) {
1913 return (s.length <= max) ? s : s.substr(0, max - 3) + '...';
1918 return a < b ? a : b;
1923 return a > b ? a : b;
1926 function fixInt(n, min, max, def)
1928 if (n === null) return def;
1930 if (isNaN(n)) return def;
1931 if (n < min) return min;
1932 if (n > max) return max;
1940 while ((n = n.replace(/(\d+)(\d{3})/g, '$1,$2')) != p) p = n;
1944 function doScaleSize(n, sm)
1946 if (isNaN(n *= 1)) return '-';
1947 if (n <= 9999) return '' + n;
1952 } while ((n > 9999) && (s < 2));
1953 return comma(n.toFixed(2)) + (sm ? '<small> ' : ' ') + (['KB', 'MB', 'GB'])[s] + (sm ? '</small>' : '');
1956 function scaleSize(n)
1958 return doScaleSize(n, 1);
1961 function timeString(mins)
1963 var h = Math.floor(mins / 60);
1964 if ((new Date(2000, 0, 1, 23, 0, 0, 0)).toLocaleString().indexOf('23') != -1)
1965 return h + ':' + (mins % 60).pad(2);
1966 return ((h == 0) ? 12 : ((h > 12) ? h - 12 : h)) + ':' + (mins % 60).pad(2) + ((h >= 12) ? ' PM' : ' AM');
1969 function features(s)
1971 var features = ['ses','brau','aoss','wham','hpamp','!nve','11n','1000et'];
1974 for (i = features.length - 1; i >= 0; --i) {
1975 if (features[i] == s) return (parseInt(nvram.t_features) & (1 << i)) != 0;
1980 function get_config(name, def)
1982 return ((typeof(nvram) != 'undefined') && (typeof(nvram[name]) != 'undefined')) ? nvram[name] : def;
1989 // -----------------------------------------------------------------------------
1991 function show_notice1(s)
1993 // ---- !!TB - USB Support: multi-line notices
1994 if (s.length) document.write('<div id="notice1">' + s.replace(/\n/g, '<br>') + '</div><br style="clear:both">');
1997 // -----------------------------------------------------------------------------
2003 name = document.location.pathname;
2004 name = name.replace(/\\/g, '/'); // IE local testing
2005 if ((i = name.lastIndexOf('/')) != -1) name = name.substring(i + 1, name.length);
2006 if (name == '') name = 'status-overview.asp';
2013 ['Status', 'status', 0, [
2014 ['Overview', 'overview.asp'],
2015 ['Device List', 'devices.asp'],
2016 ['Logs', 'log.asp'] ] ],
2017 ['Bandwidth', 'bwm', 0, [
2018 ['Real-Time', 'realtime.asp'],
2019 ['Last 24 Hours', '24.asp'],
2020 ['Daily', 'daily.asp'],
2021 ['Weekly', 'weekly.asp'],
2022 ['Monthly', 'monthly.asp'] ] ],
2023 ['Tools', 'tools', 0, [
2024 ['Ping', 'ping.asp'],
2025 ['Trace', 'trace.asp'],
2026 ['System', 'shell.asp'],
2027 ['Wireless Survey', 'survey.asp'],
2028 ['WOL', 'wol.asp'] ] ],
2030 ['Basic', 'basic', 0, [
2031 ['Network', 'network.asp'],
2032 ['Identification', 'ident.asp'],
2033 ['Time', 'time.asp'],
2034 ['DDNS', 'ddns.asp'],
2035 ['Static DHCP', 'static.asp'],
2036 ['Wireless Filter', 'wfilter.asp'] ] ],
2037 ['Advanced', 'advanced', 0, [
2038 ['Conntrack / Netfilter', 'ctnf.asp'],
2039 ['DHCP / DNS', 'dhcpdns.asp'],
2040 ['Firewall', 'firewall.asp'],
2041 ['MAC Address', 'mac.asp'],
2042 ['Miscellaneous', 'misc.asp'],
2043 ['Routing', 'routing.asp'],
2044 ['Wireless', 'wireless.asp'] ] ],
2045 ['Port Forwarding', 'forward', 0, [
2046 ['Basic', 'basic.asp'],
2048 ['Triggered', 'triggered.asp'],
2049 ['UPnP / NAT-PMP', 'upnp.asp'] ] ],
2051 ['Basic Settings', 'settings.asp'],
2052 ['Classification', 'classify.asp'],
2053 ['View Graphs', 'graphs.asp'],
2054 ['View Details', 'detailed.asp']
2056 ['Access Restriction', 'restrict.asp'],
2058 ['Scripts', 'sc', 0, [
2059 ['Startup', 'startup.asp'],
2060 ['Shutdown', 'shutdown.asp'],
2061 ['Firewall', 'firewall.asp'],
2062 ['WAN Up', 'wanup.asp']
2066 // ---- !!TB - USB, FTP, Samba
2067 ['USB and NAS', 'nas', 0, [
2068 ['USB Support', 'usb.asp']
2070 ,['FTP Server', 'ftp.asp']
2073 ,['File Sharing', 'samba.asp']
2078 ['VPN Tunneling', 'vpn', 0, [
2079 ['Server', 'server.asp'],
2080 ['Client', 'client.asp'] ] ],
2083 ['Administration', 'admin', 0, [
2084 ['Admin Access', 'access.asp'],
2085 ['Bandwidth Monitoring','bwm.asp'],
2086 ['Buttons / LED', 'buttons.asp'],
2088 ['CIFS Client', 'cifs.asp'],
2090 ['Configuration', 'config.asp'],
2091 ['Debugging', 'debug.asp'],
2093 ['JFFS', 'jffs2.asp'],
2095 ['Logging', 'log.asp'],
2096 ['Scheduler', 'sched.asp'],
2097 ['Scripts', 'scripts.asp'],
2098 ['Upgrade', 'upgrade.asp'] ] ],
2100 ['About', 'about.asp'],
2101 ['Reboot...', 'javascript:reboot()'],
2102 ['Shutdown...', 'javascript:shutdown()'],
2103 ['Logout', 'javascript:logout()']
2111 var cexp = get_config('web_mx', '').toLowerCase();
2114 if (name == 'restrict-edit.asp') name = 'restrict.asp';
2115 if ((i = name.indexOf('-')) != -1) {
2116 base = name.substring(0, i);
2117 name = name.substring(i + 1, name.length);
2121 for (i = 0; i < menu.length; ++i) {
2127 if (m.length == 2) {
2128 buf.push('<a href="' + m[1] + '" class="indent1' + (((base == '') && (name == m[1])) ? ' active' : '') + '">' + m[0] + '</a>');
2135 a = cookie.get('menu_' + m[1]);
2137 for (j = 0; j < m[3].length; ++j) {
2138 if (m[3][j][1] == a) {
2145 if (a == 'status-overview.asp') a = '/';
2146 on1 = (base == m[1]);
2147 buf.push('<a href="' + a + '" class="indent1' + (on1 ? ' active' : '') + '">' + m[0] + '</a>');
2148 if ((!on1) && (m[2] == 0) && (cexp.indexOf(m[1]) == -1)) continue;
2150 for (j = 0; j < m[3].length; ++j) {
2152 a = m[1] + '-' + sm[1];
2153 if (a == 'status-overview.asp') a = '/';
2154 buf.push('<a href="' + a + '" class="indent2' + (((on1) && (name == sm[1])) ? ' active' : '') + '">' + sm[0] + '</a>');
2158 document.write(buf.join(''));
2161 if ((base == 'qos') && (name == 'detailed.asp')) name = 'view.asp';
2162 cookie.set('menu_' + base, name);
2166 function createFieldTable(flags, desc)
2180 if ((flags.indexOf('noopen') == -1)) buf.push('<table class="fields">');
2181 for (desci = 0; desci < desc.length; ++desci) {
2182 var v = desc[desci];
2185 buf.push('<tr><td colspan=2 class="spacer"> </td></tr>');
2189 if (v.ignore) continue;
2192 if (v.rid) buf.push(' id="' + v.rid + '"');
2193 if (v.hidden) buf.push(' style="display:none"');
2198 buf.push('<td class="title indent' + (v.indent || 1) + '">' + v.title + '</td><td class="content">' + v.text + '</td></tr>');
2201 buf.push('<td colspan=2>' + v.text + '</td></tr>');
2208 buf2.push('<td class="content">');
2210 if (v.multi) fields = v.multi;
2213 for (n = 0; n < fields.length; ++n) {
2215 if (f.prefix) buf2.push(f.prefix);
2217 if ((f.type == 'radio') && (!f.id)) id = '_' + f.name + '_' + i;
2218 else id = (f.id ? f.id : ('_' + f.name));
2220 if (id1 == '') id1 = id;
2222 common = ' onchange="verifyFields(this, 1)" id="' + id + '"';
2223 if (f.attrib) common += ' ' + f.attrib;
2224 name = f.name ? (' name="' + f.name + '"') : '';
2228 buf2.push('<input type="checkbox"' + name + (f.value ? ' checked' : '') + ' onclick="verifyFields(this, 1)"' + common + '>');
2231 buf2.push('<input type="radio"' + name + (f.value ? ' checked' : '') + ' onclick="verifyFields(this, 1)"' + common + '>');
2235 switch (get_config('web_pb', '1')) {
2243 if (f.type == 'password') {
2244 common += ' autocomplete="off"';
2245 if (f.peekaboo) common += ' onfocus=\'peekaboo("' + id + '",1)\'';
2249 buf2.push('<input type="' + f.type + '"' + name + ' value="' + escapeHTML(UT(f.value)) + '" maxlength=' + f.maxlen + (f.size ? (' size=' + f.size) : '') + common + '>');
2252 buf2.push('<select' + name + common + '>');
2253 for (i = 0; i < f.options.length; ++i) {
2255 if (a.length == 1) a.push(a[0]);
2256 buf2.push('<option value="' + a[0] + '"' + ((a[0] == f.value) ? ' selected' : '') + '>' + a[1] + '</option>');
2258 buf2.push('</select>');
2261 buf2.push('<textarea' + name + common + (f.wrap ? (' wrap=' + f.wrap) : '') + '>' + escapeHTML(UT(f.value)) + '</textarea>');
2264 if (f.custom) buf2.push(f.custom);
2267 if (f.suffix) buf2.push(f.suffix);
2271 buf.push('<td class="title indent' + (v.indent ? v.indent : 1) + '">');
2272 if (id1 != '') buf.push('<label for="' + id + '">' + v.title + '</label></td>');
2273 else buf.push(+ v.title + '</td>');
2275 buf.push(buf2.join(''));
2278 if ((!flags) || (flags.indexOf('noclose') == -1)) buf.push('</table>');
2279 document.write(buf.join(''));
2282 function peekaboo(id, show)
2285 var o = document.createElement('INPUT');
2288 o.type = show ? 'text' : 'password';
2291 o.maxLength = e.maxLength;
2292 o.autocomplete = e.autocomplete;
2294 o.disabled = e.disabled;
2295 o.onchange = e.onchange;
2296 e.parentNode.replaceChild(o, e);
2302 o.onblur = function(ev) { setTimeout('peekaboo("' + this.id + '", 0)', 0) };
2303 setTimeout('try { E("' + id + '").focus() } catch (ex) { }', 0)
2306 o.onfocus = function(ev) { peekaboo(this.id, 1); };
2315 - e.type= doesn't work in IE, ok in FF
2316 - may mess keyboard tabing (bad: IE; ok: FF, Opera)... setTimeout() delay seems to help a little.
2320 // -----------------------------------------------------------------------------
2322 function reloadPage()
2324 document.location.reload(1);
2329 if (confirm("Reboot?")) form.submitHidden('tomato.cgi', { _reboot: 1, _commit: 0, _nvset: 0 });
2334 if (confirm("Shutdown?")) form.submitHidden('shutdown.cgi', { });
2339 form.submitHidden('logout.asp', { });
2342 // -----------------------------------------------------------------------------
2350 return location.href.search('file://') == 0;