forked from EPCCed/remark_theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
epcc.js
57 lines (52 loc) · 1.49 KB
/
epcc.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
49
50
51
52
53
54
55
56
57
function Footnoter() {
var self = this;
this.notes = [];
this.add = function() {
self.notes.push(this);
return '<sup>' + self.notes.length + '</sup>';
};
this.clear = function() {
self.notes = [];
};
this.end = function() {
var ans = '.footnotes[\n';
var len = self.notes.length;
for (var i = 0; i < len; i++) {
ans += '1. ' + self.notes[i] + '\n';
}
ans += '\n]\n';
self.notes = [];
return ans;
};
}
// Constructor for the EPCC theme
// Can override the header and footer macros to customise text
function EpccTheme() {
this.base = (str => str.substring(0, str.lastIndexOf("/")))(document.currentScript.src);
this.fn = new Footnoter();
// Capture this for use in closures
var self = this;
this.header = function() {
return self.subst("<img src=\"$BASEURL/FUM-logo.png\" />");
};
this.footer_text = "";
this.footer = function() {
return self.subst("<img src=\"$BASEURL/fum-cs-white.png\" /><p>"+ self.footer_text + "</p>");
}
macros = {
scale_img: function (percentage) {
var url = this;
return '<img src="' + url + '" style="width: ' + percentage + '" />';
},
fn_start: this.fn.clear,
fn_clear: this.fn.clear,
fn_show: this.fn.end,
fn: this.fn.add,
header: this.header,
footer: this.footer
}
Theme.call(this, this.base, '$BASEURL/style.css', macros, '$BASEURL/templates.md');
}
EpccTheme.prototype = Object.create(Theme.prototype);
EpccTheme.prototype.constructor = EpccTheme;
epcc = new EpccTheme();