You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NotePostApp/www/js/main.js

70 lines
1.8 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
var $$ = Dom7;
var app = new Framework7({
root: "#app",
name: "NotePost",
id: "com.netsyms.NotePostApp",
init: true,
initOnDeviceReady: false,
routes: routes
});
var mainView = app.views.create('.view-main', {
url: "/"
});
var router = mainView.router;
var NOTES = null;
var OFFLINE = false;
/**
* Thanks to https://stackoverflow.com/a/13542669
* @param {type} color
* @param {type} percent
* @returns {String}
*/
function shadeColor2(color, percent) {
var f = parseInt(color.slice(1), 16), t = percent < 0 ? 0 : 255, p = percent < 0 ? percent * -1 : percent, R = f >> 16, G = f >> 8 & 0x00FF, B = f & 0x0000FF;
return "#" + (0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B)).toString(16).slice(1);
}
function restartApplication() {
window.location = "index.html";
}
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());
}
});
switch (pagedata.name) {
case "settings":
updateSettingsData();
break;
}
});
// Run platform-specific setup code for Cordova or NW.js
initPlatform();
if (localStorage.getItem("configured") == null) {
// Open the setup page
router.navigate("/setup/0");
} else {
createNotesObject(function (n) {
NOTES = n;
router.navigate("/home");
});
}