-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.html
More file actions
111 lines (103 loc) · 2.59 KB
/
Copy pathsearch.html
File metadata and controls
111 lines (103 loc) · 2.59 KB
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
<!DOCTYPE html><html lang="ja"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>アイデアボックスサーチ</title>
</head><body>
<h1>アイデアボックスサーチ</h1>
<div class="desc"><a href=https://digital-agency.ideabox.cloud/>デジタル庁</a>と<a href=https://chibacity.ideabox.cloud/>千葉市</a>と<a href=https://fukui.ideabox.cloud/>福井県</a>のアイデアボックスのアイデアとコメントから高速サーチします(毎朝8:15更新)</div>
<input id="key" placeholder="キーワード検索(スペースで絞込)">
<div id=container>
</div>
<hr>
App: CC BY <a href=https://github.com/code4fukui/ideabox>Code for FUKUI src on GitHub</a><br>
API: <a href=https://automation.jp/>株式会社自動処理</a><br>
<style>
body {
text-align: center;
margin: 0;
}
input {
font-size: 16px;
}
h1 {
padding: .5em 0;
margin: 0;
background-color: #cef;
}
.desc {
font-size: 80%;
margin: .3em;
}
#key {
padding: .3em;
font-size: 20px;
margin: 1em;
width: 16em;
}
#container a {
display: block;
text-align: center;
color: #33d !important;
}
a {
color: #222 !important;
}
</style>
<script type="module">
const match = (d, kword) => {
kword = kword.replace(/ /g, " ");
const keys = kword.split(" ");
if (keys.length == 1 && keys[0] == "") {
return true;
}
for (const key of keys) {
if (!match1(d, key)) {
return false;
}
}
return true;
};
const match1 = (d, kword) => {
if (d.title.indexOf(kword) >= 0 || d.body.indexOf(kword) >= 0) {
return true;
}
for (const c of d.comments) {
if (c.body.indexOf(kword) >= 0) {
return true;
}
}
return false;
};
const isPC = () => navigator.userAgent.match(/Mac OS|Windows/) != null;
onload = async () => {
const namemap = { "fukui": "福井", "chibacity": "千葉市", "digital-agency": "デジタル庁" };
const getName = (url) => {
for (const name in namemap) {
if (url.startsWith("https://" + name)) {
return namemap[name];
}
}
return "不明";
};
const data = await (await fetch("data/ideas.json")).json();
data.reverse();
const show = () => {
const kword = key.value;
container.innerHTML = "";
for (const d of data) {
if (match(d, kword)) {
const link = document.createElement("a");
link.href = d.url;
link.target = "_blank";
link.textContent = `${d.title} (${getName(d.url)})`;
container.appendChild(link);
}
}
};
key.onchange = show;
if (isPC()) {
key.onkeyup = show;
}
show();
};
</script>
</body>
</html>