Merge pull request #34 from BynariStar/master
Game compatibility list fixes and improvements
This commit is contained in:
commit
4d9e87cd64
@ -24,7 +24,7 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="input-group search-box">
|
||||
<input type="text" class="form-control fuzzy-search" id="search-box" placeholder="Search...">
|
||||
<input type="text" class="form-control search" id="search-box" placeholder="Search...">
|
||||
<span onclick="clearSearch()" class="clear-search input-group-addon">X</span>
|
||||
</div>
|
||||
</td>
|
||||
@ -54,26 +54,26 @@
|
||||
|
||||
{{ range .Pages }}
|
||||
{{- $key := substr .Params.title 0 1 }}
|
||||
{{- $rating := index .Site.Data.compatibility .Params.compatibility }}
|
||||
{{- $rating := index .Site.Data.compatibility .Params.compatibility }}
|
||||
{{- $type := index .Site.Data.gameTypes (.Params.game_type | default "3ds") }}
|
||||
<tr data-key="{{ $key }}">
|
||||
<td class="hidden listing-metadata">
|
||||
{{ .Params.title }} {{ $type.name }} {{ $rating.name }} {{ dateFormat "January 2, 2006" .Params.testcase_date }}
|
||||
<span>{{ .Params.title }} {{ $type.name }} {{ $rating.name }} {{ dateFormat "January 2, 2006" .Params.testcase_date }}</span>
|
||||
</td>
|
||||
<td class="col-md-1 icon">
|
||||
<img src="/images/game/icons/{{ .File.BaseFileName }}.png" />
|
||||
</td>
|
||||
<td class="col-md-6 title">
|
||||
<td class="col-md-6 title" data-title="{{ .Params.title }}">
|
||||
<a href="{{ .Permalink }}">{{ .Params.title }}</a>
|
||||
</td>
|
||||
<td class="col-md-1 type">
|
||||
<td class="col-md-1 type" data-type="{{ $type.name }}">
|
||||
<img src="/images/game/types/{{ $type.key }}.png" title="{{ $type.name }}" />
|
||||
</td>
|
||||
<td class="col-md-1 compatibility">
|
||||
<div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}
|
||||
<td class="col-md-1 compatibility" data-compatibility="{{ $rating.key }}">
|
||||
<div class="square-icon" style="background-color: {{ $rating.color }}"></div> <span>{{ $rating.name }}</span>
|
||||
</td>
|
||||
<td class="col-md-3 date-tested">
|
||||
{{ dateFormat "January 2, 2006" .Params.testcase_date }}
|
||||
<td class="col-md-3 date-tested" data-timestamp="{{ .Params.testcase_date }}">
|
||||
<span>{{ dateFormat "January 2, 2006" .Params.testcase_date }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
@ -90,7 +90,14 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
var options = {
|
||||
valueNames: ['listing-metadata', 'icon', 'title', 'type', 'compatibility', 'date-tested'],
|
||||
valueNames: [
|
||||
'listing-metadata',
|
||||
{ name: 'title', attr: 'data-title' },
|
||||
{ name: 'type', attr: 'data-type' },
|
||||
{ name: 'compatibility', attr: 'data-compatibility' },
|
||||
{ name: 'date-tested', attr: 'data-timestamp' }
|
||||
],
|
||||
searchColumns: [ 'listing-metadata' ],
|
||||
pagination: true,
|
||||
indexAsync: true,
|
||||
page: 50
|
||||
@ -100,33 +107,43 @@
|
||||
|
||||
list.sort("title", {order: "asc"});
|
||||
|
||||
$('#search-box').keyup(function() {
|
||||
var searchString = $(this).val();
|
||||
list.fuzzySearch(searchString, ['listing-metadata']);
|
||||
});
|
||||
|
||||
list.on("updated", function(){
|
||||
$("#compatibility-list tbody tr.key").removeClass("key");
|
||||
if ($("#compatibility-list thead").find("th.asc[data-sort='title'], th.desc[data-sort='title']").length){
|
||||
$("#compatibility-list tbody tr[data-key]").each(function(){
|
||||
list.on("updated", function(list){
|
||||
var $list = $(list.list);
|
||||
var $items = $list.children();
|
||||
$items.removeClass("key");
|
||||
if ('title' == getLastSorted(list)){
|
||||
$items.each(function(){
|
||||
var key = $(this).attr("data-key")
|
||||
if ($("tr[data-key='" + key + "']:first").is($(this))){
|
||||
if (
|
||||
$list
|
||||
.children("[data-key='" + key + "']")
|
||||
.first()
|
||||
.is( $(this) )
|
||||
){
|
||||
$(this).addClass("key");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
function getLastSorted(list){
|
||||
var currentSorted = $(list.listContainer).find(".asc, .desc").attr("data-sort");
|
||||
if ('undefined' !== typeof currentSorted)
|
||||
list.lastSorted = currentSorted;
|
||||
return list.lastSorted;
|
||||
}
|
||||
|
||||
function filterTable(_) {
|
||||
var rating = this.name;
|
||||
var index = this.index;
|
||||
|
||||
$("#search-box").val(rating);
|
||||
list.search(rating, ['compatibility']);
|
||||
list.search(index, ['compatibility']);
|
||||
}
|
||||
|
||||
function clearSearch() {
|
||||
$("#search-box").val("");
|
||||
list.fuzzySearch();
|
||||
list.search();
|
||||
}
|
||||
|
||||
Highcharts.chart('highchart-container', {
|
||||
|
Loading…
Reference in New Issue
Block a user