Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

status

  • Loading branch information...
commit bea90bbd211e352f986610a361aee1d70dcf5dcb 1 parent 7fac21c
@octatone authored
Showing with 84 additions and 77 deletions.
  1. +17 −17 index.html
  2. +67 −60 js/tv.js
View
34 index.html
@@ -45,21 +45,21 @@
<div id="header">
&nbsp;
<div id="options">
- <ul id="css" class="right">
- <li><a href="#" rel="light">light</a></li>
- <li><a href="#" rel="dark">dark</a></li>
- </ul>
+ <ul id="css" class="right">
+ <li><a href="#" rel="light">light</a></li>
+ <li><a href="#" rel="dark">dark</a></li>
+ </ul>
- <form class="right">
- <input type="checkbox" id="auto" checked/>
- <label for="auto">autoplay/advance</label>
+ <form class="right">
+ <input type="checkbox" id="auto" checked/>
+ <label for="auto">autoplay/advance</label>
<input type="checkbox" id="shuffle"/>
- <label for="auto">shuffle</label>
- <input type="checkbox" id="fill"/>
- <label for="fill">fill screen</label>
- <input type="checkbox" id="sfw" checked/>
- <label for="sfw">sfw</label>
- </form>
+ <label for="auto">shuffle</label>
+ <input type="checkbox" id="fill"/>
+ <label for="fill">fill screen</label>
+ <input type="checkbox" id="sfw" checked/>
+ <label for="sfw">sfw</label>
+ </form>
</div>
</div>
<div id="sidebar">
@@ -75,7 +75,7 @@
<a href="http://americancensorship.org" target="_blank">STOP CENSORSHIP</a>
<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/>
+ <br/>
<br/><a href="https://github.com/octatone/reddit.tv" title="help improve reddit.tv" target="_blank">source</a>
<br/>
<br/><a href="mailto:marketing@reddit.com?subject=reddit.tv%20inquiry" title="advertise on reddit.tv" target="_blank">advertise</a>
@@ -86,9 +86,9 @@
<div id="video-embed"></div>
<div id="video-source"></div>
<div id="video-nav">
- <a id="prev-button" class="nav-button">&lt; PREV</a>
- <a id="next-button" class="nav-button">NEXT &gt;</a>
- <div id="vote-button"></div>
+ <a id="prev-button" class="nav-button">&lt; PREV</a>
+ <a id="next-button" class="nav-button">NEXT &gt;</a>
+ <div id="vote-button"></div>
</div>
<div id="video-list"></div>
</div>
View
127 js/tv.js
@@ -1,13 +1,14 @@
/* Globals */
var Globals = {
/* build uri for search type channels */
- search_str: (function(){
- var one_day = 86400,
+ search_str: (function () {
+
+ var one_day = 86400,
date = new Date(),
unixtime_ms = date.getTime(),
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: [
@@ -26,30 +27,30 @@ var Globals = {
{channel: 'Politics', type: 'search', feed: '/r/politics/'},
{channel: 'Atheism', type: 'search', feed: '/r/atheism/'},
{channel: 'Sports', type: 'normal', feed: '/r/sports/'}
- ],
+ ],
/* Video Domains */
domains: [
'5min.com', 'abcnews.go.com', 'animal.discovery.com', 'animoto.com', 'atom.com',
'bambuser.com', 'bigthink.com', 'blip.tv', 'break.com',
- 'cbsnews.com', 'cnbc.com', 'cnn.com', 'colbertnation.com', 'collegehumor.com',
- 'comedycentral.com', 'crackle.com', 'dailymotion.com', 'dsc.discovery.com', 'discovery.com',
- 'dotsub.com', 'edition.cnn.com', 'escapistmagazine.com', 'espn.go.com',
- 'fancast.com', 'flickr.com', 'fora.tv', 'foxsports.com',
- 'funnyordie.com', 'gametrailers.com', 'godtube.com', 'howcast.com', 'hulu.com',
- 'justin.tv', 'kinomap.com', 'koldcast.tv', 'liveleak.com', 'livestream.com',
- 'mediamatters.org', 'metacafe.com', 'money.cnn.com',
- 'movies.yahoo.com', 'msnbc.com', 'nfb.ca', 'nzonscreen.com',
- 'overstream.net', 'photobucket.com', 'qik.com', 'redux.com',
- 'revision3.com', 'revver.com', 'schooltube.com',
- 'screencast.com', 'screenr.com', 'sendables.jibjab.com',
- 'spike.com', 'teachertube.com', 'techcrunch.tv', 'ted.com',
- 'thedailyshow.com', 'theonion.com', 'traileraddict.com', 'trailerspy.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',
- 'wordpress.tv', 'worldstarhiphop.com', 'xtranormal.com',
- 'youtube.com', 'youtu.be', 'zapiks.com'
- ],
+ 'cbsnews.com', 'cnbc.com', 'cnn.com', 'colbertnation.com', 'collegehumor.com',
+ 'comedycentral.com', 'crackle.com', 'dailymotion.com', 'dsc.discovery.com', 'discovery.com',
+ 'dotsub.com', 'edition.cnn.com', 'escapistmagazine.com', 'espn.go.com',
+ 'fancast.com', 'flickr.com', 'fora.tv', 'foxsports.com',
+ 'funnyordie.com', 'gametrailers.com', 'godtube.com', 'howcast.com', 'hulu.com',
+ 'justin.tv', 'kinomap.com', 'koldcast.tv', 'liveleak.com', 'livestream.com',
+ 'mediamatters.org', 'metacafe.com', 'money.cnn.com',
+ 'movies.yahoo.com', 'msnbc.com', 'nfb.ca', 'nzonscreen.com',
+ 'overstream.net', 'photobucket.com', 'qik.com', 'redux.com',
+ 'revision3.com', 'revver.com', 'schooltube.com',
+ 'screencast.com', 'screenr.com', 'sendables.jibjab.com',
+ 'spike.com', 'teachertube.com', 'techcrunch.tv', 'ted.com',
+ 'thedailyshow.com', 'theonion.com', 'traileraddict.com', 'trailerspy.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',
+ 'wordpress.tv', 'worldstarhiphop.com', 'xtranormal.com',
+ 'youtube.com', 'youtu.be', 'zapiks.com'
+ ],
videos: [],
user_channels: [],
@@ -67,11 +68,11 @@ var Globals = {
content_minwidth: 130, // minimum width of #content w/o width 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_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) */
-$().ready(function(){
+$().ready(function(){
loadSettings();
loadTheme(Globals.theme);
displayChannels();
@@ -88,7 +89,7 @@ $().ready(function(){
$fillnav.click(function(){
fillScreen();
});
- $('#css li a').click(function() {
+ $('#css li a').click(function() {
loadTheme($(this).attr('rel'));
return false;
});
@@ -125,7 +126,7 @@ $().ready(function(){
this.scrollLeft -= (delta * 30);
});
$(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 };
switch (keyCode) {
case arrow.left: case 72: // h
@@ -183,9 +184,9 @@ $().ready(function(){
/* Main Functions */
function loadSettings() {
var channels_cookie = $.jStorage.get('user_channels'),
- auto_cookie = $.jStorage.get('auto'),
- sfw_cookie = $.jStorage.get('sfw'),
- theme_cookie = $.jStorage.get('theme'),
+ auto_cookie = $.jStorage.get('auto'),
+ sfw_cookie = $.jStorage.get('sfw'),
+ theme_cookie = $.jStorage.get('theme'),
shuffle_cookie = $.jStorage.get('shuffle');
if(auto_cookie !== null && auto_cookie !== Globals.auto){
@@ -371,7 +372,9 @@ function loadVideoList(chan) {
$thumbnail
.attr('src', 'img/noimage.png')
.attr('data-original', getThumbnailUrl(this_chan, i))
- .click(function() { loadVideo( Number($(this).attr('rel')) ); });
+ .click( function () {
+ loadVideo( Number( $(this).attr('rel') ));
+ });
$list.append($thumbnail);
}
@@ -391,7 +394,7 @@ function loadVideoList(chan) {
function loadVideo(video) {
var this_chan = Globals.cur_chan,
this_video = Globals.cur_video,
- selected_video = this_video,
+ selected_video = this_video,
videos_size = Object.size(Globals.videos[this_chan].video)-1;
if(Globals.shuffle){
@@ -509,10 +512,10 @@ function loadVideo(video) {
$vote_button.html(reddit_string).fadeTo('slow', 1);
});
- var video_source_text = 'Source: '
- + '<a href="' + Globals.videos[this_chan].video[selected_video].url + '" target="_blank">'
- + Globals.videos[this_chan].video[selected_video].domain
- + '</a>';
+ var video_source_text = 'Source: ' +
+ '<a href="' + Globals.videos[this_chan].video[selected_video].url + '" target="_blank">' +
+ Globals.videos[this_chan].video[selected_video].domain +
+ '</a>';
var $video_source = $('#video-source');
$video_source.stop(true,true).fadeOut('slow', function() {
$video_source.html(video_source_text).fadeIn('slow');
@@ -548,17 +551,17 @@ function loadVideoById(video_id) {
dataType: "jsonp",
jsonp: "jsonp",
success: function(data) {
- if(!isEmpty(data.data.children[0].data.media_embed)
- && isVideo(data.data.children[0].data.media.type)
- )
- {
+ if (!isEmpty(data.data.children[0].data.media_embed) && isVideo(data.data.children[0].data.media.type)) {
+
Globals.videos[this_chan].video.splice(0,0,data.data.children[0].data);
}
+
loadVideoList(this_chan);
loadVideo('first');
},
- error: function(jXHR, textStatus, errorThrown) {
- if(textStatus !== 'abort'){
+ error: function (jXHR, textStatus, errorThrown) {
+ if (textStatus !== 'abort') {
+
alert('Could not load data. Is reddit down?');
}
}
@@ -590,7 +593,8 @@ function loadPromo(type, id, desc){
}
created = createEmbed(url, domain);
- if(created !== false){
+ if (created !== false) {
+
embed = prepEmbed($.unescapifyHTML(created.embed), domain);
embed = prepEmbed(embed, 'size');
@@ -604,26 +608,27 @@ function loadPromo(type, id, desc){
addListeners(domain);
- var video_source_text = 'Source: '
- + '<a href="' + url + '" target="_blank">'
- + domain
- + '</a>';
+ var video_source_text = 'Source: ' + '<a href="' + url + '" target="_blank">' + domain + '</a>';
var $video_source = $('#video-source');
$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');
}
}
-function isVideo(video_domain) {
+function isVideo (video_domain) {
+
return (Globals.domains.indexOf(video_domain) !== -1);
}
//http://dreaminginjavascript.wordpress.com/2008/08/22/eliminating-duplicates/
-function filterVideoDupes(arr){
+function filterVideoDupes (arr) {
+
var i, out=[], obj={}, original_length = arr.length;
//work from last video to first video (so hottest dupe is left standing)
@@ -802,8 +807,9 @@ function prepEmbed(embed, type){
}
-function addListeners(type){
- switch(type){
+function addListeners (type) {
+
+ switch (type) {
case 'vimeo.com':
vimeo.addListeners();
}
@@ -850,8 +856,8 @@ function resizePlayer() {
curr_player_width = player.width();
curr_player_height = player.height();
- win_width = $(window).width()
- win_height = $(window).height()
+ win_width = $(window).width();
+ win_height = $(window).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));
@@ -923,7 +929,8 @@ function addChannel(subreddit){
function removeChan(chan){ //by index (integer)
var idx = getUserChan(Globals.channels[chan].channel);
if(idx){
- if(parseInt(chan) === parseInt(Globals.cur_chan)){
+ if (parseInt(chan) === parseInt(Globals.cur_chan)) {
+
chgChan('up');
}
$('#channel-'+chan).remove();
@@ -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
but rather creates a global array of shuffled keys
@@ -1049,9 +1056,9 @@ Object.size = function(obj) {
};
-function stripHTML(s) {
+function stripHTML (s) {
return s.replace(/[&<>"'\/]/g, '');
-};
+}
/* analytics */
function gaHashTrack(){
Please sign in to comment.
Something went wrong with that request. Please try again.