Small tidy of tomato.js
[tomato.git] / release / src / router / www / forward-triggered.asp
blobee0f42f126e17cecdf26d60ace096cff611f153e
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Forwarding: Triggered</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.css'>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
20 <style type='text/css'>
21 #tg-grid .co1 {
22 width: 5%;
23 text-align: center;
25 #tg-grid .co2 {
26 width: 10%;
28 #tg-grid .co3 {
29 width: 20%;
31 #tg-grid .co4 {
32 width: 20%;
34 #tg-grid .co5 {
35 width: 45%;
37 </style>
39 <script type='text/javascript' src='debug.js'></script>
41 <script type='text/javascript'>
43 // <% nvram("trigforward"); %>
45 var tg = new TomatoGrid();
47 tg.sortCompare = function(a, b) {
48 var col = this.sortColumn;
49 var da = a.getRowData();
50 var db = b.getRowData();
51 var r;
53 switch (col) {
54 case 2: // t prt
55 case 3: // f prt
56 r = cmpInt(da[col], db[col]);
57 break;
58 default:
59 r = cmpText(da[col], db[col]);
60 break;
63 return this.sortAscending ? r : -r;
66 tg.dataToView = function(data) {
67 return [data[0] ? 'On' : '', ['TCP', 'UDP', 'Both'][data[1] - 1], data[2], data[3], data[4]];
70 tg.fieldValuesToData = function(row) {
71 var f = fields.getAll(row);
72 return [f[0].checked ? 1 : 0, f[1].value, f[2].value, f[3].value, f[4].value];
75 tg.verifyFields = function(row, quiet) {
76 var f = fields.getAll(row);
77 ferror.clearAll(f);
78 if (!v_portrange(f[2], quiet)) return 0;
79 if (!v_portrange(f[3], quiet)) return 0;
80 f[4].value = f[4].value.replace(/>/g, '_');
81 if (!v_nodelim(f[4], quiet, 'Description')) return 0;
82 return 1;
85 tg.resetNewEditor = function() {
86 var f = fields.getAll(this.newEditor);
87 f[0].checked = 1;
88 f[1].selectedIndex = 0;
89 f[2].value = '';
90 f[3].value = '';
91 f[4].value = '';
92 ferror.clearAll(f);
95 tg.setup = function() {
96 this.init('tg-grid', 'sort', 50, [
97 { type: 'checkbox' },
98 { type: 'select', options: [[1, 'TCP'],[2, 'UDP'],[3,'Both']] },
99 { type: 'text', maxlen: 16 },
100 { type: 'text', maxlen: 16 },
101 { type: 'text', maxlen: 32 }]);
102 this.headerSet(['On', 'Protocol', 'Trigger Ports', 'Forwarded Ports', 'Description']);
103 var nv = nvram.trigforward.split('>');
104 for (var i = 0; i < nv.length; ++i) {
105 var r;
106 if (r = nv[i].match(/^(\d)<(\d)<(.+?)<(.+?)<(.*)$/)) {
107 r[1] *= 1;
108 r[2] *= 1;
109 r[3] = r[3].replace(/:/g, '-');
110 r[4] = r[4].replace(/:/g, '-');
111 tg.insertData(-1, r.slice(1, 6));
114 tg.sort(4);
115 tg.showNewEditor();
119 function save()
121 if (tg.isEditing()) return;
123 var data = tg.getAllData();
124 var s = '';
125 for (var i = 0; i < data.length; ++i) {
126 data[i][2] = data[i][2].replace(/-/g, ':');
127 data[i][3] = data[i][3].replace(/-/g, ':');
128 s += data[i].join('<') + '>';
130 var fom = E('_fom');
131 fom.trigforward.value = s;
132 form.submit(fom, 1);
135 function init()
137 tg.recolor();
138 tg.resetNewEditor();
139 var c;
140 if (((c = cookie.get('forward_triggered_notes_vis')) != null) && (c == '1')) toggleVisibility("notes");
143 function toggleVisibility(whichone) {
144 if (E('sesdiv_' + whichone).style.display == '') {
145 E('sesdiv_' + whichone).style.display = 'none';
146 E('sesdiv_' + whichone + '_showhide').innerHTML = '(Click here to show)';
147 cookie.set('forward_triggered_' + whichone + '_vis', 0);
148 } else {
149 E('sesdiv_' + whichone).style.display='';
150 E('sesdiv_' + whichone + '_showhide').innerHTML = '(Click here to hide)';
151 cookie.set('forward_triggered_' + whichone + '_vis', 1);
154 </script>
155 </head>
156 <body onload='init()'>
157 <form id='_fom' method='post' action='tomato.cgi'>
158 <table id='container' cellspacing=0>
159 <tr><td colspan=2 id='header'>
160 <div class='title'>Tomato</div>
161 <div class='version'>Version <% version(); %></div>
162 </td></tr>
163 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
164 <td id='content'>
165 <div id='ident'><% ident(); %></div>
167 <!-- / / / -->
169 <input type='hidden' name='_nextpage' value='forward.asp'>
170 <input type='hidden' name='_service' value='firewall-restart'>
172 <input type='hidden' name='trigforward'>
174 <div class='section-title'>Triggered Port Forwarding</div>
175 <div class='section'>
176 <table class='tomato-grid' cellspacing=1 id='tg-grid'></table>
177 <script type='text/javascript'>tg.setup();</script>
178 </div>
180 <div class='section-title'>Notes <small><i><a href='javascript:toggleVisibility("notes");'><span id='sesdiv_notes_showhide'>(Click here to show)</span></a></i></small></div>
181 <div class='section' id='sesdiv_notes' style='display:none'>
182 <ul>
183 <li>Use "-" to specify a range of ports (200-300).
184 <li>Trigger Ports are the initial LAN to WAN "trigger".
185 <li>Forwarded Ports are the WAN to LAN ports that are opened if the "trigger" is activated.
186 <li>These ports are automatically closed after a few minutes of inactivity.
187 </ul>
188 </div>
190 <!-- / / / -->
192 </td></tr>
193 <tr><td id='footer' colspan=2>
194 <span id='footer-msg'></span>
195 <input type='button' value='Save' id='save-button' onclick='save()'>
196 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
197 </td></tr>
198 </table>
199 </form>
200 </body>
201 </html>