]> git.sesse.net Git - vlc/blob - share/http/js/mosaic.js
begining of a VLM interface and some code organisations changes. The vlm
[vlc] / share / http / js / mosaic.js
1 /*****************************************************************************
2  * mosaic.js: VLC media player web interface - Mosaic specific functions
3  *****************************************************************************
4  * Copyright (C) 2005-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /**********************************************************************
25  * 
26  *********************************************************************/
27
28 function mosaic_size_change()
29 {
30     check_and_replace_int( "mosaic_rows", "1" );
31     mr = value( "mosaic_rows" );
32     check_and_replace_int( "mosaic_cols", "1" );
33     mc = value( "mosaic_cols" );
34     
35     mlayout = document.getElementById( "mosaic_layout" );
36     while( mlayout.hasChildNodes() )
37         mlayout.removeChild( mlayout.firstChild );
38
39     if( mc && mr )
40     {
41         for( y = 0; y < mr; y++ )
42         {
43             mrow = document.createElement( 'div' );
44             mrow.setAttribute( 'class', 'mosaic_row' );
45             for( x = 0; x < mc; x++ )
46             {
47                 melt = document.createElement( 'input' );
48                 melt.setAttribute( 'type', 'button' );
49                 melt.setAttribute( 'id', 'mosaic_'+x+'_'+y );
50                 melt.setAttribute( 'class', 'mosaic_element' );
51                 melt.setAttribute( 'onclick', 'mosaic_elt_choose(\'mosaic_'+x+'_'+y+'\');' );
52                 melt.setAttribute( 'value', '(click)' );
53                 mrow.appendChild( melt );
54             }
55             mlayout.appendChild( mrow );
56         }
57     }
58 }
59
60 function mosaic_add_input()
61 {
62     mlist = document.getElementById( "mosaic_list" );
63     minput = document.createElement( 'a' );
64     minput.setAttribute( 'href', 'javascript:mosaic_elt_select(\'mosaic_'+value('mosaic_input_name')+'\');');
65     minput.setAttribute( 'id', 'mosaic_'+value('mosaic_input_name') );
66     minput.setAttribute( 'value', value('mosaic_input') );
67     minput.setAttribute( 'title', value('mosaic_input') );
68     minputtxt = document.createTextNode( value('mosaic_input_name') );
69     minput.appendChild( minputtxt );
70     mlist.appendChild( minput );
71     mlist.appendChild( document.createElement( 'br' ) );
72 }
73
74 function mosaic_elt_select( id )
75 {
76     hide( 'mosaic_list' );
77     document.getElementById( document.getElementById( 'mosaic_list' ).value ).value =
78         document.getElementById( id ).getAttribute( 'value' );
79 }
80
81 function mosaic_elt_choose( id )
82 {
83     document.getElementById( 'mosaic_list' ).value = id;
84     show( 'mosaic_list' );
85 }