dialogs/vlm, js/vlm.js : add schedule support
[vlc.git] / share / http / js / vlm.js
1 /*****************************************************************************
2  * vlm.js: VLC media player web interface
3  *****************************************************************************
4  * Copyright (C) 2005-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /* replace quotes and spaces by underscores */
25 function addunderscores( str ){ return str.replace(/\'|\"| /g, '_'); }
26
27 /**********************************************************************
28  * Input dialog functions
29  *********************************************************************/
30
31 function vlm_input_edit( dest )
32 {
33     document.getElementById( 'input_dest' ).value = dest;
34     show( 'input' );
35 }
36
37 function vlm_input_change()
38 {
39     document.getElementById( value( 'input_dest' ) ).value = value( 'input_mrl' );
40     hide( 'input' );
41     document.getElementById( value( 'input_dest' ) ).focus();
42 }
43
44 function vlm_output_edit( dest )
45 {
46     document.getElementById( 'sout_dest' ).value = dest;
47     show( 'sout' );
48 }
49
50 function vlm_output_change()
51 {
52     document.getElementById( value( 'sout_dest' ) ).value = value( 'sout_mrl' ).substr(6); /* substr <-> remove :sout= */
53     hide( 'sout' );
54     document.getElementById( value( 'sout_dest' ) ).focus();
55 }
56
57 function hide_vlm_add()
58 {
59     document.getElementById( 'vlm_add_broadcast' ).style.display = 'none';
60     document.getElementById( 'vlm_add_vod' ).style.display = 'none';
61     document.getElementById( 'vlm_add_schedule' ).style.display = 'none';
62 }
63
64 function toggle_schedule_date()
65 {
66     if( checked( 'vlm_schedule_now' ) )
67     {
68         disable( 'vlm_schedule_year' );
69         disable( 'vlm_schedule_month' );
70         disable( 'vlm_schedule_day' );
71         disable( 'vlm_schedule_hour' );
72         disable( 'vlm_schedule_minute' );
73         disable( 'vlm_schedule_second' );
74     }
75     else
76     {
77         enable( 'vlm_schedule_year' );
78         enable( 'vlm_schedule_month' );
79         enable( 'vlm_schedule_day' );
80         enable( 'vlm_schedule_hour' );
81         enable( 'vlm_schedule_minute' );
82         enable( 'vlm_schedule_second' );
83     }
84 }
85
86 function toggle_schedule_repeat()
87 {
88     if( checked( 'vlm_schedule_repeat' ) )
89     {
90         enable( 'vlm_schedule_period_year' );
91         enable( 'vlm_schedule_period_month' );
92         enable( 'vlm_schedule_period_day' );
93         enable( 'vlm_schedule_period_hour' );
94         enable( 'vlm_schedule_period_minute' );
95         enable( 'vlm_schedule_period_second' );
96         enable( 'vlm_schedule_repeat_times' );
97     }
98     else
99     {
100         disable( 'vlm_schedule_period_year' );
101         disable( 'vlm_schedule_period_month' );
102         disable( 'vlm_schedule_period_day' );
103         disable( 'vlm_schedule_period_hour' );
104         disable( 'vlm_schedule_period_minute' );
105         disable( 'vlm_schedule_period_second' );
106         disable( 'vlm_schedule_repeat_times' );
107     }
108 }
109
110 function vlm_schedule_type_change( name )
111 {
112     act = document.getElementById( 'vlm_elt_' + name + '_action' ).value;
113     itemname = document.getElementById( 'vlm_elt_' + name + '_name' );
114     opt = document.getElementById( 'vlm_elt_' + name + '_opt' );
115     if( act == "play" || act == "pause" || act == "stop" )
116     {
117         itemname.style.display = "";
118         opt.style.display = "none";
119     }
120     else if( act == "seek" )
121     {
122         itemname.style.display = "";
123         opt.style.display = "";
124     }
125     else
126     {
127         itemname.style.display = "none";
128         opt.style.display = "";
129     }
130 }
131
132 function update_vlm_add_broadcast()
133 {
134     cmd = document.getElementById( 'vlm_command' );
135
136     if( value( 'vlm_broadcast_name' ) )
137     {
138         cmd.value = "new " + addunderscores( value( 'vlm_broadcast_name' ) )
139                     + " broadcast";
140
141         if( checked( 'vlm_broadcast_enabled' ) )
142         {
143             cmd.value += " enabled";
144         }
145         
146         if( checked( 'vlm_broadcast_loop' ) )
147         {
148             cmd.value += " loop";
149         }
150
151         if( value( 'vlm_broadcast_input' ) )
152         {
153             cmd.value += " input " + value( 'vlm_broadcast_input' );
154         }
155
156         if( value( 'vlm_broadcast_output' ) )
157         {
158             cmd.value += " output " + value( 'vlm_broadcast_output' );
159         }
160     }
161     else
162     {
163         cmd.value = "";
164     }
165 }
166
167 function update_vlm_add_vod()
168 {
169     cmd = document.getElementById( 'vlm_command' );
170
171     if( value( 'vlm_vod_name' ) )
172     {
173         cmd.value = "new " + addunderscores( value( 'vlm_vod_name' ) )
174                     + " vod";
175
176         if( checked( 'vlm_vod_enabled' ) )
177         {
178             cmd.value += " enabled";
179         }
180         
181         if( value( 'vlm_vod_input' ) )
182         {
183             cmd.value += " input " + value( 'vlm_vod_input' );
184         }
185
186         if( value( 'vlm_vod_output' ) )
187         {
188             cmd.value += " output " + value( 'vlm_vod_output' );
189         }
190     }
191     else
192     {
193         cmd.value = "";
194     }
195 }
196
197 function update_vlm_add_schedule()
198 {
199     cmd = document.getElementById( 'vlm_command' );
200
201     check_and_replace_int( 'vlm_schedule_year', '0000' );
202     check_and_replace_int( 'vlm_schedule_month', '00' );
203     check_and_replace_int( 'vlm_schedule_day', '00' );
204     check_and_replace_int( 'vlm_schedule_hour', '00' );
205     check_and_replace_int( 'vlm_schedule_minute', '00' );
206     check_and_replace_int( 'vlm_schedule_second', '00' );
207     check_and_replace_int( 'vlm_schedule_period_year', '0000' );
208     check_and_replace_int( 'vlm_schedule_period_month', '00' );
209     check_and_replace_int( 'vlm_schedule_period_day', '00' );
210     check_and_replace_int( 'vlm_schedule_period_hour', '00' );
211     check_and_replace_int( 'vlm_schedule_period_minute', '00' );
212     check_and_replace_int( 'vlm_schedule_period_second', '00' );
213
214     if( value( 'vlm_schedule_name' ) )
215     {
216         cmd.value = "new " + addunderscores( value( 'vlm_schedule_name' ) ) + " schedule";
217
218         if( checked( 'vlm_schedule_enabled' ) )
219         {
220             cmd.value += " enabled";
221         }
222
223         if( checked( 'vlm_schedule_now' ) )
224         {
225             cmd.value += " date now";
226         }
227         else
228         {
229             cmd.value += " date " + value( 'vlm_schedule_year' ) + "/" + value( 'vlm_schedule_month' ) + "/" + value( 'vlm_schedule_day' ) + '-' + value( 'vlm_schedule_hour' ) + ':' + value( 'vlm_schedule_minute' ) + ':' + value( 'vlm_schedule_second' );
230         }
231
232         if( checked( 'vlm_schedule_repeat' ) )
233         {
234             cmd.value += " period " + value( 'vlm_schedule_period_year' ) + "/" + value( 'vlm_schedule_period_month' ) + "/" + value( 'vlm_schedule_period_day' ) + '-' + value( 'vlm_schedule_period_hour' ) + ':' + value( 'vlm_schedule_period_minute' ) + ':' + value( 'vlm_schedule_period_second' );
235
236             if( value( 'vlm_schedule_repeat_times' ) != 0 )
237             {
238                 cmd.value += " repeat " + (value( 'vlm_schedule_repeat_times' ) - 1 );
239             }
240         }
241             
242     }
243     else
244     {
245         cmd.value = "";
246     }
247 }
248
249 function clear_vlm_add()
250 {
251     document.getElementById( 'vlm_command' ).value = "";
252     document.getElementById( 'vlm_broadcast_name' ).value = "";
253     document.getElementById( 'vlm_vod_name' ).value = "";
254 }
255
256 function clear_children( elt )
257 {
258     if( elt )
259         while( elt.hasChildNodes() )
260             elt.removeChild( elt.firstChild );
261 }
262
263 function create_button( caption, action )
264 {
265     link = document.createElement( "input" );
266     link.setAttribute( 'type', 'button' );
267     link.setAttribute( 'onclick', action );
268     link.setAttribute( 'value', caption );
269     return link;
270 }
271 function create_option( caption, value )
272 {
273     opt = document.createElement( 'option' );
274     opt.setAttribute( 'value', value );
275     opt.appendChild( document.createTextNode( caption ) );
276     return opt;
277 }
278
279 function parse_vlm_cmd()
280 {
281     if( req.readyState == 4 )
282     {
283         if( req.status == 200 )
284         {
285             vlm_answer = req.responseXML.documentElement;
286             error_tag = vlm_answer.getElementsByTagName( 'error' )[0];
287             vlme = document.getElementById( 'vlm_error' );
288             clear_children( vlme );
289             if( error_tag.hasChildNodes() )
290             {
291                 vlme.appendChild( document.createTextNode( 'Error: ' + error_tag.firstChild.data ) );
292                 vlme.style.color = "#f00";
293             }
294             else
295             {
296                 vlme.appendChild( document.createTextNode( 'Command succesful (' + value( 'vlm_command' ) + ') ' ) );
297                 vlme.style.color = "#0f0";
298                 clear_vlm_add();
299             }
300             vlme.appendChild( create_button( 'clear', 'clear_children( document.getElementById( "vlm_error" ) );' ) );
301
302             vlm_get_elements();
303         }
304     }
305 }
306
307 function parse_vlm_elements()
308 {
309     if( req.readyState == 4 )
310     {
311         if( req.status == 200 )
312         {
313             vlmb = document.getElementById( 'vlm_broadcast_list' );
314             vlmv = document.getElementById( 'vlm_vod_list' );
315             vlms = document.getElementById( 'vlm_schedule_list' );
316
317             clear_children( vlmb );
318             clear_children( vlmv );
319             clear_children( vlms );
320
321             answer = req.responseXML.documentElement;
322
323             elt = answer.firstChild;
324
325             while( elt )
326             {
327                 if( elt.nodeName == "broadcast" || elt.nodeName == "vod" )
328                 {
329                     nb = document.createElement( 'div' );
330                     nb.setAttribute( 'class', 'list_element' );
331                     if( elt.nodeName == "broadcast" )
332                     {
333                         vlmb.appendChild( nb );
334                     }
335                     else
336                     {
337                         vlmv.appendChild( nb );
338                     }
339                     nbname = document.createElement( 'b' );
340                     nbname.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) );
341                     nb.appendChild( nbname );
342                     
343                     link = document.createElement( 'input' );
344                     link.setAttribute( 'type', 'button' );
345                     if( elt.getAttribute( 'enabled' ) == 'yes' )
346                     {
347                         nb.appendChild( document.createTextNode( " enabled " ) );
348                         link.setAttribute( 'onclick', 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' );
349                         link.setAttribute( 'value', "Disable" );
350                     }
351                     else
352                     {
353                         nb.appendChild( document.createTextNode( " disabled " ) );
354                         link.setAttribute( 'onclick', 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' );
355                         link.setAttribute( 'value', "Enable" );
356                     }
357                     nb.appendChild( link );
358                     
359                     if( elt.nodeName == "broadcast" )
360                     {
361                         link = document.createElement( 'input' );
362                         link.setAttribute( 'type', 'button' );
363                         if( elt.getAttribute( 'loop' ) == 'yes' )
364                         {
365                             nb.appendChild( document.createTextNode( " loop " ) );
366
367                             link.setAttribute( 'onclick', 'vlm_unloop("'+elt.getAttribute( 'name' ) + '");' );
368                             link.setAttribute( 'value', "Un-loop" );
369                         }
370                         else
371                         {
372                             nb.appendChild( document.createTextNode( " play once " ) );
373                             
374                             link.setAttribute( 'onclick', 'vlm_loop("'+elt.getAttribute( 'name' ) + '");' );
375                             link.setAttribute( 'value', "Loop" );
376                         }
377                         nb.appendChild( link );
378
379                         if( elt.getAttribute( 'enabled' ) == 'yes' )
380                         {
381                             nb.appendChild( document.createTextNode( " " ) );
382                             nb.appendChild( create_button( 'Play', 'vlm_play("'+elt.getAttribute('name')+'");' ) );
383                         }
384
385                         nb.appendChild( document.createTextNode( " " ) );
386                         nb.appendChild( create_button( 'Pause', 'vlm_pause("'+elt.getAttribute('name')+'");' ) );
387
388                         nb.appendChild( document.createTextNode( " " ) );
389                         nb.appendChild( create_button( 'Stop', 'vlm_stop("'+elt.getAttribute('name')+'");' ) );
390                     }
391                     
392                     nb.appendChild( document.createTextNode( " " ) );
393                     nb.appendChild( create_button( 'Delete', 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' ) );
394
395                     list = document.createElement( "ul" );
396                     /* begin input list */
397                     inputs = elt.getElementsByTagName( 'input' );
398                     for( i = 0; i < inputs.length; i++ )
399                     {
400                         item = document.createElement( "li" );
401                         item.appendChild( document.createTextNode( "Input: " + inputs[i].firstChild.data + " " ) );
402                         item.appendChild( create_button( "Delete", 'vlm_delete_input("' + elt.getAttribute( 'name' ) + '", '+(i+1)+' );' ) );
403                         list.appendChild( item );
404                     }
405
406                     /* Add input */
407                     item = document.createElement( "li" );
408                     text = document.createElement( "input" );
409                     text.setAttribute( 'type', 'text' );
410                     text.setAttribute( 'size', '40' );
411                     text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_input' );
412                     item.appendChild( text );
413                     item.appendChild( document.createTextNode( ' ' ) );
414                     item.appendChild( create_button( 'Edit', 'vlm_input_edit("vlm_elt_'+elt.getAttribute('name')+'_input");') );
415                     item.appendChild( document.createTextNode( ' ' ) );
416                     item.appendChild( create_button( 'Add input', 'vlm_add_input("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_input").value );' ) );
417                     
418                     list.appendChild( item );
419                     /* end of input list */
420                     
421                     /* output */
422                     item = document.createElement( "li" );
423                     outputelt = elt.getElementsByTagName( 'output' )[0];
424                     if( outputelt.hasChildNodes() )
425                     {
426                         output = outputelt.firstChild.data;
427                     }
428                     else
429                     {
430                         output = "";
431                     }
432                     item.appendChild( document.createTextNode( 'Output: ' ) );
433                     text = document.createElement( "input" );
434                     text.setAttribute( 'type', 'text' );
435                     text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_output' );
436                     text.setAttribute( 'value', output );
437                     item.appendChild( text );
438
439                     item.appendChild( document.createTextNode( ' ' ) );
440
441                     item.appendChild( create_button( 'Edit', 'vlm_output_edit("vlm_elt_'+elt.getAttribute('name')+'_output");' ) );
442                     item.appendChild( document.createTextNode( ' ' ) );
443                     item.appendChild( create_button( 'Change output', 'vlm_output("'+elt.getAttribute( 'name' )+ '",document.getElementById("vlm_elt_'+elt.getAttribute( 'name' )+'_output").value);' ) );
444                     list.appendChild( item );
445                     /* end of output */
446
447                     /* begin options list */
448                     options = elt.getElementsByTagName( 'option' );
449                     for( i = 0; i < options.length; i++ )
450                     {
451                         item = document.createElement( "li" );
452                         item.appendChild( document.createTextNode( "Option: " + options[i].firstChild.data ) );
453                         list.appendChild( item );
454                     }
455
456                     /* Add option */
457                     item = document.createElement( "li" );
458                     item.appendChild( document.createTextNode( ' ' ) );
459                     text = document.createElement( "input" );
460                     text.setAttribute( 'type', 'text' );
461                     text.setAttribute( 'size', '40' );
462                     text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_option' );
463                     item.appendChild( text );
464                     item.appendChild( document.createTextNode( ' ' ) );
465                     item.appendChild( create_button( 'Add option', 'vlm_option("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_option").value );' ) );
466                     
467                     list.appendChild( item );
468                     /* end of options */
469                     
470                     nb.appendChild( list );
471                     
472                 }
473                 else if( elt.nodeName == "schedule" )
474                 {
475                     nb = document.createElement( 'div' );
476                     nb.setAttribute( 'class', 'list_element' );
477                     vlms.appendChild( nb );
478
479                     nbname = document.createElement( 'b' );
480                     nbname.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) );
481                     nb.appendChild( nbname );
482                     
483                     link = document.createElement( 'input' );
484                     link.setAttribute( 'type', 'button' );
485                     if( elt.getAttribute( 'enabled' ) == 'yes' )
486                     {
487                         nb.appendChild( document.createTextNode( " enabled " ) );
488                         link.setAttribute( 'onclick', 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' );
489                         link.setAttribute( 'value', "Disable" );
490                     }
491                     else
492                     {
493                         nb.appendChild( document.createTextNode( " disabled " ) );
494                         link.setAttribute( 'onclick', 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' );
495                         link.setAttribute( 'value', "Enable" );
496                     }
497                     nb.appendChild( link );
498
499                     nb.appendChild( document.createTextNode( " " ) );
500                     nb.appendChild( create_button( "Delete", 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' ) );
501
502                     list = document.createElement( 'ul' );
503
504                     item = document.createElement( 'li' );
505                     item.appendChild( document.createTextNode( "Date: " + elt.getAttribute( 'date' ) ) );
506                     list.appendChild( item );
507
508                     item = document.createElement( 'li' );
509                     item.appendChild( document.createTextNode( "Period (in seconds): " + elt.getAttribute( 'period' ) ) );
510                     list.appendChild( item );
511                     
512                     item = document.createElement( 'li' );
513                     if( elt.getAttribute( 'repeat' ) == -1 )
514                     {
515                         item.appendChild( document.createTextNode( "Number of repeats left: for ever" ) );
516                     }
517                     else
518                     {
519                         item.appendChild( document.createTextNode( "Number of repeats left: " + elt.getAttribute( 'repeat' ) ) );
520                     }
521                     list.appendChild( item );
522                     
523                     commands = elt.getElementsByTagName( 'command' );
524                     for( i = 0; i < commands.length; i++ )
525                     {
526                         item = document.createElement( "li" );
527                         item.appendChild( document.createTextNode( "Command: " + commands[i].firstChild.data + " " ) );
528                         list.appendChild( item );
529                     }
530                     
531                     item = document.createElement( 'li' );
532                     sel = document.createElement( 'select' );
533                     sel.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_action' );
534                     sel.setAttribute( 'onchange', 'vlm_schedule_type_change("'+elt.getAttribute('name')+'");');
535                     sel.appendChild( create_option( 'play', 'play' ) );
536                     sel.appendChild( create_option( 'pause', 'pause' ) );
537                     sel.appendChild( create_option( 'stop', 'stop' ) );
538                     sel.appendChild( create_option( 'seek', 'seek' ) );
539                     sel.appendChild( create_option( '(other)', '' ) );
540                     item.appendChild( sel );
541
542                     item.appendChild( document.createTextNode( " " ) );
543                     text = document.createElement( 'input' );
544                     text.setAttribute( 'type', 'text' );
545                     text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_name' );
546                     text.setAttribute( 'size', '10' );
547                     text.setAttribute( 'value', '(name)' );
548                     text.setAttribute( 'onfocus', 'if( this.value == "(name)" ) this.value = "";' );
549                     text.setAttribute( 'onblur', 'if( this.value == "" ) this.value = "(name)";' );
550                     item.appendChild( text );
551
552                     item.appendChild( document.createTextNode( " " ) );
553                     text = document.createElement( 'input' );
554                     text.setAttribute( 'type', 'text' );
555                     text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_opt' );
556                     text.setAttribute( 'size', '30' );
557                     text.setAttribute( 'value', '(options)' );
558                     text.setAttribute( 'onfocus', 'if( this.value == "(options)" ) this.value = "";' );
559                     text.setAttribute( 'onblur', 'if( this.value == "" ) this.value = "(options)";' );
560                     item.appendChild( text );
561                     item.appendChild( document.createTextNode( " " ) );
562                     item.appendChild( create_button( "Append command", 'vlm_schedule_append("' + elt.getAttribute( 'name' ) + '");') );
563                     
564                     list.appendChild( item );
565
566                     nb.appendChild( list );
567                     vlm_schedule_type_change( elt.getAttribute('name') );
568                     
569                 }
570                 elt = elt.nextSibling;
571             }
572         }
573     }
574 }
575
576 function vlm_cmd( cmd )
577 {
578     loadXMLDoc( 'requests/vlm_cmd.xml?command='+cmd.replace(/\#/g, '%23'), parse_vlm_cmd );
579 }
580
581 function vlm_get_elements( )
582 {
583     loadXMLDoc( 'requests/vlm.xml', parse_vlm_elements );
584 }
585
586 /* helper functions */
587
588 function vlm_disable( name )
589 {
590     document.getElementById( 'vlm_command' ).value = "setup "+name+" disabled";
591     vlm_cmd( value( 'vlm_command' ) );
592 }
593
594 function vlm_enable( name )
595 {
596     document.getElementById( 'vlm_command' ).value = "setup "+name+" enabled";
597     vlm_cmd( value( 'vlm_command' ) );
598 }
599
600 function vlm_loop( name )
601 {
602     document.getElementById( 'vlm_command' ).value = "setup "+name+" loop";
603     vlm_cmd( value( 'vlm_command' ) );
604 }
605
606 function vlm_unloop( name )
607 {
608     document.getElementById( 'vlm_command' ).value = "setup "+name+" unloop";
609     vlm_cmd( value( 'vlm_command' ) );
610 }
611
612 function vlm_play( name )
613 {
614     document.getElementById( 'vlm_command' ).value = "control "+name+" play";
615     vlm_cmd( value( 'vlm_command' ) );
616 }
617
618 function vlm_pause( name )
619 {
620     document.getElementById( 'vlm_command' ).value = "control "+name+" pause";
621     vlm_cmd( value( 'vlm_command' ) );
622 }
623
624 function vlm_stop( name )
625 {
626     document.getElementById( 'vlm_command' ).value = "control "+name+" stop";
627     vlm_cmd( value( 'vlm_command' ) );
628 }
629
630 function vlm_delete( name )
631 {
632     document.getElementById( 'vlm_command' ).value = "del "+name;
633     vlm_cmd( value( 'vlm_command' ) );
634 }
635
636 function vlm_delete_input( name, num )
637 {
638     document.getElementById( 'vlm_command' ).value = "setup "+name+" inputdeln "+num;
639     vlm_cmd( value( 'vlm_command' ) );
640 }
641
642 function vlm_add_input( name, input )
643 {
644     document.getElementById( 'vlm_command' ).value = "setup "+name+" input "+input;
645     vlm_cmd( value( 'vlm_command' ) );
646 }
647
648 function vlm_output( name, output )
649 {
650     document.getElementById( 'vlm_command' ).value = "setup "+name+" output "+output;
651     vlm_cmd( value( 'vlm_command' ) );
652 }
653
654 function vlm_option( name, option )
655 {
656     document.getElementById( 'vlm_command' ).value = "setup "+name+" option "+option;
657     vlm_cmd( value( 'vlm_command' ) );
658 }
659
660 function vlm_schedule_append( name )
661 {
662     act = document.getElementById( 'vlm_elt_' + name + '_action' ).value;
663     document.getElementById( 'vlm_command' ).value = "setup " + name + " append ";
664     itemname = document.getElementById( 'vlm_elt_' + name + '_name' ).value;
665     if( itemname == "(name)" ) itemname = "";
666     opt = document.getElementById( 'vlm_elt_' + name + '_opt' ).value;
667     if( opt == "(options)" ) opt = "";
668         
669     if( act == '' )
670     {
671         document.getElementById( 'vlm_command' ).value += opt;
672     }
673     else
674     {
675         document.getElementById( 'vlm_command' ).value += 'control ' + itemname + " " + act + " " + opt;
676     }
677     vlm_cmd( value( 'vlm_command' ) );
678 }
679 function vlm_send( )
680 {
681     vlm_cmd( value( 'vlm_command' ) );
682 }