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 );
function check_and_replace_int( id, val )
{
- var objRegExp = /^\d\d*$/;
+ var objRegExp = /^\d+$/;
if( value( id ) != ''
&& ( !objRegExp.test( value( id ) )
|| parseInt( value( id ) ) < 1 ) )
var randomtag = status.getElementsByTagName( 'random' );
if( randomtag.length > 0 ? randomtag[0].firstChild.data == "1" : 0)
- document.getElementById( 'btn_shuffle').setAttribute( 'class', 'on' );
+ setclass( document.getElementById( 'btn_shuffle'), 'on' );
else
- document.getElementById( 'btn_shuffle').setAttribute( 'class', 'off' );
+ setclass( document.getElementById( 'btn_shuffle'), 'off' );
var looptag = status.getElementsByTagName( 'loop' );
if( looptag.length > 0 ? looptag[0].firstChild.data == "1" : 0)
- document.getElementById( 'btn_loop').setAttribute( 'class', 'on' );
+ setclass( document.getElementById( 'btn_loop'), 'on' );
else
- document.getElementById( 'btn_loop').setAttribute( 'class', 'off' );
+ setclass( document.getElementById( 'btn_loop'), 'off' );
var repeattag = status.getElementsByTagName( 'repeat' );
if( repeattag.length > 0 ? repeattag[0].firstChild.data == "1" : 0 )
- document.getElementById( 'btn_repeat').setAttribute( 'class', 'on' );
+ setclass( document.getElementById( 'btn_repeat'), 'on' );
else
- document.getElementById( 'btn_repeat').setAttribute( 'class', 'off' );
+ setclass( document.getElementById( 'btn_repeat'), 'off' );
var tree = document.createElement( "ul" );
var categories = status.getElementsByTagName( 'category' );
}
var nd = document.createElement( "div" );
- nd.setAttribute( 'class', 'pl_node' );
+ setclass( nd, 'pl_node' );
nd.setAttribute( 'id', 'pl_'+elt.getAttribute( 'id' ) );
pos.appendChild( nd );
}
if( pos.hasChildNodes() )
pos.appendChild( document.createElement( "br" ) );
var pl = document.createElement( "a" );
- pl.setAttribute( 'class', 'pl_leaf' );
+ setclass( pl, 'pl_leaf' );
pl.setAttribute( 'href', 'javascript:pl_play('+elt.getAttribute( 'id' )+');' );
pl.setAttribute( 'id', 'pl_'+elt.getAttribute( 'id' ) );
if( elt.getAttribute( 'current' ) == 'current' )
{
- pl.setAttribute( 'style', 'font-weight: bold;' );
+ pl.style.fontWeight = 'bold';
var nowplaying = document.getElementById( 'nowplaying' );
clear_children( nowplaying );
nowplaying.appendChild( document.createTextNode( elt.getAttribute( 'name' ) ) );
if( elt.nodeName == "element" )
{
var item = document.createElement( "a" );
- item.setAttribute( 'class', 'browser' );
+ setclass( item, 'browser' );
if( elt.getAttribute( 'type' ) == 'directory' )
{
item.setAttribute( 'href', 'javascript:browse_dir(\''+escapebackslashes(addslashes(elt.getAttribute( 'path' )))+'\');');
{
pos.appendChild( document.createTextNode( ' ' ) );
var item = document.createElement( "a" );
- item.setAttribute( 'class', 'browser' );
+ setclass( item, 'browser' );
item.setAttribute( 'href', 'javascript:browse_path(\''+escapebackslashes(addslashes(elt.getAttribute( 'path' )))+'\');');
item.appendChild( document.createTextNode( '(select)' ) );
pos.appendChild( item );
{
var mdt = document.createElement( 'div' );
mdt.setAttribute( 'id', 'mosaic_dt' );
- mdt.setAttribute( 'class', 'mosaic_tbl' );
+ setclass( mdt, 'mosaic_tbl' );
mdt.style.width = mosaic_width + "px";
mdt.style.height = mosaic_height + "px";
for( x = 0; x < mosaic_cols; x++ )
{
var mcell = document.createElement( 'td' );
- mcell.setAttribute( 'class', 'mosaic_itm' );
+ setclass( mcell, 'mosaic_itm' );
mcell.style.width = cell_width + "px";
mcell.style.height = cell_height + "px";
- var melt = document.createElement( 'input' );
- melt.setAttribute( 'type', 'button' );
var id = x+'_'+y;
+ var melt = create_button( cells[id] ? cells[id] : '?', 'mosaic_elt_choose(\"'+id+'\");' );
melt.setAttribute( 'id', id );
- melt.setAttribute( 'onclick', 'mosaic_elt_choose(\''+id+'\');' );
- if( cells[id] )
- melt.setAttribute( 'value', cells[id] );
- else
- melt.setAttribute( 'value', '?' );
melt.setAttribute( 'title', 'Click to choose stream' );
mcell.appendChild( melt );
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 )
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 );
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' )
{
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' ) + '");' ) );