Skip to content

refactor(webserver): extract Dreamweaver MM_* JS into shared common.js - #90

Merged
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:fix/webserver-common-js
Jun 11, 2026
Merged

refactor(webserver): extract Dreamweaver MM_* JS into shared common.js#90
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:fix/webserver-common-js

Conversation

@ngosang

@ngosang ngosang commented Jun 11, 2026

Copy link
Copy Markdown
Member

Every main page of the default template embedded its own copy of the Dreamweaver-generated image-rollover helpers (MM_swapImgRestore, MM_preloadImages, MM_findObj, MM_swapImage), with drift between pages: dload and shared additionally carried MM_nbGroup for their toolbars. That was ~276 lines of copy-pasted script across 8 pages.

Move the five functions into a new common.js, served statically with the correct text/javascript MIME type by the webserver, and replace each inline block with a single <script src="common.js"> reference. The PHP include directive cannot be used for this because the embedded interpreter resolves it against the process working directory, so deduplication has to go through static assets.

While extracting, retire the deprecated constructs that lived inside
those blocks: the language="JavaScript" attribute, the
script-hiding comments, and the Netscape-4-era document.all / document.layers fallbacks in MM_findObj (document.getElementById covers all supported browsers).

common.js is added to the CMake INSTALL list so it ships with the template.

Verified against a running amuleweb: all 8 pages return the common.js reference with no inline MM_ leftovers, the file is served as text/javascript, and a headless-browser check confirms the navigation rollovers (MM_swapImage/MM_swapImgRestore), the toolbar group buttons (MM_nbGroup) and image preloading still work with no console errors.

Every main page of the default template embedded its own copy of the
Dreamweaver-generated image-rollover helpers (MM_swapImgRestore,
MM_preloadImages, MM_findObj, MM_swapImage), with drift between pages:
dload and shared additionally carried MM_nbGroup for their toolbars.
That was ~276 lines of copy-pasted script across 8 pages.

Move the five functions into a new common.js, served statically with
the correct text/javascript MIME type by the webserver, and replace
each inline block with a single <script src="common.js"> reference.
The PHP `include` directive cannot be used for this because the
embedded interpreter resolves it against the process working
directory, so deduplication has to go through static assets.

While extracting, retire the deprecated constructs that lived inside
those blocks: the language="JavaScript" attribute, the <!-- -->
script-hiding comments, and the Netscape-4-era document.all /
document.layers fallbacks in MM_findObj (document.getElementById
covers all supported browsers).

common.js is added to the CMake INSTALL list so it ships with the
template.

Verified against a running amuleweb: all 8 pages return the common.js
reference with no inline MM_ leftovers, the file is served as
text/javascript, and a headless-browser check confirms the navigation
rollovers (MM_swapImage/MM_swapImgRestore), the toolbar group buttons
(MM_nbGroup) and image preloading still work with no console errors.
@ngosang
ngosang merged commit 03d8975 into amule-org:master Jun 11, 2026
9 checks passed
@ngosang
ngosang deleted the fix/webserver-common-js branch June 11, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant