console.debug('gs script file'); // check stream types var videoType = false; var audioType = false; if ( paramYTLeft ) videoType = 'youtube'; else if ( $('img#gif').length ) videoType = 'gif'; else if ( $('video#gif').length ) videoType = 'video'; if ( paramYTRight ) audioType = 'youtube'; else if ( $('#audiostream').length ) audioType = 'audio'; console.debug('videoType', videoType, 'audioType', audioType); // youtube error handler function ytError(event) { var data = event.data; var msg = 'We could not load the requested Youtube video.'; if ( data == 2 ) msg = 'The Youtube video url is invalid.'; if ( data == 5 ) msg = 'The requested Youtube content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.'; if ( data == 100 ) msg = 'The Youtube video requested was not found. It has been removed or has been marked as private.'; if ( data == 101 || data == 150 ) msg = 'The owner of the requested Youtube video does not allow it to be played in embedded players or it is blocked for your region.'; $('
').text(msg).prependTo('body'); } // called by the maximize button, or programatically function maximizeVideo() { console.debug('maximizeVideo()'); if ( videoType == 'gif' ) { $('#gifarea a').attr('data-href', $('#gifarea a').attr('href')).removeAttr('href').attr('title', ''); $('#maxgif').css('display', 'block'); $('#gifarea img').addClass('maxgif').css('maxHeight', '100%').css('maxWidth', '100%'); $('#vidcover').hide(); } else if( videoType == 'video' ) { $('#maxgif').css('display', 'block'); // $('video#gif').addClass('maxgif').css('maxHeight', 'none').css('maxWidth', 'none'); $('video#gif').addClass('maxgif').css('maxHeight', '100%').css('maxWidth', '100%'); $('#vidcover,div.topnav').hide(); } else if( videoType == 'youtube' ) { $('#maxgif').css('display', 'block'); $('#leftplayer').addClass('maxgif'); $('#vidcover,div.topnav').hide(); lftplayer.setSize($('#maxgif').width()-10,$('#maxgif').height()-10); } // save preference to localStorage localStorage.setItem('maxgif', '1'); } // return player to normal size function unmaximizeVideo() { console.debug('unmaximizeVideo()'); if( videoType == 'gif' ) { $('#gifarea a').attr('href', $('#gifarea a').attr('data-href')).removeAttr('data-href').removeAttr('title'); $('#gifarea img').removeClass('maxgif'); $('#maxgif').css('display', 'none'); $('#vidcover').show(); } else if( videoType == 'video' ) { $('video#gif').removeClass('maxgif').css('maxHeight', '500px').css('maxWidth', '1000px'); $('#maxgif').css('display', 'none'); $('#vidcover,div.topnav').show(); } else if( videoType == 'youtube' ) { $('#leftplayer').removeClass('maxgif'); $('#maxgif').css('display', 'none'); $('#vidcover,div.topnav').show(); lftplayer.setSize(480, 270); } // remove pref from storage localStorage.removeItem('maxgif'); } // @todo remove alias function showmaxgif() { return maximizeVideo(); } // handler to receive events from button/player click function maxHandler(e) { if ( videoType == 'video' && $('video#gif').get(0).controls ) { return true; } // create placeholder if not called from event if ( typeof(e) == 'undefined' ) { e = { ctrlKey: false, preventDefault: function() {} }; } if ( ! e.ctrlKey ) { e.preventDefault(); if ( videoType == 'gif' ) { if ( $('#gifarea img').hasClass('maxgif') ) { unmaximizeVideo(); } else { maximizeVideo(); } } else if( videoType == 'video' ) { if ( $('video#gif').hasClass('maxgif') ) { unmaximizeVideo(); } else { maximizeVideo(); } } else if ( videoType == 'youtube' ) { if ( $('#leftplayer').hasClass('maxgif') ) { unmaximizeVideo(); } else { maximizeVideo(); } } } return false; } // load reddit iframes. called after everything else loads function loadReddit() { if (redditLoaded) return; redditLoaded = true; // if referrer url contains "anime" and does not contain "/r/gifsound" then instead of /r/gifsound widgets show /r/animegifsound widgets var subreddit = 'gifsound'; if (document.referrer.match(/anime/) && !document.referrer.match(/\/r\/gifsound/)) subreddit = 'animegifsound'; // redditHigh $.getJSON('https://www.reddit.com/r/' + subreddit + '/top/.json?limit=10&t=month&jsonp=?', function foo(result) { $.each(result.data.children.slice(0, 10), function (i, p) { var template1 = $('.template1:first').clone(); var post = p.data; if (! post.over_18) { var url = $('').attr('href', post.url.replace(/&/g, '&')).get(0); if (post.thumbnail == 'nsfw') { var thumbnail = $('').attr('href', '/nsfw.jpg').get(0); } else { var thumbnail = $('').attr('href', post.thumbnail).get(0); } if (url.hostname == 'gifsound.com') url.hostname = location.hostname; //if (url.hostname == 'gifsound.com' && location.port == '843') url.port = '843'; //if (url.hostname == 'gifsound.com') url.port = '843'; thumbnail.protocol = 'https:'; template1.removeClass('template1'); template1.find('.reddit-comment-link').attr('href', '//reddit.com/' + post.permalink).html(post.num_comments + ' comments'); template1.find('.score').html(post.score + ' points'); template1.find('.reddit-link-title').html(post.title); template1.find('.reddit-link-title').attr('href', url.href); template1.find('.thumbnail').attr('href', url.href); template1.find('.thumbnail img').attr('src', thumbnail.href); $('#redditHigh').find('.rembeddit-content div:first').append(template1); } }); }); // redditNew $.getJSON('https://www.reddit.com/r/' + subreddit + '/hot/.json?limit=10&t=all&jsonp=?', function foo(result) { $.each(result.data.children.slice(0, 10), function (i, p) { var template1 = $('.template1:first').clone(); var post = p.data; if (! post.over_18) { var url = $('').attr('href', post.url.replace(/&/g, '&')).get(0); if (post.thumbnail == 'nsfw') { var thumbnail = $('').attr('href', '/nsfw.jpg').get(0); } else { var thumbnail = $('').attr('href', post.thumbnail).get(0); } if (url.hostname == 'gifsound.com') url.hostname = location.hostname; //if (url.hostname == 'gifsound.com' && location.port == '843') url.port = '843'; //if (url.hostname == 'gifsound.com') url.port = '843'; thumbnail.protocol = 'https:'; template1.removeClass('template1'); template1.find('.reddit-comment-link').attr('href', '//reddit.com/' + post.permalink).html(post.num_comments + ' comments'); template1.find('.score').html(post.score + ' points'); template1.find('.reddit-link-title').html(post.title); template1.find('.reddit-link-title').attr('href', url.href); template1.find('.thumbnail').attr('href', url.href); template1.find('.thumbnail img').attr('src', thumbnail.href); $('#redditNew').find('.rembeddit-content div:first').append(template1); } }); }); //$('body').append('