Don't add delete buttons to youtube search results

People kept clicking them resulting in database errors for unregistered channels.
This commit is contained in:
calzoneman 2013-09-23 16:25:45 -05:00
parent 851491e4ac
commit 0addff6bab
4 changed files with 16 additions and 8 deletions

View file

@ -1,3 +1,12 @@
Mon Sep 23 16:22 2013 CDT
* lib/user.js: distinguish search result return packets with a 'source'
field that specifies where the item came from (e.g 'yt' for youtube
search, 'library' for library search)
* www/assets/js/callbacks.js: account for the change in lib/user.js
which adds a 'source' field to library search results
* www/assets/js/util.js: don't add delete buttons for youtube search
results. Apparently people keep clicking them...
Sat Sep 21 23:53 2013 CDT Sat Sep 21 23:53 2013 CDT
* lib/playlist.js, www/assets/js/player.js: Modify the server lead * lib/playlist.js, www/assets/js/player.js: Modify the server lead
function to have a 3 second lead-in period (to allow buffering). function to have a 3 second lead-in period (to allow buffering).

View file

@ -326,6 +326,7 @@ User.prototype.initCallbacks = function() {
searchfn(data.query.split(" "), function (e, vids) { searchfn(data.query.split(" "), function (e, vids) {
if(!e) { if(!e) {
self.socket.emit("searchResults", { self.socket.emit("searchResults", {
source: "yt",
results: vids results: vids
}); });
} }
@ -333,6 +334,7 @@ User.prototype.initCallbacks = function() {
} else { } else {
self.channel.search(data.query, function (vids) { self.channel.search(data.query, function (vids) {
self.socket.emit("searchResults", { self.socket.emit("searchResults", {
source: "library",
results: vids results: vids
}); });
}); });

View file

@ -953,12 +953,7 @@ Callbacks = {
generator: function (item, page, index) { generator: function (item, page, index) {
var li = makeSearchEntry(item, false); var li = makeSearchEntry(item, false);
if(hasPermission("playlistadd")) { if(hasPermission("playlistadd")) {
if(item.thumb) { addLibraryButtons(li, item.id, data.source);
addLibraryButtons(li, item.id, "yt");
}
else {
addLibraryButtons(li, item.id);
}
} }
$(li).appendTo($("#library")); $(li).appendTo($("#library"));
}, },

View file

@ -1143,11 +1143,13 @@ function clearSearchResults() {
} }
} }
function addLibraryButtons(li, id, type) { function addLibraryButtons(li, id, source) {
var btns = $("<div/>").addClass("btn-group") var btns = $("<div/>").addClass("btn-group")
.addClass("pull-left") .addClass("pull-left")
.prependTo(li); .prependTo(li);
var type = (source === "library") ? undefined : source;
if(hasPermission("playlistadd")) { if(hasPermission("playlistadd")) {
if(hasPermission("playlistnext")) { if(hasPermission("playlistnext")) {
$("<button/>").addClass("btn btn-mini") $("<button/>").addClass("btn btn-mini")
@ -1172,7 +1174,7 @@ function addLibraryButtons(li, id, type) {
}) })
.appendTo(btns); .appendTo(btns);
} }
if(CLIENT.rank >= 2) { if(CLIENT.rank >= 2 && source === "library") {
$("<button/>").addClass("btn btn-mini btn-danger") $("<button/>").addClass("btn btn-mini btn-danger")
.html("<i class='icon-trash'></i>") .html("<i class='icon-trash'></i>")
.click(function() { .click(function() {