use stock JSON entries field for data

This commit is contained in:
davemachado 2017-08-16 23:27:09 -04:00
parent d148df03db
commit 32481b8f9b
2 changed files with 40 additions and 61 deletions

View file

@ -32,7 +32,7 @@
<tr class="tbl-head">
<th>API</th>
<th>Description</th>
<th>Authorization</th>
<th>Auth</th>
<th>HTTPS</th>
<th>Category</th>
</tr>
@ -43,7 +43,7 @@
<td>{{ item.Description }}</td>
<td>{{ (item.Auth) ? item.Auth : '-' }}</td>
<td>{{ (item.HTTPS) ? '✔' : '✖' }}</td>
<td class="lol">{{ item.Section }}</td>
<td class="lol">{{ item.Category }}</td>
</tr>
</tbody>
</table>

View file

@ -1,73 +1,18 @@
function loadJSON(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', 'https://raw.githubusercontent.com/toddmotto/public-apis/master/json/entries.min.json', true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
// Required use of an anonymous callback as .open will NOT return a value
// but simply returns undefined in asynchronous mode
callback(xobj.responseText);
}
};
xobj.send(null);
}
function filterRows() {
var input, filter, table, tr, td, i;
input = document.getElementById("searchbox");
filter = input.value.toUpperCase();
table = document.getElementById("entries");
tr = table.getElementsByTagName("tr");
// Loop through all table rows and hide those who don't match the search
for (i = 0; i < tr.length; i++) {
displayRows = false;
title = tr[i].getElementsByTagName("td")[0];
if (title) {
if (title.innerHTML.toUpperCase().indexOf(filter) > -1) {
displayRows = true;
}
}
section = tr[i].getElementsByTagName("td")[4];
if (section) {
if (section.innerHTML.toUpperCase().indexOf(filter) > -1) {
displayRows = true;
}
}
if (displayRows) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
loadJSON(function(response) {
var items = JSON.parse(response);
loadJSON(function(response) {
var items = JSON.parse(response);
new Vue({
data: {
filter: ''
},
computed: {
data() {
let output = [];
for (var category in items) {
for (var api in items[category]) {
items[category][api].Category = category;
output.push(items[category][api]);
}
}
return output;
return items.entries;
}
},
methods: {
filtered(item) {
let show = true;
if(this.filter.length) {
show = false;
@ -91,3 +36,37 @@ loadJSON(function(response) {
}
}).$mount('#app');
});
function loadJSON(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', 'https://raw.githubusercontent.com/toddmotto/public-apis/master/json/entries.min.json', true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
// Required use of an anonymous callback as .open will NOT return a value
// but simply returns undefined in asynchronous mode
callback(xobj.responseText);
}
};
xobj.send(null);
}
function filterRows() {
var input, filter, table, tr, td, i;
input = document.getElementById("searchbox");
filter = input.value.toUpperCase();
table = document.getElementById("entries");
tr = table.getElementsByTagName("tr");
// Loop through all table rows and hide those who don't match the search
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}