Skip to content

Commit a0f97c5

Browse files
Implementing checkjebon-js
1 parent e7e63b4 commit a0f97c5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ <h2 class="w3-wide w3-center caps">{{ selectedSupermarket?.name }}</h2>
105105
</td>
106106
<td>
107107
<span class="w3-large">
108-
<a v-if="!product.isEstimate" v-bind:href="product.link" target="_blank" class="noline" :title="product.originalQuery">
108+
<a v-if="!product.isEstimate" v-bind:href="product.link" target="_blank" class="noline" :title="product.originalQuery?.replace(/^x\s/, '')">
109109
{{ product.name }}
110110
</a>
111111
<span v-if="!product.price || product.isEstimate">
112-
{{product.originalQuery}}
112+
{{product.originalQuery?.replace(/^x\s/, '')}}
113113
</span>
114114
</span><br>
115115
<span class="w3-text-blue-gray">

js/site/script.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ var app = new Vue(
114114
this.pricesLastUpdated = checkjebon.pricesLastUpdated();
115115
this.supermarkets = results.map(s => ({
116116
...s,
117+
products: s.products.map(p => {
118+
p.checked = p.originalQuery.startsWith("x ");
119+
return p;
120+
}),
117121
totalPrice: s.products.reduce((sum, p) => sum + (p.price || 0), 0),
118122
notFound: s.products.filter(p => p.isEstimate).length
119123
}));
@@ -159,14 +163,14 @@ var app = new Vue(
159163
},
160164
edit: async function(product, event, message)
161165
{
162-
var newProduct = window.prompt(message, product.originalQuery);
166+
var newProduct = window.prompt(message, product.originalQuery?.replace(/^x\s/, ''));
163167
if (newProduct)
164168
{
165169
this.shoppinglist = this.shoppinglist.split("\n").map(line =>
166170
{
167171
if (line.includes(product.originalQuery))
168172
{
169-
line = newProduct;
173+
line = (product.originalQuery.startsWith("x ") ? "x " : "") + newProduct;
170174
}
171175
return line;
172176
}).join("\n");

0 commit comments

Comments
 (0)