zmiany w js i html

This commit is contained in:
Mateusz Gruszczyński
2025-08-31 11:21:58 +02:00
parent ec07782444
commit 46d986ce80
3 changed files with 60 additions and 6 deletions

View File

@@ -325,15 +325,20 @@ select:focus {
color: #fff; color: #fff;
box-shadow: 0 10px 20px color-mix(in srgb, var(--brand) 35%, transparent); box-shadow: 0 10px 20px color-mix(in srgb, var(--brand) 35%, transparent);
transition: transform .04s ease, filter .15s ease, box-shadow .15s ease; transition: transform .04s ease, filter .15s ease, box-shadow .15s ease;
display: inline-block;
text-decoration: none;
display: inline-block;
} }
.btn:hover { .btn:hover {
filter: brightness(2.00) transition: transform 0.15s ease;
text-decoration: none; display: inline-block;
transform: scale(1.05);
} }
.btn:active { .btn:active {
transform: translateY(1px) transform: scale(0.95);
} }
.btn.outline { .btn.outline {
@@ -359,6 +364,30 @@ select:focus {
border-radius: 14px border-radius: 14px
} }
a.btn:hover {
text-decoration: none;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
a.btn[aria-disabled="true"] {
opacity: .5;
cursor: not-allowed;
pointer-events: none;
filter: none;
transform: none;
}
a.btn[aria-disabled="true"]:hover {
filter: none;
transform: none;
text-decoration: none;
}
/* Toast */ /* Toast */
#toast { #toast {
position: fixed; position: fixed;
@@ -663,6 +692,16 @@ select:focus {
background: var(--bg-elev) background: var(--bg-elev)
} }
.result-box .hint {
display: block;
text-align: center;
font-size: .9rem;
color: var(--muted);
opacity: 0.5;
opacity: 1.1;
text-shadow: 0 0 4px rgba(123, 212, 255, 0.4);
}
#error-dump { #error-dump {
margin: 0; margin: 0;
padding: 12px; padding: 12px;
@@ -675,6 +714,7 @@ select:focus {
overflow-wrap: anywhere; overflow-wrap: anywhere;
} }
@media (max-width:720px) { @media (max-width:720px) {
.error-card { .error-card {
padding: 12px padding: 12px

View File

@@ -86,6 +86,7 @@
const ipPreset = $('#ip-preset'); const ipPreset = $('#ip-preset');
const out = $('#generated-link'); const out = $('#generated-link');
const openBtn = $('#open-link'); const openBtn = $('#open-link');
const copyBtn = $('#copy-btn');
function showError(input, msg) { function showError(input, msg) {
const id = input.getAttribute('id'); const id = input.getAttribute('id');
@@ -94,6 +95,7 @@
input.setAttribute('aria-invalid', msg ? 'true' : 'false'); input.setAttribute('aria-invalid', msg ? 'true' : 'false');
} }
function updatePreview() { function updatePreview() {
const rawUrl = (urlInput?.value || '').trim(); const rawUrl = (urlInput?.value || '').trim();
const ip = (ipInput?.value || '').trim(); const ip = (ipInput?.value || '').trim();
@@ -103,12 +105,14 @@
if (openBtn) { if (openBtn) {
openBtn.setAttribute('href', '#'); openBtn.setAttribute('href', '#');
openBtn.setAttribute('aria-disabled', 'true'); openBtn.setAttribute('aria-disabled', 'true');
openBtn.setAttribute('disabled', 'true');
} }
if (copyBtn) copyBtn.setAttribute('disabled', 'true');
$('.result-box')?.setAttribute('data-state', 'empty'); $('.result-box')?.setAttribute('data-state', 'empty');
return; return;
} }
const normalized = normalizeUrlMaybe(rawUrl); // poprawny http/https lub '' const normalized = normalizeUrlMaybe(rawUrl);
const guessed = rawUrl ? (rawUrl.includes('://') ? rawUrl : `https://${rawUrl}`) : ''; const guessed = rawUrl ? (rawUrl.includes('://') ? rawUrl : `https://${rawUrl}`) : '';
const previewUrl = normalized || guessed; const previewUrl = normalized || guessed;
@@ -117,7 +121,9 @@
if (openBtn) { if (openBtn) {
openBtn.setAttribute('href', '#'); openBtn.setAttribute('href', '#');
openBtn.setAttribute('aria-disabled', 'true'); openBtn.setAttribute('aria-disabled', 'true');
openBtn.setAttribute('disabled', 'true');
} }
if (copyBtn) copyBtn.setAttribute('disabled', 'true');
$('.result-box')?.setAttribute('data-state', 'empty'); $('.result-box')?.setAttribute('data-state', 'empty');
return; return;
} }
@@ -130,11 +136,14 @@
if (ok) { if (ok) {
openBtn.setAttribute('href', link); openBtn.setAttribute('href', link);
openBtn.setAttribute('aria-disabled', 'false'); openBtn.setAttribute('aria-disabled', 'false');
openBtn.removeAttribute('disabled');
} else { } else {
openBtn.setAttribute('href', '#'); openBtn.setAttribute('href', '#');
openBtn.setAttribute('aria-disabled', 'true'); openBtn.setAttribute('aria-disabled', 'true');
openBtn.setAttribute('disabled', 'true');
} }
} }
if (copyBtn) copyBtn.toggleAttribute('disabled', !ok);
$('.result-box')?.setAttribute('data-state', ok ? 'ready' : 'empty'); $('.result-box')?.setAttribute('data-state', ok ? 'ready' : 'empty');
} }

View File

@@ -83,12 +83,17 @@
<input id="generated-link" type="text" value="{{ generated_link or '' }}" readonly <input id="generated-link" type="text" value="{{ generated_link or '' }}" readonly
placeholder="Link will appear here…"> placeholder="Link will appear here…">
<div class="result-buttons"> <div class="result-buttons">
<button class="btn" type="button" data-action="copy" data-target="#generated-link">Copy</button>
<button class="btn" type="button" id="copy-btn" data-action="copy"
data-target="#generated-link">Copy</button>
<a class="btn outline" id="open-link" href="{{ generated_link or '#' }}" target="_blank" <a class="btn outline" id="open-link" href="{{ generated_link or '#' }}" target="_blank"
rel="noopener" aria-disabled="{{ 'false' if generated_link else 'true' }}">Open</a> rel="noopener" aria-disabled="{{ 'false' if generated_link else 'true' }}">Open</a>
</div> </div>
</div> </div>
<small class="hint"><strong>Paste this link in your Mikrotik (IP -> DNS -> Adlist) or other DNS server / ad blocking tool</strong></small> <small class="hint">Paste this link in your Mikrotik (IP -> DNS -> Adlist) or other DNS server /
ad blocking tool</small>
</div> </div>
</section> </section>