diff --git a/code/mitch/javascript/lab_07/index.html b/code/mitch/javascript/lab_07/index.html new file mode 100644 index 00000000..5a2e57e8 --- /dev/null +++ b/code/mitch/javascript/lab_07/index.html @@ -0,0 +1,110 @@ + + + + + + + Vehicle Info + + + + + + + + +
+ Vehicle Info Machine Logo +
+ +
+

Search by Vehicle Identification Number (VIN):

+
+ + + +
+ +

OR

+ +

Search by Year, Make, and Model:

+ + + + +
+ + + +
+ + Year: {{ userYear }} + + +
+ + + +
+ + Make: {{ userMake }} + + +
+ + + +
+ + Model: {{ userModel }} + + + + + +
+ + \ No newline at end of file diff --git a/code/mitch/javascript/lab_07/script.js b/code/mitch/javascript/lab_07/script.js new file mode 100644 index 00000000..677d645b --- /dev/null +++ b/code/mitch/javascript/lab_07/script.js @@ -0,0 +1,93 @@ + + + +const App = { + data () { + return { + output: '', + userVIN: '', + userYear: '', + userMake: '', + userModel: '', + makeList: [], + modelList: [], + baseUrl: 'https://vpic.nhtsa.dot.gov/api/vehicles/', + } + }, + + created() { + this.getAllMakes() + }, + + methods: { + searchByVIN () { + axios({ + url: this.baseUrl + "DecodeVinValues/" + this.userVIN, + method: 'get', + headers: { + Accept: 'application/json' + }, + params: { + format: 'json', + }, + }).then(response => { + console.log(response) + this.output = response.data.Results[0] + this.userYear = this.output.ModelYear + this.userMake = this.output.Make + this.userModel = this.output.Model + }) + }, + getAllMakes () { + axios({ + url: this.baseUrl + "GetAllMakes/", + method: 'get', + headers: { + Accept: 'application/json' + }, + params: { + format: 'json', + }, + }).then(response => { + console.log(response) + this.makeList = response.data.Results + }) + }, + searchByMakeAndYear () { + if (this.userMake === "") return + axios({ + url: this.baseUrl + "GetModelsForMakeYear/make/" + this.userMake + "/modelyear/" + this.userYear, + method: 'get', + headers: { + Accept: 'application/json' + }, + params: { + format: 'json', + }, + }).then(response => { + console.log(response) + this.modelList = response.data.Results + }) + }, + undo (userObject) { + if (userObject == "year") { + this.userYear = "" + this.userMake = "" + this.userModel ="" + this.modelList = [] + }else if (userObject == "make") { + this.userMake = "" + this.userModel ="" + this.modelList = [] + }else if (userObject == "model") { + this.userModel = "" + } + }, + } +} + +const app = Vue.createApp(App) + + +app.component('vue-select', VueNextSelect) +app.mount('#app') diff --git a/code/mitch/javascript/lab_07/vim_logo.jpeg b/code/mitch/javascript/lab_07/vim_logo.jpeg new file mode 100644 index 00000000..875dae20 Binary files /dev/null and b/code/mitch/javascript/lab_07/vim_logo.jpeg differ