Permalink
Browse files

sorting for normal channels

  • Loading branch information...
1 parent bea90bb commit c4f95f9a41d8971432c98c4726fc409e8db8810e @octatone committed Aug 19, 2012
Showing with 34 additions and 2 deletions.
  1. +8 −0 index.html
  2. +26 −2 js/tv.js
View
@@ -51,6 +51,14 @@
</ul>
<form class="right">
+ <label for="sorting">sorting</label>
+ <select id="sorting">
+ <option value="hot">hot</option>
+ <option value="top:day">top today</option>
+ <option value="top:week">top week</option>
+ <option value="top:month">top month</option>
+ <option value="top:year">top year</option>
+ </select>
<input type="checkbox" id="auto" checked/>
<label for="auto">autoplay/advance</label>
<input type="checkbox" id="shuffle"/>
View
@@ -52,6 +52,8 @@ var Globals = {
'youtube.com', 'youtu.be', 'zapiks.com'
],
+ sorting: 'hot',
+
videos: [],
user_channels: [],
cur_video: 0,
@@ -125,6 +127,12 @@ $().ready(function(){
$('#video-list').bind('mousewheel', function(event,delta){
this.scrollLeft -= (delta * 30);
});
+ $('#sorting').on('change', function () {
+
+ Globals.sorting = $('#sorting').val();
+ Globals.videos = [];
+ loadChannel(Globals.channels[Globals.cur_chan].channel, null);
+ });
$(document).keydown(function (e) {
if(!$(e.target).is('form>*')) {
var keyCode = e.keyCode || e.which, arrow = {left: 37, up: 38, right: 39, down: 40 };
@@ -736,12 +744,28 @@ function getFeedURI(channel){
}
function formatFeedURI(channel_obj){
+
+ var sorting = Globals.sorting.split(':');
+ var sortType = '';
+ var sortOption = '';
+ var uri;
+
+ if (sorting.length === 2) {
+
+ sortType = sorting[0] + '/';
+ sortOption = '&t=' + sorting[1];
+ }
+
switch(channel_obj.type){
case 'search':
- return channel_obj.feed + Globals.search_str + '&limit=100';
+ uri = channel_obj.feed + Globals.search_str + '&limit=100';
+ break;
default:
- return channel_obj.feed + '.json?limit=100';
+ uri = channel_obj.feed + sortType + '.json?limit=100' + sortOption;
}
+
+ console.log(uri);
+ return uri;
}
function getChanName(feed){

0 comments on commit c4f95f9

Please sign in to comment.