main app code and some default modules

This commit is contained in:
nojhan 2012-12-03 00:16:14 +01:00
commit abd2dadb45
7 changed files with 407 additions and 0 deletions

41
www/js/install-button.js Normal file
View file

@ -0,0 +1,41 @@
define(function(require) {
var install = require('install');
function update() {
var btn = document.getElementById('install-btn');
if(install.state == 'uninstalled') {
btn.style.display = 'block';
}
else if(install.state == 'installed' || install.state == 'unsupported') {
btn.style.display = 'none';
}
}
function init() {
var btn = document.getElementById('install-btn');
btn.addEventListener('click', function() {
install();
});
install.on('change', update);
install.on('error', function(e, err) {
// Feel free to customize this
alert('There was an error during installation.');
});
install.on('showiOSInstall', function() {
// Feel free to customize this
alert('To install, press the forward arrow in Safari ' +
'and touch "Add to Home Screen"');
});
}
if(!document.getElementById('install-btn')) {
document.addEventListener('DOMContentLoaded', init);
}
else {
init();
}
});