-
Notifications
You must be signed in to change notification settings - Fork 1
/
tab.html
460 lines (401 loc) · 24.9 KB
/
tab.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<!DOCTYPE html>
<html lang="en" style="--c-selection-bg:red;">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tab!</title>
<link href="/css/main.min.css" rel="stylesheet">
<style>
html,
body {
overflow: hidden;
height: 100%;
}
</style>
<link href="/favicon.ico" rel="shortcut icon">
<!-- Primary Meta Tags -->
<meta name="title" content="Tab!">
<meta name="author" content="Michael Ryan">
<meta name="description" content="A utility page that can be used as a tab bar spacer. It allows the user to store notes in markdown and customize the tab title and icon.">
<meta name="keywords" content="tab,title,name,icon,note,message,markdown">
<meta name="created" content="2022-12-16T00:00:00+0000">
<meta name="modified" content="2022-12-16T00:00:00+0000">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://somethingstrange.com/tab.html">
<meta property="og:title" content="Tab!">
<meta property="og:description" content="A utility page that can be used as a tab bar spacer. It allows the user to store notes in markdown and customize the tab title and icon.">
<meta property="og:image" content="https://somethingstrange.com/tab/meta_image.png">
<meta property="og:site_name" content="somethingSTRANGE">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://somethingstrange.com/tab.html">
<meta property="twitter:title" content="Tab!">
<meta property="twitter:description" content="A utility page that can be used as a tab bar spacer. It allows the user to store notes in markdown and customize the tab title and icon.">
<meta property="twitter:image" content="https://somethingstrange.com/tab/meta_image.png">
<!-- Other -->
<meta name="apple-mobile-web-app-status-bar-style" content="#fff">
<meta name="theme-color" content="#fff">
</head>
<body class="theme__dark" id="tab">
<nav class="top-bar" role="navigation"></nav>
<div id="tab-panes">
<div id="tab-pane-toolbar">
<div data-mode="0" id="tab-mode">
<button id="mode-edit-disabled" onclick="editEnabled()">
<span style="line-height:1em; vertical-align:middle;"><svg style="height:1em; width:1em" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><use style="--fa-pc:currentColor;--fa-po:1;--fa-sc:currentColor;--fa-so:0.4;" xlink:href="#duotone-caret-square-right"/></svg></span>
</button>
<button id="mode-edit-enabled" onclick="editDisabled()">
<span style="line-height:1em; vertical-align:middle;"><svg style="height:1em; width:1em" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><use style="--fa-pc:currentColor;--fa-po:1;--fa-sc:currentColor;--fa-so:0.4;" xlink:href="#duotone-caret-square-down"/></svg></span>
</button>
</div>
<div data-dirty="0" id="tab-state">
<div id="state-dirty">
<span style="line-height:1em; vertical-align:middle;"><svg style="height:1em; width:1em" viewBox="0 0 576 512" xmlns="http://www.w3.org/2000/svg"><use style="--fa-pc:currentColor;--fa-po:1;--fa-sc:currentColor;--fa-so:0.4;" xlink:href="#duotone-edit"/></svg></span>
<div class="state-label">Edited</div>
</div>
<div id="state-saved">
<span style="line-height:1em; vertical-align:middle;"><svg style="height:1em; width:1em" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><use style="--fa-pc:currentColor;--fa-po:1;--fa-sc:currentColor;--fa-so:0.4;" xlink:href="#duotone-save"/></svg></span>
<div class="state-label">Saved</div>
</div>
</div>
<div class="flex-grow"></div>
<div class="site-logo">
<a class="site-link" href="/" rel="home" title="somethingSTRANGE">
<span class="logo-svg"><svg height="96" viewBox="0 0 128 96" width="128" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="m36 32c0-16 12-28 28-28s28 12 28 28c0 8-2 12-2 12s-2 6.25-2 8.125 1 3.875 3 5.875 3 2.5 5 3h1e-4c2 0.5 3.9999 1 5.9999 0 1-0.5 2-1.375 3-2.25s2-1.75 3-2.25c2-1 3.5-1.5 6-1.5s7 2 7 5-1 5-4 7c-2 1.5-3.5 1-4 0.5s-1-1.5-1-1.5 2 0 3-0.5 2-2 2-4-1-2.5-3-2.5-4 1-7 4-4.5 4-6 4.5-4.5 0.5-7-0.5-7-3-7-3 2 3 3 7 7 5 9.5 5 7-0.5 8.5-2 1.5-3 1.5-3l0.5 1s0.5 1.5-0.5 3.5-5.5 3.5-10 4-9 0.5-11.5-1.5c-1.2978-1.0382-1.7871-2.3459-2.3773-3.9231-0.5467-1.461-1.18-3.1533-2.6227-5.0769-2.3858-3.1811-2.8743-3.8323-3.4772-3.9657-0.1553-0.0343-0.3181-0.0343-0.5228-0.0343-1 0-2 0-2 1.5 0 0.4035 0.0724 0.8432 0.1587 1.3678 0.2346 1.4253 0.5723 3.4772-0.1587 7.1322-0.1065 0.5324-0.213 1.0478-0.3158 1.5456l-5e-4 0.0023-8e-4 0.0039-2e-4 0.0011c-0.8624 4.1732-1.4687 7.1076 0.3173 8.4471 1.568 1.176 3.136 1.1227 5.4269 1.0448 0.6311-0.0215 1.3171-0.0448 2.0731-0.0448 3.5 0 7-2 7-2s3.5-2 7.5-2 7.5 2.5 7.5 2.5 2 1 5.5 1 7-4.5 7-4.5 1.5 0 1.5 1-0.5 3-2.5 5c-0.292 0.2918-0.562 0.5836-0.827 0.8692-1.55 1.6718-2.902 3.1308-7.173 3.1308-2.5 0-4-0.75-5.5-1.5s-3-1.5-5.5-1.5c-2.9912 0-4.5509 1.2526-6.0706 2.4732-1.0206 0.8198-2.0233 1.625-3.4294 2.0268-1.6076 0.4593-2.8987 0.2857-4.2126 0.1091-1.5466-0.208-3.1246-0.4201-5.2874 0.3909-4 1.5-6.5 1-9 0s-5-3.5-5-6c0-1.1931 0.2277-2.1584 0.4659-3.1677 0.2608-1.1056 0.5341-2.264 0.5341-3.8323 0-1.5684-0.2733-2.8634-0.5341-4.0994-0.2382-1.1284-0.4659-2.2076-0.4659-3.4006v-4.5c0-2-1-2-1-2h-2l-1 2s-1 4 0 10-0.5 10-0.5 10-2 4-7 5-6.5 0.5-10.5-1c-2.7335-1.0251-4.066-1.8166-5.2741-2.5343-0.5597-0.3325-1.0927-0.6491-1.7259-0.9657-2-1-5.5-2-8-2-2.1353 0-3.541 0.7295-5.1519 1.5654-0.2752 0.1428-0.5563 0.2887-0.8481 0.4346-2 1-6.5 2-9.5 1.5s-4-1.5-5.5-3-2-3-2-4 0.5-2 0.5-2 1 0 1.5 1c0.07602 0.152 0.14049 0.3041 0.20569 0.4579l3e-5 1e-4c0.36366 0.8577 0.75049 1.7701 3.2943 3.042 3 1.5 6.5 1 9.5-1.5s5.5-3 8-3 6 0.5 9.5 2.5 8 3.5 9.5 3.5 3.5-0.5 4.5-2 1.5-3.5 1-6-0.5-3-0.5-5 1-6.5 1-6.5-2 3.5-4 4.5c-0.3246 0.1623-0.6754 0.3246-1.0356 0.4911-1.8591 0.8598-3.9644 1.8335-3.9644 3.5089 0 2 2 3 4 2 1 1-0.5 3-2 3.5s-3.5 0-3.5 0c-2.7324-1.7992-3.631-4.2374-2.5-7.5l4.5-7c1.3743-1.9413 1.4258-2.4981-0.5-2-3.8706 3.1725-6.2716 4.6073-11 6.5-4.4646 1.72-7.5311 2.0505-14 1.5-4.279-0.5754-6.5-1.5-9-4s-2.5-5.5-2-8.5 4-5.5 6-5.5c1.959 0 3.2761 0.6922 3.958 2.3919 0.1879 1.5095-0.0451 1.9427-0.958 2.1081-0.8004-2.19-2-2.5-3.5-2s-2 1.5-2.5 3-0.5 5 2.5 7c6.5 3.5 13.5 0.5 20.5-5.5 1.5-1.2857 3-3 4-5s1-2.75 1-4.875-2-8.125-2-8.125-2-4-2-12zm-17.03 25.423-0.0124-0.0311-2e-4 -0.0015 0.0126 0.0326zm0 0 0.0151 0.0388 0.0145 0.0382-0.0296-0.077zm62.03-13.423c0 4.4183-2.2386 8-5 8s-5-3.5817-5-8 2.2386-8 5-8 5 3.5817 5 8zm-29 8c2.7614 0 5-2.2386 5-5s-2.2386-5-5-5-5 2.2386-5 5 2.2386 5 5 5zm8-14v-0.5c-0.2125 0-0.3347 0-0.4433 0.0384-0.147 0.0519-0.2692 0.1741-0.5567 0.4616-0.5 0.5-1 1-4.5-1-0.2188-0.1459-0.427-0.2917-0.6307-0.4345l-1e-4 -1e-4c-1.1929-0.8359-2.2339-1.5654-4.3692-1.5654-1.5 0-3.5 1-4.5 2s-2.5 1-2.5 1 0 1 1.5 1c0.6547 0 1.2142-0.3811 1.8448-0.8105 0.814-0.5544 1.7464-1.1895 3.1552-1.1895 2.1353 0 3.541 0.7295 5.1519 1.5654l2e-4 1e-4c0.2751 0.1428 0.5562 0.2886 0.8479 0.4345 1.1875 0.5937 1.6699 0.8349 2.1798 0.9329 0.349 0.0671 0.7108 0.0671 1.3202 0.0671 1.5 0 1.5-2 1.5-2zm12-7.5s1 0.5 4-1.5 4-2 5.5-2 2.5 1 3.5 2c0.7133 0.7133 0.9178 0.9178 1.1579 0.9764 0.0965 0.0236 0.1988 0.0236 0.3421 0.0236 0.5 0 0.5-1 0.5-1s-1-0.5-2.5-2-2.5-2-4.5-2-4 2-4 2l-2 1.5s-0.5 0.5-2 0.5-3-0.5-3-0.5v0.5s0 0.5 1 1 2 0.5 2 0.5z" fill="currentColor" fill-rule="evenodd"></path><path d="m100 12c-4 4-7 6-7 6s3 6 3 14-3 15-3 15l-1 4 1 2s2.5-7 5-7 6 7 6 7 3.5-15 10-15 12 4 12 4-5-10-9-22-4-17-5-17.5-1-0.5-2-0.5-6 6-10 10z" fill="currentColor"></path><path d="m28 12c4 4 7 6 7 6s-3 6-3 14 3 15 3 15l1 4-1 2s-2.5-7-5-7-6 7-6 7-3.5-15-10-15-12 4-12 4 5-10 9-22 4-17 5-17.5 1-0.5 2-0.5 6 6 10 10z" fill="currentColor"></path></svg></span>
</a>
</div>
</div>
<div id="tab-pane-editor">
<div class="tab-editor-textfield tab-title">
<label for="tab-title" id="tab-title-label">Name</label>
<input id="tab-title" maxlength="32" onchange="save()" oninput="onTitleInput()">
<div class="tab-chars-remaining">0</div>
</div>
<div class="tab-editor-textfield">
<label for="tab-icon" id="tab-icon-label">Icon</label>
<input id="tab-icon" maxlength="64" onchange="save()" oninput="onIconInput()">
<div class="tab-icon-dropdown">
<button class="tab-icon-dropdown-button" onclick="onIconDropdownClick()">
<span style="line-height:1em; vertical-align:middle;"><svg style="height:1em; width:1em" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><use style="--fa-pc:currentColor;--fa-po:1;--fa-sc:currentColor;--fa-so:0.4;" xlink:href="#duotone-icons"/></svg></span>
</button>
<div class="tab-icon-dropdown--content" id="tab-icon-dropdown">
<button data-icon="none"></button>
<button data-icon="alpha-a"></button>
<button data-icon="alpha-b"></button>
<button data-icon="alpha-c"></button>
<button data-icon="alpha-d"></button>
<button data-icon="alpha-1"></button>
<button data-icon="alpha-2"></button>
<button data-icon="alpha-3"></button>
<button data-icon="alpha-4"></button>
<button data-icon="alpha-5"></button>
<button data-icon="alpha-6"></button>
<button data-icon="alpha-7"></button>
<button data-icon="alpha-8"></button>
<button data-icon="alpha-9"></button>
<button data-icon="alpha-0"></button>
<button data-icon="fa-left"></button>
<button data-icon="fa-right"></button>
<button data-icon="fa-right-left"></button>
<button data-icon="fa-floppy-disk"></button>
<button data-icon="fa-code"></button>
<button data-icon="fa-list"></button>
<button data-icon="fa-memo-pad"></button>
<button data-icon="fa-note"></button>
<button data-icon="fa-store"></button>
<button data-icon="fa-cart-shopping"></button>
<button data-icon="steam-card"></button>
<button data-icon="emoji-question"></button>
<button data-icon="emoji-exclamation"></button>
<button data-icon="emoji-bangbang"></button>
<button data-icon="emoji-interrobang"></button>
<button data-icon="emoji-horns"></button>
<button data-icon="emoji-thumbs-up"></button>
<button data-icon="emoji-thumbs-down"></button>
<button data-icon="emoji-happy"></button>
<button data-icon="emoji-mad"></button>
<button data-icon="boost"></button>
<button data-icon="emoji-check"></button>
<button data-icon="emoji-cross"></button>
<button data-icon="emoji-melting-face"></button>
<button data-icon="emoji-devil"></button>
<button data-icon="emoji-heart"></button>
<button data-icon="emoji-jack-o-lantern"></button>
<button data-icon="emoji-skull"></button>
<button data-icon="emoji-spider"></button>
<button data-icon="emoji-christmas-tree"></button>
<button data-icon="emoji-gift"></button>
<button data-icon="emoji-alien"></button>
<button data-icon="emoji-game-die"></button>
<button data-icon="emoji-alien-monster"></button>
<button data-icon="emoji-joystick"></button>
<button data-icon="emoji-apple"></button>
<button data-icon="emoji-cherries"></button>
<button data-icon="emoji-grapes"></button>
<button data-icon="emoji-lemon"></button>
<button data-icon="emoji-strawberry"></button>
<button data-icon="emoji-pretzel"></button>
<button data-icon="emoji-hamburger"></button>
<button data-icon="emoji-french-fries"></button>
<button data-icon="emoji-pizza"></button>
<button data-icon="emoji-taco"></button>
<button data-icon="emoji-sun"></button>
<button data-icon="emoji-moon"></button>
<button data-icon="emoji-star"></button>
<button data-icon="emoji-sparkles"></button>
<button data-icon="emoji-trophy"></button>
<button data-icon="emoji-party-popper"></button>
<button data-icon="emoji-100"></button>
<button data-icon="emoji-fire"></button>
<button data-icon="emoji-rocket"></button>
<button data-icon="emoji-gem-stone"></button>
<button data-icon="emoji-nazar-amulet"></button>
<button data-icon="emoji-eyes"></button>
<button data-icon="emoji-musical-notes"></button>
<button data-icon="markdown"></button>
<button data-icon="bones"></button>
</div>
</div>
<div class="tab-chars-remaining">0</div>
</div>
<div class="tab-editor-textarea">
<div class="tab-label-row">
<label for="tab-note" id="tab-note-label">Note</label>
<div class="tab-editor-options">
<button class="tab-editor-option-button" data-enabled="0" id="option-line-wrap" onclick="onToggleLineWrapClick()" title="Line Wrap">
<span style="line-height:1em; vertical-align:middle;"><svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><use style="--fa-pc:currentColor;--fa-po:1;--fa-sc:currentColor;--fa-so:0.4;" xlink:href="#solid-turn-down-left"/></svg></span>
</button>
</div>
<div class="tab-chars-remaining-label">Characters remaining: <span class="tab-chars-remaining">0</span></div>
</div>
<textarea id="tab-note" maxlength="1400" onchange="save()" oninput="onNoteInput()"></textarea>
</div>
</div>
<div id="tab-pane-preview"></div>
</div>
<div id="svg-use-src" style="display:none">
<svg viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><g id="duotone-caret-square-right"><path class="fa-secondary" d="M400 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h352a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48zm-83.82 232L182.29 380.65c-8.22 7.16-22.29 2.09-22.29-8V139.4c0-10.14 14.06-15.21 22.29-8.05L316.18 248a10.38 10.38 0 0 1 0 16z" style="fill:var(--fa-sc); opacity:var(--fa-so)"/><path class="fa-primary" d="M316.18 264L182.29 380.65c-8.22 7.16-22.29 2.09-22.29-8V139.4c0-10.14 14.07-15.21 22.29-8.05L316.18 248a10.38 10.38 0 0 1 0 16z" style="fill:var(--fa-pc); opacity:var(--fa-po)"/></g></svg>
<svg viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><g id="duotone-caret-square-down"><path class="fa-secondary" d="M400 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h352a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48zm-51.37 182.31L232.06 348.16a10.38 10.38 0 0 1-16.12 0L99.37 214.31C92.17 206 97.28 192 107.43 192h233.14c10.15 0 15.26 14 8.06 22.31z" style="fill:var(--fa-sc); opacity:var(--fa-so)"/><path class="fa-primary" d="M348.63 214.31L232.06 348.16a10.38 10.38 0 0 1-16.12 0L99.37 214.31C92.17 206 97.28 192 107.43 192h233.14c10.15 0 15.26 14 8.06 22.31z" style="fill:var(--fa-pc); opacity:var(--fa-po)"/></g></svg>
<svg viewBox="0 0 576 512" xmlns="http://www.w3.org/2000/svg"><g id="duotone-edit"><path class="fa-secondary" d="M564.6 60.2l-48.8-48.8a39.11 39.11 0 0 0-55.2 0l-35.4 35.4a9.78 9.78 0 0 0 0 13.8l90.2 90.2a9.78 9.78 0 0 0 13.8 0l35.4-35.4a39.11 39.11 0 0 0 0-55.2zM427.5 297.6l-40 40a12.3 12.3 0 0 0-3.5 8.5v101.8H64v-320h229.8a12.3 12.3 0 0 0 8.5-3.5l40-40a12 12 0 0 0-8.5-20.5H48a48 48 0 0 0-48 48v352a48 48 0 0 0 48 48h352a48 48 0 0 0 48-48V306.1a12 12 0 0 0-20.5-8.5z" style="fill:var(--fa-sc); opacity:var(--fa-so)"/><path class="fa-primary" d="M492.8 173.3a9.78 9.78 0 0 1 0 13.8L274.4 405.5l-92.8 10.3a19.45 19.45 0 0 1-21.5-21.5l10.3-92.8L388.8 83.1a9.78 9.78 0 0 1 13.8 0z" style="fill:var(--fa-pc); opacity:var(--fa-po)"/></g></svg>
<svg viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><g id="duotone-save"><path class="fa-secondary" d="M288 352a64 64 0 1 1-64-64 64 64 0 0 1 64 64z" style="fill:var(--fa-sc); opacity:var(--fa-so)"/><path class="fa-primary" d="M433.94 129.94l-83.88-83.88A48 48 0 0 0 316.12 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h352a48 48 0 0 0 48-48V163.88a48 48 0 0 0-14.06-33.94zM224 416a64 64 0 1 1 64-64 64 64 0 0 1-64 64zm96-204a12 12 0 0 1-12 12H76a12 12 0 0 1-12-12V108a12 12 0 0 1 12-12h228.52a12 12 0 0 1 8.48 3.52l3.48 3.48a12 12 0 0 1 3.52 8.48z" style="fill:var(--fa-pc); opacity:var(--fa-po)"/></g></svg>
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><g id="duotone-icons"><path class="fa-secondary" d="M137.86 22.44L128 32.58l-9.85-10.14C93.05-3.5 52.25-7.7 24.86 15.64c-31.41 26.78-33 74.85-5 103.88l96.75 99.83a15.68 15.68 0 0 0 22.65 0l96.75-99.83c28.14-29 26.5-77.1-4.91-103.88C203.75-7.7 163-3.5 137.86 22.44zM499.4 352.1h-60.58l22.36-50.75c2.1-6.65-3.94-13.21-12.18-13.21h-75.6c-6.3 0-11.65 3.9-12.49 9.1l-16.8 106.93c-1 6.3 4.88 11.89 12.49 11.89h62.32l-24.2 83c-1.89 6.65 4.2 12.9 12.23 12.9a13.26 13.26 0 0 0 10.92-5.25l92.4-138.91c4.88-6.91-1.16-15.7-10.87-15.7z" style="fill:var(--fa-sc); opacity:var(--fa-so)"/><path class="fa-primary" d="M260.57 319.84h-48l-7.08-14.24a27.39 27.39 0 0 0-25.66-17.78h-71.71a27.39 27.39 0 0 0-25.66 17.78l-7 14.24h-48A27.45 27.45 0 0 0 0 347.3v137.25A27.45 27.45 0 0 0 27.43 512h233.14A27.45 27.45 0 0 0 288 484.55V347.3a27.45 27.45 0 0 0-27.43-27.46zM144 468a52 52 0 1 1 52-52 52 52 0 0 1-52 52zM478.08.33L329.51 23.17C314.87 25.42 304 38.92 304 54.83V161.6a83.25 83.25 0 0 0-16-1.7c-35.35 0-64 21.48-64 48s28.65 48 64 48c35.2 0 63.73-21.32 64-47.66V99.66l112-17.22v47.18a83.25 83.25 0 0 0-16-1.7c-35.35 0-64 21.48-64 48s28.65 48 64 48c35.2 0 63.73-21.32 64-47.66V32c0-19.48-16-34.42-33.92-31.67z" style="fill:var(--fa-pc); opacity:var(--fa-po)"/></g></svg>
<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><g id="solid-turn-down-left"><path class="fa-primary" d="M5.7 274.3L143.7 136.3c5.3-5.3 12.5-8.3 20-8.3c15.6 0 28.3 12.7 28.3 28.3l0 83.7 208 0c8.8 0 16-7.2 16-16l0-160c0-17.7 14.3-32 32-32l32 0c17.7 0 32 14.3 32 32l0 160c0 61.9-50.1 112-112 112l-208 0 0 83.7c0 15.6-12.7 28.3-28.3 28.3c-7.5 0-14.7-3-20-8.3L5.7 301.6C2 298 0 293.1 0 288s2-10 5.7-13.7z" style="fill:var(--fa-pc); opacity:var(--fa-po)"/></g></svg>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
<script>
const preview = document.getElementById('tab-pane-preview');
const editor = document.getElementById('tab-pane-editor');
const tabEdit = document.getElementById('tab-mode');
const tabState = document.getElementById('tab-state');
const tabTitle = document.getElementById('tab-title');
const tabIcon = document.getElementById('tab-icon');
const tabNote = document.getElementById('tab-note');
const tabTitleRemaining = tabTitle.parentNode.querySelector('.tab-chars-remaining');
const tabIconRemaining = tabIcon.parentNode.querySelector('.tab-chars-remaining');
const tabNoteRemaining = tabNote.parentNode.querySelector('.tab-chars-remaining');
const tabIconPanel = document.querySelector('.tab-icon-dropdown--content');
const tabOptionLineWrap = document.getElementById('option-line-wrap');
const tabTitleMaxLength = 32;
const tabIconMaxLength = 64;
const tabNoteMaxLength = 1400;
const tokenEdit = 'e';
const tokenIcon = 'i';
const tokenNote = 'n';
const tokenTitle = 't';
const tokenOptionLineWrap = 'w';
const converter = new showdown.Converter();
converter.setOption('tables', 'true');
converter.setOption('tasklists', 'true');
converter.setOption('emoji', 'true');
converter.setOption('underline', 'true');
converter.setOption('strikethrough', 'true');
converter.setOption('literalMidWordUnderscores', 'true');
converter.setOption('moreStyling', 'true');
converter.setOption('parseImgDimensions', 'true');
converter.setOption('omitExtraWLInCodeBlocks', 'true');
function editDisabled() {
tabEdit.dataset.mode = "0";
markDirty();
save();
}
function editEnabled() {
tabEdit.dataset.mode = "1";
markDirty();
save();
}
function load() {
let url = new URL(window.location.href);
let mode = url.searchParams.get(tokenEdit) ?? "0";
let icon = url.searchParams.get(tokenIcon) ?? "";
let note = url.searchParams.get(tokenNote) ?? "";
let title = url.searchParams.get(tokenTitle) ?? "";
let isEditEnabled = mode === "1";
if (isEditEnabled) {
editor.classList.add('tab-editor--enabled');
tabState.classList.add('tab-editor--enabled');
}
let optionEnabled = (url.searchParams.get(tokenOptionLineWrap) ?? "1") === "1";
setOption(tabOptionLineWrap, optionEnabled, tabNote, 'tab-editor-option-wrap');
tabEdit.dataset.mode = isEditEnabled ? "1" : "0";
tabTitle.value = Base64Decode(title);
tabIcon.value = Base64Decode(icon);
tabNote.value = Base64Decode(note);
onTitleInput(true);
onIconInput(true);
onNoteInput(true);
markSaved();
}
function save() {
if (!isDirty()) {
return;
}
let url = new URL(window.location.href);
setSearchParam(url, tokenEdit, tabEdit.dataset.mode, "0");
setSearchParam(url, tokenTitle, Base64Encode(tabTitle.value), "");
setSearchParam(url, tokenIcon, Base64Encode(tabIcon.value), "");
setSearchParam(url, tokenNote, Base64Encode(tabNote.value), "");
setSearchParam(url, tokenOptionLineWrap, tabOptionLineWrap.dataset.enabled, "1");
window.location.href = url.href;
markSaved();
}
function setSearchParam(url, key, value, defaultValue) {
url.searchParams.delete(key);
if (value !== defaultValue) {
url.searchParams.set(key, value);
}
}
function markDirty() {
tabState.dataset.dirty = 'true';
}
function markSaved() {
tabState.dataset.dirty = 'false';
}
function isDirty() {
return tabState.dataset.dirty === 'true';
}
function Base64Decode(base64) {
return decodeURIComponent(atob(base64));
}
function Base64Encode(data) {
return btoa(encodeURIComponent(data));
}
function onTitleInput(forceUpdate = false) {
updateRemaining(tabTitleRemaining, tabTitleMaxLength - tabTitle.value.length);
updateTitle(forceUpdate);
}
function onIconInput(forceUpdate = false) {
updateRemaining(tabIconRemaining, tabIconMaxLength - tabIcon.value.length);
updateIcon(forceUpdate);
}
function onNoteInput(forceUpdate = false) {
updateRemaining(tabNoteRemaining, tabNoteMaxLength - tabNote.value.length);
updatePreview(forceUpdate);
}
function onIconDropdownClick() {
document.getElementById("tab-icon-dropdown").classList.toggle("tab-icon-dropdown--show");
}
function toggleOption(option, target, className) {
let enabled = option.dataset.enabled === "1";
setOption(option, !enabled, target, className);
}
function setOption(option, enabled, target, className) {
option.dataset.enabled = enabled ? "1" : "0";
if (enabled) {
target.classList.add(className);
} else {
target.classList.remove(className);
}
}
function onToggleLineWrapClick() {
toggleOption(tabOptionLineWrap, tabNote, 'tab-editor-option-wrap');
markDirty();
save();
}
// Close the dropdown if the user clicks outside of it
window.onclick = function (event) {
if (!tabIconPanel.classList.contains('tab-icon-dropdown--show')) {
return;
}
let el = event.target.closest('.tab-icon-dropdown-button');
if (el === null && event.target !== tabIconPanel) {
tabIconPanel.classList.remove('tab-icon-dropdown--show');
// console.log(event.target);
// // if (!event.target.matches('.tab-icon-dropdown-button svg use')) {
// let dropdowns = document.getElementsByClassName("tab-icon-dropdown--content");
// console.log('dropdowns: ' + dropdowns.length);
// let i;
// for (i = 0; i < dropdowns.length; i++) {
// let openDropdown = dropdowns[i];
// if (openDropdown.classList.contains('tab-icon-dropdown--show')) {
// openDropdown.classList.remove('tab-icon-dropdown--show');
// }
// }
}
}
function updateRemaining(el, value) {
el.innerHTML = value;
}
function replacePatterns(text) {
const vineRegex = /]\((@vine:\s*(\S*)\s*)\)/igm;
text = text.replaceAll(vineRegex, '](https://www.amazon.com/vine/vine-items?search=$2)');
const cardsRegex = /^(\|\{CARDS}\|)$/igm;
text = text.replaceAll(cardsRegex, '🍒 1:1 [H] - [W] -\n\n1:1 trades within this same set. Thanks!\n\n|Card|Need|Bots|\n|---|:--:|---|');
return text;
}
function updatePreview(forceUpdate = false) {
let text = replacePatterns(tabNote.value);
let html = converter.makeHtml(text);
if (preview.innerHTML !== html) {
preview.innerHTML = html;
if (!forceUpdate) {
markDirty();
}
}
}
function initDropdownIcons() {
let buttons = document.getElementById('tab-icon-dropdown').getElementsByTagName('button');
for (let i = 0, n = buttons.length; i < n; i++) {
initDropdownIcon(buttons[i]);
}
}
function initDropdownIcon(el) {
let icon = el.dataset.icon;
if (icon === undefined) {
console.warn('Dropdown icon has bad or missing data');
return;
}
el.onclick = function () {
setIcon(icon)
};
el.title = icon;
let img = document.createElement('img');
img.src = 'tab/' + icon + '.ico';
el.appendChild(img);
}
function setIcon(icon = '') {
tabIcon.value = 'tab/' + icon + '.ico';
onIconInput();
save();
}
function updateIcon(forceUpdate = false) {
let icon = tabIcon.value.trim();
let link = document.querySelector("link[rel~='icon']");
link.href = icon.length > 0 ? icon : '/favicon/favicon-32x32.png';
if (!forceUpdate) {
markDirty();
}
}
function updateTitle(forceUpdate = false) {
const ZeroWidthSpace = '\u200B';
let title = tabTitle.value.trim();
document.title = title.length > 0 ? title : ZeroWidthSpace;
if (!forceUpdate) {
markDirty();
}
}
load();
initDropdownIcons();
</script>
</body>
</html>