]> git.sesse.net Git - vlc/blobdiff - share/http/js/vlm.js
Add hide/show vlm helper button. Original idea by Albert (http://forum.videolan.org...
[vlc] / share / http / js / vlm.js
index 40c5df1933188d8439f6e4efedcae92ec4504125..2082c7bbe399ec07c122ee585e8074b28c01efd7 100644 (file)
@@ -28,6 +28,27 @@ 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;
@@ -262,10 +283,17 @@ function clear_vlm_add()
 
 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 )
@@ -327,7 +355,7 @@ function parse_vlm_elements()
                 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 );
@@ -340,41 +368,31 @@ function parse_vlm_elements()
                     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' )
                         {
@@ -515,28 +533,23 @@ function parse_vlm_elements()
                 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' ) + '");' ) );