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

42 lines
826 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 {
2020-05-03 13:00:08 +02:00
dipjson: {"ip": "", "hostname": "", "city": "", "country": ""},
returnstring: "",
2020-03-11 16:58:12 +01:00
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;
2020-05-03 13:00:08 +02:00
if (this.dipjson.hostname != "") {
this.returnstring = this.dipjson.ip + '/' + this.dipjson.hostname;
} else {
this.returnstring = this.dipjson.ip;
}
2020-03-11 16:58:12 +01:00
})
.catch(err => {
});
},
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
);