forked from ucsb-cs56-m18/ucsb-cs56-m18.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexam.js
49 lines (38 loc) · 1.2 KB
/
exam.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
---
layout: null
---
$(document).ready(function(){
console.log("exam.js: document is ready");
$('.page-break-before').each(function(i) {
var pageNum = i+1;
var prev = $(this).prev();
var evenOddClass = (pageNum % 2 == 0)?
"even-page" : "odd-page";
$(this).addClass(evenOddClass);
var $div = $("<div>", {class: "pagebreak " + evenOddClass});
prev.append($div);
$('.exam-page-header-template').first().clone().appendTo($div);
if (pageNum %2 ==0) {
var img = $('<img>');
img.addClass("even-page-staple-img");
img.attr('src', "/images/Staple-Even-Pages.png");
img.appendTo($div);
} else {
$('.exam-name-header-template').first().clone().appendTo($div);
}
prev.css('margin-bottom','0');
});
$('td.page-num').each(function(i) {
var pageNum = i + 1
$(this).html(pageNum); // re-calculate page numbers
$(this).data("pageNum",pageNum);
if (pageNum % 2==0) {
$(this).parents(".pagebreak").removeClass("odd-page");
$(this).parents(".pagebreak").addClass("even-page");
} else {
$(this).parents(".pagebreak").removeClass("even-page");
$(this).parents(".pagebreak").addClass("odd-page");
}
});
console.log("exam.js: done");
});