summaryrefslogtreecommitdiff
path: root/vcards.js
blob: 8d728690f818bf861e90a279a2e3d44ce811b53f (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
if (typeof JFRTEAMY_VCARDS == 'undefined') {
    JFRTEAMY_VCARDS = true;
    window.onload = function() {
        var idPattern = /r=([0-9]*)/;
        var links = document.getElementsByTagName('a');
        var fotoSpan = document.getElementById('foto');
        var loader = document.createElement('img');
        loader.src = 'images/A.gif';
        loader.style.display = 'none';
        loader.style.margin = '0 30px';
        fotoSpan.parentNode.insertBefore(loader, fotoSpan);
        var loadedPid = undefined;
        for (var i = 0; i < links.length; i++) {
            var link = new URL(links[i].href);
            if (link.hostname.substr(-10) == 'msc.com.pl') {
                var pidMatch = link.search.match(idPattern);
                if (pidMatch) {
                    var pid = pidMatch[1];
                    if (parseInt(pid) < 30000) {
                        links[i].onmouseover = (function(p) { return function() {
                            if (p != loadedPid) {
                                var iframeURL = 'http://cezar.brydzystow.pl/' + p;
                                var iframe = document.createElement('iframe');
                                iframe.src = iframeURL;
                                iframe.onload = function() {
                                    iframe.width = '600px';
                                    iframe.height = '500px';
                                    iframe.style.border = 'none';
                                    fotoSpan.style.visibility = 'visible';
                                    loader.style.display = 'none';
                                }
                                fotoSpan.innerHTML = '';
                                loader.style.display = 'inline-block';
                                fotoSpan.style.visibility = 'hidden';
                                fotoSpan.append(iframe);
                                loadedPid = p;
                            }
                        }})(pid);
                    } else {
                        links[i].href = '#';
                        links[i].onmouseover = function() {
                            fotoSpan.innerHTML = '';
                        }
                    }
                }
            }
        }
    }
}