-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
145 lines (138 loc) · 3.5 KB
/
index.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Vue</title>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<style>
.box{
border: 1px solid black;
width: 30%;
}
.active {
background-color: mediumaquamarine;
color: darkred;
}
</style>
</head>
<body>
<div id="app">
<img src="https://vuejs.org/images/logo.png" alt="Vue logo">
<h1 v-bind:style="colorStyle">{{ greeting }}</h1>
<ul>
<li>
To learn more about Vue, visit
<a :href="docsURL" target="_blank">
{{ humanizeURL(docsURL) }}
</a>
</li>
<li>
For live help with simple questions, check out
<a :href="gitterURL" target="_blank">
the Gitter chat
</a>
</li>
<li>
For more complex questions, post to
<a :href="forumURL" target="_blank">
the forum
</a>
</li>
</ul>
<div>
<select name="config-select" id="config-select" v-on:click.stop v-model="currentConfigIndex" style="height: 100%;">
<option v-for="c in config" v-bind:value="c.index">{{capitalize(c.name)}}</option>
</select>
<input type="checkbox" v-bind:checked="ignoreColor" v-model="ignoreColor">Ignore Color</input>
<ul>
<li>
{{currentConfig.index}}
</li>
<li>
{{currentConfig.name}}
</li>
<li>
{{currentConfig.color}}
</li>
</ul>
</div>
<div class="box">
<ul style="list-style: none;">
<li v-for="c in config">{{ c.name }}</li>
</ul>
</div>
</div>
<script>
var vapp = new Vue({
el: '#app',
data: {
greeting: 'This is a test for Github',
docsURL: 'http://vuejs.org/guide/',
gitterURL: 'https://gitter.im/vuejs/vue',
forumURL: 'http://forum.vuejs.org/',
config: [
{
index: 1,
name: "first",
color: 'red'
},
{
index: 2,
name: "second",
color: 'yellow'
},
{
index: 3,
name: "third",
color: 'green'
}
],
currentConfigIndex: 1,
ignoreColor: false
},
methods: {
humanizeURL: function (url) {
return url
.replace(/^https?:\/\//, '')
.replace(/\/$/, '')
},
capitalize: function (string) {
return string[0].toUpperCase() + string.substr(1);
},
listClicked: function () {
console.log("Clicked")
}
},
computed: {
currentConfig: function () {
var that = this;
var config= that.config.filter(function (obj){
return obj.index == that.currentConfigIndex;
})[0];
return config ? config : that.config[0]
// Or this to set the currentConfigIndex back
// if (config) {
// return config;
// } else {
// that.currentConfigIndex = 1
// return that.config[0]
// }
},
configIndexes: function () {
var indexes = [];
this.config.forEach(function (obj) {
indexes.push(obj.index)
})
return indexes;
},
colorStyle: function () {
if (this.ignoreColor) {
return "";
} else {
return "color: " + this.currentConfig.color
}
}
}
})
</script>
</body>
</html>