2
/* reusable implementation of expand/collapse buttons, used to show/hide
3
* "more detailed" sections of the page.
7
var collapse_cache = new Object();
8
var collapse_all_cache = new Object();
10
function cacheElement(group, name, remainder, element) {
11
var g = collapse_cache[group];
12
if (typeof(g) == "undefined") {
14
collapse_cache[group] = g;
17
if (typeof(n) == "undefined") {
21
n.push(new Array(remainder, element));
24
function cacheAllElement(group, name, element) {
25
var g = collapse_all_cache[group];
26
if (typeof(g) == "undefined") {
28
collapse_all_cache[group] = g;
30
g.push(new Array(name, element));
34
* cache all the elements that have a collapse-<group>-<name>-* class on them.
35
* javascript can be very slow so this should make the UI more responsive.
37
function sortCollapseElements() {
38
var elements = document.getElementsByTagName("*");
39
for (var i = 0; i < elements.length; i++) {
40
var classes = elements[i].className.split(' ');
41
for (var j = 0; j < classes.length; j++) {
42
if (classes[j].indexOf("collapse-") == 0) {
43
var segments = classes[j].split('-');
44
if (segments.length == 4) {
45
cacheElement(segments[1], segments[2], segments[3], elements[i]);
47
if (segments.length == 3) {
48
cacheAllElement(segments[1], segments[2], elements[i]);
56
function collapseContent(group, name) {
57
return 'collapse-' + group + '-' + name + '-content';
60
function collapseDisplay(group, name, display) {
61
// display mode for the disclosure triangles:
62
var dthide = 'inline', dtshow = 'none';
63
if (display == 'none') { dthide = 'none'; dtshow = 'inline'; }
65
var elements = collapse_cache[group][name];
66
for (var i in elements) {
67
var kind = elements[i][0], node = elements[i][1];
69
node.style.display = dtshow;
70
} else if (kind == "hide") {
71
node.style.display = dthide;
72
} else if (kind == "content") {
73
node.style.display = display;
78
function collapseAllDisplay(group, display) {
79
for (var name in collapse_cache[group]) {
80
collapseDisplay(group, name, display);
83
var dthide = 'inline', dtshow = 'none';
84
if (display == 'none') { dthide = 'none'; dtshow = 'inline'; }
85
for (var element in collapse_all_cache[group]) {
86
var x = collapse_all_cache[group][element];
87
var name = x[0], node = x[1];
88
if (name == "showall") {
89
node.style.display = dtshow;
90
} else if (name == "hideall") {
91
node.style.display = dthide;
100
var hh = d.getHours(), mm = d.getMinutes(), ss = d.getSeconds(), ms = d.getMilliseconds();
101
var ds = ((hh < 10) ? "0" + hh : hh) + ":" + ((mm < 10) ? "0" + mm : mm) + ":" + ((ss < 10) ? "0" + ss : ss) + "." + ((ms < 10) ? "00" + ms : ((ms < 100) ? "0" + ms : ms));
102
console.log("[" + ds + "] " + s);
105
function diff_url(url) {
106
if (document.cookie.indexOf('diff=unified') >= 0) {
107
this.location.href = url + "-u";
109
this.location.href = url + "-s";
113
function show_sbs() {
114
collapseDisplay('style', 'sbs', 'table');
115
collapseDisplay('style', 'unified', 'none');
116
document.cookie='diff=sbs';
118
function show_unified() {
119
collapseDisplay('style', 'unified', 'table');
120
collapseDisplay('style', 'sbs', 'none');
121
document.cookie='diff=unified';
124
sortCollapseElements();
125
if (document.cookie.indexOf('diff=unified') >= 0) { show_unified(); }