-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsearch.html
More file actions
180 lines (163 loc) ยท 8.35 KB
/
search.html
File metadata and controls
180 lines (163 loc) ยท 8.35 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
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
180
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WDProp: Search Properties: John Samuel</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="wdprop.js"></script>
</head>
<body onload="findPropertyOnLoad()">
<div id="mobile-menu-toggle" onclick="toggleMobileMenu()">
<span></span>
<span></span>
<span></span>
</div>
<div id="header">
<div id="logo"><a href="./index.html">WDProp</a>
<span id="subtitle">Everything about Wikidata properties</span>
</div>
<div id="theme-toggle" onclick="toggleTheme()" title="Toggle theme"></div>
</div>
<div id="sidebar">
<div id="sidebarlinks">
<ul>
<li><a href="./index.html">๐ Dashboard</a></li>
<li><a href="./languages.html">๐ Languages</a></li>
<li><a href="./datatypes.html">๐ Data types</a></li>
<li><a href="./properties.html">๐ง Properties</a></li>
<li><a href="./classes.html">๐ฆ Property Classes</a></li>
<li><a href="./provenance.html">๐ Provenance</a></li>
<li><a href="./search.html">๐ Search</a></li>
<li><a href="./compare.html">โ๏ธ Compare</a></li>
<li><a href="templates/translated.html">๐ฌ Property Discussion</a></li>
<li><a href="./wikiprojects.html">๐ Wikiprojects</a></li>
<li><a href="./wdprop.html">โน๏ธ About</a> </li>
</ul>
</div>
</div>
<div id="content">
<!-- Search Hero -->
<div class="search-hero">
<h2 class="search-hero-title">Search</h2>
<p class="search-hero-subtitle">Find Wikidata properties or WikiProjects by keyword</p>
<!-- Tabs -->
<div class="search-tabs">
<button class="search-tab active" id="tab-properties" onclick="switchSearchTab('properties')">
๐ง Properties
</button>
<button class="search-tab" id="tab-wikiprojects" onclick="switchSearchTab('wikiprojects')">
๐ WikiProjects
</button>
</div>
<!-- Properties search panel -->
<div class="search-panel active" id="panel-properties">
<form action="./search.html" onsubmit="findProperty(event, this)" class="search-form">
<div class="search-input-wrap">
<span class="search-input-icon">๐</span>
<input id="search" name="search" type="text" class="search-field" placeholder="e.g. software, person, locationโฆ" autocomplete="off" />
<button type="submit" class="search-submit-btn">Search</button>
</div>
</form>
<div class="search-examples">
<span class="search-examples-label">Try:</span>
<a href="./search.html?search=software&language=en" class="search-chip">software</a>
<a href="./search.html?search=programming+language&language=en" class="search-chip">programming language</a>
<a href="./search.html?search=person&language=en" class="search-chip">person</a>
<a href="./search.html?search=location&language=en" class="search-chip">location</a>
<a href="./search.html?search=date&language=en" class="search-chip">date</a>
</div>
</div>
<!-- WikiProjects search panel -->
<div class="search-panel" id="panel-wikiprojects">
<form action="./search.html" onsubmit="findWikiProjects(event, this)" class="search-form">
<div class="search-input-wrap">
<span class="search-input-icon">๐</span>
<input id="searchproject" name="searchproject" type="text" class="search-field" placeholder="e.g. heritage, biology, musicโฆ" autocomplete="off" />
<button type="submit" class="search-submit-btn">Search</button>
</div>
</form>
<div class="search-examples">
<span class="search-examples-label">Try:</span>
<a href="#" class="search-chip" onclick="fillAndSubmitProject('heritage')">heritage</a>
<a href="#" class="search-chip" onclick="fillAndSubmitProject('biology')">biology</a>
<a href="#" class="search-chip" onclick="fillAndSubmitProject('music')">music</a>
<a href="#" class="search-chip" onclick="fillAndSubmitProject('geography')">geography</a>
</div>
</div>
</div>
<!-- Results -->
<div class="section" id="resultsSection" style="display:none;">
<div id="searchResults"></div>
</div>
<!-- Query (collapsed by default) -->
<div class="section search-query-section" id="querySection" style="display:none;">
<button class="search-query-toggle" onclick="toggleQuerySection()">
<span class="search-query-toggle-icon">โ๏ธ</span> Show SPARQL Query
<span class="search-query-chevron">โผ</span>
</button>
<div id="searchResultsQuery" class="search-query-body" style="display:none;"></div>
</div>
</div>
<div id="footer">
<p id="footertext">Powered by <a href="https://www.wikidata.org/">Wikidata</a> and <a href="https://mediawiki.org/">MediaWiki</a> API</p>
</div>
<script>
function switchSearchTab(tab) {
// Update tab buttons
document.getElementById('tab-properties').classList.toggle('active', tab === 'properties');
document.getElementById('tab-wikiprojects').classList.toggle('active', tab === 'wikiprojects');
// Update panels
document.getElementById('panel-properties').classList.toggle('active', tab === 'properties');
document.getElementById('panel-wikiprojects').classList.toggle('active', tab === 'wikiprojects');
}
function fillAndSubmitProject(value) {
event.preventDefault();
document.getElementById('searchproject').value = value;
let sparqlQuery = getSearchWikiProjectQuery("'" + value + "'");
queryWikidata(sparqlQuery, createDivWikiProjects, "searchResults");
showResultsSection();
}
function showResultsSection() {
document.getElementById('resultsSection').style.display = 'block';
document.getElementById('querySection').style.display = 'block';
}
function toggleQuerySection() {
let body = document.getElementById('searchResultsQuery');
let chevron = document.querySelector('.search-query-chevron');
let btn = document.querySelector('.search-query-toggle');
if (body.style.display === 'none') {
body.style.display = 'block';
chevron.textContent = 'โฒ';
btn.classList.add('open');
} else {
body.style.display = 'none';
chevron.textContent = 'โผ';
btn.classList.remove('open');
}
}
// Wrap findProperty so the results section (containing the spinner)
// is revealed BEFORE queryWikidata fires โ not only after data arrives.
var _origFindProperty = findProperty;
findProperty = function(event, form) {
showResultsSection();
_origFindProperty(event, form);
};
// Same for the on-load path (handles ?search= URL param)
var _origFindPropertyOnLoad = findPropertyOnLoad;
findPropertyOnLoad = function() {
// Only reveal if there's actually a search param pending
if (window.location.search.indexOf('search=') !== -1) {
showResultsSection();
}
_origFindPropertyOnLoad();
};
// Wrap findWikiProjects for the WikiProjects tab
var _origFindWikiProjects = findWikiProjects;
findWikiProjects = function(event, form) {
showResultsSection();
_origFindWikiProjects(event, form);
};
</script>
</body>
</html>