--- a/ts/main.ts +++ b/ts/main.ts @@ -0,0 +1,8 @@ +/* + * Modified by Electronics Workbench on 2026-11-19. + * Changes: Remove optional offline service-worker registration for standalone hosting. + * SPDX-License-Identifier: GPL-2.0-or-later + * This modified CircuitJS1 file is licensed under GNU GPL version 2 + * or, at your option, any later version. Existing upstream notices + * and authorship are preserved. + */ @@ -25,32 +33 @@ -// Registered only in production builds so dev mode doesn't log a 404 for a -// service-worker.js that dist.sh generates as a deploy-time step (see -// ts/service-worker.template.js). 'service-worker.js' is deliberately a -// plain page-relative path (not ModuleBase-relative): register() resolves -// it against circuitjs.html's own location, which is where it needs to -// live for its scope to cover the whole deployed site. -// -// Not under file:// (the Electron offline app): the files are already local, -// and the worker's fetch() can't load file: URLs, so once it takes control -// every uncached request (about.html, circuits) fails. Unregister any worker -// that an earlier build left behind. -if (import.meta.env.PROD && 'serviceWorker' in navigator && location.protocol === 'file:') { - navigator.serviceWorker.getRegistrations().then(regs => { - for (const reg of regs) - reg.unregister(); - }); -} else if (import.meta.env.PROD && 'serviceWorker' in navigator) { - const registerServiceWorker = () => { - navigator.serviceWorker.register('service-worker.js').then(registration => { - console.log('Service Worker registered with scope:', registration.scope); - }).catch(error => { - console.error('Service Worker registration failed:', error); - }); - }; - // The top-level await above can outlast the page's load event, in which - // case a 'load' listener added now would never fire. - if (document.readyState === 'complete') - registerServiceWorker(); - else - window.addEventListener('load', registerServiceWorker); -} - +// Electronics Workbench hosting patch (2026-11-19): no optional offline service worker. --- a/ts/UIManager.ts +++ b/ts/UIManager.ts @@ -0,0 +1,8 @@ +/* + * Modified by Electronics Workbench on 2026-11-19. + * Changes: Adjust sidebar control geometry/help, light canvas colours and information-panel styling; numerical algorithms are unchanged. + * SPDX-License-Identifier: GPL-2.0-or-later + * This modified CircuitJS1 file is licensed under GNU GPL version 2 + * or, at your option, any later version. Existing upstream notices + * and authorship are preserved. + */ @@ -78 +86 @@ - this.vpw = UIManager.VERTICALPANELWIDTH; + this.vpw = UIManager.VERTICALPANELWIDTH - 25; @@ -439,0 +448 @@ + static readonly LIGHT_CANVAS_BACKGROUND = new Color("#e2eaf4"); @@ -448,0 +458 @@ + powerHelp: HTMLElement; @@ -784 +794,2 @@ - this.powerLabel.textContent = Locale.LS("Power Brightness"); + this.powerLabel.id = "power-colour-intensity-label"; + this.powerLabel.textContent = Locale.LS("Power colour intensity"); @@ -788,0 +800,6 @@ + this.powerHelp = document.createElement('p'); + this.powerHelp.id = 'power-colour-intensity-help'; + this.powerHelp.className = 'power-help'; + this.powerBar.element.setAttribute('aria-labelledby', this.powerLabel.id); + this.powerBar.element.setAttribute('aria-describedby', this.powerHelp.id); + this.verticalPanel.appendChild(this.powerHelp); @@ -1058,2 +1075,2 @@ - g.setColor(Color.white); - this.cv.style.backgroundColor = '#fff'; + g.setColor(UIManager.LIGHT_CANVAS_BACKGROUND); + this.cv.style.backgroundColor = '#e2eaf4'; @@ -1298,3 +1315,10 @@ - g.setColor(this.menus.printableCheckItem.getState() ? "#eee" : "#111"); - g.fillRect(leftX, this.app.circuitArea.height - h, - this.app.circuitArea.width, this.canvasHeight - this.app.circuitArea.height + h); + const bottomTop = this.app.circuitArea.height - h; + const bottomHeight = this.canvasHeight - this.app.circuitArea.height + h; + g.setColor(this.menus.printableCheckItem.getState() ? "#edf5ff" : "#111"); + g.fillRect(leftX, bottomTop, this.app.circuitArea.width, bottomHeight); + if (this.menus.printableCheckItem.getState() && bottomHeight > 0) { + g.setColor("#cbdcef"); + g.setLineWidth(1.0); + g.drawRect(leftX + .5, bottomTop + .5, + Math.max(0, this.app.circuitArea.width - leftX - 1), Math.max(0, bottomHeight - 1)); + } @@ -1395 +1419 @@ - return Color.white; + return UIManager.LIGHT_CANVAS_BACKGROUND; @@ -1404,0 +1429 @@ + this.powerHelp.textContent = 'Display intensity only; circuit power is unchanged.'; @@ -1407,0 +1433 @@ + this.powerHelp.textContent = 'Enable Options → Show Power to colour components by power dissipation.'; --- a/ts/CircuitElm.ts +++ b/ts/CircuitElm.ts @@ -0,0 +1,8 @@ +/* + * Modified by Electronics Workbench on 2026-11-19. + * Changes: Outline light-mode current dots for contrast; current calculation, animation positions and dark-mode drawing are unchanged. + * SPDX-License-Identifier: GPL-2.0-or-later + * This modified CircuitJS1 file is licensed under GNU GPL version 2 + * or, at your option, any later version. Existing upstream notices + * and authorship are preserved. + */ @@ -525,0 +534 @@ + const lightBackground = CircuitElm.app.menus.printableCheckItem.getState(); @@ -528,0 +538,5 @@ + if (lightBackground) { + g.setColor("#6b3d13"); + g.fillRect(x0-3, y0-3, 6, 6); + g.setColor(CircuitElm.currentColor); + } --- a/ts/style.css +++ b/ts/style.css @@ -0,0 +1,8 @@ +/* + * Modified by Electronics Workbench on 2026-11-19. + * Changes: Remove the unused legacy menu-background image URL while preserving its original solid colour. + * SPDX-License-Identifier: GPL-2.0-or-later + * This modified CircuitJS1 file is licensed under GNU GPL version 2 + * or, at your option, any later version. Existing upstream notices + * and authorship are preserved. + */ @@ -107 +115 @@ - background: #e3e8f3 url(images/hborder.png) repeat-x 0px -2003px; + background: #e3e8f3;