From 380ef6006b6efcde94fd7a0df2b2a9d723707391 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 2 Aug 2025 13:21:07 +0000 Subject: [PATCH] Fiddle: move the About button into the header bar and get it working together with the optional jquery.terminal console mode. FossilOrigin-Name: 9639382c5478115df7c1584c14a52c176fe747df73078419be4ab276374a704b --- ext/wasm/fiddle/fiddle.js | 33 ++++++++++++++++++++++++--------- ext/wasm/fiddle/index.html | 32 +++++++++++++++++++++----------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 53 insertions(+), 28 deletions(-) diff --git a/ext/wasm/fiddle/fiddle.js b/ext/wasm/fiddle/fiddle.js index ada40b2247..45ef69326f 100644 --- a/ext/wasm/fiddle/fiddle.js +++ b/ext/wasm/fiddle/fiddle.js @@ -406,13 +406,16 @@ self.onSFLoaded(); }); - /** Toggle the "About" view on and off. */ SF.toggleAbout = function(){ - this.eOther.classList.toggle('hidden'); - this.eAbout.classList.toggle('hidden'); + if( document.body.classList.toggle('about') ){ + this.eAbout.classList.remove('hidden'); + SF.eMainView.classList.add('hidden'); + }else{ + this.eAbout.classList.add('hidden'); + SF.eMainView.classList.remove('hidden'); + } }.bind({ - eOther: E("#main-wrapper"), eAbout: E("#view-about") }); @@ -425,6 +428,9 @@ delete this.onSFLoaded; // Unhide all elements which start out hidden EAll('.initially-hidden').forEach((e)=>e.classList.remove('initially-hidden')); + SF.eMainView = EAll('.app-view:not(.hidden)')[0] + /** The main view widget. Initially the first non-hidden + .app-view element. */; if( (new URL(self.location.href).searchParams).has('about') ){ SF.toggleAbout() /* for use while editing the About page */; } @@ -823,21 +829,30 @@ //SF.echo(null/*clear any output generated by the init process*/); if(window.jQuery && window.jQuery.terminal){ /* Set up the terminal-style view... */ - const eTerm = window.jQuery('#view-terminal').empty(); - SF.jqTerm = eTerm.terminal(SF.dbExec.bind(SF),{ + const eTerm = E('#view-terminal'); + const jqeTerm = window.jQuery(eTerm).empty(); + SF.jqTerm = jqeTerm.terminal(SF.dbExec.bind(SF),{ prompt: 'sqlite> ', greetings: false /* note that the docs incorrectly call this 'greeting' */ }); /* Set up a button to toggle the views... */ - const head = E('header#titlebar'); + const head = E('#titlebar-buttons'); const btnToggleView = document.createElement('button'); btnToggleView.appendChild(document.createTextNode("Toggle View")); head.appendChild(btnToggleView); + const eOthers = EAll('.app-view:not(#view-terminal)'); + const eOtherMain = E('#view-split'); btnToggleView.addEventListener('click',function f(){ - EAll('.app-view').forEach(e=>e.classList.toggle('hidden')); + document.body.classList.remove('about'); if(document.body.classList.toggle('terminal-mode')){ - ForceResizeKludge(); + eOthers.forEach((e)=>e.classList.add('hidden')); + SF.eMainView = eTerm; + }else{ + eTerm.classList.add('hidden'); + SF.eMainView = eOtherMain; } + SF.eMainView.classList.remove('hidden'); + ForceResizeKludge(); }, false); btnToggleView.click()/*default to terminal view*/; } diff --git a/ext/wasm/fiddle/index.html b/ext/wasm/fiddle/index.html index 9b49748809..0196129549 100644 --- a/ext/wasm/fiddle/index.html +++ b/ext/wasm/fiddle/index.html @@ -5,16 +5,27 @@ SQLite3 Fiddle - + +