Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two features #293

Merged
merged 4 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 39 additions & 14 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ <h1>
</div>
</div>
</div>
<div id="confs">
<div id="coming_confs">
{% for conf in site.data.conferences %}
<div id="{{conf.id}}" class="{% for sub in conf.sub %} {{sub}}-conf {% endfor %}">
<div id="{{conf.id}}" class="ConfItem {% for sub in conf.sub %} {{sub}}-conf {% endfor %}">
<div class="row conf-row">
<div class="col-xs-5 col-sm-6">
<a class="conf-title" href="/conference?id={{ conf.id }}">{{conf.title}} {{conf.year}}</a>
Expand Down Expand Up @@ -108,7 +109,9 @@ <h1>
</div>
<div class="row">
<div class="col-xs-12">
<span title="Click to only show {{conf.sub}} conferences" data-sub="{{conf.sub}}" class="conf-sub"></span>
{% for sub in conf.sub %}
<span title="Click to only show {{sub}} conferences" data-sub="{{sub}}" class="conf-sub {{sub}}-tag"></span>
{% endfor %}
</div>
</div>
<hr>
Expand All @@ -117,6 +120,7 @@ <h1>
</div>
<div id="past_confs">
</div>
</div>
<footer>
<div class="row">
<div class="col-xs-12 col-sm-6">
Expand Down Expand Up @@ -169,7 +173,9 @@ <h1>
}

{% for conf in site.data.conferences %}
$('#{{conf.id}} .conf-sub').html(sub2name["{{conf.sub}}"].toLocaleLowerCase());
{% for sub in conf.sub %}
$('#{{conf.id}} .{{sub}}-tag').html(sub2name["{{sub}}"].toLocaleLowerCase());
{% endfor %}
{% if conf.deadline == "TBA" %}
$('#{{conf.id}} .timer').html("TBA");
$('#{{conf.id}} .deadline-time').html("TBA");
Expand Down Expand Up @@ -215,13 +221,24 @@ <h1>

// check if date has passed, add 'past' class to it
var today = moment();
if (today.diff(confDate) > 0) {
diff = today.diff(confDate)
$('#{{conf.id}}').attr("diff", diff)
if (diff > 0) {
$('#{{conf.id}}').addClass('past');
$('#{{conf.id}}').appendTo($("#past_confs"))
}
{% endif %}
{% endfor %}

// Sort coming_confs and past_confs
$("#coming_confs .ConfItem").sort(function (a, b) {
return $(b).attr('diff') - $(a).attr('diff');
}).appendTo($("#coming_confs"));

$("#past_confs .ConfItem").sort(function (a, b) {
return $(b).attr('diff') - $(a).attr('diff');
}).appendTo($("#past_confs"));

// Get subjects from URL
var url = new URL(window.location);
var subs = url.searchParams.get('sub');
Expand All @@ -230,6 +247,18 @@ <h1>
} else {
subs = subs.toUpperCase().split(',');
}
if (subs != undefined) {
// Hide unchecked subs
for (var i = 0; i < all_subs.length; i++) {
if (subs.indexOf(all_subs[i]) < 0) {
$('.' + all_subs[i] + '-conf').hide();
}
}
// In case a conf with multiple types is wrongly hid, show all confs with at least one checked type.
for (var i = 0; i < subs.length; i++) {
$('.' + subs[i] + '-conf').show();
}
}
// Get subjects from browser cache
if (subs === undefined) {
subs = all_subs;
Expand All @@ -241,12 +270,6 @@ <h1>
$('#' + subs[i] + '-checkbox').prop('checked', true);
}
}
// Hide unchecked subs
for (var i = 0; i < all_subs.length; i++) {
if (subs.indexOf(all_subs[i]) < 0) {
$('.' + all_subs[i] + '-conf').hide();
}
}
store.set('{{ site.domain }}', subs);
window.history.pushState('', '', '/?sub=' + subs.join());

Expand All @@ -265,6 +288,10 @@ <h1>
var idx = subs.indexOf(csub);
if (idx >= 0)
subs.splice(idx, 1);
// In case a conf with multiple types (including this type) is wrongly hid, show all confs with at least one checked type.
for (var i = 0; i < subs.length; i++) {
$('.' + subs[i] + '-conf').show();
}
}
console.log(subs);
store.set('{{ site.domain }}', subs);
Expand All @@ -279,11 +306,9 @@ <h1>
$('#' + subs[i] + '-checkbox').prop('checked', false);
$('.' + subs[i] + '-conf').hide();
}
else {
$('#' + subs[i] + '-checkbox').prop('checked', true);
$('.' + subs[i] + '-conf').show();
}
}
$('#' + csub + '-checkbox').prop('checked', true);
$('.' + csub + '-conf').show();
subs = [csub];
console.log(subs);
store.set('{{ site.domain }}', subs);
Expand Down
1 change: 1 addition & 0 deletions static/css/deadlines.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ footer {
background: rgba(236, 240, 241, 0.7);
font-size: 13px;
padding: 3px 5px;
margin-right: 8px;
cursor: pointer;
font-weight: 300;
}
Expand Down