⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.js

📁 VLC Player Source Code
💻 JS
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * functions.js: VLC media player web interface ***************************************************************************** * Copyright (C) 2005-2006 the VideoLAN team * $Id: functions.js 21264 2007-08-19 17:48:28Z dionoea $ * * 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. *****************************************************************************//********************************************************************** * Global variables *********************************************************************/var old_time = 0;var pl_cur_id;var albumart_id = -1;/********************************************************************** * Slider functions *********************************************************************/ var slider_mouse_down = 0;var slider_dx = 0;var input_options = new Array();/* findPosX() from http://www.quirksmode.rg/js/indpos.html */function findPosX(obj){    var curleft = 0;    if (obj.offsetParent)    {        while (obj.offsetParent)        {            curleft += obj.offsetLeft            obj = obj.offsetParent;        }    }    else if (obj.x)        curleft += obj.x;    return curleft;}function slider_seek( e, bar ){    seek(Math.floor(( e.clientX + document.body.scrollLeft - findPosX( bar )) / 4)+"%25");}function slider_down( e, point ){    slider_mouse_down = 1;    slider_dx = e.clientX - findPosX( point );}function slider_up( e, bar ){    slider_mouse_down = 0;    /* slider_seek( e, bar ); */}function slider_move( e, bar ){    if( slider_mouse_down == 1 )    {        var slider_position  = Math.floor( e.clientX - slider_dx + document.body.scrollLeft - findPosX( bar ));        document.getElementById( 'main_slider_point' ).style.left = slider_position+"px";        slider_seek( e, bar );    }}/********************************************************************** * Misc utils *********************************************************************//* XMLHttpRequest wrapper */function loadXMLDoc( url, callback ){  // branch for native XMLHttpRequest object  if ( window.XMLHttpRequest )  {    req = new XMLHttpRequest();    req.onreadystatechange = callback;    req.open( "GET", url, true );    req.send( null );  // branch for IE/Windows ActiveX version  }  else if ( window.ActiveXObject )  {    req = new ActiveXObject( "Microsoft.XMLHTTP" );    if ( req )    {      req.onreadystatechange = callback;      req.open( "GET", url, true );      req.send();    }  }}/* fomat time in second as hh:mm:ss */function format_time( s ){    var hours = Math.floor(s/3600);    var minutes = Math.floor((s/60)%60);    var seconds = Math.floor(s%60);    if( hours < 10 ) hours = "0"+hours;    if( minutes < 10 ) minutes = "0"+minutes;    if( seconds < 10 ) seconds = "0"+seconds;    return hours+":"+minutes+":"+seconds;}/* delete all a tag's children and add a text child node */function set_text( id, val ){    var elt = document.getElementById( id );    while( elt.hasChildNodes() )        elt.removeChild( elt.firstChild );    elt.appendChild( document.createTextNode( val ) );}/* set item's 'element' attribute to value */function set_css( item, element, value ){    for( var j = 0; j < document.styleSheets.length; j++ )    {        var cssRules = document.styleSheets[j].cssRules;        if( !cssRules ) cssRules = document.styleSheets[j].rules;        for( var i = 0; i < cssRules.length; i++)        {            if( cssRules[i].selectorText == item )            {                if( cssRules[i].style.setProperty )                    cssRules[i].style.setProperty( element, value, null );                else                    cssRules[i].style.setAttribute( toCamelCase( element ), value );                return;            }        }    }}/* get item's 'element' attribute */function get_css( item, element ){    for( var j = 0; j < document.styleSheets.length; j++ )    {        var cssRules = document.styleSheets[j].cssRules;        if( !cssRules ) cssRules = document.styleSheets[j].rules;        for( var i = 0; i < cssRules.length; i++)        {            if( cssRules[i].selectorText == item )            {                if( cssRules[i].style.getPropertyValue )                    return cssRules[i].style.getPropertyValue( element );                else                    return cssRules[i].style.getAttribute( toCamelCase( element ) );            }        }    }}function toggle_show( id ){    var element = document.getElementById( id );    if( element.style.display == 'block' || element.style.display == '' )    {        element.style.display = 'none';    }    else    {        element.style.display = 'block';    }}function toggle_show_node( id ){    var element = document.getElementById( 'pl_'+id );    var img = document.getElementById( 'pl_img_'+id );    if( element.style.display == 'block' || element.style.display == '' )    {        element.style.display = 'none';        img.setAttribute( 'src', 'images/plus.png' );        img.setAttribute( 'alt', '[+]' );    }    else    {        element.style.display = 'block';        img.setAttribute( 'src', 'images/minus.png' );        img.setAttribute( 'alt', '[-]' );    }}function show( id ){ document.getElementById( id ).style.display = 'block'; }function showinline( id ){ document.getElementById( id ).style.display = 'inline'; }function hide( id ){ document.getElementById( id ).style.display = 'none'; }function checked( id ){ return document.getElementById( id ).checked; }function value( id ){ return document.getElementById( id ).value; }function setclass( obj, value ){    obj.setAttribute( 'class', value ); /* Firefox */    obj.setAttribute( 'className', value ); /* IE */}function radio_value( name ){    var radio = document.getElementsByName( name );    for( var i = 0; i < radio.length; i++ )    {        if( radio[i].checked )        {            return radio[i].value;        }    }    return "";}function check_and_replace_int( id, val ){    var objRegExp = /^\d+$/;    if( value( id ) != ''        && ( !objRegExp.test( value( id ) )             || parseInt( value( id ) ) < 1 ) )        return document.getElementById( id ).value = val;    return document.getElementById( id ).value;}function addslashes( str ){ return str.replace(/\'/g, '\\\''); }function escapebackslashes( str ){ return str.replace(/\\/g, '\\\\'); }function toCamelCase( str ){    str = str.split( '-' );    var cml = str[0];    for( var i=1; i<str.length; i++)        cml += str[i].charAt(0).toUpperCase()+str[i].substring(1);    return cml;}function disable( id ){ document.getElementById( id ).disabled = true; }function enable( id ){ document.getElementById( id ).disabled = false; }function button_over( element ){ element.style.border = "1px solid #000"; }function button_out( element ){ element.style.border = "1px solid #fff"; }function button_out_menu( element ){ element.style.border = "1px solid transparent"; }function show_menu( id ){ document.getElementById(id).style.display = 'block'; }function hide_menu( id ){ document.getElementById(id).style.display = 'none'; }/* toggle show help under the buttons */function toggle_btn_text(){    if( get_css( '.btn_text', 'display' ) == 'none' )    {        set_css( '.btn_text', 'display', 'block' );    }    else    {        set_css( '.btn_text', 'display', 'none' );    }}function clear_children( elt ){       if( elt )        while( elt.hasChildNodes() )            elt.removeChild( elt.firstChild );}/********************************************************************** * Interface actions *********************************************************************//* input actions */function in_playenqueue( cmd ){    var input = value('input_mrl');    var url = 'requests/status.xml?command=in_'+cmd+'&input='+encodeURIComponent( addslashes(escapebackslashes(input)) );    for( i in input_options )        if( input_options[i] != ':option=value' )            url += '&option='+encodeURIComponent( addslashes(escapebackslashes(input_options[i]) ));    loadXMLDoc( url, parse_status );    setTimeout( 'update_playlist()', 1000 );}function in_play(){    in_playenqueue( 'play' );}function in_enqueue(){    in_playenqueue( 'enqueue' );}/* playlist actions */function pl_play( id ){    loadXMLDoc( 'requests/status.xml?command=pl_play&id='+id, parse_status );    pl_cur_id = id;    setTimeout( 'update_playlist()', 1000 );}function pl_pause(){    loadXMLDoc( 'requests/status.xml?command=pl_pause&id='+pl_cur_id, parse_status );}function pl_stop(){    loadXMLDoc( 'requests/status.xml?command=pl_stop', parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_next(){    loadXMLDoc( 'requests/status.xml?command=pl_next', parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_previous(){    loadXMLDoc( 'requests/status.xml?command=pl_previous', parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_delete( id ){    loadXMLDoc( 'requests/status.xml?command=pl_delete&id='+id, parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_empty(){    loadXMLDoc( 'requests/status.xml?command=pl_empty', parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_sort( sort, order ){    loadXMLDoc( 'requests/status.xml?command=pl_sort&id='+order+'&val='+sort, parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_shuffle(){    loadXMLDoc( 'requests/status.xml?command=pl_random', parse_status );    setTimeout( 'update_playlist()', 1000 );}function pl_loop(){    loadXMLDoc( 'requests/status.xml?command=pl_loop', parse_status );}function pl_repeat(){    loadXMLDoc( 'requests/status.xml?command=pl_repeat', parse_status );}function pl_sd( value ){    loadXMLDoc( 'requests/status.xml?command=pl_sd&val='+value, parse_status );}/* misc actions */function volume_down(){    loadXMLDoc( 'requests/status.xml?command=volume&val=-20', parse_status );}function volume_up(){    loadXMLDoc( 'requests/status.xml?command=volume&val=%2B20', parse_status );}function seek( pos ){    loadXMLDoc( 'requests/status.xml?command=seek&val='+pos, parse_status );}function fullscreen(){    loadXMLDoc( 'requests/status.xml?command=fullscreen', parse_status );}function snapshot(){    loadXMLDoc( 'requests/status.xml?command=snapshot', parse_status );}function hotkey( str ){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -