add groups, add items
This commit is contained in:
@ -1,74 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
refresh();
|
||||
|
||||
userinfo();
|
||||
|
||||
$(document).on("click", ".btn_detail", function() {
|
||||
window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
|
||||
});
|
||||
|
||||
$(".btn_add").click(function() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shoppinglist",
|
||||
data: {
|
||||
name: $(".name").val(),
|
||||
description: $(".description").val()
|
||||
}, success(result) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn_delete", function() {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/shoppinglist",
|
||||
data: {
|
||||
sl_id: $(this).closest("tr").attr("id")
|
||||
}, success(result) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
|
||||
$("tbody").empty();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
success(data) {
|
||||
for(let item of data) {
|
||||
$(".tb_myshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
|
||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>"
|
||||
+ "<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/sharedshoppinglists",
|
||||
success(data) {
|
||||
for(let item of data) {
|
||||
$(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
|
||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function userinfo() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/userinfo_json",
|
||||
success(data) {
|
||||
$(".userinfo").empty();
|
||||
$(".userinfo").append("Logged in as: " + data.profile.displayName);
|
||||
$(".user_img").attr("src", data.profile.photos[0].value);
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user