Upload files to "src/pkjs"
This commit is contained in:
79
src/pkjs/app.js
Normal file
79
src/pkjs/app.js
Normal file
@@ -0,0 +1,79 @@
|
||||
var BASE_CONFIG_URL = 'http://singleserveapps.github.io/basic-steps-config/';
|
||||
//var BASE_CONFIG_URL = 'http://singleserveapps.github.io/basic-steps-config-beta/';
|
||||
|
||||
Pebble.addEventListener('showConfiguration', function() {
|
||||
var rectURL = BASE_CONFIG_URL + 'index.html';
|
||||
var roundURL = BASE_CONFIG_URL + 'config_round.html';
|
||||
var watch;
|
||||
|
||||
if(Pebble.getActiveWatchInfo) {
|
||||
try {
|
||||
watch = Pebble.getActiveWatchInfo();
|
||||
} catch(err) {
|
||||
watch = {
|
||||
platform: "basalt",
|
||||
};
|
||||
}
|
||||
} else {
|
||||
watch = {
|
||||
platform: "aplite",
|
||||
};
|
||||
}
|
||||
|
||||
if(watch.platform == "aplite"){
|
||||
Pebble.openURL(rectURL);
|
||||
} else if(watch.platform == "chalk") {
|
||||
Pebble.openURL(roundURL);
|
||||
} else {
|
||||
Pebble.openURL(rectURL);
|
||||
}
|
||||
});
|
||||
|
||||
Pebble.addEventListener('webviewclosed', function(e) {
|
||||
var configData = JSON.parse(decodeURIComponent(e.response));
|
||||
|
||||
console.log('Configuration page returned: ' + JSON.stringify(configData));
|
||||
|
||||
if (!configData.displayDigitalTime) {
|
||||
console.log("hrColor: ", parseInt(configData.hrColor, 16));
|
||||
console.log("minColor: ", parseInt(configData.minColor, 16));
|
||||
console.log("wsdColor: ", parseInt(configData.wsdColor, 16));
|
||||
console.log("backgroundColor: ", parseInt(configData.backgroundColor, 16));
|
||||
console.log("hourFont: ", parseInt(configData.hourFont, 10));
|
||||
console.log("minutesFont: ", parseInt(configData.minutesFont, 10));
|
||||
|
||||
// Assemble dictionary using our keys
|
||||
var options_dictionary = {
|
||||
"KEY_HR_COLOR": parseInt(configData.hrColor, 16),
|
||||
"KEY_MIN_COLOR": parseInt(configData.minColor, 16),
|
||||
"KEY_WSD_COLOR": parseInt(configData.wsdColor, 16),
|
||||
"KEY_BACKGROUND_COLOR": parseInt(configData.backgroundColor, 16),
|
||||
"KEY_HOUR_FONT": parseInt(configData.hourFont, 10),
|
||||
"KEY_MINUTES_FONT": parseInt(configData.minutesFont, 10)
|
||||
};
|
||||
|
||||
// Send to Pebble
|
||||
Pebble.sendAppMessage(options_dictionary,
|
||||
function(e) {
|
||||
console.log("webviewclosed: Watchface options successfully sent to Pebble");
|
||||
},
|
||||
function(e) {
|
||||
console.log('webviewclosed: Unable to deliver message with transactionId=' + e.data.transactionId + ' Error is: ' + e.error.message);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Pebble.addEventListener('ready', function() {
|
||||
console.log('PebbleKit JS Ready!');
|
||||
|
||||
// Notify the watchapp that it is now safe to send messages
|
||||
Pebble.sendAppMessage({ 'KEY_JS_READY': 1 });
|
||||
|
||||
});
|
||||
|
||||
Pebble.addEventListener('appmessage',
|
||||
function(e) {
|
||||
console.log("Got message: " + JSON.stringify(e));
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user