Skip to content

Instantly share code, notes, and snippets.

@Natgho
Created January 22, 2021 12:35
Show Gist options
  • Save Natgho/f8b1f242fa5a458974e6167404c8b867 to your computer and use it in GitHub Desktop.
Save Natgho/f8b1f242fa5a458974e6167404c8b867 to your computer and use it in GitHub Desktop.
index.js
import geolocation from '@system.geolocation';
import battery from '@system.battery';
export default {
data: {
index: 0,
latlon: "",
accuracy: 0,
battery: 0,
percentage: 0,
myInterval: NaN,
todolist: [
{
title: 'Check the System',
date: '2021-01-01 10:00:00',
},
{
title: 'Add Notification',
date: '2021-01-02 20:00:00',
},
{
title: 'Create New Repo',
date: '2020-01-02 21:00:00',
},
{
title: 'Other Sample Header',
date: '2020-06-27 20:00:00',
},
{
title: 'Other Sample Header',
date: '2020-06-27 20:00:00',
},
{
title: 'Other Sample Header',
date: '2020-06-27 20:00:00',
},
{
title: 'Other Sample Header',
date: '2020-06-27 20:00:00',
},
],
},
updateData() {
var anchor = this;
geolocation.getLocation({
success: function (data) {
anchor.latlon = "\n" + data.latitude + "\n" + data.longitude;
anchor.accuracy = data.accuracy;
}
})
battery.getStatus({
success: function (data) {
anchor.battery = data.level;
}
})
},
onInit() {
this.updateData();
},
startProgressBar(){
var anchor = this;
anchor.myInterval = setInterval(function () {
if (anchor.percentage <= 100) {
anchor.percentage += 1;
} else {
anchor.percentage = 0;
}
}, 100);
},
stopProgressBar(){
var anchor = this;
clearInterval(anchor.myInterval);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment