Skip to content

Commit

Permalink
status
Browse files Browse the repository at this point in the history
  • Loading branch information
octatone committed Aug 19, 2012
1 parent 7fac21c commit bea90bb
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 77 deletions.
34 changes: 17 additions & 17 deletions index.html
Expand Up @@ -45,21 +45,21 @@
<div id="header"> <div id="header">
&nbsp; &nbsp;
<div id="options"> <div id="options">
<ul id="css" class="right"> <ul id="css" class="right">
<li><a href="#" rel="light">light</a></li> <li><a href="#" rel="light">light</a></li>
<li><a href="#" rel="dark">dark</a></li> <li><a href="#" rel="dark">dark</a></li>
</ul> </ul>


<form class="right"> <form class="right">
<input type="checkbox" id="auto" checked/> <input type="checkbox" id="auto" checked/>
<label for="auto">autoplay/advance</label> <label for="auto">autoplay/advance</label>
<input type="checkbox" id="shuffle"/> <input type="checkbox" id="shuffle"/>
<label for="auto">shuffle</label> <label for="auto">shuffle</label>
<input type="checkbox" id="fill"/> <input type="checkbox" id="fill"/>
<label for="fill">fill screen</label> <label for="fill">fill screen</label>
<input type="checkbox" id="sfw" checked/> <input type="checkbox" id="sfw" checked/>
<label for="sfw">sfw</label> <label for="sfw">sfw</label>
</form> </form>
</div> </div>
</div> </div>
<div id="sidebar"> <div id="sidebar">
Expand All @@ -75,7 +75,7 @@
<a href="http://americancensorship.org" target="_blank">STOP CENSORSHIP</a> <a href="http://americancensorship.org" target="_blank">STOP CENSORSHIP</a>
<br/> <br/>
<br/><a href="http://reddit.com/r/reddit_tv" target="_blank" title="reddit.tv on reddit - bug reports, feature requests, channel suggestions">/r/reddit_tv</a> <br/><a href="http://reddit.com/r/reddit_tv" target="_blank" title="reddit.tv on reddit - bug reports, feature requests, channel suggestions">/r/reddit_tv</a>
<br/> <br/>
<br/><a href="https://github.com/octatone/reddit.tv" title="help improve reddit.tv" target="_blank">source</a> <br/><a href="https://github.com/octatone/reddit.tv" title="help improve reddit.tv" target="_blank">source</a>
<br/> <br/>
<br/><a href="mailto:marketing@reddit.com?subject=reddit.tv%20inquiry" title="advertise on reddit.tv" target="_blank">advertise</a> <br/><a href="mailto:marketing@reddit.com?subject=reddit.tv%20inquiry" title="advertise on reddit.tv" target="_blank">advertise</a>
Expand All @@ -86,9 +86,9 @@
<div id="video-embed"></div> <div id="video-embed"></div>
<div id="video-source"></div> <div id="video-source"></div>
<div id="video-nav"> <div id="video-nav">
<a id="prev-button" class="nav-button">&lt; PREV</a> <a id="prev-button" class="nav-button">&lt; PREV</a>
<a id="next-button" class="nav-button">NEXT &gt;</a> <a id="next-button" class="nav-button">NEXT &gt;</a>
<div id="vote-button"></div> <div id="vote-button"></div>
</div> </div>
<div id="video-list"></div> <div id="video-list"></div>
</div> </div>
Expand Down
127 changes: 67 additions & 60 deletions js/tv.js
@@ -1,13 +1,14 @@
/* Globals */ /* Globals */
var Globals = { var Globals = {
/* build uri for search type channels */ /* build uri for search type channels */
search_str: (function(){ search_str: (function () {
var one_day = 86400,
var one_day = 86400,
date = new Date(), date = new Date(),
unixtime_ms = date.getTime(), unixtime_ms = date.getTime(),
unixtime = parseInt(unixtime_ms / 1000); unixtime = parseInt(unixtime_ms / 1000);
return "search/.json?q=%28and+%28or+site%3A%27youtube.com%27+site%3A%27vimeo.com%27+site%3A%27youtu.be%27%29+timestamp%3A"+(unixtime - 5*one_day)+"..%29&restrict_sr=on&sort=top&syntax=cloudsearch"; return "search/.json?q=%28and+%28or+site%3A%27youtube.com%27+site%3A%27vimeo.com%27+site%3A%27youtu.be%27%29+timestamp%3A"+(unixtime - 5*one_day)+"..%29&restrict_sr=on&sort=top&syntax=cloudsearch";
})(), })(),


/* Channels Object */ /* Channels Object */
channels: [ channels: [
Expand All @@ -26,30 +27,30 @@ var Globals = {
{channel: 'Politics', type: 'search', feed: '/r/politics/'}, {channel: 'Politics', type: 'search', feed: '/r/politics/'},
{channel: 'Atheism', type: 'search', feed: '/r/atheism/'}, {channel: 'Atheism', type: 'search', feed: '/r/atheism/'},
{channel: 'Sports', type: 'normal', feed: '/r/sports/'} {channel: 'Sports', type: 'normal', feed: '/r/sports/'}
], ],


/* Video Domains */ /* Video Domains */
domains: [ domains: [
'5min.com', 'abcnews.go.com', 'animal.discovery.com', 'animoto.com', 'atom.com', '5min.com', 'abcnews.go.com', 'animal.discovery.com', 'animoto.com', 'atom.com',
'bambuser.com', 'bigthink.com', 'blip.tv', 'break.com', 'bambuser.com', 'bigthink.com', 'blip.tv', 'break.com',
'cbsnews.com', 'cnbc.com', 'cnn.com', 'colbertnation.com', 'collegehumor.com', 'cbsnews.com', 'cnbc.com', 'cnn.com', 'colbertnation.com', 'collegehumor.com',
'comedycentral.com', 'crackle.com', 'dailymotion.com', 'dsc.discovery.com', 'discovery.com', 'comedycentral.com', 'crackle.com', 'dailymotion.com', 'dsc.discovery.com', 'discovery.com',
'dotsub.com', 'edition.cnn.com', 'escapistmagazine.com', 'espn.go.com', 'dotsub.com', 'edition.cnn.com', 'escapistmagazine.com', 'espn.go.com',
'fancast.com', 'flickr.com', 'fora.tv', 'foxsports.com', 'fancast.com', 'flickr.com', 'fora.tv', 'foxsports.com',
'funnyordie.com', 'gametrailers.com', 'godtube.com', 'howcast.com', 'hulu.com', 'funnyordie.com', 'gametrailers.com', 'godtube.com', 'howcast.com', 'hulu.com',
'justin.tv', 'kinomap.com', 'koldcast.tv', 'liveleak.com', 'livestream.com', 'justin.tv', 'kinomap.com', 'koldcast.tv', 'liveleak.com', 'livestream.com',
'mediamatters.org', 'metacafe.com', 'money.cnn.com', 'mediamatters.org', 'metacafe.com', 'money.cnn.com',
'movies.yahoo.com', 'msnbc.com', 'nfb.ca', 'nzonscreen.com', 'movies.yahoo.com', 'msnbc.com', 'nfb.ca', 'nzonscreen.com',
'overstream.net', 'photobucket.com', 'qik.com', 'redux.com', 'overstream.net', 'photobucket.com', 'qik.com', 'redux.com',
'revision3.com', 'revver.com', 'schooltube.com', 'revision3.com', 'revver.com', 'schooltube.com',
'screencast.com', 'screenr.com', 'sendables.jibjab.com', 'screencast.com', 'screenr.com', 'sendables.jibjab.com',
'spike.com', 'teachertube.com', 'techcrunch.tv', 'ted.com', 'spike.com', 'teachertube.com', 'techcrunch.tv', 'ted.com',
'thedailyshow.com', 'theonion.com', 'traileraddict.com', 'trailerspy.com', 'thedailyshow.com', 'theonion.com', 'traileraddict.com', 'trailerspy.com',
'trutv.com', 'twitvid.com', 'ustream.com', 'viddler.com', 'video.google.com', 'trutv.com', 'twitvid.com', 'ustream.com', 'viddler.com', 'video.google.com',
'video.nationalgeographic.com', 'video.pbs.org', 'video.yahoo.com', 'vids.myspace.com', 'vimeo.com', 'video.nationalgeographic.com', 'video.pbs.org', 'video.yahoo.com', 'vids.myspace.com', 'vimeo.com',
'wordpress.tv', 'worldstarhiphop.com', 'xtranormal.com', 'wordpress.tv', 'worldstarhiphop.com', 'xtranormal.com',
'youtube.com', 'youtu.be', 'zapiks.com' 'youtube.com', 'youtu.be', 'zapiks.com'
], ],


videos: [], videos: [],
user_channels: [], user_channels: [],
Expand All @@ -67,11 +68,11 @@ var Globals = {
content_minwidth: 130, // minimum width of #content w/o width of player content_minwidth: 130, // minimum width of #content w/o width of player
content_minheight: 320, // minimum height of #content w/o height of player content_minheight: 320, // minimum height of #content w/o height of player
vd_minwidth: 30, // minimum width of #video-display w/o width of player vd_minwidth: 30, // minimum width of #video-display w/o width of player
vd_minheight: 213, // minimum height of #video-display w/o height of player vd_minheight: 213 // minimum height of #video-display w/o height of player
}; };


/* MAIN (Document Ready) */ /* MAIN (Document Ready) */
$().ready(function(){ $().ready(function(){
loadSettings(); loadSettings();
loadTheme(Globals.theme); loadTheme(Globals.theme);
displayChannels(); displayChannels();
Expand All @@ -88,7 +89,7 @@ $().ready(function(){
$fillnav.click(function(){ $fillnav.click(function(){
fillScreen(); fillScreen();
}); });
$('#css li a').click(function() { $('#css li a').click(function() {
loadTheme($(this).attr('rel')); loadTheme($(this).attr('rel'));
return false; return false;
}); });
Expand Down Expand Up @@ -125,7 +126,7 @@ $().ready(function(){
this.scrollLeft -= (delta * 30); this.scrollLeft -= (delta * 30);
}); });
$(document).keydown(function (e) { $(document).keydown(function (e) {
if(!$(e.target).is('form>*')) { if(!$(e.target).is('form>*')) {
var keyCode = e.keyCode || e.which, arrow = {left: 37, up: 38, right: 39, down: 40 }; var keyCode = e.keyCode || e.which, arrow = {left: 37, up: 38, right: 39, down: 40 };
switch (keyCode) { switch (keyCode) {
case arrow.left: case 72: // h case arrow.left: case 72: // h
Expand Down Expand Up @@ -183,9 +184,9 @@ $().ready(function(){
/* Main Functions */ /* Main Functions */
function loadSettings() { function loadSettings() {
var channels_cookie = $.jStorage.get('user_channels'), var channels_cookie = $.jStorage.get('user_channels'),
auto_cookie = $.jStorage.get('auto'), auto_cookie = $.jStorage.get('auto'),
sfw_cookie = $.jStorage.get('sfw'), sfw_cookie = $.jStorage.get('sfw'),
theme_cookie = $.jStorage.get('theme'), theme_cookie = $.jStorage.get('theme'),
shuffle_cookie = $.jStorage.get('shuffle'); shuffle_cookie = $.jStorage.get('shuffle');


if(auto_cookie !== null && auto_cookie !== Globals.auto){ if(auto_cookie !== null && auto_cookie !== Globals.auto){
Expand Down Expand Up @@ -371,7 +372,9 @@ function loadVideoList(chan) {
$thumbnail $thumbnail
.attr('src', 'img/noimage.png') .attr('src', 'img/noimage.png')
.attr('data-original', getThumbnailUrl(this_chan, i)) .attr('data-original', getThumbnailUrl(this_chan, i))
.click(function() { loadVideo( Number($(this).attr('rel')) ); }); .click( function () {
loadVideo( Number( $(this).attr('rel') ));
});


$list.append($thumbnail); $list.append($thumbnail);
} }
Expand All @@ -391,7 +394,7 @@ function loadVideoList(chan) {
function loadVideo(video) { function loadVideo(video) {
var this_chan = Globals.cur_chan, var this_chan = Globals.cur_chan,
this_video = Globals.cur_video, this_video = Globals.cur_video,
selected_video = this_video, selected_video = this_video,
videos_size = Object.size(Globals.videos[this_chan].video)-1; videos_size = Object.size(Globals.videos[this_chan].video)-1;


if(Globals.shuffle){ if(Globals.shuffle){
Expand Down Expand Up @@ -509,10 +512,10 @@ function loadVideo(video) {
$vote_button.html(reddit_string).fadeTo('slow', 1); $vote_button.html(reddit_string).fadeTo('slow', 1);
}); });


var video_source_text = 'Source: ' var video_source_text = 'Source: ' +
+ '<a href="' + Globals.videos[this_chan].video[selected_video].url + '" target="_blank">' '<a href="' + Globals.videos[this_chan].video[selected_video].url + '" target="_blank">' +
+ Globals.videos[this_chan].video[selected_video].domain Globals.videos[this_chan].video[selected_video].domain +
+ '</a>'; '</a>';
var $video_source = $('#video-source'); var $video_source = $('#video-source');
$video_source.stop(true,true).fadeOut('slow', function() { $video_source.stop(true,true).fadeOut('slow', function() {
$video_source.html(video_source_text).fadeIn('slow'); $video_source.html(video_source_text).fadeIn('slow');
Expand Down Expand Up @@ -548,17 +551,17 @@ function loadVideoById(video_id) {
dataType: "jsonp", dataType: "jsonp",
jsonp: "jsonp", jsonp: "jsonp",
success: function(data) { success: function(data) {
if(!isEmpty(data.data.children[0].data.media_embed) if (!isEmpty(data.data.children[0].data.media_embed) && isVideo(data.data.children[0].data.media.type)) {
&& isVideo(data.data.children[0].data.media.type)
)
{
Globals.videos[this_chan].video.splice(0,0,data.data.children[0].data); Globals.videos[this_chan].video.splice(0,0,data.data.children[0].data);
} }

loadVideoList(this_chan); loadVideoList(this_chan);
loadVideo('first'); loadVideo('first');
}, },
error: function(jXHR, textStatus, errorThrown) { error: function (jXHR, textStatus, errorThrown) {
if(textStatus !== 'abort'){ if (textStatus !== 'abort') {

alert('Could not load data. Is reddit down?'); alert('Could not load data. Is reddit down?');
} }
} }
Expand Down Expand Up @@ -590,7 +593,8 @@ function loadPromo(type, id, desc){
} }


created = createEmbed(url, domain); created = createEmbed(url, domain);
if(created !== false){ if (created !== false) {

embed = prepEmbed($.unescapifyHTML(created.embed), domain); embed = prepEmbed($.unescapifyHTML(created.embed), domain);
embed = prepEmbed(embed, 'size'); embed = prepEmbed(embed, 'size');


Expand All @@ -604,26 +608,27 @@ function loadPromo(type, id, desc){


addListeners(domain); addListeners(domain);


var video_source_text = 'Source: ' var video_source_text = 'Source: ' + '<a href="' + url + '" target="_blank">' + domain + '</a>';
+ '<a href="' + url + '" target="_blank">'
+ domain
+ '</a>';
var $video_source = $('#video-source'); var $video_source = $('#video-source');
$video_source.stop(true,true).fadeOut('slow', function() { $video_source.stop(true,true).fadeOut('slow', function() {
$video_source.html(video_source_text).fadeIn('slow'); $video_source.html(video_source_text).fadeIn('slow');
}); });

}
else {


}else{
consoleLog('unable to create promo embed'); consoleLog('unable to create promo embed');
} }
} }


function isVideo(video_domain) { function isVideo (video_domain) {

return (Globals.domains.indexOf(video_domain) !== -1); return (Globals.domains.indexOf(video_domain) !== -1);
} }


//http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/ //http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/
function filterVideoDupes(arr){ function filterVideoDupes (arr) {

var i, out=[], obj={}, original_length = arr.length; var i, out=[], obj={}, original_length = arr.length;


//work from last video to first video (so hottest dupe is left standing) //work from last video to first video (so hottest dupe is left standing)
Expand Down Expand Up @@ -802,8 +807,9 @@ function prepEmbed(embed, type){


} }


function addListeners(type){ function addListeners (type) {
switch(type){
switch (type) {
case 'vimeo.com': case 'vimeo.com':
vimeo.addListeners(); vimeo.addListeners();
} }
Expand Down Expand Up @@ -850,8 +856,8 @@ function resizePlayer() {


curr_player_width = player.width(); curr_player_width = player.width();
curr_player_height = player.height(); curr_player_height = player.height();
win_width = $(window).width() win_width = $(window).width();
win_height = $(window).height() win_height = $(window).height();


// consoleLog('content_min size: ' + (Globals.content_minwidth+curr_player_width) + 'x' + (Globals.content_minheight+curr_player_height)); // consoleLog('content_min size: ' + (Globals.content_minwidth+curr_player_width) + 'x' + (Globals.content_minheight+curr_player_height));
// consoleLog('vd_min size: ' + (Globals.vd_minwidth+curr_player_width) + 'x' + (Globals.vd_minheight+curr_player_height)); // consoleLog('vd_min size: ' + (Globals.vd_minwidth+curr_player_width) + 'x' + (Globals.vd_minheight+curr_player_height));
Expand Down Expand Up @@ -923,7 +929,8 @@ function addChannel(subreddit){
function removeChan(chan){ //by index (integer) function removeChan(chan){ //by index (integer)
var idx = getUserChan(Globals.channels[chan].channel); var idx = getUserChan(Globals.channels[chan].channel);
if(idx){ if(idx){
if(parseInt(chan) === parseInt(Globals.cur_chan)){ if (parseInt(chan) === parseInt(Globals.cur_chan)) {

chgChan('up'); chgChan('up');
} }
$('#channel-'+chan).remove(); $('#channel-'+chan).remove();
Expand All @@ -937,7 +944,7 @@ function removeChan(chan){ //by index (integer)
} }
} }


function shuffleChan(chan){ //by index (integer function shuffleChan (chan) { //by index (integer
/* /*
does not shuffle actual video array does not shuffle actual video array
but rather creates a global array of shuffled keys but rather creates a global array of shuffled keys
Expand Down Expand Up @@ -1049,9 +1056,9 @@ Object.size = function(obj) {
}; };




function stripHTML(s) { function stripHTML (s) {
return s.replace(/[&<>"'\/]/g, ''); return s.replace(/[&<>"'\/]/g, '');
}; }


/* analytics */ /* analytics */
function gaHashTrack(){ function gaHashTrack(){
Expand Down

0 comments on commit bea90bb

Please sign in to comment.