@@ -12,7 +12,7 @@ <h1 class="post-title">{{ page.title | escape }}</h1>
1212
1313 < div class ="post-content ">
1414 {{ content }}
15- {% assign contents = site.content | where: "category", page.slug | sort: "slug" | reverse | sort: "expected_value", "first" | reverse %}
15+ {%- assign contents = site.content | where: "category", page.slug | sort: "slug" | reverse | sort: "expected_value", "first" | reverse - %}
1616 < table id ="mainContentList ">
1717 < thead >
1818 < th > Name</ th >
@@ -25,91 +25,92 @@ <h1 class="post-title">{{ page.title | escape }}</h1>
2525 < th > < i class ="fas fa-cloud-arrow-down "> </ i > < span style ="display: none "> Downloads</ span > </ th >
2626 </ thead >
2727 < tbody >
28- {% for p in contents %}
28+ {%- for p in contents - %}
2929 < tr id ="{{ p.slug }} ">
30- < td > < a href ="{{ p.url }} " target ="_blank "> {% include_cached content_icon.html category=page.slug subcat=p.subcat %} {{ p.title | markdownify | remove: '< p > ' | remove: '</ p > ' }}</ a > </ td >
31- < td > {% include content_filelinks.html content=p newtab=true %}</ td >
30+ < td > < a href ="{{ p.url }} " target ="_blank "> {%- include_cached content_icon.html category=page.slug subcat=p.subcat - %} {{ p.title | markdownify | remove: '< p > ' | remove: '</ p > ' }}</ a > </ td >
31+ < td > {%- include content_filelinks.html content=p newtab=true - %}</ td >
3232 < td > {{ p.year }}</ td >
3333 < td > {%- if p.authors.size > 0 -%}
34- {% include_cached content_authors_string.html content=p %}
34+ {%- include_cached content_authors_string.html content=p - %}
3535 {%- elsif p.editor -%}
36- {% assign editors = p.editor | split: " and " %}
37- {% include_cached content_authors_string.html authors=editors %}
36+ {%- assign editors = p.editor | split: " and " - %}
37+ {%- include_cached content_authors_string.html authors=editors - %}
3838 {%- elsif p.reader -%}
39- {% assign readers = p.reader | split: " and " %}
40- {% include_cached content_authors_string.html authors=readers %}
39+ {%- assign readers = p.reader | split: " and " - %}
40+ {%- include_cached content_authors_string.html authors=readers - %}
4141 {%- elsif p.translator -%}
42- {% assign translators = p.translator | split: " and " %}
43- {% include_cached content_authors_string.html authors=translators %}
42+ {%- assign translators = p.translator | split: " and " - %}
43+ {%- include_cached content_authors_string.html authors=translators - %}
4444 {%- endif -%}
4545 </ td >
4646 {%- assign primarytag = false -%}
47- {% assign ordinality = 9999 %}
48- {% if p.course %}
49- {% for candidatecourse in site.courses %}
50- {% if p.course == candidatecourse.slug %}
51- {% capture primarytag %}< a href ="{{ candidatecourse.url }} ">
47+ {%- assign ordinality = 9999 - %}
48+ {%- if p.course - %}
49+ {%- for candidatecourse in site.courses - %}
50+ {%- if p.course == candidatecourse.slug - %}
51+ {%- capture primarytag - %}< a href ="{{ candidatecourse.url }} ">
5252 < i class ="{{ candidatecourse.icon }} "> </ i >
5353 {{ candidatecourse.title | escape }}
54- </ a > {% endcapture %}
55- {% assign ordinality = forloop.index %}
56- {% break %}
57- {% endif %}
58- {% endfor %}
59- {% unless primarytag %}
60- {% for candidatetag in site.tags %}
61- {% if candidatetag.slug == p.course %}
62- {% capture primarytag %}< a href ="{{ candidatetag.url }} ">
54+ </ a > {%- endcapture - %}
55+ {%- assign ordinality = forloop.index - %}
56+ {%- break - %}
57+ {%- endif - %}
58+ {%- endfor - %}
59+ {%- unless primarytag - %}
60+ {%- for candidatetag in site.tags - %}
61+ {%- if candidatetag.slug == p.course - %}
62+ {%- capture primarytag - %}< a href ="{{ candidatetag.url }} ">
6363 < i class ="fas fa-tag "> </ i >
6464 {{ candidatetag.title | escape }}
65- </ a > {% endcapture %}
66- {% assign ordinality = forloop.index | plus: site.courses.size %}
67- {% break %}
68- {% endif %}
69- {% endfor %}
70- {% endunless %}
71- {% endif %}
72- {% unless primarytag %}
73- {% for candidatetag in site.tags %}
74- {% if p.tags contains candidatetag.slug %}
75- {% capture primarytag %}< a href ="{{ candidatetag.url }} ">
65+ </ a > {%- endcapture - %}
66+ {%- assign ordinality = forloop.index | plus: site.courses.size - %}
67+ {%- break - %}
68+ {%- endif - %}
69+ {%- endfor - %}
70+ {%- endunless - %}
71+ {%- endif - %}
72+ {%- unless primarytag - %}
73+ {%- for candidatetag in site.tags - %}
74+ {%- if p.tags contains candidatetag.slug - %}
75+ {%- capture primarytag - %}< a href ="{{ candidatetag.url }} ">
7676 < i class ="fas fa-tag "> </ i >
7777 {{ candidatetag.title | escape }}
78- </ a > {% endcapture %}
79- {% assign ordinality = forloop.index | plus: site.courses.size %}
80- {% break %}
81- {% endif %}
82- {% endfor %}
78+ </ a > {%- endcapture - %}
79+ {%- assign ordinality = forloop.index | plus: site.courses.size - %}
80+ {%- break - %}
81+ {%- endif - %}
82+ {%- endfor - %}
8383 {%- endunless -%}
8484 < td data-order ="{{ ordinality }} ">
85- {% if primarytag %}
85+ {%- if primarytag - %}
8686 {{ primarytag }}
87- {% endif %}
87+ {%- endif - %}
8888 </ td >
8989 < td >
9090 {{ p.date | date: "%Y-%m-%d %H:%M" }}
9191 </ td >
9292 < td data-order ="{{ p.total_mins }} ">
93- {% include content_size.html content=p %}
93+ {%- include content_size.html content=p - %}
9494 </ td >
9595 < td >
96- {% assign plus = 1 %}
97- {% unless p.external_url or p.drive_links.size > 0 %}{% assign plus = 0 %}{% endunless %}
96+ {%- assign plus = 1 - %}
97+ {%- unless p.external_url or p.drive_links.size > 0 - %}{%- assign plus = 0 - %}{%- endunless - %}
9898 {{ site.data.content_downloads[p.content_path] | default: 0 | plus: plus }}
9999 </ td >
100100 </ tr >
101- {% endfor %}
101+ {%- endfor - %}
102102 </ tbody >
103103 </ table >
104104 </ div >
105105
106106</ article >
107107
108- < link rel ="stylesheet " href ="/assets/css/datatables{% if jekyll.environment == "production " %}.min{% endif %}.css" />
108+ < link rel ="stylesheet " href ="/assets/css/datatables{%- if jekyll.environment == "production " - %}.min{%- endif - %}.css" />
109109< style >
110110 # main {max-width : revert;}
111111</ style >
112- < script src ="/assets/js/datatables{% if jekyll.environment == "production " %}.min{% endif %}.js"> </ script >
112+ < script src ="/assets/js/datatables{%- if jekyll.environment == "production " -%}.min{%- endif -%}.js"> </ script >
113+ < script src ="/assets/js/utils.js "> </ script >
113114< script >
114115 const initialwindowwidth = $ ( window ) . width ( ) ;
115116 const mainContentList = new DataTable ( "#mainContentList" , {
@@ -133,4 +134,43 @@ <h1 class="post-title">{{ page.title | escape }}</h1>
133134 { "targets" : [ 7 ] , "visible" : initialwindowwidth > 820 }
134135 ]
135136 } ) ;
137+ const requestedOrder = getQueryVariable ( 'order' ) ; // e.g. ?order=1.asc
138+ const requestedCols = getQueryVariable ( 'cols' ) ; // e.g. ?cols=0.1.10.11
139+ const requestedPageSize = getQueryVariable ( 'n' ) ; // e.g. ?n=50
140+ const requestedPage = getQueryVariable ( 'p' ) ; // e.g. ?n=50&p=2
141+ if ( requestedCols || requestedOrder || requestedPage || requestedPageSize ) {
142+ setTimeout ( ( ) => {
143+ let needsDraw = false ;
144+ if ( requestedOrder ) {
145+ const order = requestedOrder . split ( '.' ) ;
146+ if ( order . length == 2 ) {
147+ order [ 0 ] = parseInt ( order [ 0 ] ) ;
148+ mainContentList . order ( order ) ;
149+ needsDraw = true ;
150+ }
151+ }
152+ if ( requestedCols ) {
153+ const cols = requestedCols . split ( '.' ) ;
154+ mainContentList . columns ( ) . every ( ( i ) => {
155+ mainContentList . columns ( i ) . visible ( cols . includes ( i . toString ( ) ) ) ;
156+ } ) ;
157+ }
158+ if ( requestedPageSize ) {
159+ const ps = parseInt ( requestedPageSize ) ;
160+ if ( ps > 0 ) {
161+ mainContentList . page . len ( ps ) ;
162+ needsDraw = true ;
163+ }
164+ }
165+ if ( needsDraw ) {
166+ mainContentList . draw ( ) ;
167+ }
168+ if ( requestedPage ) {
169+ const p = parseInt ( requestedPage ) ;
170+ if ( p >= 0 ) {
171+ mainContentList . page ( p ) . draw ( false ) ;
172+ }
173+ }
174+ } , 5 ) ;
175+ }
136176</ script >
0 commit comments