website/themes/hugo-theme-wave/static/js/main.js
2020-03-11 16:58:12 +01:00

39 lines
749 B
JavaScript

// dip service
var dip = new Vue({
el: '#dip',
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);
}
}
}
}
);