/
oUnit.js
73 lines (66 loc) · 1.93 KB
/
oUnit.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/***********************************************************************
* The OUnit library *
* *
* Copyright (C) 2013 Sylvain Le Gall. *
* *
* See LICENSE for details. *
***********************************************************************/
var successHidden = true;
function displaySuccess(display) {
var div = document.getElementsByClassName('ounit-success');
for (var i = 0; i < div.length; i++) {
div[i].style.display = display;
};
};
function toggleSuccess() {
if (successHidden) {
displaySuccess('block');
} else {
displaySuccess('none');
};
successHidden = ! successHidden;
var button = document.getElementById('toggleVisibiltySuccess');
if (successHidden) {
button.textContent = 'Show success';
} else {
button.textContent = 'Hide success';
};
};
function resetTestCurrent() {
var div = document.getElementById('ounit-current');
if (div) {
div.removeAttribute('id');
};
};
function setTestCurrent(div) {
resetTestCurrent();
div.id = "ounit-current";
div.scrollIntoView(true);
};
function nextTest() {
var div = document.getElementsByClassName('ounit-test');
var found = false;
var foundCurrent = false;
var idx = 0;
if (div) {
for (; !found && idx < div.length; idx++) {
if (foundCurrent && div[idx].style.display != 'none') {
found = true;
};
if (div[idx].id == "ounit-current") {
foundCurrent = true;
};
};
if (!foundCurrent && div.length > 0) {
setTestCurrent(div[0]);
} else if (found) {
setTestCurrent(div[idx - 1]);
} else {
resetTestCurrent();
};
};
};
function gotoTop() {
window.scrollTo(0,0);
resetTestCurrent();
};