function traceToggle(id, clazz) {
    var el = document.getElementById(id),
        current = el.style.display,
        i;

    if (clazz) {
        var tags = document.getElementsByTagName('*');
        for (i = tags.length - 1; i >= 0 ; i--) {
            if (tags[i].className === clazz) {
                tags[i].style.display = 'none';
            }
        }
    }

    el.style.display = current === 'none' ? 'block' : 'none';
}

function traceSwitchIcons(id1, id2) {
    var icon1, icon2, display1, display2;

    icon1 = document.getElementById(id1);
    icon2 = document.getElementById(id2);

    display1 = icon1.style.display;
    display2 = icon2.style.display;

    icon1.style.display = display2;
    icon2.style.display = display1;
}

window.addEventListener('load', function () {
    var els = document.querySelectorAll('.traces-toggle');
    for (var i = 0;; i++) {
        if (els[i] == undefined) {
            break;
        }
        els[i].onclick = function (e) {
            var t = e.path[1].classList[1];
            var allowReturn = false;
            if (e.path[1].classList[2] && e.path[1].classList[2] == 'traces-return') {
                allowReturn = true;
            }
            traceToggle(t);
            traceSwitchIcons('icon-' + t + '-open', 'icon-' + t + '-close');
            if (allowReturn) {
                return false;
            }
        };
    }
});

@@ -67,25 +67,25 @@
 ById(id)
-,
+;
 %0A    
-   
+var
  current
@@ -107,19 +107,8 @@
 play
-,%0A        i
 ;%0A%0A 
@@ -168,19 +168,23 @@
 tsBy
-TagName('*'
+ClassName(clazz
 );%0A 
@@ -195,16 +195,20 @@
    for (
+var 
 i = tags
@@ -240,59 +240,8 @@
 ) %7B%0A
-            if (tags%5Bi%5D.className === clazz) %7B%0A    
     
@@ -280,30 +280,16 @@
 'none';%0A
-            %7D%0A
         

use getElementsByClassName in traceToggle