Ask in the page's own dialog, not confirm(), which the iOS app answered Cancel (#462)
Deleting a downloaded file from the iOS app did nothing: no DELETE reached ipx-web or ipx.
WKWebView answers confirm() Cancel without showing it unless the app implements the panel,
which 614f270 does (#453), but only once the app is rebuilt. ask() is a <dialog> of the
page's own, in the top layer, so it opens over a dialog already up (the file menu, Settings)
and leaves it as it was, and Escape answers it alone. Every confirm() in the page and the
admin page goes through it; the tests answer it rather than the browser's dialog, and the
warning before sharing a feed with its key in the address, untested before, now is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,26 @@ function asLink(el: HTMLElement, current: boolean){
|
||||
}
|
||||
const ESCAPED: Record<string,string> ={'&':'&','<':'<','>':'>','"':'"',"'":'''};
|
||||
const esc = (s: string|null|undefined) => (s??'').replace(/[&<>"']/g,c=>ESCAPED[c]);
|
||||
/// Asks before something hard to take back, in a dialog of the page's own. Not confirm(): the iOS
|
||||
/// app answered that Cancel without showing it, so nothing that asked first went ahead there
|
||||
/// (#453, #462). A <dialog> of its own, in the top layer, so it opens over a dialog already up and
|
||||
/// leaves it as it was; Escape or a tap on Cancel answers no.
|
||||
function ask(text: string, yes: string): Promise<boolean>{
|
||||
const d=document.createElement('dialog');
|
||||
d.className='card ask';
|
||||
d.innerHTML=`<p></p><div class="cardacts"><button type="button" class="btn" value="">Cancel</button>
|
||||
<button type="button" class="btn danger" value="y"></button></div>`;
|
||||
d.querySelector('p')!.textContent=text;
|
||||
d.querySelector('[value="y"]')!.textContent=yes;
|
||||
document.body.append(d);
|
||||
return new Promise(done=>{
|
||||
d.onclick=(e: MouseEvent)=>{ const b=(e.target as Element).closest('button'); if(b) d.close(b.value); };
|
||||
// Escape answers this dialog alone, not the one under it too.
|
||||
d.onkeydown=(e: KeyboardEvent)=>{ if(e.key==='Escape') e.stopPropagation(); };
|
||||
d.onclose=()=>{ d.remove(); done(d.returnValue==='y'); };
|
||||
d.showModal();
|
||||
});
|
||||
}
|
||||
// A feed's link, only if it is a web address: esc() keeps a javascript: or data: one working (#326).
|
||||
const webUrl = (u: string|null|undefined): string|null => /^https?:\/\//i.test(u??'') ? u! : null;
|
||||
// Icons: Font Awesome Free 7.3.1 by @fontawesome - https://fontawesome.com
|
||||
@@ -213,7 +233,7 @@ async function copyText(text: string,btn?: HTMLElement){
|
||||
/// ponytail: a guess from the address. A private feed whose key has another name is shared
|
||||
/// without asking; add its pattern here when one turns up.
|
||||
async function share(title: string, url: string, btn?: HTMLElement){
|
||||
if(carriesAccess(url) && !confirm(ACCESS_WARNING+'\n\nShare it anyway?')) return;
|
||||
if(carriesAccess(url) && !await ask(ACCESS_WARNING, 'Share it anyway')) return;
|
||||
await sendLink(title, url, btn);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user