-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinal.html
95 lines (93 loc) · 3.36 KB
/
final.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vue.js Tutorial | API Example</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="app">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="lead-form">
<h1 class="text-center">Fill Out This Form</h1>
<hr />
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" placeholder="Starting Zip" v-model='startingzip'>
<span class="city-span" v-text='startingCity'></span>
</div>
<div class="col-md-6">
<input type="text" class="form-control" placeholder="Ending Zip" v-model='endingzip'>
<span class="city-span" v-text='endingCity'></span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="btn btn-primary btn-block" id="submit-form">Submit</button>
</div>
</div>
</div><!-- end of .lead-form -->
</div> <!-- end of .col-md-6.col-md-offset-3 -->
</div> <!-- end of .row -->
</div> <!-- end of .container -->
</div> <!-- end of #app -->
</body>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
<script src="https://unpkg.com/[email protected]/lodash.min.js"></script>
<script>
var app = new Vue({
el: '#app',
data:{
startingzip:'',
startingCity:'',
endingzip:'',
endingCity:''
},
watch:{
startingzip: function(){
this.startingCity = ''
if(this.startingzip.length==5){
this.lookupstartingzip()
}
},
endingzip: function(){
this.endingCity = ''
if(this.endingzip.length ==5){
this.lookupendingzip()
}
}
},
methods:{
lookupstartingzip: _.debounce(function(){
var app = this
app.startingCity='Searching...'
axios.get('http://ziptasticapi.com/' + app.startingzip)
.then(function(response){
app.startingCity = response.data.city + ', ' + response.data.state
})
.catch(function (error) {
app.startingCity ='Invalid Zipcode'
})
},500),
lookupendingzip: _.debounce(function(){
var app = this
app.endingCity='Searching...'
axios.get('http://ziptasticapi.com/' + app.endingzip)
.then(function(response){
app.endingCity = response.data.city + ', ' + response.data.state
})
.catch(function (error) {
app.endingCity ='Invalid Zipcode'
})
},500)
}
})
</script>
</html>