1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-08-06 13:26:36 +02:00

fix js not showing inline in downloaded file. fixes #53

This commit is contained in:
Kushagra Gour
2017-01-28 00:38:46 +05:30
parent 8ea24447a9
commit 2d091a292a

View File

@@ -611,7 +611,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
}); });
} }
function getCompleteHtml(html, css) { function getCompleteHtml(html, css, js) {
var externalJs = externalJsTextarea.value.split('\n').reduce(function (scripts, url) { var externalJs = externalJsTextarea.value.split('\n').reduce(function (scripts, url) {
return scripts + (url ? '\n<script src="' + url + '"></script>' : ''); return scripts + (url ? '\n<script src="' + url + '"></script>' : '');
}, ''); }, '');
@@ -623,10 +623,16 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
+ '<style id="webmakerstyle">\n' + css + '\n</style>\n' + '<style id="webmakerstyle">\n' + css + '\n</style>\n'
+ '</head>\n' + '</head>\n'
+ '<body>\n' + html + '\n' + '<body>\n' + html + '\n'
+ externalJs + '\n<script src="' + externalJs + '\n';
if (js) {
contents += '<script>\n' + js + '\n//# sourceURL=userscript.js';
} else {
contents += '<script src="'
+ 'filesystem:chrome-extension://' + 'filesystem:chrome-extension://'
+ chrome.i18n.getMessage('@@extension_id') + '/temporary/' + 'script.js' + '">\n' + chrome.i18n.getMessage('@@extension_id') + '/temporary/' + 'script.js' + '">'
+ '</script></body>\n</html>'; }
contents += '\n</script>\n</body>\n</html>';
return contents; return contents;
} }
@@ -658,7 +664,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
} }
function createPreviewFile(html, css, js) { function createPreviewFile(html, css, js) {
var contents = getCompleteHtml(html, css, js); var contents = getCompleteHtml(html, css);
var blob = new Blob([ contents ], { type: "text/plain;charset=UTF-8" }); var blob = new Blob([ contents ], { type: "text/plain;charset=UTF-8" });
var blobjs = new Blob([ js ], { type: "text/plain;charset=UTF-8" }); var blobjs = new Blob([ js ], { type: "text/plain;charset=UTF-8" });