From 901ab07a3f3851a84186a9f4f8feeff7f13b4f46 Mon Sep 17 00:00:00 2001 From: Grammatopoulos Apostolos Date: Fri, 10 Jul 2020 21:23:16 +0300 Subject: [PATCH] Auction: Show/Hide button remember selection Issue #167 --- PROGRESS.md | 6 ++--- source/core/source/auction.js | 41 ++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/PROGRESS.md b/PROGRESS.md index a0a08623..2f8bc33e 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -1,13 +1,13 @@ ## Progress on Version 4.3.1 [Beta] ![version type](https://img.shields.io/badge/version-beta-yellow.svg?style=flat-square) -![improvements](https://img.shields.io/badge/improvements-0-green.svg?style=flat-square) +![improvements](https://img.shields.io/badge/improvements-1-green.svg?style=flat-square) ![bug fixes](https://img.shields.io/badge/bug%20fixes-1-red.svg?style=flat-square) ![translations](https://img.shields.io/badge/translations-1-blue.svg?style=flat-square) ### IMPROVEMENTS -- **General** - - [x] None +- **Auction** + - [x] Auction: Show/Hide button remember selection (Issue #167) ### BUG FIXES diff --git a/source/core/source/auction.js b/source/core/source/auction.js index bc0314c4..11bdde5d 100644 --- a/source/core/source/auction.js +++ b/source/core/source/auction.js @@ -129,21 +129,11 @@ var gca_auction = { let button = document.createElement("a"); button.className = "gca-auction-show-hide-button"; button.dataset.tooltip = '[[["'+ gca_locale.get("auction", "hide_your_gold_here") +'","#fff;font-size:12px;"]]]'; - button.dataset.status = false; - button.style.filter = "grayscale(100%)"; - button.addEventListener('click', function () { - // Show/hide items - if ( this.dataset.status == "false" ){ - jQuery(".auction_bid_div:not(:has(.gca-auction-good-price))").closest("td").hide(); - jQuery('input[name ="buyout"]').hide(); - this.style.filter = "grayscale(0%)"; - }else{ - jQuery(".auction_bid_div:not(:has(.gca-auction-good-price))").closest("td").show(); - jQuery('input[name ="buyout"]').show(); - this.style.filter = "grayscale(100%)"; - } - this.dataset.status = ( this.dataset.status == "false" ); - }, false); + button.addEventListener('click', function(){ + let status = gca_data.section.get("cache", "auction_show_hide_button_status", false ); + gca_data.section.set("cache", "auction_show_hide_button_status", !status ); + gca_auction.showHideNonHideYourGoldItems(this, !status); + } , false); filters.appendChild(button); filters.appendChild(document.createElement("br")); @@ -195,6 +185,27 @@ var gca_auction = { tmp = gca_tools.strings.removeDots(items[i].textContent).match(/\s*(\d+)\s*(\d+)\s*$/); document.getElementsByName('buyout')[i].className += (gold < parseInt(tmp[1], 10) || rubies < parseInt(tmp[2], 10)) ? " gca-auction-can-not-buy" : " gca-auction-can-buy"; } + + // Set button status + // True = hide items, False = do not hide + let status = gca_data.section.get("cache", "auction_show_hide_button_status", false); + if ( status ) + this.showHideNonHideYourGoldItems(button, status); + else + button.style.filter = "grayscale(100%)"; + }, + + showHideNonHideYourGoldItems : function(that, status) { + // Show/hide items + if ( status == true ){ + jQuery(".auction_bid_div:not(:has(.gca-auction-good-price))").closest("td").hide(); + jQuery('input[name ="buyout"]').hide(); + that.style.filter = "grayscale(0%)"; + }else{ + jQuery(".auction_bid_div:not(:has(.gca-auction-good-price))").closest("td").show(); + jQuery('input[name ="buyout"]').show(); + that.style.filter = "grayscale(100%)"; + } }, itemsLevelShow : function() {