Hello Peter,
For a one-liner replacement this works fine.
I now try to insert a larger block of JavaScript. Now I fighting with error popup
json error in htmlpreprocessot: invalid escape character
So how about extending the preprozessor to allow the Parameter "replace": followed by a filename with full path to insert the complete file.
Or where can I have the wrong escape character? Which characters have to be escaped?
This is my JavaScript to insert:
Code: Select all
<script type='text/javascript'>
<!--
// ================== careful changing anything below ===================
// EMSCRIPTEN loading newlisp-js-lib.js showing progress of downloading
// importing newlispEvaklStr and defining preRun and postRun functions
var Module = {
preRun: [],
postRun: [(function() {
// import newlispEvalStr from newlisp-js-lib.js library
newlispEvalStr = Module.cwrap('newlispEvalStr', 'string', ['string']);
// preload newLISP functions from code textarea id='code'
// newlispEvalStr(document.getElementById('code').value);
// preload memoizing table
// newlispEvalStr('(fibo 150)(fibo 300)(fibo 450)');
})],
print: (function() { return function(text) { }; })(),
printErr: function(text) { },
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Date.now() < 30) return; // if progress update, skip if too soon
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ?'Preparing... (' + (this.totalDependencies-left) +
'/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
// ========================================================================
-->
</script>
<script async type="text/javascript" src="js/newlisp-js-lib.js"></script>
Regards