-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
88 lines (84 loc) · 3.85 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
layout: default
title: CLRS
---
<h1 class="title">
<i onclick="randomAssignment()" class="bi bi-mortarboard-fill"></i> {{ "clrs" | upcase }}
</h1>
<h2 class="randomAssignment"></h2>
{% assign count = 0 %}
{% assign complete = 0 %}
<div id="hub-container">
<div class="row">
{% for chapter in site.data.chapters %}
{% if chapter.type == "Chapter" %}
{% assign prefix = "ch" %}
{% assign id = chapter.id %}
{% else %}
{% assign prefix = chapter.id %}
{% assign id = "" %}
{% endif %}
{% assign exercises = prefix | append: id | append: "_e" %}
{% assign problems = prefix | append: id | append: "_p" %}
<div class="col-xl-4 col-lg-6 col-12 mt-3 mb-3">
<div class="card">
<h5 class="card-header">{{ chapter.type | append: " " | append: id}}</h5>
<div class="card-body">
<strong>Exercises</strong>
<div class="row no-gutters mt-2 mb-2">
{% for solution in site.data[exercises] %}
{% capture count %}{{ count | plus: 1 }}{% endcapture %}
{% if solution.link == null %}
<div class="col-3 clrs-link clrs-incomplete">
{{ solution.name }}
</div>
{% else %}
{% capture complete %}{{ complete | plus: 1 }}{% endcapture %}
<div class="col-3 clrs-link">
<a href="{{ solution.link }}">{{ solution.name }}</a>
</div>
{% endif %}
{% endfor %}
</div>
<strong>Problems</strong>
<div class="row no-gutters mt-2 mb-2">
{% for solution in site.data[problems] %}
{% capture count %}{{ count | plus: 1 }}{% endcapture %}
{% if solution.link == null %}
<div class="col-3 clrs-link clrs-incomplete">
{{ solution.name }}
</div>
{% else %}
{% capture complete %}{{ complete | plus: 1 }}{% endcapture %}
<div class="col-3 clrs-link">
<a href="{{ solution.link }}">{{ solution.name }}</a>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
<div class="row" id="percent-container">
<h3 id="percent">{{complete | times: 1.0 | divided_by: count | times: 10000 | round | divided_by: 100.0}}% complete</h1>
</div>
</div>
<script>
function randomAssignment() {
var assignment = $('.randomAssignment');
var cards = $('.card > .card-body > .row > .clrs-incomplete').parent().parent().parent();
var random = Math.floor(Math.random()*cards.length);
var result = cards.eq(random).find('.clrs-link.clrs-incomplete').first().html().trim();
var prefix = "random assignment: ";
var exerciseReg = /[A-D\d]\.\d\-\d/;
var problemReg = /[A-D\d]\-\d/;
if (exerciseReg.test(result)) {
prefix += "Exercise ";
} else if (problemReg.test(result)) {
prefix += "Problem "
}
assignment.text(prefix + result);
}
</script>