Skip to content

Commit 9b8f632

Browse files
authored
CLDR-18154 site: add search panel (#4512)
1 parent 8d51d27 commit 9b8f632

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

docs/site/assets/css/page.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,10 @@ header .nav a.uplink {
864864
color: white;
865865
}
866866

867+
header .nav div#searchbox {
868+
margin-inline-start: auto;
869+
}
870+
867871
body.page a.showmap {
868872
color: white;
869873
text-decoration: none;

docs/site/assets/js/cldrsite.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,48 @@ const PageContents = {
214214
`,
215215
};
216216

217+
const SearchBox = {
218+
components: {},
219+
props: {},
220+
methods: {
221+
keyup(event) {
222+
if (event.key === "Enter" || event?.keycode === 13) {
223+
this.search();
224+
}
225+
},
226+
updateSearch(event) {
227+
this.searchText = event.target.value;
228+
},
229+
search() {
230+
const text = this.searchText;
231+
if (!text || !text.trim()) return;
232+
const u = new URL(
233+
"https://www.google.com/search?q=site%3Acldr.unicode.org%2F+"
234+
);
235+
let q = u.searchParams.get("q");
236+
q = q + text; // append their search
237+
u.searchParams.set("q", q);
238+
document.location.assign(u); // Go!
239+
},
240+
},
241+
setup() {
242+
const searchText = ref("");
243+
return {
244+
searchText,
245+
};
246+
},
247+
template: `
248+
<input size="30" placeholder="Search CLDR…" @keyup="keyup" :value="searchText" @input="updateSearch"/><button id="searchbutton" title="search" @click="search">🔎</button>
249+
`,
250+
};
251+
217252
const app = Vue.createApp(
218253
{
219254
components: {
220255
AncestorPages,
221256
SubPagesPopup,
222257
SiteMap,
258+
SearchBox,
223259
},
224260
setup(props) {
225261
// the tree.json data
@@ -332,6 +368,9 @@ const app = Vue.createApp(
332368
<AncestorPages :ancestorPages="ancestorPages"/>
333369
334370
</div>
371+
<div id="searchbox">
372+
<SearchBox />
373+
</div>
335374
</div>
336375
</div>`,
337376
},

0 commit comments

Comments
 (0)