From c55f4084283035eebbad4b4690562e4044609493 Mon Sep 17 00:00:00 2001 From: Rob Vella Date: Fri, 31 Jul 2020 02:31:08 -0700 Subject: [PATCH] Change array structure --- .gitignore | 2 ++ app.js | 24 +++++++++++------------- fetchData.php | 2 -- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5617c92..a4cd6ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ yarn-error.log storage/* + +/vendor/ diff --git a/app.js b/app.js index 79db40a..7fdf0cb 100644 --- a/app.js +++ b/app.js @@ -6,11 +6,10 @@ */ Vue.component('lt-node-link', { - template: `{{ node }}`, + template: `{{ node }}`, props: ['node', 'type'], data() { return { - uri: '', urlMap: { 0: '#', 1: 'http://stats.allstarlink.org/nodeinfo.cgi?node=', @@ -18,8 +17,10 @@ Vue.component('lt-node-link', { } } }, - mounted() { - this.uri = this.urlMap[this.type] + this.node; + methods: { + getUrl() { + return this.urlMap[this.type] + this.node; + } } }); @@ -34,10 +35,7 @@ let App = new Vue({ uri: 'fetchData.php', lastData: null, logs: [], - nodes: { - 1: [], - 2: [] - }, + nodes: {}, nodeTypeLabels: { 0: 'Unknown', 1: 'Allstar', @@ -87,8 +85,8 @@ let App = new Vue({ }, getNodeInfo(node, type) { - if (typeof this.nodes[type][node] !== "undefined") { - let info = this.nodes[type][node]; + if (typeof this.nodes[type+node] !== "undefined") { + let info = this.nodes[type+node]; if (typeof info.callsign === "undefined") return; return `${info.callsign} ${info.desc} ${info.location}`; } else { @@ -133,13 +131,13 @@ let App = new Vue({ // if (typeof this.nodes[type][node] === "undefined") { // this.nodes[type][node] = null; // return this.fetchNodeInfo(node, type); - if (this.nodes[type][node]) { + if (this.nodes[type+node]) { // Don't even call fetchNode** - return this.nodes[type][node]; + return this.nodes[type+node]; } axios.get(this.uri + '?cmd=node&type='+type+'&node='+node).then(({data}) => { - this.nodes[type][node] = data; + this.nodes[type+node] = data; }); }, diff --git a/fetchData.php b/fetchData.php index e80c802..9df2f63 100644 --- a/fetchData.php +++ b/fetchData.php @@ -29,8 +29,6 @@ return; function fetchNodeInfoAllstar($node) { $db = fetchAllStarDb(); - if (empty($node)) return []; - $db = explode("\n", $db); foreach ($db as $row) { $row = explode("|", $row);