jQuery rewrite
This commit is contained in:
parent
cfeca13484
commit
094c189d23
@ -22,26 +22,24 @@ $(document).ready(fl_enhancer);
|
|||||||
let items_total_value_displayed = false;
|
let items_total_value_displayed = false;
|
||||||
|
|
||||||
function display_items_total_value() {
|
function display_items_total_value() {
|
||||||
// If anyone spams the "bazaar" link
|
// Prevents multiple display if spamming the "bazaar" link
|
||||||
if (items_total_value_displayed) {
|
if (items_total_value_displayed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only computing the sum if all items are displayed
|
// Only computing the sum if all items are displayed
|
||||||
let shop = document.getElementsByClassName('menu-item--active');
|
let shop = $('button.menu-item--active')
|
||||||
if ( shop.length && shop[0].textContent != "Sell my things") {
|
if (shop.length && shop.text() != "Sell my things") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let total_price = 0;
|
let total_price = 0;
|
||||||
for (let item of window.document.getElementsByClassName('shop__item')) {
|
$('li.shop__item').each( function( index, element ){
|
||||||
let num_object = item.getElementsByClassName('js-item-value');
|
total_price = (
|
||||||
let price_object = item.getElementsByClassName('item__price');
|
$( this ).find('span.js-item-value').text() * // Number of items
|
||||||
if (price_object.length && num_object.length) {
|
$( this ).find('div.item__price').text() // Price
|
||||||
let num = num_object[0].textContent;
|
);
|
||||||
let price = price_object[0].textContent;
|
});
|
||||||
total_price += ( num * price);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('.input--item-search').after('<li class="shop__item js-item item "><div class="item__desc"><span class="js-item-name item__name">Total value:</span> <div class="price item__price">' + total_price + '</div></div></li>');
|
$('.input--item-search').after('<li class="shop__item js-item item "><div class="item__desc"><span class="js-item-name item__name">Total value:</span> <div class="price item__price">' + total_price + '</div></div></li>');
|
||||||
items_total_value_displayed = true;
|
items_total_value_displayed = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user