📄 vlm.js
字号:
nb.appendChild( create_button( "Disable", 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' ) ); } else { nb.appendChild( document.createTextNode( " disabled " ) ); nb.appendChild( create_button( "Enable", 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' ) ); } if( elt.nodeName == "broadcast" ) { if( elt.getAttribute( 'loop' ) == 'yes' ) { nb.appendChild( document.createTextNode( " 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' ) + '");' ) ); } if( elt.getAttribute( 'enabled' ) == 'yes' ) { nb.appendChild( document.createTextNode( " " ) ); nb.appendChild( create_button( 'Play', 'vlm_play("'+elt.getAttribute('name')+'");' ) ); } nb.appendChild( document.createTextNode( " " ) ); nb.appendChild( create_button( 'Pause', 'vlm_pause("'+elt.getAttribute('name')+'");' ) ); nb.appendChild( document.createTextNode( " " ) ); nb.appendChild( create_button( 'Stop', 'vlm_stop("'+elt.getAttribute('name')+'");' ) ); } nb.appendChild( document.createTextNode( " " ) ); nb.appendChild( create_button( 'Delete', 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' ) ); var list = document.createElement( "ul" ); /* begin input list */ var item = document.createElement( "li" ); list.appendChild( item ); item.appendChild( document.createTextNode( "Inputs: " ) ); var text = document.createElement( "input" ); 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");') ); item.appendChild( document.createTextNode( ' ' ) ); item.appendChild( create_button( 'Add input', 'vlm_add_input("'+elt.getAttribute('name')+'",document.getElementById("vlm_elt_'+elt.getAttribute('name')+'_input").value );' ) ); var inputs = elt.getElementsByTagName( 'input' ); if( inputs.length > 0 ) { var ilist = document.createElement( "ol" ); ilist.setAttribute( 'start', '1' ); item.appendChild( ilist ); for( i = 0; i < inputs.length; i++ ) { var item = document.createElement( "li" ); item.appendChild( document.createTextNode( inputs[i].firstChild.data + " " ) ); item.appendChild( create_button( "Delete", 'vlm_delete_input("' + elt.getAttribute( 'name' ) + '", '+(i+1)+' );' ) ); ilist.appendChild( item ); } } /* end of input list */ /* output */ var item = document.createElement( "li" ); outputelt = elt.getElementsByTagName( 'output' )[0]; if( outputelt.hasChildNodes() ) { output = outputelt.firstChild.data; } else { output = ""; } item.appendChild( document.createTextNode( 'Output: ' ) ); var text = document.createElement( "input" ); 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( ' ' ) ); item.appendChild( create_button( 'Edit', 'vlm_output_edit("vlm_elt_'+elt.getAttribute('name')+'_output");' ) ); item.appendChild( document.createTextNode( ' ' ) ); item.appendChild( create_button( 'Change output', 'vlm_output("'+elt.getAttribute( 'name' )+ '",document.getElementById("vlm_elt_'+elt.getAttribute( 'name' )+'_output").value);' ) ); list.appendChild( item ); /* end of output */ /* begin options list */ var item = document.createElement( "li" ); list.appendChild( item ); item.appendChild( document.createTextNode( "Options: " ) ); /* Add option */ var text = document.createElement( "input" ); 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 options = elt.getElementsByTagName( 'option' ); if( options.length > 0 ) { var olist = document.createElement( "ul" ); item.appendChild( olist ); for( i = 0; i < options.length; i++ ) { var item = document.createElement( "li" ); item.appendChild( document.createTextNode( options[i].firstChild.data ) ); olist.appendChild( item ); } } /* end of options */ /* Instances list */ var instances = elt.getElementsByTagName( 'instance' ); if( instances.length > 0 ) { var item = document.createElement("li"); var ilist = document.createElement("ul"); list.appendChild( item ); item.appendChild(document.createTextNode("Instances:")); item.appendChild( ilist ); for( i = 0; i < instances.length; i++ ) { var iname = instances[i].getAttribute( 'name' ); var istate = instances[i].getAttribute( 'state' ); var iposition = Number( instances[i].getAttribute( 'position' ) * 100); var itime = Math.floor( instances[i].getAttribute( 'time' ) / 1000000); var ilength = Math.floor( instances[i].getAttribute( 'length' ) / 1000000); var irate = instances[i].getAttribute( 'rate' ); 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 + " (" + iplaylistindex + ") " + (iposition.toFixed(2)) + "%" + " " + format_time( itime ) + "/" + format_time( ilength ) ) ); ilist.appendChild( item ); } } /* end of instances list */ nb.appendChild( list ); } else if( elt.nodeName == "schedule" ) { var nb = document.createElement( 'div' ); setclass( nb, 'list_element' ); vlms.appendChild( nb ); var nbname = document.createElement( 'b' ); nbname.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) ); nb.appendChild( nbname ); if( elt.getAttribute( 'enabled' ) == 'yes' ) { nb.appendChild( document.createTextNode( " enabled " ) ); nb.appendChild( create_button( "Disable", 'vlm_disable("'+elt.getAttribute( 'name' ) + '");' ) ); } else { nb.appendChild( document.createTextNode( " disabled " ) ); nb.appendChild( create_button( "Enable", 'vlm_enable("'+elt.getAttribute( 'name' ) + '");' ) ); } nb.appendChild( document.createTextNode( " " ) ); nb.appendChild( create_button( "Delete", 'vlm_delete("'+elt.getAttribute( 'name' ) + '");' ) ); var list = document.createElement( 'ul' ); var item = document.createElement( 'li' ); item.appendChild( document.createTextNode( "Date: " + elt.getAttribute( 'date' ) ) ); list.appendChild( item ); var item = document.createElement( 'li' ); item.appendChild( document.createTextNode( "Period (in seconds): " + elt.getAttribute( 'period' ) ) ); list.appendChild( item ); var item = document.createElement( 'li' ); if( elt.getAttribute( 'repeat' ) == -1 ) { item.appendChild( document.createTextNode( "Number of repeats left: for ever" ) ); } else { item.appendChild( document.createTextNode( "Number of repeats left: " + elt.getAttribute( 'repeat' ) ) ); } list.appendChild( item ); var commands = elt.getElementsByTagName( 'command' ); for( i = 0; i < commands.length; i++ ) { var item = document.createElement( "li" ); item.appendChild( document.createTextNode( "Command: " + commands[i].firstChild.data + " " ) ); list.appendChild( item ); } var item = document.createElement( 'li' ); var sel = document.createElement( 'select' ); sel.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_action' ); sel.setAttribute( 'onchange', 'vlm_schedule_type_change("'+elt.getAttribute('name')+'");'); sel.appendChild( create_option( 'play', 'play' ) ); sel.appendChild( create_option( 'pause', 'pause' ) ); sel.appendChild( create_option( 'stop', 'stop' ) ); sel.appendChild( create_option( 'seek', 'seek' ) ); sel.appendChild( create_option( '(other)', '' ) ); item.appendChild( sel ); item.appendChild( document.createTextNode( " " ) ); var text = document.createElement( 'input' ); text.setAttribute( 'type', 'text' ); text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_name' ); text.setAttribute( 'size', '10' ); text.setAttribute( 'value', '(name)' ); text.setAttribute( 'onfocus', 'if( this.value == "(name)" ) this.value = "";' ); text.setAttribute( 'onblur', 'if( this.value == "" ) this.value = "(name)";' ); item.appendChild( text ); item.appendChild( document.createTextNode( " " ) ); text = document.createElement( 'input' ); text.setAttribute( 'type', 'text' ); text.setAttribute( 'id', 'vlm_elt_'+elt.getAttribute('name')+'_opt' ); text.setAttribute( 'size', '30' ); text.setAttribute( 'value', '(options)' ); text.setAttribute( 'onfocus', 'if( this.value == "(options)" ) this.value = "";' ); text.setAttribute( 'onblur', 'if( this.value == "" ) this.value = "(options)";' ); item.appendChild( text ); item.appendChild( document.createTextNode( " " ) ); item.appendChild( create_button( "Append command", 'vlm_schedule_append("' + elt.getAttribute( 'name' ) + '");') ); list.appendChild( item ); nb.appendChild( list ); vlm_schedule_type_change( elt.getAttribute('name') ); } elt = elt.nextSibling; } } }}function vlm_cmd( cmd ){ loadXMLDoc( 'requests/vlm_cmd.xml?command='+encodeURIComponent(cmd), 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 "+sanitize_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_batch( batch ){ var i; var commands = batch.split( '\n' ); for( i = 0; i < commands.length; i++ ) { document.getElementById( 'vlm_command' ).value = commands[i]; vlm_cmd( value( 'vlm_command' ) ); }}function vlm_schedule_append( name ){ var act = document.getElementById( 'vlm_elt_' + name + '_action' ).value; document.getElementById( 'vlm_command' ).value = "setup " + name + " append "; var itemname = document.getElementById( 'vlm_elt_' + name + '_name' ).value; if( itemname == "(name)" ) itemname = ""; var opt = document.getElementById( 'vlm_elt_' + name + '_opt' ).value; if( opt == "(options)" ) opt = ""; if( act == '' ) { document.getElementById( 'vlm_command' ).value += opt; } else { document.getElementById( 'vlm_command' ).value += 'control ' + itemname + " " + act + " " + opt; } vlm_cmd( value( 'vlm_command' ) );}function vlm_send( ){ vlm_cmd( value( 'vlm_command' ) );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -