Restore some pre-valid behavior. Partly suggestions of Minckster.
[pyTivo/TheBayer.git] / plugins / settings / templates / settings.tmpl
blob2004e42425f65a8263d18f09ca514dcde6dffcd3
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\r
2 "http://www.w3.org/TR/html4/strict.dtd">\r
3 <html>\r
4 <head>\r
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
6 <title>pyTivo Web Configuration</title>\r
7 <style type="text/css">\r
8 html, body {\r
9     margin: 0;\r
10     padding: 0;\r
11     border: none;\r
12     height: 100%;\r
13     overflow: hidden;\r
14     background-color: rgb(250, 250, 250)\r
15 }\r
17 tr.row1 {\r
18     background-color: rgb(240, 240, 240)\r
19 }\r
21 table#main {\r
22     background-color: rgb(255, 255, 255);\r
23     border: 1px solid rgb(220, 220, 220);\r
24     height: 85%;\r
25     text-align: left;\r
26     margin-left: auto;\r
27     margin-right: auto\r
28 }\r
29 </style>\r
30 <script type="text/javascript">\r
32 function fillBlank()\r
33 {\r
34     var texts = document.getElementsByTagName('input');\r
35     for (var i_tem = 0; i_tem < texts.length; i_tem++) {\r
36         if (texts[i_tem].value == '') {\r
37             texts[i_tem].value = ' ';\r
38         }\r
39     }\r
40 }\r
42 function switchDiv(pass, type)\r
43 {\r
44     //loop through the array and hide/show each element by id\r
45     var divs = document.getElementsByTagName('div');\r
46     for (var i = 0; i < divs.length; i++) {\r
47         if (divs[i].id.match(type)) {\r
48             if (divs[i].id == pass) {\r
49                 divs[i].style.visibility = 'visible'\r
50             } else {\r
51                 divs[i].style.visibility = 'hidden'\r
52             }\r
53         }\r
54     }\r
55 }\r
57 function deleteSection(id)\r
58 {\r
59     var name = select_section.section.options[id].text;\r
60     if (name == 'Global Server Settings') {\r
61         alert('Delete Error:\n\nSorry the Global Server Settings ' +\r
62               'Section is required for pyTivo to run and cannot be deleted');\r
63         return true;\r
64     }\r
65     var answer = confirm("Are you sure you wish to delete the '" + name +\r
66                          "' Section?")\r
67     if (answer) {\r
68         switchDiv('set-delete', 'set-');\r
69         select_section.section.options[id] = null;\r
70         var field = document.getElementById(name).value;\r
71         document.getElementById(field).value = 'Delete_Me';\r
72         saveNotify();\r
73         return true;\r
74     }\r
75 }\r
77 function resetpyTivo()\r
78 {\r
79     var answer = confirm("Are you sure you wish to reset the pyTivo " +\r
80                          "Server? Any unsaved changes will be lost!")\r
81     if (answer) {\r
82         window.location =\r
83             "/TiVoConnect?Command=Reset&amp;Container=$quote($container)"\r
84     }\r
85 }\r
87 function showData(form)\r
88 {\r
89     var section = "";\r
90     var setting = "";\r
91     re = /[\[\]<>|]/;\r
92     inputs = form.getElementsByTagName("input");\r
93     for (i = 0; i < inputs.length; i++) {\r
94         if (inputs[i].type == 'text' && re.exec(inputs[i].value)) {\r
95             setting = inputs[i].name;\r
96             break;\r
97         }\r
98     }\r
99     if (setting != "") {\r
100         var map = document.getElementById('Section_Map').value.split(']');\r
101         map.pop();\r
102         splitSetting = setting.split('.');\r
103         for (i = 0; i < map.length; i++) {\r
104             key = map[i].split('|');\r
105             if (splitSetting[0] == 'Server') {\r
106                 section = 'server';\r
107                 break;\r
108             }\r
109             if (key[0] == splitSetting[0]) {\r
110                 section = key[1];\r
111                 break;\r
112             }\r
113         }\r
114         alert("Invalid Entry:\nSorry these are not allowed \n[]<>|");\r
115         switchDiv('set-' + section, 'set-');\r
116         document.getElementById(setting).select();\r
117         return false;\r
118     }\r
119     fillBlank();\r
120     document.config.submit();\r
123 function saveNotify()\r
125     document.getElementById('B1').style.fontWeight = 'bold';\r
126     document.getElementById('B2').disabled = true;\r
129 </script>\r
130 </head>\r
131 <body>\r
133 #def row($i, $key, $section, $source)\r
134     #set $j = $i%2\r
135     <tr class="row$(j)">\r
136     <td style="text-align: left">$key:</td>\r
137     <td>\r
138     <input size="20" id="opts.$section.$key" name="opts.$section.$key"\r
139     #if $key in $source\r
140         value="$source[$key]"\r
141     #else\r
142         value=""\r
143     #end if\r
144      onChange="saveNotify();" onfocus="switchDiv('help-$key', 'help-');\r
145      return true;" type="text">\r
146     </td>\r
147     </tr>\r
148 #end def\r
150 #def rows($section, $source_data, $source_known)\r
151     <hr style="width: 100%; height: 2px;">\r
152     <table style="margin-left: auto; margin-right: auto">\r
153     #set $i = 0\r
154     #for $key in $source_known\r
155         #set $i += 1\r
156         $row($i, $key, $section, $source_data)\r
157     #end for\r
159     <tr><td colspan="2" align="center" style="border-bottom:\r
160      1px solid rgb(153, 153, 153);">User Defined Settings:</td></tr>\r
162     #set $i = 0\r
163     #for $key in $source_data\r
164         #if not $key in $source_known\r
165             #set $i += 1\r
166             $row($i, $key, $section, $source_data)\r
167         #end if\r
168     #end for\r
169     </table>\r
170 #end def\r
172 #def add_setting($name, $section)\r
173     <div style="width: 330px; position: relative;">\r
174     <div id="add-$name-button" style="width: 330px; position: absolute; \r
175      left: 0px; top: 0px;">\r
176     <br>\r
177     <input type="button" value="Add Setting" \r
178      onclick="switchDiv('add-$name-field', 'add-$name-');\r
179      return true;">\r
180     </div>\r
181     <div id="add-$name-field" style="position: absolute;\r
182      left: 0px; top: 0px; visibility: hidden;">\r
183     <table style="width: 315px;">\r
184     <tr>\r
185     <td colspan="2" align="center" style="border-bottom: 1px solid \r
186      rgb(153, 153, 153);">Add a Setting</td>\r
187     </tr>\r
188     <tr><td>Setting Name:</td><td>Setting Value:</td></tr>\r
189     <tr>\r
190     #for $x in ('setting', 'value')\r
191         <td>\r
192         <input size="16" type="text" onChange="saveNotify();"\r
193          id="opts.$(section).new_$x" name="opts.$(section).new__$x" value="">\r
194         </td>\r
195     #end for\r
196     </tr>\r
197     </table>\r
198     </div>\r
199     </div>\r
200 #end def\r
202 #set $section_size = 'width: 200px; height: 100%'\r
203 #set $settings_size = 'width: 350px; height: 100%; overflow: auto'\r
204 #set $help_size = 'width: 350px; height: 100%; overflow: auto'\r
206 <p style="text-align: center"><big><big><big>pyTivo Web \r
207 Configuration</big></big></big>\r
208 <a href="javascript:switchDiv('help-Instructions', 'help-');">help</a></p>\r
209 <table id="main" border="0" cellpadding="0" cellspacing="4">\r
211     <tr style="height: 100%">\r
213       <td style="border-right: 1px dotted rgb(153, 153, 153); \r
214        vertical-align: top; overflow: hidden; height: 100%">\r
215       <div id="leftframe" style="position: relative; text-align: center; \r
216        $section_size">\r
217       <form name="select_section" action="NOTUSED"><p>Sections<br>\r
218         <select name="section" size="7" \r
219          onclick="switchDiv(options[selectedIndex].value, 'set-');\r
220          return true;">\r
221         <option value="set-server">Global Server Settings</option>\r
222         <option value="set-hd_tivos">HD TiVo Settings</option>\r
223         <option value="set-sd_tivos">SD TiVo Settings</option>\r
224 #for $name, $data in $shares_data\r
225         <option value="set-$name">$name</option>\r
226 #end for\r
227 #for $name, $data in $tivos_data\r
228         <option value="set-$name">$name</option>\r
229 #end for\r
230         </select>\r
232         <input name="B4" value="Delete Section" type="button" \r
233          onclick="deleteSection(select_section.section.selectedIndex)">\r
234         <input name="B5" value="Add Section" type="button" \r
235          onclick="switchDiv('set-add', 'set-');return true;">\r
236       </p></form>\r
238       <hr>Administration\r
239       <form action="NOTUSED">\r
240         <p><input name="B1" id="B1" value="Save Changes" \r
241          type="button" onclick="showData(document.config); return true;">\r
242         <input id="B2" name="B2" value="Soft Reset pyTivo" type="button" \r
243          onclick="resetpyTivo();"></p>\r
244       </form>\r
246       </div>\r
247       </td>\r
249       <td style="vertical-align: top; height: 100%">\r
251       <div id="settings" style="$settings_size; position: relative;">\r
253       <form name="config" method="POST" action="TiVoConnect" \r
254        onsubmit="fillBlank(); showData(this);"><div style="height: 100%">\r
256       <input type="hidden" name="Command" value="UpdateSettings">\r
257       <input type="hidden" name="Container" value="$container">\r
259 <div id="set-server" style="$settings_size; text-align: center;\r
260  position: absolute; left: 0px; top: 0px; visibility: hidden">\r
261         <b>Global Server Settings</b><br>\r
262         $rows('Server', $server_data, $server_known)\r
263         $add_setting('server', 'Server')\r
264 </div>\r
266 <div id="set-hd_tivos" style="$settings_size; text-align: center;\r
267  position: absolute; left: 0px; top: 0px; visibility: hidden">\r
268         <b>HD TiVo Settings</b><br>\r
269         $rows('_tivo_HD', $hd_tivos_data, $hd_tivos_known)\r
270         $add_setting('hd_tivos', '_tivo_HD')\r
271 </div>\r
273 <div id="set-sd_tivos" style="$settings_size; text-align: center;\r
274  position: absolute; left: 0px; top: 0px; visibility: hidden">\r
275         <b>SD TiVo Settings</b><br>\r
276         $rows('_tivo_SD', $sd_tivos_data, $sd_tivos_known)\r
277         $add_setting('sd_tivos', '_tivo_SD')\r
278 </div>\r
280 #set $section_count = 0\r
281 #set $section_map = ''\r
282 #for $name, $data in $shares_data\r
283         #set $section_count += 1\r
284         #set $section_number = 'section-' + str($section_count)\r
285         <input type="hidden" name="opts.$name" id="opts.$name" \r
286          value="$section_number">\r
287         #set $section_map += $section_number + '|' + $name + ']'\r
288         <div id="set-$name" style="text-align: center; position: absolute;\r
289          $settings_size; left: 0px; top: 0px; visibility: hidden">\r
290         [<input size="20" onChange="saveNotify();" id="$section_number" \r
291          name="$section_number" value="$name">]<br>\r
292         $rows($section_number, $data, $shares_known)\r
293         $add_setting($name, $section_number)\r
294         </div>\r
295 #end for\r
297 #for $name, $data in $tivos_data\r
298         #set $section_count += 1\r
299         #set $section_number = 'section-' + str($section_count)\r
300         <input type="hidden" name="opts.$name" id="opts.$name" \r
301          value="$section_number">\r
302         #set $section_map += $section_number + '|' + $name + ']'\r
303         <div id="set-$name" style="text-align: center; position: absolute;\r
304          $settings_size; left: 0px; top: 0px; visibility: hidden">\r
305         [<input size="20" onChange="saveNotify();" id="$section_number" \r
306          name="$section_number" value="$name">]<br>\r
307         $rows($section_number, $data, $tivos_known)\r
308         $add_setting($name, $section_number)\r
309         </div>\r
310 #end for\r
311 <div id="set-add" style="text-align: center;position: absolute; left: 0px;\r
312  top: 0px; visibility: hidden; $settings_size">\r
313         Add a New Section\r
314         <hr>\r
315         <table>\r
316         <tr>\r
317         <td> Section Name :</td><td> \r
318         <input onChange="saveNotify();" type="text" size="20"\r
319          name="new_Section" value=""\r
320          onfocus="switchDiv('help-Add_a_New_Section', 'help-'); return true;">\r
321         </td></tr></table>\r
322         The new section name will be added to the pyTivo.conf file when \r
323         you click <b>Save Changes</b>.\r
324 </div>\r
325 <div id="set-delete" style="text-align: center; position: absolute;\r
326  left: 0px; top: 0px; visibility: hidden; $settings_size">\r
327         Delete a Section\r
328         <hr>\r
329         <br>\r
330         The Section has been marked for deletion. However it will not be \r
331         actually deleted until you click the <b>Save Changes</b> button.\r
332 </div>\r
333 <input type="hidden" id="Section_Map" name="Section_Map" value="$section_map">\r
334       </div></form>\r
336       </div>\r
338       </td>\r
340       <td style="border-left: 1px dotted rgb(153, 153, 153);\r
341        vertical-align: top; height: 100%">\r
342       <div id="sidesections" style="$help_size; position: relative;">\r
343       <!-- HELP SECTIONS -->\r
344       #for $setting in $help_list\r
345           #if $setting == 'Instructions'\r
346               #set $vis = 'visible'\r
347           #else\r
348               #set $vis = 'hidden'\r
349           #end if\r
350           <div id="help-$setting" style="visibility: $vis; $help_size;\r
351            position: absolute; left: 0px; top: 0px;">\r
352           <p style="text-align: center"><strong>$setting</strong></p>\r
353           #for $line in $help_list[$setting]\r
354               <p><strong>$(line.split(':', 1)[0]):</strong>\r
355                $(line.split(':', 1)[1])</p>\r
356           #end for\r
357           </div>\r
358       #end for\r
359       <!-- END HELP SECTIONS -->\r
360       </div>\r
362       </td>\r
364     </tr>\r
366 </table>\r
367 </body>\r
368 </html>\r