To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / virt / statics / script.js @ 0:1e44d666ced1

History | View | Annotate | Download (1.32 KB)

1
function init() {
2
        init_long_literals();
3
}
4

    
5
var long_literal_counter = 0;
6
var long_literal_spans = {};
7
var long_literal_texts = {};
8
function init_long_literals() {
9
    var spans = document.getElementsByTagName('span');
10
    for (i = 0; i < spans.length; i++) {
11
        if (spans[i].className != 'literal') continue;
12
        var span = spans[i];
13
        var textNode = span.firstChild;
14
        var text = textNode.data;
15
        if (text.length < 300) continue;
16
        var match = text.match(/([^\0]{150}[^\0]*? )([^\0]*)/);
17
        if (!match) continue;
18
        span.insertBefore(document.createTextNode(match[1] + ' ... '), span.firstChild);
19
        span.removeChild(textNode);
20
        var link = document.createElement('a');
21
        link.href = 'javascript:expand(' + long_literal_counter + ');';
22
        link.appendChild(document.createTextNode('\u00BBmore\u00BB'));
23
        link.className = 'expander';
24
        span.insertBefore(link, span.firstChild.nextSibling);
25
        long_literal_spans[long_literal_counter] = span;
26
        long_literal_texts[long_literal_counter] = textNode;
27
        long_literal_counter = long_literal_counter + 1;
28
    }
29
}
30

    
31
function expand(i) {
32
    var span = long_literal_spans[i];
33
    span.removeChild(span.firstChild);
34
    span.removeChild(span.firstChild);
35
    span.insertBefore(long_literal_texts[i], span.firstChild);
36
}