Gustavo Luigi 2022-08-30 11:36:00 +02:00
parent 73faccfe64
commit 7e848f1548
1 changed files with 5 additions and 35 deletions

View File

@ -1,6 +1,7 @@
<!doctype html>
<html lang="{{str_replace('_', '-', app()->getLocale())}}">
<head>
<meta name="get-contents" content="{{url('/contents/all')}}">
@insert("content.includes.meta")
@insert("content.includes.css")
@yield('head')
@ -103,9 +104,10 @@
let objProducts = [];
function updateProductsInLocalStorage(){
localStorage.setItem("products", JSON.stringify(objProducts));
$('#count-products-in-bag').text(objProducts.length);
if(objProducts.length > 0) {
$.get("{{url('/contents/all')}}/"+objProducts.join(","), function(response, status){
$('#count-products-in-bag').text(response.contents.length);
$('#count-products-in-bag').show();
$.get($('meta[name="get-contents"]').attr('content')+"/"+objProducts.join(","), function(response, status){
$('#list-products-in-bag').html('');
response.contents.forEach(function(item){
$('#list-products-in-bag').append(`
@ -123,7 +125,6 @@
<option value="2">Anzahl: 2</option>
<option value="3">Anzahl: 3</option>
</select>
<a href="" class="text-muted small text-decoration-none">Löschen</a>
</td>
<td class="align-middle text-end">18,00€</td>
</tr>`);
@ -132,43 +133,12 @@
}else $('#count-products-in-bag').hide();
}
function addToBag(productId){
if(objProducts.indexOf(productId) == -1) objProducts.push(productId);
if(objProducts.indexOf(productId) == -1) objProducts.push(productId+':'+1);
updateProductsInLocalStorage();
}
$(window).on('load', function(){
if(localStorage.getItem("products") != null) objProducts = JSON.parse(localStorage.getItem("products"));
<<<<<<< HEAD
$.get("{{url('/contents/all')}}/"+objProducts.join(","), function(response, status){
$('#count-products-in-bag').text(response.contents.length);
if(response.contents.length > 0) response.contents.forEach(function(item){
$('#list-products-in-bag').append(`
<tr>
<td class="text-start">
<img class="rounded img-fluid" src="https://picsum.photos/120/120">
</td>
<td class="text-start">
<span class="fs-5">${item.title}</span>
<br>
<small class="text-success">sofort verfügbar</small>
<br>
<select class="form-select form-select-sm" style="width:120px;" aria-label="Default select example">
<option selected value="1">Anzahl: 1</option>
<option value="2">Anzahl: 2</option>
<option value="3">Anzahl: 3</option>
</select>
<a href="" class="text-muted small text-decoration-none">Löschen</a>
ds
</td>
<td class="align-middle text-end">18,00€
<br>
</td>
</tr>`);
});
else $('#count-products-in-bag').hide();
});
=======
updateProductsInLocalStorage();
>>>>>>> e4497e2d3c22ce5756190e6ee74fbeb1d9d09fad
});
</script>
@yield('scripts')