website/themes/hugo-theme-wave/static/js/main.js
Paul Lecuq ca3719a6e5
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
updated dipjson management
2020-05-03 13:00:08 +02:00

42 lines
826 B
JavaScript

// dip service
var dip = new Vue({
el: '#dip',
data () {
return {
dipjson: {"ip": "", "hostname": "", "city": "", "country": ""},
returnstring: "",
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;
if (this.dipjson.hostname != "") {
this.returnstring = this.dipjson.ip + '/' + this.dipjson.hostname;
} else {
this.returnstring = this.dipjson.ip;
}
})
.catch(err => {
});
},
runTimer: function () {
if (this.autorefresh) {
this.interval = setInterval(this.updateIP,10000);
}
}
}
}
);