Make script tags work when inside pages

This commit is contained in:
Skylar Ittner 2018-11-07 17:13:12 -07:00
parent 2c3092ecb4
commit 44a0da1f2b

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var $$ = Dom7;
var shown_notifications = []; var shown_notifications = [];
var app = new Framework7({ var app = new Framework7({
@ -85,16 +87,13 @@ document.addEventListener("backbutton", function (event) {
document.addEventListener("deviceready", function () { document.addEventListener("deviceready", function () {
loadingProgressDialog = app.dialog.progress('Loading...', 0);
loadingProgressDialog.setText('');
if (cordova.platformId == 'android') { if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString("#1976d2"); StatusBar.backgroundColorByHexString("#1976d2");
} }
// Enable/disable jQuery animations depending on user preference
$.fx.off = !(localStorage.getItem("animations") === null || localStorage.getItem("animations") === "true");
if (isconfigvalid()) { if (isconfigvalid()) {
loadingProgressDialog = app.dialog.progress('Loading...', 0);
loadingProgressDialog.setText('');
loadingProgressDialog.setProgress(20); loadingProgressDialog.setProgress(20);
loadingProgressDialog.setText('Account'); loadingProgressDialog.setText('Account');
getuserinfo(function () { getuserinfo(function () {
@ -106,7 +105,7 @@ document.addEventListener("deviceready", function () {
loadingProgressDialog.setProgress(60); loadingProgressDialog.setProgress(60);
// Load homepage/dashboard // Load homepage/dashboard
loadingProgressDialog.setText('Apps'); loadingProgressDialog.setText('Apps');
loadHomePage(); loadHomePage(false);
}); });
} else { } else {
// Try to recover data from NativeStorage back to localStorage // Try to recover data from NativeStorage back to localStorage
@ -130,6 +129,15 @@ router.on("pageBeforeIn", function (pagedata) {
}); });
router.on("pageInit", function (pagedata) { router.on("pageInit", function (pagedata) {
pagedata.$el.find('script').each(function (el) {
if ($$(this).attr('src')) {
var s = document.createElement('script');
s.src = $$(this).attr('src');
$$('head').append(s);
} else {
eval($$(this).text());
}
});
app.progressbar.hide(); app.progressbar.hide();
switch (pagedata.name) { switch (pagedata.name) {
case "settings": case "settings":