Updated javascript syntax errors.

This commit is contained in:
chris062689@gmail.com 2018-10-16 20:35:35 -04:00
parent e7d4e9eb67
commit 90e0694c06

View File

@ -65,31 +65,93 @@
{{ define "scripts" }} {{ define "scripts" }}
<script type="text/javascript"> <script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () { $(function() {
Highcharts.chart('highchart-container', { function getLastSorted(list){
chart: { type: 'bar', backgroundColor: null }, var currentSorted = $(list.listContainer).find(".asc, .desc").attr("data-sort");
colors: [{{ range .Site.Data.compatibility }}"{{ .color }}", {{- end }}], if ('undefined' !== typeof currentSorted)
credits: { enabled: false }, list.lastSorted = currentSorted;
exporting: { enabled: false }, return list.lastSorted;
title: { text: '' }, }
xAxis: { categories: [''] },
yAxis: { min: 0, max: {{ len .Data.Pages }}, title: { text: '' } }, function filterTable(_) {
legend: { enabled: false }, var rating = this.name;
plotOptions: { var index = this.index;
series: {
stacking: 'normal', $("#search-box").val(rating);
cursor: 'pointer', list.search(index, ['compatibility']);
events: { }
click: null
} function clearSearch() {
} $("#search-box").val("");
}, list.search();
series: [ }
{{- $dataPages := .Data.Pages }}
{{- range.Site.Data.compatibility }} var options = {
{{- $dataPagesFiltered := where $dataPages ".Params.compatibility".key }} valueNames: [
{ "name": "{{ .name }}", "data": [{{ len $dataPagesFiltered }}] }, 'listing-metadata',
{{- end }}]}); { name: 'title', attr: 'data-title' },
}, false); { name: 'type', attr: 'data-type' },
{ name: 'compatibility', attr: 'data-compatibility' },
{ name: 'date-tested', attr: 'data-timestamp' }
],
searchColumns: [ 'listing-metadata' ],
pagination: [
{ paginationClass: "paginationTop" },
{ paginationClass: "paginationBottom" }
],
indexAsync: true,
page: 50
};
var list = new List('game-listing', options);
list.sort("title", {order: "asc"});
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 (
$list
.children("[data-key='" + key + "']")
.first()
.is( $(this) )
){
$(this).addClass("key");
}
})
}
});
$('#game-listing .clear-search').click(clearSearch);
Highcharts.chart('highchart-container', {
chart: { type: 'bar' },
colors: [{{ range .Site.Data.compatibility }}"{{ .color }}", {{- end }}],
credits: { enabled: false },
exporting: { enabled: false },
title: { text: '' },
xAxis: { categories: [''] },
yAxis: { min: 0, max: {{ len .Data.Pages }}, title: { text: '' } },
legend: { enabled: false },
plotOptions: { series: {
stacking: 'normal',
cursor: 'pointer',
events: {
click: filterTable
}
} },
series: [
{{- $dataPages := .Data.Pages }}
{{- range .Site.Data.compatibility }}
{{- $dataPagesFiltered := where $dataPages ".Params.compatibility" .key }}
{ "name": "{{ .name }}", "data": [ {{ len $dataPagesFiltered }} ] },
{{- end }}
]
});
});
</script> </script>
{{ end }} {{ end }}