Column sorting fixes, thanks to Tony550
[tomato.git] / release / src / router / www / admin-scripts.asp
bloba6d76784f8e7dce9521c4768e179926d2b627d02
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(); %>] Admin: Scripts</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 .as-script {
22 font: 12px monospace;
23 width: 99%;
24 height: 400px;
25 overflow: scroll;
26 border: 1px solid #eee;
27 border-top: none;
29 </style>
31 <script type='text/javascript' src='debug.js'></script>
33 <script type='text/javascript'>
35 // <% nvram("script_init,script_shut,script_fire,script_wanup"); %>
37 tabs = [['as-init', 'Init'],['as-shut', 'Shutdown'],['as-fire','Firewall'],['as-wanup', 'WAN Up']];
39 function tabSelect(name)
41 tabHigh(name);
42 for (var i = 0; i < tabs.length; ++i) {
43 var on = (name == tabs[i][0]);
44 elem.display(tabs[i][0] + '-text', on);
46 if (i >= tabs.length) return;
47 E(name + '-text').focus();
48 cookie.set('scripts_tab', name)
51 function wordWrap()
53 for (var i = 0; i < tabs.length; ++i) {
54 var e = E(tabs[i][0] + '-text');
55 var s = e.value;
56 var c = e.cloneNode(false);
57 wrap = E('as-wordwrap').checked;
58 c.setAttribute('wrap', wrap ? 'virtual' : 'off');
59 e.parentNode.replaceChild(c, e);
60 c.value = s;
64 function save()
66 var i, t, n, x;
68 for (i = 0; i < tabs.length; ++i) {
69 t = tabs[i];
70 n = E(t[0] + '-text').value.length;
71 x = (t[0] == 'as-fire') ? 8192 : 4096;
72 if (n > x) {
73 tabSelect(t[0]);
74 alert(t[1] + ' script is too long. Maximum allowed is ' + x + ' bytes.');
75 return;
78 form.submit('_fom', 1);
81 function earlyInit()
83 for (var i = 0; i < tabs.length; ++i) {
84 var t = tabs[i][0];
85 E(t + '-text').value = nvram['script_' + t.replace('as-', '')];
87 tabSelect(cookie.get('scripts_tab') || 'as-init');
89 </script>
91 </head>
92 <body>
93 <form id='_fom' method='post' action='tomato.cgi'>
94 <table id='container' cellspacing=0>
95 <tr><td colspan=2 id='header'>
96 <div class='title'>Tomato</div>
97 <div class='version'>Version <% version(); %></div>
98 </td></tr>
99 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
100 <td id='content'>
101 <div id='ident'><% ident(); %></div>
103 <!-- / / / -->
105 <input type='hidden' name='_nextpage' value='admin-scripts.asp'>
107 <script type='text/javascript'>
108 tabCreate.apply(this, tabs);
110 wrap = cookie.get('scripts_wrap') || 0;
111 y = Math.floor(docu.getViewSize().height * 0.65);
112 s = 'height:' + ((y > 300) ? y : 300) + 'px;display:none';
113 for (i = 0; i < tabs.length; ++i) {
114 t = tabs[i][0];
115 W('<textarea class="as-script" name="script_' + t.replace('as-', '') + '" id="' + t + '-text" wrap=' + (wrap ? 'virtual' : 'off') + ' style="' + s + '"></textarea>');
117 W('<br><input type="checkbox" id="as-wordwrap" onclick="wordWrap()" onchange="wordWrap()" ' +
118 (wrap ? 'checked' : '') + '> Word Wrap');
119 </script>
121 <!-- / / / -->
123 </td></tr>
124 <tr><td id='footer' colspan=2>
125 <span id='footer-msg'></span>
126 <input type='button' value='Save' id='save-button' onclick='save()'>
127 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
128 </td></tr>
129 </table>
130 </form>
131 <script type='text/javascript'>earlyInit();</script>
132 </body>
133 </html>