From 0787871f2b6d61197816813604d9b48fd02f72b6 Mon Sep 17 00:00:00 2001 From: fen Date: Thu, 10 Sep 2026 09:33:49 -0500 Subject: [PATCH] Fix #163: remove dead iscan/createCan path breaking /new Create --- internal/web/static/new.js | 57 -------------------------------------- 1 file changed, 57 deletions(-) diff --git a/internal/web/static/new.js b/internal/web/static/new.js index 16bbd47..6e81f19 100644 --- a/internal/web/static/new.js +++ b/internal/web/static/new.js @@ -151,8 +151,6 @@ $('reguess').addEventListener('click', guessLang); content.addEventListener('paste', () => setTimeout(guessLang, 0)); async function create() { - // #4: can mode — bundle the editor + extra items into a can via multipart - if ($('iscan').checked) return createCan(); // #38: file attached -> file paste (1 file = 1 paste; text is ignored) if (attachedFile) return createFilePaste(); @@ -330,61 +328,6 @@ async function createFilePaste() { finishCreate(data); } -// #4: can creation — POST multipart to /api/pastes/can. The main editor is -// the first item; each extra can-item row is another text item. -async function createCan() { - const items = []; - if (content.value.trim()) { - items.push({title: $('title').value || 'main', content: content.value, language: $('language').value || ''}); - } - document.querySelectorAll('#can-items .can-item-row').forEach(row => { - const t = row.querySelector('.can-item-title').value.trim(); - const c = row.querySelector('.can-item-content').value; - if (c.trim()) items.push({title: t || ('item-' + (items.length + 1)), content: c}); - }); - if (!items.length) { toast('Nothing to put in the can', 'error'); return; } - - const fd = new FormData(); - fd.append('title', $('title').value || 'Untitled can'); - fd.append('json_items', JSON.stringify(items)); - if ($('haspw').checked) fd.append('password', $('password').value); - if ($('unlisted').checked) fd.append('visibility', 'unlisted'); - const exp = document.querySelector('input[name="exp"]:checked').value; - if (exp === 'custom') { - const dur = composeCustomExpiry(); - if (dur === null) { toast('Check the custom expiry', 'error'); return; } - if (dur) fd.append('expires_in', dur); - } else if (exp) { - fd.append('expires_in', exp); - } - if ($('custom').value.trim()) fd.append('custom_slug', $('custom').value.trim()); - - const res = await fetch('/api/pastes/can', {method: 'POST', body: fd}); - const data = await res.json(); - if (!res.ok) { - showResult(friendlyError(data), 'err'); - toast('Can create failed', 'error'); - return; - } - const url = location.origin + data.url; - showResult('' + url + ' ', 'ok'); - const copyBtn = document.getElementById('result-copy'); - copyBtn.addEventListener('click', () => { - try { - navigator.clipboard.writeText(url); - copyBtn.classList.add('ok'); - copyBtn.textContent = 'Success!'; - setTimeout(() => { copyBtn.classList.remove('ok'); copyBtn.textContent = '⧉'; }, 2000); - } catch(e) { toast('Copy failed', 'error'); } - }); - // password-protected can: unlock now with the password we already have (#26 parity) - if ($('haspw').checked && data.id) { - const pd = new FormData(); - pd.append('password', $('password').value); - try { await fetch('/can/' + data.id, {method: 'POST', body: pd}); } catch(e) {} - } - location.href = data.url; -} // reset stale result state when returning via Back (bfcache) (#28) window.addEventListener('pageshow', e => { if (!e.persisted) return;