@@ -69,16 +69,15 @@ export function addKakakuColumns(
69
69
if ( options ?. pppHidden ) {
70
70
partPickerPriceCell . style . display = 'none' ;
71
71
}
72
- const kakakuHeaderPriceCell = document . createElement ( 'th' ) ;
73
- kakakuHeaderPriceCell . dataset . kakaku = 'true' ;
74
- const kakakuDotCom = browser . i18n . getMessage ( 'kakaku_com' ) ;
75
- const priceIntlStr = browser . i18n . getMessage ( 'Price' ) ;
76
- kakakuHeaderPriceCell . innerHTML = `${ kakakuDotCom } <br>${ priceIntlStr } ` ;
77
- kakakuHeaderPriceCell . style . paddingRight = '1rem' ;
78
- kakakuHeaderPriceCell . style . minWidth = '9rem' ;
79
- // headerRow.insertBefore(kakakuHeaderPriceCell, partPickerPriceCell);
72
+ const kakakuHeaderPriceCell = createKakakuPriceHeaderCell ( ) ;
80
73
insertAfter ( kakakuHeaderPriceCell , partPickerPriceCell ) ;
81
74
75
+ if ( ! headerRow . querySelector ( 'th.th__where' ) ) {
76
+ // add where column for saved parts list table
77
+ const whereHeaderCell = createWhereHeaderCell ( ) ;
78
+ insertAfter ( whereHeaderCell , kakakuHeaderPriceCell ) ;
79
+ }
80
+
82
81
// fix buy col width
83
82
const buyHeader : HTMLTableCellElement | null =
84
83
headerRow . querySelector ( 'th.th__buy' ) ;
@@ -102,12 +101,7 @@ export function addKakakuColumns(
102
101
if ( options ?. pppHidden ) {
103
102
priceCell . style . display = 'none' ;
104
103
}
105
- const kakakuTotalPriceCell = document . createElement ( 'td' ) ;
106
- kakakuTotalPriceCell . dataset . kakaku = 'true' ;
107
- kakakuTotalPriceCell . style . fontSize = '1.25rem' ;
108
- kakakuTotalPriceCell . style . fontWeight = '700' ;
109
- kakakuTotalPriceCell . textContent = '¥0' ;
110
- // kakakuTotalPriceCell = totalRow.insertBefore(kakakuTotalPriceCell, priceCell);
104
+ const kakakuTotalPriceCell = createTotalPriceCell ( ) ;
111
105
insertAfter ( kakakuTotalPriceCell , priceCell ) ;
112
106
113
107
const rows : NodeListOf < HTMLTableRowElement > = partListTable . querySelectorAll (
@@ -136,23 +130,23 @@ export function addKakakuColumns(
136
130
if ( options ?. pppHidden ) {
137
131
priceCell . style . display = 'none' ;
138
132
}
139
- const kakakuPriceCell = document . createElement ( 'td' ) ;
140
- kakakuPriceCell . dataset . kakaku = 'true' ;
141
- kakakuPriceCell . textContent = '' ;
142
- // kakakuPriceCell = row.insertBefore(kakakuPriceCell, priceCell);
133
+ const kakakuPriceCell = createPriceCell ( ) ;
143
134
insertAfter ( kakakuPriceCell , priceCell ) ;
144
135
145
- // get name cell
136
+ let whereCell : HTMLTableCellElement | null =
137
+ row . querySelector ( 'td.td__where' ) ;
138
+ if ( ! whereCell ) {
139
+ whereCell = createWhereCell ( ) ;
140
+ insertAfter ( whereCell , kakakuPriceCell ) ;
141
+ }
142
+
146
143
const nameCell : HTMLTableCellElement | null =
147
144
row . querySelector ( 'td.td__name' ) ;
148
145
149
146
const buyButton : HTMLAnchorElement | null = row . querySelector (
150
147
'td.td__buy > a.button' ,
151
148
) ;
152
149
153
- const whereCell : HTMLTableCellElement | null =
154
- row . querySelector ( 'td.td__where' ) ;
155
-
156
150
const part = parts [ i ] ;
157
151
if ( ! part ) {
158
152
return ;
@@ -211,6 +205,52 @@ export function addKakakuColumns(
211
205
partListTable . dataset . kakaku = 'true' ;
212
206
}
213
207
208
+ function createKakakuPriceHeaderCell ( ) {
209
+ const kakakuHeaderPriceCell = document . createElement ( 'th' ) ;
210
+ kakakuHeaderPriceCell . dataset . kakaku = 'true' ;
211
+ const kakakuDotCom = browser . i18n . getMessage ( 'kakaku_com' ) ;
212
+ const priceIntlStr = browser . i18n . getMessage ( 'Price' ) ;
213
+ kakakuHeaderPriceCell . innerHTML = `${ kakakuDotCom } <br>${ priceIntlStr } ` ;
214
+ kakakuHeaderPriceCell . style . paddingRight = '1rem' ;
215
+ kakakuHeaderPriceCell . style . minWidth = '9rem' ;
216
+ return kakakuHeaderPriceCell ;
217
+ }
218
+
219
+ function createWhereHeaderCell ( ) {
220
+ const whereHeaderCell = document . createElement ( 'th' ) ;
221
+ whereHeaderCell . dataset . kakaku = 'true' ;
222
+ whereHeaderCell . textContent = browser . i18n . getMessage ( 'where' ) ;
223
+ whereHeaderCell . classList . add ( 'th__where' ) ;
224
+ return whereHeaderCell ;
225
+ }
226
+
227
+ function createTotalPriceCell ( ) {
228
+ const kakakuTotalPriceCell = document . createElement ( 'td' ) ;
229
+ kakakuTotalPriceCell . dataset . kakaku = 'true' ;
230
+ kakakuTotalPriceCell . style . fontSize = '1.25rem' ;
231
+ kakakuTotalPriceCell . style . fontWeight = '700' ;
232
+ kakakuTotalPriceCell . textContent = '¥0' ;
233
+ return kakakuTotalPriceCell ;
234
+ }
235
+
236
+ function createPriceCell ( ) {
237
+ const kakakuPriceCell = document . createElement ( 'td' ) ;
238
+ kakakuPriceCell . dataset . kakaku = 'true' ;
239
+ kakakuPriceCell . textContent = '' ;
240
+ return kakakuPriceCell ;
241
+ }
242
+
243
+ function createWhereCell ( ) {
244
+ const whereCell = document . createElement ( 'td' ) ;
245
+ whereCell . dataset . kakaku = 'true' ;
246
+ whereCell . classList . add ( 'td__where' , 'td--empty' ) ;
247
+ const hiddenLabel = document . createElement ( 'h6' ) ;
248
+ hiddenLabel . classList . add ( 'xs-block' , 'md-hide' ) ;
249
+ hiddenLabel . textContent = 'Where' ;
250
+ whereCell . appendChild ( hiddenLabel ) ;
251
+ return whereCell ;
252
+ }
253
+
214
254
function updateName ( nameCell : HTMLTableCellElement , item ?: KakakuItem ) {
215
255
const existing = nameCell . querySelector ( 'a.price-part-picker.name' ) ;
216
256
if ( ! item ) {
@@ -333,6 +373,7 @@ function updateWhere(
333
373
link . href = item . shop . itemUrl || '' ;
334
374
link . textContent = item . shop . name || '' ;
335
375
link . style . width = 'auto' ;
376
+ link . style . whiteSpace = 'nowrap' ;
336
377
whereCell . classList . remove ( 'td--empty' ) ;
337
378
whereCell . appendChild ( link ) ;
338
379
}
0 commit comments