website/themes/hugo-theme-wave/static/js/main.js

39 lines
749 B
JavaScript
Raw Normal View History

2020-02-08 22:13:01 +01:00
// dip service
2020-03-11 16:58:12 +01:00
var dip = new Vue({
el: '#dip',
2020-02-09 10:43:22 +01:00
2020-03-11 16:58:12 +01:00
data () {
return {
title: "Public IP Address Service",
dipjson: {"ip": null, "hostname": null, "city": null, "country": null},
autorefresh: false,
interval: null,
}
},
mounted () {
this.updateIP();
this.runTimer();
},
methods: {
updateIP: function () {
axios.get("https://ip.paulbsd.com/json")
.then(response => {
this.dipjson = response.data;
})
.catch(err => {
// Manage the state of the application if the request
// has failed
});
},
runTimer: function () {
if (this.autorefresh) {
this.interval = setInterval(this.updateIP,10000);
}
}
2020-02-09 10:43:22 +01:00
}
2020-02-08 22:13:01 +01:00
}
2020-03-11 16:58:12 +01:00
);