Created
September 14, 2015 19:52
-
-
Save stenehall/efc177fe6d5986560059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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