Skip to content

Commit

Permalink
Update priced item highlight to handle pricing with premium stash tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelberardino committed Aug 11, 2019
1 parent fb3ce5d commit f495df2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ TODO
More rigourous item description generation
Shop id for the link after shop generation
Don't hardcode account passwords!
Search bar?
22 changes: 20 additions & 2 deletions data/template/parts/helpers.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,24 @@
realm.options[realm.selectedIndex].value);
}

function itemIsForSale(id) {
// Check if item has a price attached to it.
var currency = document.getElementById(id + '-currency');
if (currency.style.display != 'none') {
return true;
}

// Check if item has a price set in game with a premium tab.
var item = document.getElementById(id);
var desc = item.getAttribute("data-premium-price");
if (desc != undefined && desc != "" ) {
return true;
}

// No price found anywhere.
return false;
}

function highlightItems(highlightType) {
var items = document.getElementsByClassName('newItemContainer');
// Retrieve all sellable objects
Expand All @@ -569,14 +587,14 @@
items[i].style.opacity = 1.0;
break;
case 'sell':
if (currency.style.display != 'none') {
if (itemIsForSale(id)) {
items[i].style.opacity = 1.0;
} else {
items[i].style.opacity = 0.3;
}
break;
case 'noprice':
if (currency.style.display == 'none') {
if (!itemIsForSale(id)) {
items[i].style.opacity = 1.0;
} else {
items[i].style.opacity = 0.3;
Expand Down
1 change: 1 addition & 0 deletions data/template/parts/item.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
style="position: absolute; left: {{ DeducePosX $layoutType .InventoryId $layout .X .Y $idx }}px; top: {{ DeducePosY $layoutType .InventoryId $layout .X .Y $idx }}px; display: {{ $visibility }};"
data-sell="{{ SellDescription . $charName }}"
data-desc="{{ template "itemtext" $item }}"
data-premium-price="{{ .Note }}"
onclick="openModal('item-{{ .Id }}', '{{ .Name }}', '{{ .Type }}')">
<div id="item-{{ .Id }}-currency" class="item-price" style="display: none;">
<img id="item-{{ .Id }}-currency-img" class="thumbnail" src="" />
Expand Down

0 comments on commit f495df2

Please sign in to comment.