File: fixUnstyledOptions.js

package info (click to toggle)
mnemo2 2.1.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,508 kB
  • ctags: 429
  • sloc: php: 1,745; xml: 639; sql: 83; makefile: 60
file content (37 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download
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
/**
 * Safari and Konqueror don't style select lists. Find them and add a
 * "*" to options with class="selected" so that the user has an
 * indication of which shares are chosen.
 *
 * $Horde: mnemo/js/fixUnstyledOptions.js,v 1.1.2.2 2006/03/12 03:08:35 chuck Exp $
 */

/* We do everything onload so that the entire document is present
 * before we start searching it for <option> elements. */
if (window.addEventListener) {
    window.addEventListener('load', mark_selected_options, false);
} else if (window.attachEvent) {
    window.attachEvent('onload', mark_selected_options);
} else if (window.onload != null) {
    var old_onload = window.onload;
    window.onload = function(e)
    {
        old_onload(e);
        mark_selected_options();
    };
} else {
    window.onload = mark_selected_options;
}

function mark_selected_options()
{
    if (!document.getElementsByTagName) {
        return;
    }
    options = document.getElementsByTagName('option');
    for (var i = 0; i < options.length; ++i) {
        if (options[i].className.indexOf('selected') != -1) {
            options[i].innerHTML = "* " + options[i].innerHTML;
        }
    }
}