diff --git a/lsp/functions.js b/lsp/functions.js index d6949bb6..934b03e0 100644 --- a/lsp/functions.js +++ b/lsp/functions.js @@ -190,7 +190,7 @@ */ function parseURL(url) { - var pattern = /(https?)\:\/\/([^:\/]+)\:(\d+)?/; + var pattern = /(https?)\:\/\/([^:\/]+)\:(\d+)?/i; var retobj = {protocol: '', host: '', port: ''}; var results = url.match(pattern); @@ -391,14 +391,3 @@ } } - -/* - if(status == 1) - { - $(row.children()[3]).html("Running"); - } - $(row.children()[3]).html("" + (status == 0 ? 'Offline' : (!status ? 'Unknown, checking...' : status) ) + ""); - } - -*/ - diff --git a/lsp/main.js b/lsp/main.js index f3e56a1a..65eee688 100644 --- a/lsp/main.js +++ b/lsp/main.js @@ -1,12 +1,4 @@ - -/* WERKLOG todolist -// TODO FIXME remove deze comment als het klaar is -settings.settings.statistics[streamID].log (zelfde als curr maar log = gesloten connecties, dus ex-users -TODO als server het stuurt -*/ - - /** * Local settings page * DDVTECH @@ -102,7 +94,7 @@ TODO als server het stuurt { case 'login': - var host = $('').attr('type', 'text').attr('placeholder', 'HTTP://LOCALHOST:4242'); + var host = $('').attr('type', 'text').attr('placeholder', 'HTTP://' + (location.host == '' ? 'localhost:4242' : location.host) + '/api'); var user = $('').attr('type', 'text').attr('placeholder', 'USERNAME'); var pass = $('').attr('type', 'password').attr('placeholder', 'PASSWORD'); var conn = $('').click(function() @@ -438,14 +430,7 @@ TODO als server het stuurt { var row = $('#stream-' + stream); var status = streams[stream][0]; -/* - if(status == 1) - { - $(row.children()[3]).html("Running"); - } - $(row.children()[3]).html("" + (status == 0 ? 'Offline' : (!status ? 'Unknown, checking...' : status) ) + ""); - } -*/ + $(row.children()[3]).html( formatStatus(status) ); $(row.children()[4]).text(streams[stream][1]); @@ -485,16 +470,7 @@ TODO als server het stuurt $tr.append( $('').text(cstr.name) ); -/* - if(cstr.online && cstr.online == 1) - { - $tr.append( $('').html("Running") ); - }else{ - $tr.append( $('').html("" + (cstr.online == 0 ? 'Offline' : 'Unknown, checking...') + "") ); - } -*/ - $tr.append( $('').html( formatStatus( cstr.online ) ) ); - + $tr.append( $('').html( formatStatus( cstr.online ) ) ); var cviewers = 0; @@ -680,9 +656,10 @@ TODO als server het stuurt if(isThereAHTTPConnector()) { - var embed = 'http://' + parseURL(settings.server).host + ':8080/embed_' + streamname + '.js'; + var embedbase = 'http://' + parseURL(settings.server).host + ':8080/'; - $('#page').append( $('').attr('class', 'nocapitals').text('The embed URL is "' + embed + '".') ); + $('#page').append( $('').attr('class', 'nocapitals').text('The info embed URL is "' + embedbase + 'info_' + streamname + '.js".') ); + $('#page').append( $('').attr('class', 'nocapitals').text('The embed embed URL is "' + embedbase + 'embed_' + streamname + '.js".') ); $('#page').append( $('').text('preview').click(function() { @@ -701,7 +678,12 @@ TODO als server het stuurt var embed = 'http://' + parseURL(settings.server).host + ':8080/embed_' + streamname + '.js'; - $('#page').append( $('').html( "" ) ); + $('#page').append( $('').attr('id', 'previewcontainer') ); + + // jQuery doesn't work -> use DOM magic + var script = document.createElement('script'); + script.src = embed; + document.getElementById('previewcontainer').appendChild( script ); break; @@ -709,7 +691,6 @@ TODO als server het stuurt - case 'limits': $table = $(''); $table.html("TypeHard/softValueapplies toAction"); diff --git a/src/embed.js b/src/embed.js index 51c23b60..b2adba71 100644 --- a/src/embed.js +++ b/src/embed.js @@ -33,7 +33,7 @@ function mistembed(streamname) { case 'f4v': return supports.flashversion >= 11; break; case 'rtmp': return supports.flashversion >= 10; break; - case 'flv': return supports.flashversion >= 7; break; + case 'flv': return supports.flashversion >= 7; break; default: return false; } @@ -42,13 +42,16 @@ function mistembed(streamname) // build HTML for certain kinds of types function buildPlayer(src, container, videowidth, videoheight) { + // used to recalculate the width/height + var ratio; + // get the container's width/height var containerwidth = parseInt(container.scrollWidth, 10); var containerheight = parseInt(container.scrollHeight, 10); if(videowidth > containerwidth && containerwidth > 0) { - var ratio = videowidth / containerwidth; + ratio = videowidth / containerwidth; videowidth /= ratio; videoheight /= ratio; @@ -56,23 +59,26 @@ function mistembed(streamname) if(videoheight > containerheight && containerheight > 0) { - var ratio = videoheight / containerheight; + ratio = videoheight / containerheight; videowidth /= ratio; videoheight /= ratio; } - switch(src.type) { case 'f4v': case 'rtmp': case 'flv': - container.innerHTML = ''; + container.innerHTML = ''; + break; + + case 'fallback': + container.innerHTML = 'No support for any player found'; break; } - }; + }; @@ -108,7 +114,7 @@ function mistembed(streamname) if( hasSupport( video.source[i].type ) ) { // we support this kind of video, so build it. - buildPlayer(video.source[i], container, video.width, video.height); + buildPlayer(video.source[i], container.parentNode, video.width, video.height); // we've build a player, so we're done here foundPlayer = true; @@ -118,8 +124,8 @@ function mistembed(streamname) if(!foundPlayer) { - // of all the streams given, none was supported (eg. no flash and HTML5 video). Fall back. - container.innerHTML = 'fallback here'; + // of all the streams given, none was supported (eg. no flash and HTML5 video). Display error + buildPlayer({type: 'fallback'}, container.parentNode, video.width, video.height); } }
').attr('class', 'nocapitals').text('The embed URL is "' + embed + '".') ); + $('#page').append( $('
').attr('class', 'nocapitals').text('The info embed URL is "' + embedbase + 'info_' + streamname + '.js".') ); + $('#page').append( $('
').attr('class', 'nocapitals').text('The embed embed URL is "' + embedbase + 'embed_' + streamname + '.js".') ); $('#page').append( $('').text('preview').click(function() { @@ -701,7 +678,12 @@ TODO als server het stuurt var embed = 'http://' + parseURL(settings.server).host + ':8080/embed_' + streamname + '.js'; - $('#page').append( $('').html( "" ) ); + $('#page').append( $('').attr('id', 'previewcontainer') ); + + // jQuery doesn't work -> use DOM magic + var script = document.createElement('script'); + script.src = embed; + document.getElementById('previewcontainer').appendChild( script ); break; @@ -709,7 +691,6 @@ TODO als server het stuurt - case 'limits': $table = $(''); $table.html("TypeHard/softValueapplies toAction"); diff --git a/src/embed.js b/src/embed.js index 51c23b60..b2adba71 100644 --- a/src/embed.js +++ b/src/embed.js @@ -33,7 +33,7 @@ function mistembed(streamname) { case 'f4v': return supports.flashversion >= 11; break; case 'rtmp': return supports.flashversion >= 10; break; - case 'flv': return supports.flashversion >= 7; break; + case 'flv': return supports.flashversion >= 7; break; default: return false; } @@ -42,13 +42,16 @@ function mistembed(streamname) // build HTML for certain kinds of types function buildPlayer(src, container, videowidth, videoheight) { + // used to recalculate the width/height + var ratio; + // get the container's width/height var containerwidth = parseInt(container.scrollWidth, 10); var containerheight = parseInt(container.scrollHeight, 10); if(videowidth > containerwidth && containerwidth > 0) { - var ratio = videowidth / containerwidth; + ratio = videowidth / containerwidth; videowidth /= ratio; videoheight /= ratio; @@ -56,23 +59,26 @@ function mistembed(streamname) if(videoheight > containerheight && containerheight > 0) { - var ratio = videoheight / containerheight; + ratio = videoheight / containerheight; videowidth /= ratio; videoheight /= ratio; } - switch(src.type) { case 'f4v': case 'rtmp': case 'flv': - container.innerHTML = ''; + container.innerHTML = ''; + break; + + case 'fallback': + container.innerHTML = 'No support for any player found'; break; } - }; + }; @@ -108,7 +114,7 @@ function mistembed(streamname) if( hasSupport( video.source[i].type ) ) { // we support this kind of video, so build it. - buildPlayer(video.source[i], container, video.width, video.height); + buildPlayer(video.source[i], container.parentNode, video.width, video.height); // we've build a player, so we're done here foundPlayer = true; @@ -118,8 +124,8 @@ function mistembed(streamname) if(!foundPlayer) { - // of all the streams given, none was supported (eg. no flash and HTML5 video). Fall back. - container.innerHTML = 'fallback here'; + // of all the streams given, none was supported (eg. no flash and HTML5 video). Display error + buildPlayer({type: 'fallback'}, container.parentNode, video.width, video.height); } }