fixed search and buy functionality failing on items that are not drinks

This commit is contained in:
Konrad Mohrfeldt 2011-10-16 15:10:42 +02:00
parent 8c05fb6b0f
commit 61c344f936
1 changed files with 10 additions and 11 deletions

View File

@ -1,8 +1,8 @@
jQuery(document).ready(function($) {
if(!$("html").hasClass("loggedIn"))
return;
var search_input = $("div.search input.autocomplete");
var selected_item = [];
var selection = false;
@ -15,7 +15,7 @@ jQuery(document).ready(function($) {
$.each(data, function(key, item) {
items[item.id] = item;
source.push({
value: item.id,
label: "<span class='preview pk" + item.id + "'><img src='" +
@ -40,8 +40,7 @@ jQuery(document).ready(function($) {
},
focus: function(event, ui) {
selection = ui.item;
//search_input.val(items[selection.value].fields.name);
$("ul.ui-autocomplete").children().removeClass("focus");
$(".pk" + selection.value).parent().parent()
.addClass("focus");
@ -58,22 +57,22 @@ jQuery(document).ready(function($) {
search_input.keydown(function(event) {
selected_item = $(".pk" + selection.value).siblings(".buy");
if(lock && event.keyCode === 39) {
selected_item.addClass("load");
$.post("/api2/buyable/item/" + selection.value, {
"deposit": "1"
"POSTDATA": "YUNOCANTBEEMPTY"
}, function(data, status) {
selected_item.removeClass("load");
if(status === "success") {
selected_item.addClass("success");
//TODO neuer kontostand wär schnaffte
} else {
selected_item.addClass("failure");
}
lock = false;
});
} else {
@ -84,7 +83,7 @@ jQuery(document).ready(function($) {
selected_item.removeClass("lock");
else
selected_item.addClass("lock");
selected_item.removeClass("failure success");
});