all: handle VLM broadcast and vod elements.
authorAntoine Cellerier <dionoea@videolan.org>
Sun, 22 Jan 2006 15:59:52 +0000 (15:59 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sun, 22 Jan 2006 15:59:52 +0000 (15:59 +0000)
 todo: - seeking on broadcast elements
       - schedules
       - file(or textbox) load / save. might need some changes to the VLM
         core in order to export commands to a string (and not to a file)

share/http/dialogs/vlm
share/http/js/vlm.js
share/http/style.css
share/http/vlm.html

index f219aeb..8adbcb8 100644 (file)
@@ -40,6 +40,8 @@ sout and vlmelements .
     <input type="text" id="vlm_command" size="60" />
     <input type="button" value="Send" onclick="vlm_send();" />
     <br />
+    <span id="vlm_error"></span>
+    <br />
     <button id="btn_broadcast" onclick="hide_vlm_add();show('vlm_add_broadcast');update_vlm_add_broadcast();" onmouseover="button_over(this);" onmouseout="button_out(this);">
       Broadcast
     </button>
@@ -99,19 +101,19 @@ sout and vlmelements .
   <div class="title">
     Broadcast Elements
   </div>
-  <div class="vlm_broadcast_list"></div>
+  <div id="vlm_broadcast_list" class="list"></div>
 </div>
 
 <div id="vlm_vod" class="dialog" >
   <div class="title">
     Video on Demand Elements
   </div>
-  <div class="vlm_vod_list"></div>
+  <div id="vlm_vod_list" class="list"></div>
 </div>
 
 <div id="vlm_schedule" class="dialog" >
   <div class="title">
     Schedule Elements
   </div>
-  <div class="vlm_schedule_list"></div>
+  <div id="vlm_schedule_list" class="list"></div>
 </div>
index 90d503f..2b10186 100644 (file)
@@ -88,6 +88,10 @@ function update_vlm_add_broadcast()
             cmd.value += " output " + value( 'vlm_broadcast_output' );
         }
     }
+    else
+    {
+        cmd.value = "";
+    }
 }
 
 function update_vlm_add_vod()
@@ -114,12 +118,30 @@ function update_vlm_add_vod()
             cmd.value += " output " + value( 'vlm_vod_output' );
         }
     }
+    else
+    {
+        cmd.value = "";
+    }
 }
 
 function update_vlm_add_schedule()
 {
 }
 
+function clear_vlm_add()
+{
+    document.getElementById( 'vlm_command' ).value = "";
+    document.getElementById( 'vlm_broadcast_name' ).value = "";
+    document.getElementById( 'vlm_vod_name' ).value = "";
+}
+
+function clear_children( elt )
+{
+    if( elt )
+        while( elt.hasChildNodes() )
+            elt.removeChild( elt.firstChild );
+}
+
 function parse_vlm_cmd()
 {
     if( req.readyState == 4 )
@@ -128,10 +150,240 @@ function parse_vlm_cmd()
         {
             vlm_answer = req.responseXML.documentElement;
             error_tag = vlm_answer.getElementsByTagName( 'error' )[0];
+            vlme = document.getElementById( 'vlm_error' );
+            clear_children( vlme );
             if( error_tag.hasChildNodes() )
             {
-                vlm_error = error_tag.firstChild.data;
-                alert( vlm_error );
+                vlme.appendChild( document.createTextNode( 'Error: ' + error_tag.firstChild.data ) );
+                vlme.style.color = "#f00";
+            }
+            else
+            {
+                vlme.appendChild( document.createTextNode( 'Command succesful (' + value( 'vlm_command' ) + ') ' ) );
+                vlme.style.color = "#0f0";
+                clear_vlm_add();
+            }
+            link = document.createElement( "input" );
+            link.setAttribute( 'type', 'button' );
+            link.setAttribute( 'onclick', 'clear_children( document.getElementById( "vlm_error" ) );' );
+            link.setAttribute( 'value', 'clear' );
+            vlme.appendChild( link );
+
+            vlm_get_elements();
+        }
+    }
+}
+
+function parse_vlm_elements()
+{
+    if( req.readyState == 4 )
+    {
+        if( req.status == 200 )
+        {
+            vlmb = document.getElementById( 'vlm_broadcast_list' );
+            vlmv = document.getElementById( 'vlm_vod_list' );
+            vlms = document.getElementById( 'vlm_schedule_list' );
+
+            clear_children( vlmb );
+            clear_children( vlmv );
+            clear_children( vlms );
+
+            answer = req.responseXML.documentElement;
+
+            elt = answer.firstChild;
+
+            while( elt )
+            {
+                if( elt.nodeName == "broadcast" || elt.nodeName == "vod" )
+                {
+                    nb = document.createElement( 'div' );
+                    nb.setAttribute( 'class', 'list_element' );
+                    if( elt.nodeName == "broadcast" )
+                    {
+                        vlmb.appendChild( nb );
+                    }
+                    else
+                    {
+                        vlmv.appendChild( nb );
+                    }
+                    nbname = document.createElement( 'b' );
+                    nbname.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) );
+                    nb.appendChild( nbname );
+                    
+                    link = document.createElement( 'input' );
+                    link.setAttribute( 'type', 'button' );
+                    if( elt.getAttribute( 'enabled' ) == 'yes' )
+                    {
+                        nb.appendChild( document.createTextNode( " enabled " ) );
+                        link.setAttribute( 'onclick', 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' );
+                        link.setAttribute( 'value', "Disable" );
+                    }
+                    else
+                    {
+                        nb.appendChild( document.createTextNode( " disabled " ) );
+                        link.setAttribute( 'onclick', 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' );
+                        link.setAttribute( 'value', "Enable" );
+                    }
+                    nb.appendChild( link );
+                    
+                    if( elt.nodeName == "broadcast" )
+                    {
+                        link = document.createElement( 'input' );
+                        link.setAttribute( 'type', 'button' );
+                        if( elt.getAttribute( 'loop' ) == 'yes' )
+                        {
+                            nb.appendChild( document.createTextNode( " loop " ) );
+
+                            link.setAttribute( 'onclick', 'vlm_unloop("'+elt.getAttribute( 'name' ) + '");' );
+                            link.setAttribute( 'value', "Un-loop" );
+                        }
+                        else
+                        {
+                            nb.appendChild( document.createTextNode( " play once " ) );
+                            
+                            link.setAttribute( 'onclick', 'vlm_loop("'+elt.getAttribute( 'name' ) + '");' );
+                            link.setAttribute( 'value', "Loop" );
+                        }
+                        nb.appendChild( link );
+
+                        if( elt.getAttribute( 'enabled' ) == 'yes' )
+                        {
+                            nb.appendChild( document.createTextNode( " " ) );
+                            link = document.createElement( 'input' );
+                            link.setAttribute( 'type', 'button' );
+                            link.setAttribute( 'onclick', 'vlm_play("'+elt.getAttribute('name')+'");' );
+                            link.setAttribute( 'value', 'Play' );
+                            nb.appendChild( link );
+                        }
+
+                        nb.appendChild( document.createTextNode( " " ) );
+                        link = document.createElement( 'input' );
+                        link.setAttribute( 'type', 'button' );
+                        link.setAttribute( 'onclick', 'vlm_pause("'+elt.getAttribute('name')+'");' );
+                        link.setAttribute( 'value', 'Pause' );
+                        nb.appendChild( link );
+
+                        nb.appendChild( document.createTextNode( " " ) );
+                        link = document.createElement( 'input' );
+                        link.setAttribute( 'type', 'button' );
+                        link.setAttribute( 'onclick', 'vlm_stop("'+elt.getAttribute('name')+'");' );
+                        link.setAttribute( 'value', 'Stop' );
+                        nb.appendChild( link );
+                    }
+                    
+                    nb.appendChild( document.createTextNode( " " ) );
+                    link = document.createElement( 'input' );
+                    link.setAttribute( 'type', 'button' );
+                    link.setAttribute( 'onclick', 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' );
+                    link.setAttribute( 'value', "Delete" );
+                    nb.appendChild( link );
+
+                    list = document.createElement( "ul" );
+                    /* begin input list */
+                    inputs = elt.getElementsByTagName( 'input' );
+                    for( i = 0; i < inputs.length; i++ )
+                    {
+                        item = document.createElement( "li" );
+                        item.appendChild( document.createTextNode( "Input: " + inputs[i].firstChild.data + " " ) );
+                        link = document.createElement( "input" );
+                        link.setAttribute( 'type', 'button' );
+                        link.setAttribute( 'onclick', 'vlm_delete_input("' + elt.getAttribute( 'name' ) + '", '+(i+1)+' );' );
+                        link.setAttribute( 'value', "Delete" );
+                        item.appendChild( link );
+                        list.appendChild( item );
+                    }
+
+                    /* Add input */
+                    item = document.createElement( "li" );
+                    text = document.createElement( "input" );
+                    text.setAttribute( 'type', 'text' );
+                    text.setAttribute( 'size', '40' );
+                    text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_input' );
+                    item.appendChild( text );
+                    item.appendChild( document.createTextNode( ' ' ) );
+                    edit = document.createElement( "input" );
+                    edit.setAttribute( 'type', 'button' );
+                    edit.setAttribute( 'value', 'Edit' );
+                    edit.setAttribute( 'onclick', 'vlm_input_edit("vlm_elt_'+elt.getAttribute('name')+'_input");');
+                    item.appendChild( edit );
+                    item.appendChild( document.createTextNode( ' ' ) );
+                    link = document.createElement( "input" );
+                    link.setAttribute( 'type', 'button' );
+                    link.setAttribute( 'onclick', 'vlm_add_input("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_input").value );' );
+                    link.setAttribute( 'value', 'Add input' );
+                    item.appendChild( link );
+                    
+                    list.appendChild( item );
+                    /* end of input list */
+                    
+                    /* output */
+                    item = document.createElement( "li" );
+                    outputelt = elt.getElementsByTagName( 'output' )[0];
+                    if( outputelt.hasChildNodes() )
+                    {
+                        output = outputelt.firstChild.data;
+                    }
+                    else
+                    {
+                        output = "";
+                    }
+                    item.appendChild( document.createTextNode( 'Output: ' ) );
+                    text = document.createElement( "input" );
+                    text.setAttribute( 'type', 'text' );
+                    text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_output' );
+                    text.setAttribute( 'value', output );
+                    item.appendChild( text );
+
+                    item.appendChild( document.createTextNode( ' ' ) );
+
+                    edit = document.createElement( "input" );
+                    edit.setAttribute( 'type', 'button' );
+                    edit.setAttribute( 'value', 'Edit' );
+                    edit.setAttribute( 'onclick', 'vlm_output_edit("vlm_elt_'+elt.getAttribute('name')+'_output");');
+                    item.appendChild( edit );
+                    list.appendChild( item );
+                    item.appendChild( document.createTextNode( ' ' ) );
+                    link = document.createElement( "input" );
+                    link.setAttribute( 'type', 'button' );
+                    link.setAttribute( 'onclick', 'vlm_output("'+elt.getAttribute( 'name' )+ '",document.getElementById("vlm_elt_'+elt.getAttribute( 'name' )+'_output").value);' );
+                    link.setAttribute( 'value', 'Change output' );
+                    item.appendChild( link );
+                    /* end of output */
+
+                    /* begin options list */
+                    options = elt.getElementsByTagName( 'option' );
+                    for( i = 0; i < options.length; i++ )
+                    {
+                        item = document.createElement( "li" );
+                        item.appendChild( document.createTextNode( "Option: " + options[i].firstChild.data ) );
+                        list.appendChild( item );
+                    }
+
+                    /* Add option */
+                    item = document.createElement( "li" );
+                    item.appendChild( document.createTextNode( ' ' ) );
+                    text = document.createElement( "input" );
+                    text.setAttribute( 'type', 'text' );
+                    text.setAttribute( 'size', '40' );
+                    text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_option' );
+                    item.appendChild( text );
+                    item.appendChild( document.createTextNode( ' ' ) );
+                    link = document.createElement( "input" );
+                    link.setAttribute( 'type', 'button' );
+                    link.setAttribute( 'onclick', 'vlm_option("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_option").value );' );
+                    link.setAttribute( 'value', 'Add option' );
+                    item.appendChild( link );
+                    
+                    list.appendChild( item );
+                    /* end of options */
+                    
+                    nb.appendChild( list );
+                    
+                }
+                else if( elt.nodeName == "schedule" )
+                {
+                }
+                elt = elt.nextSibling;
             }
         }
     }
@@ -139,7 +391,86 @@ function parse_vlm_cmd()
 
 function vlm_cmd( cmd )
 {
-    loadXMLDoc( 'requests/vlm_cmd.xml?command='+cmd, parse_vlm_cmd );
+    loadXMLDoc( 'requests/vlm_cmd.xml?command='+cmd.replace(/\#/g, '%23'), parse_vlm_cmd );
+}
+
+function vlm_get_elements( )
+{
+    loadXMLDoc( 'requests/vlm.xml', parse_vlm_elements );
+}
+
+/* helper functions */
+
+function vlm_disable( name )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" disabled";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_enable( name )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" enabled";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_loop( name )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" loop";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_unloop( name )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" unloop";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_play( name )
+{
+    document.getElementById( 'vlm_command' ).value = "control "+name+" play";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_pause( name )
+{
+    document.getElementById( 'vlm_command' ).value = "control "+name+" pause";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_stop( name )
+{
+    document.getElementById( 'vlm_command' ).value = "control "+name+" stop";
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_delete( name )
+{
+    document.getElementById( 'vlm_command' ).value = "del "+name;
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_delete_input( name, num )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" inputdeln "+num;
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_add_input( name, input )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" input "+input;
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_output( name, output )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" output "+output;
+    vlm_cmd( value( 'vlm_command' ) );
+}
+
+function vlm_option( name, option )
+{
+    document.getElementById( 'vlm_command' ).value = "setup "+name+" option "+option;
+    vlm_cmd( value( 'vlm_command' ) );
 }
 
 function vlm_send( )
index 3ea4d1a..7921580 100644 (file)
@@ -96,11 +96,14 @@ div.controls button {
        background-color: #fff;
 }
 
-ul#list, ul#list ul {
-       list-style-type: none;
-       padding-top: 0px;
-       margin-top: 0px;
-       padding-left: 1em;
+div.list {
+       padding: 1em;
+}
+div.list_element {
+       padding-bottom: 0.3em;
+}
+div.list_element ul {
+       margin: 0px;
 }
 
 div.pl_node {
index c885583..144e44e 100644 (file)
@@ -35,7 +35,7 @@
 
 </head>
 
-<body onload=";">
+<body onload="vlm_get_elements();">
 
 <vlc id="rpn" param1="page vlm store" />