Implement search functionality + add game button (#31)
This commit is contained in:
parent
46434df5e8
commit
2979cefc38
|
@ -16,120 +16,127 @@
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div id="game-sections">
|
<div id="game-listing">
|
||||||
<div class="btn-group" role="group">
|
<div>
|
||||||
<a class="btn btn-secondary" href="##">#</a>
|
<form class="pull-right">
|
||||||
{{ range (seq 'a' 'z') }}
|
<div class="form-group">
|
||||||
<a class="btn btn-secondary" href="#{{ printf "%c" . }}">{{ printf "%c" . }}</a>
|
<table>
|
||||||
{{ end }}
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="input-group search-box">
|
||||||
|
<input type="text" class="form-control fuzzy-search" id="search-box" placeholder="Search...">
|
||||||
|
<span onclick="clearSearch()" class="clear-search input-group-addon">X</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="https://services.citra-emu.org/game/" class="btn btn-default">Add a Game</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<table id="compatibility-list" class="table table-responsive">
|
<ul class="pagination pull-left"></ul>
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th></th>
|
|
||||||
<th>Title</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th>Compatibility</th>
|
|
||||||
<th>Date Tested</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{ range .Data.Pages.GroupByParam "section_id" }}
|
|
||||||
<tr>
|
|
||||||
<td id="game-section-header">
|
|
||||||
<h3 id="{{ .Key }}">{{ .Key }}</h3>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
{{ range .Pages }}
|
<table id="compatibility-list" class="table table-responsive">
|
||||||
{{- $rating := index .Site.Data.compatibility .Params.compatibility }}
|
<thead>
|
||||||
{{- $type := index .Site.Data.gameTypes (.Params.game_type | default "3ds") }}
|
<tr>
|
||||||
<tr data-compatibility="{{ $rating.name }}">
|
<th></th>
|
||||||
<td class="col-md-1"><img src="{{ .Site.BaseURL }}images/game/icons/{{ .File.BaseFileName }}.png" /></td>
|
<th>Title</th>
|
||||||
<td class="col-md-6"><a href="{{ .Permalink }}">{{ .Params.title }}</a></td>
|
<th>Type</th>
|
||||||
<td class="col-md-1"><img src="{{ .Site.BaseURL }}images/game/types/{{ $type.key }}.png" title="{{ $type.name }}" /></td>
|
<th>Compatibility</th>
|
||||||
<td class="col-md-1"><div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</td>
|
<th>Date Tested</th>
|
||||||
<td class="col-md-3">{{ dateFormat "January 2, 2006" .Params.testcase_date }}</td>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
|
<tbody class="list">
|
||||||
|
{{ range .Data.Pages.GroupByParam "section_id" }}
|
||||||
|
<tr>
|
||||||
|
<td id="game-section-header">
|
||||||
|
<h3 id="{{ .Key }}">{{ .Key }}</h3>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{{ range .Pages }}
|
||||||
|
{{- $rating := index .Site.Data.compatibility .Params.compatibility }}
|
||||||
|
{{- $type := index .Site.Data.gameTypes (.Params.game_type | default "3ds") }}
|
||||||
|
<tr data-compatibility="{{ $rating.name }}">
|
||||||
|
<td class="hidden listing-metadata">
|
||||||
|
{{ .Params.title }} {{ $type.name }} {{ $rating.name }} {{ dateFormat "January 2, 2006" .Params.testcase_date }}
|
||||||
|
</td>
|
||||||
|
<td class="col-md-1">
|
||||||
|
<img src="/images/game/icons/{{ .File.BaseFileName }}.png" />
|
||||||
|
</td>
|
||||||
|
<td class="col-md-6">
|
||||||
|
<a href="{{ .Permalink }}">{{ .Params.title }}</a>
|
||||||
|
</td>
|
||||||
|
<td class="col-md-1">
|
||||||
|
<img src="/images/game/types/{{ $type.key }}.png" title="{{ $type.name }}" />
|
||||||
|
</td>
|
||||||
|
<td class="col-md-1">
|
||||||
|
<div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}
|
||||||
|
</td>
|
||||||
|
<td class="col-md-3">
|
||||||
|
{{ dateFormat "January 2, 2006" .Params.testcase_date }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ define "scripts" }}
|
{{ define "scripts" }}
|
||||||
|
<script src="/js/vendor/list.min.js"></script>
|
||||||
<script src="https://code.highcharts.com/highcharts.js"></script>
|
<script src="https://code.highcharts.com/highcharts.js"></script>
|
||||||
<script src="https://code.highcharts.com/modules/exporting.js"></script>
|
<script src="https://code.highcharts.com/modules/exporting.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function filterTable(e){
|
var options = {
|
||||||
var rating = this.name;
|
valueNames: ['listing-metadata'],
|
||||||
|
pagination: true,
|
||||||
|
indexAsync: true,
|
||||||
|
page: 50
|
||||||
|
};
|
||||||
|
|
||||||
//If clicked on a new color, hides all other colors
|
var list = new List('game-listing', options);
|
||||||
if (rating != window.lastClicked){
|
|
||||||
clearFilter();
|
|
||||||
window.lastClicked = rating;
|
|
||||||
var chart = $("#highchart-container").highcharts()
|
|
||||||
window.clearButton = chart.renderer.button('Clear Filter', null, null, function(){ clearFilter() }, {
|
|
||||||
zIndex: 20
|
|
||||||
}).attr({
|
|
||||||
align: 'right',
|
|
||||||
title: 'Clear compatibility filter'
|
|
||||||
}).add().align({
|
|
||||||
align: 'right',
|
|
||||||
x: -16,
|
|
||||||
y: 18
|
|
||||||
}, false, null);
|
|
||||||
|
|
||||||
$("#compatibility-list tbody tr[data-compatibility][data-compatibility!=\"" + rating + "\"]").css('display', 'none');
|
function filterTable(_) {
|
||||||
|
var rating = this.name;
|
||||||
|
|
||||||
//Checks if section headers are empty and hides them if they are
|
$("#search-box").val(rating);
|
||||||
$("#compatibility-list tbody tr:not([data-compatibility])").each(function(){
|
list.fuzzySearch(rating);
|
||||||
var elements = $(this).nextUntil("#compatibility-list tbody tr:not([data-compatibility])").filter(function(){
|
}
|
||||||
return $(this).css('display') != 'none';
|
|
||||||
});
|
|
||||||
var containsVisible = !!elements.length;
|
|
||||||
if (!containsVisible)
|
|
||||||
$(this).css('display', 'none');
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
clearFilter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function clearFilter(){
|
|
||||||
$("#compatibility-list tbody tr").css('display', '');
|
|
||||||
if (window.clearButton){
|
|
||||||
window.clearButton.destroy();
|
|
||||||
window.clearButton = undefined;
|
|
||||||
window.lastClicked = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Highcharts.chart('highchart-container', {
|
function clearSearch() {
|
||||||
chart: { type: 'bar' },
|
$("#search-box").val("");
|
||||||
colors: [{{ range .Site.Data.compatibility }}"{{ .color }}", {{- end }}],
|
list.fuzzySearch();
|
||||||
credits: { enabled: false },
|
}
|
||||||
exporting: { enabled: false },
|
|
||||||
title: { text: '' },
|
Highcharts.chart('highchart-container', {
|
||||||
xAxis: { categories: [''] },
|
chart: { type: 'bar' },
|
||||||
yAxis: { min: 0, max: {{ len .Data.Pages }}, title: { text: '' } },
|
colors: [{{ range .Site.Data.compatibility }}"{{ .color }}", {{- end }}],
|
||||||
legend: { enabled: false },
|
credits: { enabled: false },
|
||||||
plotOptions: { series: {
|
exporting: { enabled: false },
|
||||||
stacking: 'normal',
|
title: { text: '' },
|
||||||
cursor: 'pointer',
|
xAxis: { categories: [''] },
|
||||||
events: {
|
yAxis: { min: 0, max: {{ len .Data.Pages }}, title: { text: '' } },
|
||||||
click: filterTable
|
legend: { enabled: false },
|
||||||
}
|
plotOptions: { series: {
|
||||||
} },
|
stacking: 'normal',
|
||||||
series: [
|
cursor: 'pointer',
|
||||||
{{- $dataPages := .Data.Pages }}
|
events: {
|
||||||
{{- range .Site.Data.compatibility }}
|
click: filterTable
|
||||||
{{- $dataPagesFiltered := where $dataPages ".Params.compatibility" .key }}
|
}
|
||||||
{ "name": "{{ .name }}", "data": [ {{ len $dataPagesFiltered }} ] },
|
} },
|
||||||
{{- end }}
|
series: [
|
||||||
]
|
{{- $dataPages := .Data.Pages }}
|
||||||
});
|
{{- range .Site.Data.compatibility }}
|
||||||
|
{{- $dataPagesFiltered := where $dataPages ".Params.compatibility" .key }}
|
||||||
|
{ "name": "{{ .name }}", "data": [ {{ len $dataPagesFiltered }} ] },
|
||||||
|
{{- end }}
|
||||||
|
]
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -336,3 +336,15 @@ a:hover, a:focus {
|
||||||
#game-section-header {
|
#game-section-header {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-search {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
margin: 0 20px;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Reference in New Issue