Commit 3bef3e14 authored by Antoine Cellerier's avatar Antoine Cellerier

all: handle VLM broadcast and vod elements.

 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)
       
parent 32178135
...@@ -40,6 +40,8 @@ sout and vlmelements . ...@@ -40,6 +40,8 @@ sout and vlmelements .
<input type="text" id="vlm_command" size="60" /> <input type="text" id="vlm_command" size="60" />
<input type="button" value="Send" onclick="vlm_send();" /> <input type="button" value="Send" onclick="vlm_send();" />
<br /> <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);"> <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 Broadcast
</button> </button>
...@@ -99,19 +101,19 @@ sout and vlmelements . ...@@ -99,19 +101,19 @@ sout and vlmelements .
<div class="title"> <div class="title">
Broadcast Elements Broadcast Elements
</div> </div>
<div class="vlm_broadcast_list"></div> <div id="vlm_broadcast_list" class="list"></div>
</div> </div>
<div id="vlm_vod" class="dialog" > <div id="vlm_vod" class="dialog" >
<div class="title"> <div class="title">
Video on Demand Elements Video on Demand Elements
</div> </div>
<div class="vlm_vod_list"></div> <div id="vlm_vod_list" class="list"></div>
</div> </div>
<div id="vlm_schedule" class="dialog" > <div id="vlm_schedule" class="dialog" >
<div class="title"> <div class="title">
Schedule Elements Schedule Elements
</div> </div>
<div class="vlm_schedule_list"></div> <div id="vlm_schedule_list" class="list"></div>
</div> </div>
...@@ -88,6 +88,10 @@ function update_vlm_add_broadcast() ...@@ -88,6 +88,10 @@ function update_vlm_add_broadcast()
cmd.value += " output " + value( 'vlm_broadcast_output' ); cmd.value += " output " + value( 'vlm_broadcast_output' );
} }
} }
else
{
cmd.value = "";
}
} }
function update_vlm_add_vod() function update_vlm_add_vod()
...@@ -114,12 +118,30 @@ function update_vlm_add_vod() ...@@ -114,12 +118,30 @@ function update_vlm_add_vod()
cmd.value += " output " + value( 'vlm_vod_output' ); cmd.value += " output " + value( 'vlm_vod_output' );
} }
} }
else
{
cmd.value = "";
}
} }
function update_vlm_add_schedule() 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() function parse_vlm_cmd()
{ {
if( req.readyState == 4 ) if( req.readyState == 4 )
...@@ -128,10 +150,240 @@ function parse_vlm_cmd() ...@@ -128,10 +150,240 @@ function parse_vlm_cmd()
{ {
vlm_answer = req.responseXML.documentElement; vlm_answer = req.responseXML.documentElement;
error_tag = vlm_answer.getElementsByTagName( 'error' )[0]; error_tag = vlm_answer.getElementsByTagName( 'error' )[0];
vlme = document.getElementById( 'vlm_error' );
clear_children( vlme );
if( error_tag.hasChildNodes() ) if( error_tag.hasChildNodes() )
{ {
vlm_error = error_tag.firstChild.data; vlme.appendChild( document.createTextNode( 'Error: ' + error_tag.firstChild.data ) );
alert( vlm_error ); 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() ...@@ -139,7 +391,86 @@ function parse_vlm_cmd()
function vlm_cmd( 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( ) function vlm_send( )
......
...@@ -96,11 +96,14 @@ div.controls button { ...@@ -96,11 +96,14 @@ div.controls button {
background-color: #fff; background-color: #fff;
} }
ul#list, ul#list ul { div.list {
list-style-type: none; padding: 1em;
padding-top: 0px; }
margin-top: 0px; div.list_element {
padding-left: 1em; padding-bottom: 0.3em;
}
div.list_element ul {
margin: 0px;
} }
div.pl_node { div.pl_node {
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</head> </head>
<body onload=";"> <body onload="vlm_get_elements();">
<vlc id="rpn" param1="page vlm store" /> <vlc id="rpn" param1="page vlm store" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment