* Input dialog functions
*********************************************************************/
+function toggle_show_vlm_helper()
+{
+ var vlmh = document.getElementById( "vlm_helper" );
+ var vlmhctrl = document.getElementById( "vlm_helper_controls" );
+ var btn = document.getElementById( "btn_vlm_helper_toggle" );
+ if( vlmh.style.display == 'block' || vlmh.style.display == '')
+ {
+ vlmh.style.display = 'none';
+ vlmhctrl.style.display = 'none';
+ btn.removeChild( btn.firstChild );
+ btn.appendChild( document.createTextNode( 'Show VLM helper' ) );
+ }
+ else
+ {
+ vlmh.style.display = 'block';
+ vlmhctrl.style.display = 'inline';
+ btn.removeChild( btn.firstChild );
+ btn.appendChild( document.createTextNode( 'Hide VLM helper' ) );
+ }
+}
+
function vlm_input_edit( dest )
{
document.getElementById( 'input_dest' ).value = dest;
function vlm_input_change()
{
- document.getElementById( value( 'input_dest' ) ).value = value( 'input_mrl' );
+ document.getElementById( value( 'input_dest' ) ).value = value( 'input_mrl' ).replace( /\ :/g, " option " );
hide( 'input' );
document.getElementById( value( 'input_dest' ) ).focus();
}
function vlm_output_change()
{
- document.getElementById( value( 'sout_dest' ) ).value = value( 'sout_mrl' ).substr(6); /* substr <-> remove :sout= */
+ document.getElementById( value( 'sout_dest' ) ).value = value( 'sout_mrl' ).substr(6).replace( /\ :/g, " option " ); /* substr <-> remove :sout= */
hide( 'sout' );
document.getElementById( value( 'sout_dest' ) ).focus();
}
}
}
+function sanitize_input( str )
+{
+ return str.replace( /\"/g, '\\\"' ).replace( /^/, '"' ).replace( /$/, '"' ).replace( /\ option\ /g, '" option "' );
+}
+
function update_vlm_add_broadcast()
{
var cmd = document.getElementById( 'vlm_command' );
if( value( 'vlm_broadcast_input' ) )
{
- cmd.value += " input " + value( 'vlm_broadcast_input' );
+ cmd.value += " input " + sanitize_input( value( 'vlm_broadcast_input' ) );
}
if( value( 'vlm_broadcast_output' ) )
if( value( 'vlm_vod_input' ) )
{
- cmd.value += " input " + value( 'vlm_vod_input' );
+ cmd.value += " input " + sanitize_input( value( 'vlm_vod_input' ) );
}
if( value( 'vlm_vod_output' ) )
document.getElementById( 'vlm_vod_name' ).value = "";
}
-function clear_children( elt )
-{
- if( elt )
- while( elt.hasChildNodes() )
- elt.removeChild( elt.firstChild );
-}
-
function create_button( caption, action )
{
- var link = document.createElement( "input" );
- link.setAttribute( 'type', 'button' );
- link.setAttribute( 'onclick', action );
- link.setAttribute( 'value', caption );
+/* var link = document.createElement( "input" );
+ link.setAttribute( 'type', 'button' );*/
+ /* link.setAttribute( 'onclick', action ); */
+ /* Above doesn't work on ie. You need to use something like
+ * link.onclick = function() { alert( 'pouet' ); };
+ * instead ... conclusion: IE is crap */
+ /* link.setAttribute( 'value', caption );*/
+
+ var d = document.createElement( 'div' );
+ d.innerHTML = "<input type='button' onclick='"+action+"' value='"+caption+"' />"; /* other IE work around ... still crap. Use double quotes only in action */
+ var link = d.firstChild;
return link;
}
function create_option( caption, value )
if( elt.nodeName == "broadcast" || elt.nodeName == "vod" )
{
var nb = document.createElement( 'div' );
- nb.setAttribute( 'class', 'list_element' );
+ setclass( nb, 'list_element' );
if( elt.nodeName == "broadcast" )
{
vlmb.appendChild( nb );
nbname.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) );
nb.appendChild( nbname );
- var 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" );
+ nb.appendChild( create_button( "Disable", 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' ) );
}
else
{
nb.appendChild( document.createTextNode( " disabled " ) );
- link.setAttribute( 'onclick', 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' );
- link.setAttribute( 'value', "Enable" );
+ nb.appendChild( create_button( "Enable", 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' ) );
}
- 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" );
+ nb.appendChild( create_button( 'Un-loop', 'vlm_unloop("'+elt.getAttribute( 'name' ) + '");' ) );
}
else
{
nb.appendChild( document.createTextNode( " play once " ) );
+ nb.appendChild( create_button( 'Loop', 'vlm_loop("'+elt.getAttribute( 'name' ) + '");' ) );
- link.setAttribute( 'onclick', 'vlm_loop("'+elt.getAttribute( 'name' ) + '");' );
- link.setAttribute( 'value', "Loop" );
}
- nb.appendChild( link );
if( elt.getAttribute( 'enabled' ) == 'yes' )
{
text.setAttribute( 'type', 'text' );
text.setAttribute( 'size', '40' );
text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_input' );
+ text.setAttribute( 'onkeypress', 'if( event.keyCode == 13 ) vlm_add_input("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_input").value );' );
item.appendChild( text );
item.appendChild( document.createTextNode( ' ' ) );
item.appendChild( create_button( 'Edit', 'vlm_input_edit("vlm_elt_'+elt.getAttribute('name')+'_input");') );
if( inputs.length > 0 )
{
var ilist = document.createElement( "ol" );
- ilist.setAttribute( 'start', '0' );
+ ilist.setAttribute( 'start', '1' );
item.appendChild( ilist );
for( i = 0; i < inputs.length; i++ )
{
text.setAttribute( 'type', 'text' );
text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_output' );
text.setAttribute( 'value', output );
+ text.setAttribute( 'onkeypress', 'if( event.keyCode == 13 ) vlm_output("'+elt.getAttribute( 'name' )+ '",document.getElementById("vlm_elt_'+elt.getAttribute( 'name' )+'_output").value);' );
item.appendChild( text );
item.appendChild( document.createTextNode( ' ' ) );
text.setAttribute( 'type', 'text' );
text.setAttribute( 'size', '40' );
text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_option' );
+ text.setAttribute( 'onkeypress', 'if( event.keyCode == 13 ) vlm_option("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_option").value );' );
item.appendChild( text );
item.appendChild( document.createTextNode( ' ' ) );
item.appendChild( create_button( 'Add option', 'vlm_option("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_option").value );' ) );
var ititle = instances[i].getAttribute( 'title' );
var ichapter = instances[i].getAttribute( 'chapter' );
var iseekable = instances[i].getAttribute( 'seekable' );
+ var iplaylistindex = instances[i].getAttribute( 'playlistindex' );
var item = document.createElement( "li" );
- item.appendChild( document.createTextNode( iname + ": " + istate + " " + (iposition.toFixed(2)) + "%" + " " + format_time( itime ) + "/" + format_time( ilength ) ) );
+ item.appendChild( document.createTextNode( iname + ": " + istate + " (" + iplaylistindex + ") " + (iposition.toFixed(2)) + "%" + " " + format_time( itime ) + "/" + format_time( ilength ) ) );
ilist.appendChild( item );
}
}
else if( elt.nodeName == "schedule" )
{
var nb = document.createElement( 'div' );
- nb.setAttribute( 'class', 'list_element' );
+ setclass( nb, 'list_element' );
vlms.appendChild( nb );
var nbname = document.createElement( 'b' );
nbname.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) );
nb.appendChild( nbname );
- var 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" );
+ nb.appendChild( create_button( "Disable", 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' ) );
}
else
{
nb.appendChild( document.createTextNode( " disabled " ) );
- link.setAttribute( 'onclick', 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' );
- link.setAttribute( 'value', "Enable" );
+ nb.appendChild( create_button( "Enable", 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' ) );
}
- nb.appendChild( link );
nb.appendChild( document.createTextNode( " " ) );
nb.appendChild( create_button( "Delete", 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' ) );
function vlm_cmd( cmd )
{
- loadXMLDoc( 'requests/vlm_cmd.xml?command='+cmd.replace(/\#/g, '%23'), parse_vlm_cmd );
+ loadXMLDoc( 'requests/vlm_cmd.xml?command='+encodeURIComponent(cmd), parse_vlm_cmd );
}
function vlm_get_elements( )
function vlm_add_input( name, input )
{
- document.getElementById( 'vlm_command' ).value = "setup "+name+" input "+input;
+ document.getElementById( 'vlm_command' ).value = "setup "+name+" input "+sanitize_input( input );
vlm_cmd( value( 'vlm_command' ) );
}