otl.js
author Mahlon E. Smith <mahlon@martini.nu>
Fri, 24 Jul 2009 07:39:57 -0700
changeset 0 868dae1581ff
permissions -rw-r--r--
Initial commit and migration to Mercurial.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     1
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     2
// otl_handler javascript functions
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     3
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     4
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     5
var scroll = new Array();
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     6
var itemcount = 0;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     7
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     8
function init_page()
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
     9
{
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    10
    if (! document.getElementById ) return false;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    11
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    12
    var spans = document.getElementsByTagName('span');
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    13
    for (i = 0; i < spans.length; i++) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    14
        var id = spans[i].getAttribute('id');
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    15
        if (id == null || id == "") continue;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    16
        if (id.indexOf("itemtoplevel_") == -1) continue;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    17
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    18
        // ie doesn't support negative substr positions :\
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    19
        // var num = id.substr(-1, 1);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    20
        var num = id.substr(13, 1);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    21
        var itemtoplevel = spans[i];
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    22
        var itemgroup    = document.getElementById("itemgroup_" + num);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    23
        if (! itemtoplevel || ! itemgroup) continue;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    24
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    25
        itemcount++;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    26
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    27
        itemgroup.style.display    = 'none';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    28
        itemgroup.style.overflow   = 'hidden';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    29
        itemtoplevel.onmouseover   = function() { this.className = 'level0_over'; }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    30
        itemtoplevel.onmouseout    = function() { this.className = 'level0'; } 
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    31
        itemtoplevel.onmouseup     = function() { this.className = 'level0'; toggle(this); return false; }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    32
        itemtoplevel.onselectstart = function() { return false; }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    33
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    34
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    35
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    36
    return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    37
}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    38
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    39
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    40
function toggle(i)
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    41
{
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    42
    var ig = document.getElementById( i.id.replace("toplevel", "group") );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    43
    if (! ig ) return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    44
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    45
    var num = ig.id.substr(10,1);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    46
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    47
    // show
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    48
    if (ig.style.display == "" ||
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    49
        ig.style.display == "none") {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    50
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    51
        ig.style.height = "0pt";
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    52
        ig.style.display = 'block';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    53
        grow(num);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    54
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    55
        // hide others
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    56
        for (i = 0; i != itemcount; i++) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    57
           if (i != num) shrink(i);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    58
        }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    59
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    60
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    61
    // hide
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    62
    else {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    63
        shrink(num);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    64
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    65
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    66
    return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    67
}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    68
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    69
function grow(num)
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    70
{
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    71
    var ig = document.getElementById( "itemgroup_" + num );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    72
    if (! ig ) return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    73
    scroll[num] = 1;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    74
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    75
    var curheight = parseInt(ig.style.height.replace("pt", ""));
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    76
    if (curheight >= 250) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    77
        ig.style.overflow = 'auto';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    78
        scroll[num] = 0;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    79
        return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    80
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    81
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    82
    var newheight = curheight + 25 + "pt";
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    83
    ig.style.height = newheight;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    84
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    85
    setTimeout("grow(" + num + ")", 30);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    86
    return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    87
}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    88
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    89
function shrink(num)
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    90
{
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    91
    var ig = document.getElementById( "itemgroup_" + num );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    92
    if (! ig ) return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    93
    if (scroll[num] == 1) return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    94
    ig.style.overflow = 'hidden';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    95
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    96
    var curheight = parseInt(ig.style.height.replace("pt", ""));
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    97
    if (curheight == 0) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    98
        ig.style.display = 'none';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    99
        return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   100
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   101
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   102
    var newheight = curheight - 50 + "pt";
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   103
    ig.style.height = newheight;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   104
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   105
    setTimeout("shrink(" + num + ")", 30);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   106
    return;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   107
}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   108
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   109