added pebble-js-app.js in preparation for settings page

master
Alina Marquardt 2015-11-20 20:49:25 +01:00
parent ef66876379
commit 9ca7fd9f0e
1 changed files with 23 additions and 0 deletions

23
src/js/pebble-js-app.js Normal file
View File

@ -0,0 +1,23 @@
Pebble.addEventListener('ready', function() {
console.log('PebbleKit JS ready!');
});
Pebble.addEventListener('showConfiguration', function() {
var url='http://pebble.lastfuture.de/config/supersimple13/';
console.log('Showing configuration page: '+url);
Pebble.openURL(url);
});
Pebble.addEventListener('webviewclosed', function(e) {
var configData = JSON.parse(decodeURIComponent(e.response));
console.log('Configuration page returned: '+JSON.stringify(configData));
if (configData.colors) {
Pebble.sendAppMessage({
colors: configData.colors
}, function() {
console.log('Send successful!');
}, function() {
console.log('Send failed!');
});
}
});