-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create /mine page, showing your courses (see #23)
- Loading branch information
Showing
8 changed files
with
138 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
<div style="text-align: center;"> | ||
<!-- <small>Resitting an exam? <a href="http://www.scripts.sasg.ed.ac.uk/registry/examinations/index.cfm">Check when your exam is</a>.</small> --> | ||
</div> | ||
|
||
{% if page.url != "/" %} | ||
<a id="sem1-btn" class="btn">view semester 1</a> | ||
<a id="sem2-btn" class="btn">view semester 2</a> | ||
<a id="all-btn" class="btn">view all</a> | ||
{% endif %} | ||
|
||
<div id="bi-interactive"> | ||
<div class="bi-loading"> | ||
<a class="btn" href="#">Loading...</a> | ||
</div> | ||
|
||
<div id="login" style="display:none;"> | ||
<a class="btn" href="https://weblogin.inf.ed.ac.uk/cosign-bin/cosign.cgi?cosign-betterinformatics.com&https://betterinformatics.com{{ page.url }}">Log in</a> | ||
</div> | ||
|
||
<div id="user" style="display:none;"> | ||
<a href="/mine" class="btn"><span id="user-name"></span>'s courses</a> | ||
<a href="https://weblogin.inf.ed.ac.uk/cosign-bin/logout" class="btn">Logout</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: Your Courses | ||
short-title: Your Courses | ||
layout: default | ||
--- | ||
{% include nav.html %} | ||
|
||
{% include frontpage-header.html %} | ||
|
||
<div class="bi-loading"> | ||
<h3>Your courses are loading...</h3> | ||
</div> | ||
|
||
<div id="my-sections" style="display: none;"> | ||
|
||
{% assign len = page.path.size | minus: 3 | minus: 7 %} | ||
|
||
<!-- First show pinned sections --> | ||
|
||
{% assign sections = site.sections | where: "pinned", true | sort: "title" %} | ||
{% if page.show-archived == false %} | ||
{% assign sections = sections | where: "archived", "false" %} | ||
{% endif %} | ||
|
||
{% include sections.html sections=sections hidden=hidden %} | ||
|
||
<!-- Then show non-pinned sections --> | ||
|
||
{% assign sections = site.sections | where: "pinned", false | sort: "title" %} | ||
{% if page.show-archived == false %} | ||
{% assign sections = sections | where: "archived", "false" %} | ||
{% endif %} | ||
|
||
{% include sections.html sections=sections hidden=hidden %} | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
function loadSemesterButtons() { | ||
$("#sem1-btn,#sem2-btn,#all-btn").click(btn => { | ||
// First show everything | ||
$("[data-semester]").show(); | ||
|
||
var sem = btn.target.id.slice(3, 4); | ||
if (sem == "1") { | ||
$("[data-semester='2']").hide(); | ||
} else if (sem == "2") { | ||
$("[data-semester='1']").hide(); | ||
} | ||
}); | ||
} | ||
|
||
function loadProvider() { | ||
$.ajax({url:"https://provider.betterinformatics.com", xhrFields:{withCredentials:true}}) | ||
.done( | ||
(resp) => { | ||
const data = resp.data; | ||
|
||
const year = "inf" + (data.Year.slice(2)); | ||
|
||
if (data.IsStudent && window.location.pathname.slice(0, 5) == "/mine") { | ||
$("section").each(function(_, section) { | ||
section = $(section); | ||
|
||
if (section.data("pinned") && (section.data("year") == year)) { | ||
return; | ||
} | ||
|
||
if (!data.Modules.includes(section.data("course"))) { | ||
section.remove(); | ||
} | ||
}); | ||
|
||
$("#my-sections").show(); | ||
} | ||
|
||
$(".bi-loading").hide(); | ||
$("#user-name").text(data.Name); | ||
$("#user").show(); | ||
} | ||
).fail( | ||
() => { | ||
if (window.location.pathname.slice(0, 5) == "/mine") { | ||
window.location = "https://weblogin.inf.ed.ac.uk/cosign-bin/cosign.cgi?cosign-betterinformatics.com&" + window.location.href; | ||
} | ||
|
||
$("#login").show(); | ||
$(".bi-loading").hide(); | ||
} | ||
); | ||
} | ||
|
||
$(() => { | ||
// Load provider | ||
loadProvider(); | ||
|
||
// Load the semester buttons | ||
loadSemesterButtons(); | ||
}) |
5190ea3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a monstrously large method for
loadProvider()
, would it not be better to break it up a bit or extract the fat arrow methods into their own functions?5190ea3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is... glorious
Like actually properly awesome [sends internet points]
5190ea3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neanias that is probably a good idea