Skip to content
This repository
Browse code

sorting for normal channels

  • Loading branch information...
commit c4f95f9a41d8971432c98c4726fc409e8db8810e 1 parent bea90bb
Raymond May Jr. authored

Showing 2 changed files with 34 additions and 2 deletions. Show diff stats Hide diff stats

  1. +8 0 index.html
  2. +26 2 js/tv.js
8 index.html
@@ -51,6 +51,14 @@
51 51 </ul>
52 52
53 53 <form class="right">
  54 + <label for="sorting">sorting</label>
  55 + <select id="sorting">
  56 + <option value="hot">hot</option>
  57 + <option value="top:day">top today</option>
  58 + <option value="top:week">top week</option>
  59 + <option value="top:month">top month</option>
  60 + <option value="top:year">top year</option>
  61 + </select>
54 62 <input type="checkbox" id="auto" checked/>
55 63 <label for="auto">autoplay/advance</label>
56 64 <input type="checkbox" id="shuffle"/>
28 js/tv.js
@@ -52,6 +52,8 @@ var Globals = {
52 52 'youtube.com', 'youtu.be', 'zapiks.com'
53 53 ],
54 54
  55 + sorting: 'hot',
  56 +
55 57 videos: [],
56 58 user_channels: [],
57 59 cur_video: 0,
@@ -125,6 +127,12 @@ $().ready(function(){
125 127 $('#video-list').bind('mousewheel', function(event,delta){
126 128 this.scrollLeft -= (delta * 30);
127 129 });
  130 + $('#sorting').on('change', function () {
  131 +
  132 + Globals.sorting = $('#sorting').val();
  133 + Globals.videos = [];
  134 + loadChannel(Globals.channels[Globals.cur_chan].channel, null);
  135 + });
128 136 $(document).keydown(function (e) {
129 137 if(!$(e.target).is('form>*')) {
130 138 var keyCode = e.keyCode || e.which, arrow = {left: 37, up: 38, right: 39, down: 40 };
@@ -736,12 +744,28 @@ function getFeedURI(channel){
736 744 }
737 745
738 746 function formatFeedURI(channel_obj){
  747 +
  748 + var sorting = Globals.sorting.split(':');
  749 + var sortType = '';
  750 + var sortOption = '';
  751 + var uri;
  752 +
  753 + if (sorting.length === 2) {
  754 +
  755 + sortType = sorting[0] + '/';
  756 + sortOption = '&t=' + sorting[1];
  757 + }
  758 +
739 759 switch(channel_obj.type){
740 760 case 'search':
741   - return channel_obj.feed + Globals.search_str + '&limit=100';
  761 + uri = channel_obj.feed + Globals.search_str + '&limit=100';
  762 + break;
742 763 default:
743   - return channel_obj.feed + '.json?limit=100';
  764 + uri = channel_obj.feed + sortType + '.json?limit=100' + sortOption;
744 765 }
  766 +
  767 + console.log(uri);
  768 + return uri;
745 769 }
746 770
747 771 function getChanName(feed){

0 comments on commit c4f95f9

Please sign in to comment.
Something went wrong with that request. Please try again.