Created
March 16, 2018 03:21
-
-
Save sawatsky/6182c9aaf770e4616113818b89a06c1f to your computer and use it in GitHub Desktop.
Faux-database stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"drivers": [ | |
{ "id": 1, "name": "John Smith", "phone": "123-123-1233", "license": "SAWATHL082JD", "SIN": "234-234-234", "mailingAddress": { "line1": "234 123th Ave NE", "line2": "Apt. 234", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" }, "trucks": [ 1, 2 ], "trailers": [ 1 ] }, | |
{ "id": 2, "name": "Jane Doe", "phone": "754-324-2342", "license": "FHJSH934KJ", "SIN": "464-444-454", "mailingAddress": { "line1": "1241 231th St.", "line2": "Apt. 12", "city": "Melbourne", "region": "wa", "country": "us", "code": "12311" }, "trucks": [ 3 ], "trailers": [ 2 ] }, | |
{ "id": 3, "name": "Gordon Ramsey", "phone": "555-345-9789", "license": "4523452345", "SIN": "333-555-444", "mailingAddress": { "line1": "345 123th Ave NE", "line2": "Apt. 32", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" }, "trucks": [ 4 ], "trailers": [] }, | |
{ "id": 4, "name": "Ash Ketchum", "phone": "345-123-6574", "license": "3425234545", "SIN": "111-234-232", "mailingAddress": { "line1": "2 234th Ave SE", "line2": "Apt. 5462", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" }, "trucks": [ 5 ], "trailers": [ 3, 4 ] }, | |
{ "id": 5, "name": "John Cena", "phone": "555-345-3453", "license": "1231321", "SIN": "786-676-474", "mailingAddress": { "line1": "345 3453th Ave NE", "line2": "Apt. 3452", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" }, "trucks": [], "trailers": [] } | |
], | |
"clients": [ | |
{ "id": 1, "name": "QFC", "creditBalance": 1231.23, "currencyType": "usd", "creditLimit": 2342.32, "paymentInterval": 3, "taxFormula": "asdf", "rateFormula": "adsf", "dispatcher": { "name": "Bella Donna", "phone": "123-123-1231" }, "billingInformation": { "name": "Mr. QFC", "phone": "111-111-1111", "billingAddress": { "line1": "2 234th Ave SE", "line2": "Apt. 5462", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } } }, | |
{ "id": 2, "name": "Walmart", "creditBalance": 2123.23, "currencyType": "usd", "creditLimit": 2342.32, "paymentInterval": 6, "taxFormula": "asdf", "rateFormula": "adsf", "dispatcher": { "name": "Dean Wesson", "phone": "123-234-1231" }, "billingInformation": { "name": "Mr. Walmart", "phone": "234-111-1111", "billingAddress": { "line1": "25 234th Ave SE", "line2": "Apt. 23", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } } }, | |
{ "id": 3, "name": "Whole Foods", "creditBalance": 456456.23, "currencyType": "usd", "creditLimit": 23422.32, "paymentInterval": 3, "taxFormula": "asdf", "rateFormula": "adsf", "dispatcher": { "name": "Cole Pope", "phone": "555-123-1231" }, "billingInformation": { "name": "Mr. Foods", "phone": "111-756-1111", "billingAddress": { "line1": "266 234th Ave SE", "line2": "Apt. 34", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } } }, | |
{ "id": 4, "name": "SalesForce", "creditBalance": 456423.23, "currencyType": "usd", "creditLimit": 223.32, "paymentInterval": 1, "taxFormula": "asdf", "rateFormula": "adsf", "dispatcher": { "name": "Sam Smith", "phone": "123-123-7655" }, "billingInformation": { "name": "Mr. Force", "phone": "111-111-3333", "billingAddress": { "line1": "23 234th Ave SE", "line2": "Apt. 657", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } } } | |
], | |
"trips": [ | |
{ "id": 1, "clientId": 3, "purchaseNumber": "1231234Q", "customer": "Concur", "orderNumber": "1231231", "pickupInformation": { "date": "May 4, 2012 4:45pm", "location": { "line1": "23 234th Ave SE", "line2": "Apt. 657", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } }, "deliveryInformations": [ { "date": "May 4, 2012 4:45pm", "location": { "line1": "23 234th Ave SE", "line2": "Apt. 657", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" }, "date": "May 4, 2012 4:45pm", "location": { "line1": "23 234th Ave SE", "line2": "Apt. 657", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } } ], "fuelSurcharge": 123.22, "rateFormula": "asdf", "driverId": 1, "truckId": 2, "trailerId": 5 }, | |
{ "id": 2, "clientId": 2, "purchaseNumber": "1243SSS12", "customer": "Ross's Dress For Less", "orderNumber": "642634523423", "pickupInformation": { "date": "May 10, 2019 4:00pm", "location": { "line1": "123 234th Ave SE", "line2": "Apt. 4123", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } }, "deliveryInformations": [ { "date": "May 15, 2019 4:45pm", "location": { "line1": "1231 234th Ave SE", "line2": "Apt. 657", "city": "Bellevue", "region": "wa", "country": "us", "code": "98004" } } ], "fuelSurcharge": 33.22, "rateFormula": "asdf", "driverId": 4, "truckId": 6, "trailerId": 4 } | |
], | |
"trucks": [ | |
{ "id": 1, "type": "Type A", "mileage": 12311, "serviceDate": "April 1, 2018" }, | |
{ "id": 2, "type": "Type B", "mileage": 123, "serviceDate": "June 2, 2014" }, | |
{ "id": 3, "type": "Type A", "mileage": 46354, "serviceDate": "June 1, 2019" }, | |
{ "id": 4, "type": "Type C", "mileage": 52345, "serviceDate": "August 7, 2014" }, | |
{ "id": 5, "type": "Type C", "mileage": 2343, "serviceDate": "June 17, 2012" }, | |
{ "id": 6, "type": "Type A", "mileage": 534523, "serviceDate": "December 1, 2014" } | |
], | |
"trailers": [ | |
{ "id": 1, "rentedOrOwned": 1, "axleCount": 6 }, | |
{ "id": 2, "rentedOrOwned": 2, "axleCount": 17 }, | |
{ "id": 3, "rentedOrOwned": 2, "axleCount": 10 }, | |
{ "id": 4, "rentedOrOwned": 1, "axleCount": 4 }, | |
{ "id": 5, "rentedOrOwned": 2, "axleCount": 12 } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAll(resource) { | |
var xmlHttpRequest = new XMLHttpRequest(); | |
xmlHttpRequest.open("GET", "http://localhost:3000/" + resource + "/", true); | |
xmlHttpRequest.onreadystatechange = function() { | |
if (xmlHttpRequest.readyState == XMLHttpRequest.DONE && xmlHttpRequest.status == 200) { | |
try { | |
var data = JSON.parse(xmlHttpRequest.responseText); | |
for (var i = 0; i < data.length; i++) { | |
var trHead = document.createElement("tr"); | |
var tr = document.createElement("tr"); | |
var entries = Object.entries(data[i]); | |
for (var j = 0; j < entries.length; j++) { | |
if (i == 0) { | |
var th = document.createElement("th"); | |
th.innerHTML = entries[j][0]; | |
trHead.appendChild(th); | |
} | |
var td = document.createElement("td"); | |
td.innerHTML = entries[j][1]; | |
tr.appendChild(td); | |
} | |
if (i == 0) { | |
document.querySelector("#data").appendChild(trHead); | |
} | |
document.querySelector("#data").appendChild(tr); | |
} | |
} catch (error) { | |
console.error(error); | |
} | |
} | |
}; | |
xmlHttpRequest.send(); | |
} | |
function create(resource) { | |
} | |
function get(resource) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment