diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js
index e4b966ee..549a81c9 100644
--- a/www/assets/js/callbacks.js
+++ b/www/assets/js/callbacks.js
@@ -692,21 +692,26 @@ Callbacks = {
},
librarySearchResults: function(data) {
- var n = $("#library").children().length;
- for(var i = 0; i < n; i++) {
- $("#library")[0].removeChild($("#library").children()[0]);
- }
- var ul = $("#library")[0];
- for(var i = 0; i < data.results.length; i++) {
- var li = makeQueueEntry(data.results[i]);
- if(RANK >= Rank.Moderator || OPENQUEUE || LEADER) {
- if(data.results[i].thumb)
- addLibraryButtons(li, data.results[i].id, true);
- else
- addLibraryButtons(li, data.results[i].id);
+ clearSearchResults();
+ $("#library").data("entries", data.results);
+ if(data.results.length > 100) {
+ var pag = $("
").addClass("pagination")
+ .attr("id", "search_pagination")
+ .insertAfter($("#library"));
+ var btns = $("").appendTo(pag);
+ for(var i = 0; i < data.results.length / 100; i++) {
+ var li = $("").appendTo(btns);
+ (function(i) {
+ $("").attr("href", "javascript:void(0)")
+ .text(i+1)
+ .click(function() {
+ loadSearchPage(i);
+ })
+ .appendTo(li);
+ })(i);
}
- $(li).appendTo(ul);
}
+ loadSearchPage(0);
},
/* REGION Polls */
diff --git a/www/assets/js/client.js b/www/assets/js/client.js
index 3016055e..4e821698 100644
--- a/www/assets/js/client.js
+++ b/www/assets/js/client.js
@@ -559,6 +559,10 @@ $("#youtube_search").click(function() {
});
});
+$("#search_clear").click(function() {
+ clearSearchResults();
+});
+
function fluidLayout() {
$(".row").each(function() {
$(this).removeClass("row").addClass("row-fluid");
diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js
index a17c17f9..ee071209 100644
--- a/www/assets/js/functions.js
+++ b/www/assets/js/functions.js
@@ -448,6 +448,29 @@ function addLibraryButtons(li, id, yt) {
}
}
+function loadSearchPage(page) {
+ $("#library").html("");
+ var results = $("#library").data("entries");
+ var start = page * 100;
+ for(var i = start; i < start + 100 && i < results.length; i++) {
+ var li = makeQueueEntry(results[i]);
+ if(hasPermission("playlistadd")) {
+ if(results[i].thumb) {
+ addLibraryButtons(li, results[i].id, true);
+ }
+ else {
+ addLibraryButtons(li, results[i].id);
+ }
+ }
+ $(li).appendTo($("#library"));
+ }
+}
+
+function clearSearchResults() {
+ $("#library").html("");
+ $("#search_pagination").remove();
+}
+
// Rearranges the queue
function moveVideo(src, dest, noanim) {
var li = $($("#queue").children()[src]);
diff --git a/www/channel.html b/www/channel.html
index 04cac9f8..48f32184 100644
--- a/www/channel.html
+++ b/www/channel.html
@@ -85,6 +85,7 @@