-
Notifications
You must be signed in to change notification settings - Fork 3
/
sheaf.js
48 lines (42 loc) · 1.4 KB
/
sheaf.js
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
/******************************************************************************
**
** sheaf.js
**
** A library that supports the representation and automated rendering of
** lecture notes for mathematics and computer science courses.
**
** Web: sheaf.io
** Version: 0.0.1.0
**
** JavaScript functions used for rendering of sheaf course
** material XML files as HTML webpages.
*/
/******************************************************************************
*/
$(document).ready(function() {
// Render diagrams.
protoql.Visualizations($('.pql'));
// Adjust source code styling (in addition to highlight.js styling).
$('code').each(function(){
$(this).css('background-color','#F7F7F7');
$(this).html(($(this).html().trim()));
});
// Hide the solutions.
$('.solution_toggle').click(function(e) {
var sol = $(this).parent().next();
$(this).text((sol.is(':visible')) ? 'show solution' : 'hide solution');
sol.slideToggle();
});
// Update links to references with indices.
var idToBibIndex = {};
$('.cite').each(function() {
var id = $(this)[0].children[0].id, index = $(this)[0].innerText.slice(1,-1);
idToBibIndex[id] = index;
});
$('a').each(function() {
var id = $(this)[0].attributes[0].nodeValue.slice(1);
if (idToBibIndex[id] != null && $(this)[0].childNodes[0].data == '#')
$(this)[0].childNodes[0].data = idToBibIndex[id];
});
})
/*eof*/