Skip to content

Commit

Permalink
Include the license script in XHTML, see #1413
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson authored and marlitas committed Jan 2, 2024
1 parent 932244f commit ab80eb7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions js/grunt/buildRunnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ module.exports = async function( repo, minifyOptions, allHTML, brand, localesOpt
stringMap: stringMap,
htmlHeader: htmlHeader,
initializationScript: xhtmlInitializationScript,
licenseScript: licenseScript,
scripts: productionScripts
} );

Expand Down
5 changes: 4 additions & 1 deletion js/grunt/packageXHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = function( xhtmlDir, config ) {
brand, // {string}
stringMap, // {Object}, map[ locale ][ stringKey ] => {string}
initializationScript, // {string} - separate from the rest of the scripts since it needs to be able to run in IE.
licenseScript, // {string}
scripts, // {Array.<string>}
htmlHeader // {string}
} = config;
Expand All @@ -41,6 +42,7 @@ module.exports = function( xhtmlDir, config ) {

const localizedTitle = stringMap[ ChipperConstants.FALLBACK_LOCALE ][ getTitleStringKey( repo ) ];

const licenseScriptFilename = `${repo}_license_${brand}.js`;
const initializationScriptFilename = `${repo}_initialization_${brand}.js`;

const script = scripts.join( '\n' );
Expand All @@ -49,10 +51,11 @@ module.exports = function( xhtmlDir, config ) {
const xhtml = ChipperStringUtils.replacePlaceholders( grunt.file.read( '../chipper/templates/sim.xhtml' ), {
PHET_SIM_TITLE: encoder.htmlEncode( localizedTitle ),
PHET_HTML_HEADER: htmlHeader,
PHET_INITIALIZATION_SCRIPT: `<script type="text/javascript" src="${initializationScriptFilename}" charset="utf-8"></script>`,
PHET_INITIALIZATION_SCRIPT: `<script type="text/javascript" src="${licenseScriptFilename}" charset="utf-8"></script><script type="text/javascript" src="${initializationScriptFilename}" charset="utf-8"></script>`,
PHET_SIM_SCRIPTS: `<script type="text/javascript" src="${scriptFilename}" charset="utf-8"></script>`
} );
grunt.file.write( `${xhtmlDir}/${repo}_all${brand === 'phet' ? '' : `_${brand}`}.xhtml`, xhtml );
grunt.file.write( `${xhtmlDir}/${licenseScriptFilename}`, licenseScript );
grunt.file.write( `${xhtmlDir}/${initializationScriptFilename}`, initializationScript );
grunt.file.write( `${xhtmlDir}/${scriptFilename}`, script );
};
3 changes: 0 additions & 3 deletions templates/chipper-initialization.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
window.phet = window.phet|| {};
window.phet.chipper = window.phet.chipper || {};

window.phet.chipper.project = '{{PHET_PROJECT}}';
window.phet.chipper.version = '{{PHET_VERSION}}';
window.phet.chipper.buildTimestamp = '{{PHET_BUILD_TIMESTAMP}}';
Expand Down

0 comments on commit ab80eb7

Please sign in to comment.