2
2
// Basic Imports
3
3
import { RouterLink , RouterView } from ' vue-router'
4
4
import Logo from ' @/assets/logo.svg?component'
5
+ import PollIcon from ' @/assets/icons/poll.svg?component'
6
+ import GHIcon from ' @/assets/icons/github.svg?component'
5
7
import AutoComplete from ' primevue/autocomplete'
6
8
import Button from " primevue/button"
7
9
import Toast from ' primevue/toast'
@@ -10,25 +12,26 @@ import Toast from 'primevue/toast'
10
12
<template >
11
13
<Toast />
12
14
<!-- HTML For Header -->
13
- <header id =" header" v-bind:class =" { 'homePageLogo': $route.path == '/' }" >
14
-
15
- <div class =" left-nav" >
16
- <RouterLink to =" /" > <Logo class =" logo" height =" 75" width =" 75" /> </RouterLink >
17
- <div class =" search" >
18
- <AutoComplete v-model =" selection" placeholder =" Search for a building or class..." :suggestions =" filteredResults" @complete =" filterResults" @item-select =" searchFunc" ></AutoComplete >
19
- </div >
15
+ <header id =" header" >
16
+ <div id =" left-nav" >
17
+ <RouterLink to =" /" > <Logo class =" logo" height =" 75" width =" 75" />
18
+ </RouterLink >
20
19
</div >
21
20
22
- <div class =" right-nav" >
23
- <
a href =
" mailto:[email protected] " ><
Button class =
" nav-btn" >
24
- <img src = " ./assets/icons/poll.svg " height =" 30 " width =" 30 " />
21
+ <div id =" right-nav" >
22
+ <a href =" https://forms.gle/Tu5xSSjK1MkZDXK69 " target = " _blank " rel = " noopener noreferrer " ><Button class =" nav-btn" aria-label = " Feedback " >
23
+ <PollIcon height =" 25 " width =" 25 " />
25
24
</Button ></a >
26
- <a href =" https://github.com/Vacansee" ><Button class =" nav-btn" >
27
- <img src = " ./assets/icons/github.svg " height =" 30 " width =" 30 " />
25
+ <a href =" https://github.com/Vacansee/app " target = " _blank " rel = " noopener noreferrer " ><Button class =" nav-btn" aria-label = " GitHub " >
26
+ <GHIcon height =" 25 " width =" 25 " />
28
27
</Button ></a >
29
28
</div >
30
- </header >
31
-
29
+ </header >
30
+ <div id =" mobile-nav" >
31
+ <Teleport to =" #left-nav" :disabled =" global.aspectRatio > 1.5" >
32
+ <AutoComplete class =" search" :style =" {'width':'100%'}" :input-style =" {'width': '100%'}" v-model =" selection" :placeholder =" ex" :suggestions =" suggest" @complete =" filterRes" @item-select =" goTo" @focus.native =" searchFocus(true)" @blur.native =" searchFocus(false)" ></AutoComplete >
33
+ </Teleport >
34
+ </div >
32
35
33
36
<RouterView />
34
37
</template >
@@ -37,7 +40,14 @@ import Toast from 'primevue/toast'
37
40
export default {
38
41
data () {
39
42
return {
40
- filteredResults: [],
43
+ exs: [
44
+ " a building: Russell Sage" ,
45
+ " a dept. code: CSCI 1200" ,
46
+ " a room: DCC 308" ,
47
+ " a CRN: 80385"
48
+ ],
49
+ ex: " " ,
50
+ suggest: [],
41
51
selection: " "
42
52
}
43
53
},
@@ -52,81 +62,129 @@ export default {
52
62
else
53
63
document .getElementById (" header" ).style .opacity = " 1" ;
54
64
}
55
- },
56
- ' global.error' : {
57
- handler () {
58
- if (this .global .error ) this .$showToast ({title: ' Failed to load data' , body: this .global .error })
59
- }
60
65
}
61
66
},
67
+ mounted () {
68
+ this .changeEx ()
69
+ setInterval (this .changeEx , 5000 );
70
+ },
62
71
methods: {
63
- filterResults (event ) {
64
- // filter buildings and classes
72
+ changeEx () {
73
+ const ex = this .exs .shift ()
74
+ this .ex = ` Try ${ ex} ` ; this .exs .push (ex)
75
+ },
76
+ searchFocus (is ) {
77
+ this .global .sFocus = is
78
+ // console.log("sFocus:", is)
79
+ },
80
+ filterRes (event ) {
81
+ // Case & whitespace insensitive, ignore some characters:
82
+ const query = event .query .toLowerCase ().replace (/ \s {2,} / g , ' ' ).replace (/ ["#] / g , ' ' )
65
83
setTimeout (() => {
66
- this .filteredResults = [];
67
- Object .keys (this .global .data ).map ((bid ) => {
68
- this .filteredResults .push (bid .toString () + " (" + this .global .data [bid].meta .name .toString () + " )" );
84
+ this .suggest = []
85
+ // Transform, sort, filter global.data + global.searchData:
86
+ this .suggest = Object .keys (this .global .data ).concat (this .global .searchData .flatMap (Object .keys ))
87
+ .map (key => {
88
+ if (key in this .global .data ) return ` ${ key .toString ()} (${ this .global .data [key].meta .name .toString ()} )`
89
+ else return key
69
90
})
70
- this .filteredResults .sort ();
71
- this .filteredResults = this .filteredResults .map ((bid ) => {
72
- return bid .replace (/ _/ g , ' ' );
73
- })
74
- .filter ((result ) => {
75
- return result .toLowerCase ().includes (event .query .toLowerCase ());
76
- });
77
- }, 250 );
91
+ .filter (s => s .toLowerCase ().includes (query))
92
+ .sort ()
93
+ .map (s => s .replace (/ _/ g , ' ' ));
94
+ }, 100 );
78
95
},
79
- searchFunc () {
80
- // select building or class here
81
- this .global .bldg = this .selection .substring (0 , this .selection .indexOf (" (" ) - 1 );
82
- this .selection = " " ;
96
+ goTo () {
97
+ const abbrev = this .selection .substring (0 , this .selection .indexOf (" (" ) - 1 )
98
+ if (abbrev in this .global .data ) {
99
+ this .global .bldg = abbrev, this .selection = " "
100
+ console .log (` Building "${ abbrev} " selected` )
101
+ return
102
+ }
103
+ else if (this .selection in this .global .searchData [2 ]) { // toRoom
104
+ const [bldg , room ] = this .selection .split (" " )
105
+ this .global .floor = parseInt (room[0 ]) // TODO: non-numerical room #s
106
+ this .global .room = room, this .global .bldg = bldg
107
+ console .log (` Room "${ this .selection } " selected` )
108
+ this .selection = " "
109
+ return
110
+ }
111
+ let CRN = " "
112
+ if (this .selection in this .global .searchData [1 ]) { // deptToCRN
113
+ CRN = this .global .searchData [1 ][this .selection ]
114
+ console .log (` Using dept code "${ this .selection } "` )
115
+ }
116
+ else if (this .selection in this .global .searchData [0 ]) CRN = this .selection // byCRN
117
+ // TODO: show all locations (pins), calc time 'til begin/end
118
+ const [bldg , room ] = Object .keys (this .global .searchData [0 ][CRN ])[0 ].split (" " )
119
+ this .global .floor = parseInt (room[0 ])
120
+ this .global .room = room, this .global .bldg = bldg, this .selection = " "
121
+ console .log (` Room w/ CRN #${ CRN } selected` )
83
122
}
84
123
}
85
124
}
86
125
</script >
87
126
<style scoped>
88
127
@import ' ./assets/main.css' ;
89
128
/* Everything from here on in the file is basic css */
90
- .homePageLogo {
91
- position : absolute ;
92
- }
93
129
94
130
header {
95
- z-index : 7 ;
96
- display : flex ;
97
- padding : 1 rem ;
131
+ pointer-events : none ;
132
+ position : absolute ;
133
+ z-index : 6 ;
98
134
}
99
135
100
136
.logo {
101
- display : block ;
102
- margin : 0 1rem 0 0 ;
137
+ margin-right : 1rem ;
103
138
pointer-events : all ;
139
+ filter : drop-shadow (0px 5px 20px white );
104
140
}
105
141
106
142
.nav-btn {
143
+ fill : #205C5B ;
107
144
margin : .5rem ;
145
+ width : 3.25rem ;
146
+ height : 3.25rem ;
147
+ justify-content : center ;
148
+ background-color : var (--unusedfill );
149
+ border : 2px solid var (--buildbord );
150
+ box-shadow : 0px 5px 25px rgba (0 , 10 , 20 , 0.08 );
108
151
pointer-events : all ;
109
152
}
110
153
111
- .left-nav {
112
- position : fixed ;
154
+ .nav-btn :hover ,
155
+ .nav-btn :active {
156
+ fill : white ;
157
+ }
158
+
159
+ #left-nav {
113
160
display : flex ;
114
- pointer-events : none ;
115
161
padding : .5rem 1rem ;
116
- top : 0 ;
117
- left : 0 ;
118
162
}
119
163
120
164
.search {
165
+ width : 250px !important ;
166
+ border : 2px solid var (--walkpath );
167
+ box-shadow : 0px 5px 25px rgba (0 , 10 , 20 , 0.08 );
168
+ border-radius : 10px ;
121
169
align-self : center ;
122
170
pointer-events : all ;
123
171
}
124
172
125
- . right-nav {
173
+ # right-nav {
126
174
position : fixed ;
127
- pointer-events : none ;
128
175
padding : .8rem 1rem ;
129
176
top : 0 ;
130
177
right : 0 ;
131
178
}
179
+
180
+ #mobile-nav {
181
+ width : 100% ;
182
+ display : flex ;
183
+ justify-content : center ;
184
+ pointer-events : none ;
185
+ position : absolute ;
186
+ bottom : 2vh ;
187
+ z-index : 6 ;
188
+ }
189
+
132
190
</style >
0 commit comments