var seedsInfo = new Vue({ parent: navbar, el: '#seeds', delimiters: ["${", "}"], data: { seedsInfo: [], loading: true, netcode: "N3main", interval: null }, watch: { netcode: function (newVal, oldVal) { clearInterval(this.interval); this.loadSeedsInfo(true); this.interval = setInterval(() => this.loadSeedsInfo(false), 15000); }, seedsInfo: function (newVal, oldVal) { setTimeout(() => this.loading = false, 500); } }, methods: { loadSeedsInfo(net_changed) { this.loading = true; fetch("/api/" + this.netcode + "/seeds") .then(resp => { resp.json() .then(json => { this.seedsInfo = json; }) .catch(e => { console.log(e) if (net_changed) { this.seedsInfo = []; } }); }) .catch(e => { console.log(e) if (net_changed) { this.seedsInfo = []; } }); } }, mounted: function () { this.loadSeedsInfo(false); this.interval = setInterval(() => this.loadSeedsInfo(false), 15000); } });