aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-19 05:09:51 -0800
committerFuwn <[email protected]>2024-01-19 05:09:51 -0800
commitb09eddff178e8f51c60ac7b85006d7ae8aab476d (patch)
treedb8b1a7bd97dbbcd3d2d2431815ef8b47f379d55
parentfeat(index): more examples (diff)
downloadcounter-b09eddff178e8f51c60ac7b85006d7ae8aab476d.tar.xz
counter-b09eddff178e8f51c60ac7b85006d7ae8aab476d.zip
refactor(index): simplify script
-rw-r--r--views/index.pug30
1 files changed, 14 insertions, 16 deletions
diff --git a/views/index.pug b/views/index.pug
index 69e2aba..136a211 100644
--- a/views/index.pug
+++ b/views/index.pug
@@ -1,14 +1,14 @@
html
head
title='Urushi Counter'
- meta(name='viewport', content='width=device-width, initial-scale=1')
- link(rel='icon', type='image/png', href='favicon.png')
- link(rel='stylesheet', href='https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.min.css')
+ meta(name='viewport' content='width=device-width, initial-scale=1')
+ link(rel='icon' type='image/png' href='favicon.png')
+ link(rel='stylesheet' href='https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.min.css')
body
.tool
code #{site}/get/@
- input#name(type='text', placeholder=':name', style='display: inline-block; width: 80px; height: 1.4em; line-height: 1.4em; margin: 0 4px; vertical-align: middle;')
+ input#name(type='text' placeholder=':handle' style='display: inline-block; width: 80px; height: 1.4em; line-height: 1.4em; margin: 0 4px; vertical-align: middle;')
code ?theme=
select#theme(style='display: inline-block; height: 1.6em; line-height: 1.6em; font-size: 14px; margin: 0 4px; padding: 0 4px; vertical-align: middle;')
option(value='urushi') urushi
@@ -18,24 +18,22 @@ html
option(value='rule34') rule34
option(value='gelbooru') gelbooru
option(value='gelbooru-h') gelbooru-h
- button#get(style='margin: 10px 0;') Get
+ button#get Generate
img#result(style='display: block;')
script.
- var btn = document.getElementById('get'),
- img = document.getElementById('result')
-
- btn.addEventListener('click', function() {
- var name = document.getElementById('name'),
- themeEl = document.getElementById('theme')
- var text = name.value ? name.value.trim() : ''
- var theme = themeEl.value || 'moebooru'
- if(!text) {
- alert('Please input counter name.')
+ document.getElementById('get').addEventListener('click', () => {
+ const name = document.getElementById('name');
+ const text = name.value ? name.value.trim() : '';
+ const theme = document.getElementById('theme').value || 'moebooru';
+
+ if (!text) {
+ alert('Enter a valid counter handle to continue.');
+
return
}
- img.src = '#{site}/get/@' + text + '?theme=' + theme
+ document.getElementById('result').src = `#{site}/get/@${text}?theme=${theme}`;
})
h2 Usage