]> Git — Sourcephile - doclang.git/blob - src/style/dtc-errors.js
Polish code
[doclang.git] / src / style / dtc-errors.js
1 /* == Algorithm for show/unshow ==
2 Each hint/file is given a number, hint# or file#
3 When we say showOnly with a class name we add the rules to
4 the css #content div {display:none}, #content div.className {display:block}
5 When going back to showAll we remove these results
6 */
7
8 /* CSS utils */
9 function css_del(n) {
10 var css = document.styleSheets[0];
11 for (var i = 0; i < n; i++)
12 css.deleteRule(css.cssRules.length-1);
13 }
14
15 function css_add(s) {
16 var css = document.styleSheets[0];
17 css.insertRule(s, css.cssRules.length);
18 }
19
20 /* Show/Hide logic */
21 var last = "";
22 function show(id) {
23 if (id == last) return;
24 if (id == "") {
25 css_del(3);
26 css_add(".errors-all {font-weight: bold;}");
27 }
28 else {
29 if (last == "") {
30 css_del(1);
31 css_add(".errors-content > ol > li {display:none;}");
32 }
33 else {
34 css_del(2);
35 }
36 css_add(".errors-content > ol > li." + id + " {display:list-item;}");
37 css_add("#" + id + "{font-weight:bold;}");
38 }
39 last = id;
40 }