-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
179 lines (166 loc) · 6.45 KB
/
search.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
permalink: '/search/'
---
<!DOCTYPE html>
<html lang="en">
{% include head.html title="Search" %}
<body>
{% include header.html %} {% include social-media.html %}
<script src="https://unpkg.com/vue@3.2.13/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>
<div id="app" class="hero is-fullheight-with-navbar">
<div class="hero-body">
<div
v-if="orgList.length"
class="columns is-centered is-multiline"
style="width: 100%"
>
<div
v-for="org in orgList"
:key="org.abbr"
class="column is-one-fifth"
>
<div class="container">
{% raw %}
<figure
class="
image
is-square
is-fullwidth
is-relative
is-clickable
"
@click="redirect(`${baseurl}/${org.abbr}`)"
>
<img
:src="baseurl + org.logo"
:alt="`${org.abbr} Logo`"
/>
</figure>
<a
:href="`${baseurl}/${org.abbr}`"
class="button is-fullwidth btn-glass white-btn"
>{{ org.abbr.toUpperCase() }}</a
>
{% endraw %}
</div>
</div>
</div>
<div
v-else
class="container has-text-centered decoration-container"
>
<p
class="
title
is-1
pink-title-gradient
has-text-weight-black
responsive
"
>
NO MATCHES FOUND FOR YOUR SEARCH
</p>
<p
class="
subtitle
is-3
grape
has-text-weight-semibold
responsive
"
>
Kindly search with no misspelled words or abbreviation
</p>
<img
src="{{site.baseurl}}/assets/img/decorations/favorites/circles/1.png"
alt=""
class="decorative"
id="favorites-circles-1"
/>
<img
src="{{site.baseurl}}/assets/img/decorations/favorites/circles/2.png"
alt=""
class="decorative"
id="favorites-circles-2"
/>
<img
src="{{site.baseurl}}/assets/img/decorations/favorites/circles/3.png"
alt=""
class="decorative"
id="favorites-circles-3"
/>
<img
src="{{site.baseurl}}/assets/img/decorations/favorites/ribbons/1.png"
alt=""
class="decorative"
id="favorites-ribbons-1"
/>
<img
src="{{site.baseurl}}/assets/img/decorations/favorites/triangles/1.png"
alt=""
class="decorative"
id="favorites-triangles-1"
/>
<img
src="{{site.baseurl}}/assets/img/decorations/favorites/triangles/2.png"
alt=""
class="decorative"
id="favorites-triangles-2"
/>
</div>
</div>
</div>
<script>
const emitter = mitt();
let orgs =
JSON.parse(localStorage.getItem('orgs')) || Vue.reactive([]);
let query =
new URLSearchParams(window.location.search)
.get('q')
?.trim()
?.toLowerCase() || '';
const search = document.getElementById('search');
search.value = query;
search.onkeyup = (e) => {
emitter.emit('queryChange', search.value.trim().toLowerCase());
};
if (!orgs.length) {
fetch('{{ site.baseurl }}/assets/js/org.json')
.then((response) => response.json())
.then((data) => {
orgs.push(...data);
localStorage.setItem('orgs', JSON.stringify(data));
});
}
Vue.createApp({
data: () => {
return { orgs, query, baseurl: '{{ site.baseurl }}' };
},
computed: {
orgList() {
return this.query
? this.orgs.filter(
(org) =>
org.abbr.includes(this.query) ||
org.name.includes(this.query)
)
: this.orgs;
},
},
methods: {
redirect(link) {
window.location.assign(link);
},
},
created() {
emitter.on('queryChange', (query) => {
this.query = query;
window.history.replaceState(null, '', `?q=${query}`);
});
},
}).mount('#app');
</script>
{% include footer.html %}
</body>
</html>