Skip to content

Instantly share code, notes, and snippets.

@stenehall
Created September 14, 2015 19:52
Show Gist options
  • Save stenehall/efc177fe6d5986560059 to your computer and use it in GitHub Desktop.
Save stenehall/efc177fe6d5986560059 to your computer and use it in GitHub Desktop.
var onLocked;
device.screen.on('off', function () {
onLocked = 0;
var now = new Date();
onLocked = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), 0, 0);
});
device.screen.on("unlock", function(){
var timeDiff = Math.floor((new Date().getTime() - onLocked.getTime()) / 1000 ); // Minutes
if(timeDiff > 60) {
feeds.weather.get(
{
location: 'Linköping',
locationtype: 'city',
unittype: 'm'
},
function onSucess (weather, textStatus, response) {
var messageBox = device.notifications.createMessageBox('Weather info');
messageBox.content = "It's " + weather.now.temperature + "C, Rain:" + weather.now.rain + "% It's " + weather.now.sky;
messageBox.buttons = [ 'Ok' ];
messageBox.show();
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment