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