update formatting

This commit is contained in:
davemachado
2017-08-16 23:08:45 -04:00
parent f56df6c2e0
commit f54ad9e8de
3 changed files with 60 additions and 58 deletions
+50 -45
View File
@@ -1,5 +1,52 @@
loadJSON(function(response) {
var items = JSON.parse(response);
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); // Replace 'my_data' with the path to your file
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);
new Vue({
data: {
filter: ''
@@ -19,7 +66,7 @@
methods: {
filtered(item) {
let show = true;
if(this.filter.length) {
show = false;
@@ -38,50 +85,8 @@
});
}
return show;
}
}
}).$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); // Replace 'my_data' with the path to your file
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++) {
title = tr[i].getElementsByTagName("td")[0];
section = tr[i].getElementsByTagName("td")[4];
if (title) {
if (title.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
if (section) {
if (section.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}