📄 vlm.js
字号:
/***************************************************************************** * vlm.js: VLC media player web interface ***************************************************************************** * Copyright (C) 2005-2006 the VideoLAN team * $Id$ * * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//* replace quotes and spaces by underscores */function addunderscores( str ){ return str.replace(/\'|\"| /g, '_'); }/********************************************************************** * 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; show( 'input' );}function vlm_input_change(){ document.getElementById( value( 'input_dest' ) ).value = value( 'input_mrl' ).replace( /\ :/g, " option " ); hide( 'input' ); document.getElementById( value( 'input_dest' ) ).focus();}function vlm_output_edit( dest ){ document.getElementById( 'sout_dest' ).value = dest; show( 'sout' );}function vlm_output_change(){ 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 hide_vlm_add(){ document.getElementById( 'vlm_add_broadcast' ).style.display = 'none'; document.getElementById( 'vlm_add_vod' ).style.display = 'none'; document.getElementById( 'vlm_add_schedule' ).style.display = 'none'; document.getElementById( 'vlm_add_other' ).style.display = 'none';}function toggle_schedule_date(){ if( checked( 'vlm_schedule_now' ) ) { disable( 'vlm_schedule_year' ); disable( 'vlm_schedule_month' ); disable( 'vlm_schedule_day' ); disable( 'vlm_schedule_hour' ); disable( 'vlm_schedule_minute' ); disable( 'vlm_schedule_second' ); } else { enable( 'vlm_schedule_year' ); enable( 'vlm_schedule_month' ); enable( 'vlm_schedule_day' ); enable( 'vlm_schedule_hour' ); enable( 'vlm_schedule_minute' ); enable( 'vlm_schedule_second' ); }}function toggle_schedule_repeat(){ if( checked( 'vlm_schedule_repeat' ) ) { enable( 'vlm_schedule_period_year' ); enable( 'vlm_schedule_period_month' ); enable( 'vlm_schedule_period_day' ); enable( 'vlm_schedule_period_hour' ); enable( 'vlm_schedule_period_minute' ); enable( 'vlm_schedule_period_second' ); enable( 'vlm_schedule_repeat_times' ); } else { disable( 'vlm_schedule_period_year' ); disable( 'vlm_schedule_period_month' ); disable( 'vlm_schedule_period_day' ); disable( 'vlm_schedule_period_hour' ); disable( 'vlm_schedule_period_minute' ); disable( 'vlm_schedule_period_second' ); disable( 'vlm_schedule_repeat_times' ); }}function vlm_schedule_type_change( name ){ var act = document.getElementById( 'vlm_elt_' + name + '_action' ).value; var itemname = document.getElementById( 'vlm_elt_' + name + '_name' ); var opt = document.getElementById( 'vlm_elt_' + name + '_opt' ); if( act == "play" || act == "pause" || act == "stop" ) { itemname.style.display = ""; opt.style.display = "none"; } else if( act == "seek" ) { itemname.style.display = ""; opt.style.display = ""; } else { itemname.style.display = "none"; opt.style.display = ""; }}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_name' ) ) { cmd.value = "new " + addunderscores( value( 'vlm_broadcast_name' ) ) + " broadcast"; if( checked( 'vlm_broadcast_enabled' ) ) { cmd.value += " enabled"; } if( checked( 'vlm_broadcast_loop' ) ) { cmd.value += " loop"; } if( value( 'vlm_broadcast_input' ) ) { cmd.value += " input " + sanitize_input( value( 'vlm_broadcast_input' ) ); } if( value( 'vlm_broadcast_output' ) ) { cmd.value += " output " + value( 'vlm_broadcast_output' ); } } else { cmd.value = ""; }}function update_vlm_add_vod(){ var cmd = document.getElementById( 'vlm_command' ); if( value( 'vlm_vod_name' ) ) { cmd.value = "new " + addunderscores( value( 'vlm_vod_name' ) ) + " vod"; if( checked( 'vlm_vod_enabled' ) ) { cmd.value += " enabled"; } if( value( 'vlm_vod_input' ) ) { cmd.value += " input " + sanitize_input( value( 'vlm_vod_input' ) ); } if( value( 'vlm_vod_output' ) ) { cmd.value += " output " + value( 'vlm_vod_output' ); } } else { cmd.value = ""; }}function update_vlm_add_schedule(){ var cmd = document.getElementById( 'vlm_command' ); check_and_replace_int( 'vlm_schedule_year', '0000' ); check_and_replace_int( 'vlm_schedule_month', '00' ); check_and_replace_int( 'vlm_schedule_day', '00' ); check_and_replace_int( 'vlm_schedule_hour', '00' ); check_and_replace_int( 'vlm_schedule_minute', '00' ); check_and_replace_int( 'vlm_schedule_second', '00' ); check_and_replace_int( 'vlm_schedule_period_year', '0000' ); check_and_replace_int( 'vlm_schedule_period_month', '00' ); check_and_replace_int( 'vlm_schedule_period_day', '00' ); check_and_replace_int( 'vlm_schedule_period_hour', '00' ); check_and_replace_int( 'vlm_schedule_period_minute', '00' ); check_and_replace_int( 'vlm_schedule_period_second', '00' ); if( value( 'vlm_schedule_name' ) ) { cmd.value = "new " + addunderscores( value( 'vlm_schedule_name' ) ) + " schedule"; if( checked( 'vlm_schedule_enabled' ) ) { cmd.value += " enabled"; } if( checked( 'vlm_schedule_now' ) ) { cmd.value += " date now"; } else { 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' ); } if( checked( 'vlm_schedule_repeat' ) ) { 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' ); if( value( 'vlm_schedule_repeat_times' ) != 0 ) { cmd.value += " repeat " + (value( 'vlm_schedule_repeat_times' ) - 1 ); } } } else { cmd.value = ""; }}function update_vlm_add_other(){ var cmd = document.getElementById( 'vlm_command' ); cmd.value = "";}function clear_vlm_add(){ document.getElementById( 'vlm_command' ).value = ""; document.getElementById( 'vlm_broadcast_name' ).value = ""; document.getElementById( 'vlm_vod_name' ).value = "";}function create_button( caption, action ){/* 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 ){ var opt = document.createElement( 'option' ); opt.setAttribute( 'value', value ); opt.appendChild( document.createTextNode( caption ) ); return opt;}function parse_vlm_cmd(){ if( req.readyState == 4 ) { if( req.status == 200 ) { var vlm_answer = req.responseXML.documentElement; var error_tag = vlm_answer.getElementsByTagName( 'error' )[0]; var vlme = document.getElementById( 'vlm_error' ); clear_children( vlme ); if( error_tag.hasChildNodes() ) { 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(); } vlme.appendChild( create_button( 'clear', 'clear_children( document.getElementById( "vlm_error" ) );' ) ); vlm_get_elements(); } }}function parse_vlm_elements(){ if( req.readyState == 4 ) { if( req.status == 200 ) { var vlmb = document.getElementById( 'vlm_broadcast_list' ); var vlmv = document.getElementById( 'vlm_vod_list' ); var vlms = document.getElementById( 'vlm_schedule_list' ); clear_children( vlmb ); clear_children( vlmv ); clear_children( vlms ); answer = req.responseXML.documentElement; var elt = answer.firstChild; while( elt ) { if( elt.nodeName == "broadcast" || elt.nodeName == "vod" ) { var nb = document.createElement( 'div' ); setclass( nb, 'list_element' ); if( elt.nodeName == "broadcast" ) { vlmb.appendChild( nb ); } else { vlmv.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 " ) );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -