summaryrefslogtreecommitdiffstats
path: root/public/js/module.js
blob: 1d3012949ea13ddd6a21d4615052b078f1f45311 (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
50
51
52
53
54
(function(Icinga) {

    var Nagvis = function(module) {

        this.module = module;

        this.idCache = {};

        this.initialize();

        this.module.icinga.logger.debug('Nagvis module loaded');
    };

    Nagvis.prototype = {

        initialize: function()
        {
            $('#nagvis-iframe').on('load', this.frameLoaded.bind(this));
        },

        frameLoaded: function (event) {
            var currentMap;
            var icinga = this.module.icinga;
            var $iframe = $('#nagvis-iframe');
            var matchNagvis = /[\?&]show=([^\&]+)/;
            var matchIcinga = /[\?&]map=([^\&]+)/;
            var currentMap = null;
            var shownMap = null;

            icinga.logger.debug('Nagvis frame loaded');
            if (currentMap = $iframe.contents()[0].location.search.match(matchNagvis)) {
                currentMap = currentMap[1];
            }
            if (shownMap = document.location.search.match(matchIcinga)) {
                shownMap = shownMap[1];
            }
            if (currentMap !== null && shownMap !== currentMap) {
                this.setCurrentMap(currentMap);
            }
        },

        setCurrentMap: function (map) {
//icinga.logger.info(icinga.utils.addUrlParams(document.location.pathname + '?' + document.location.search, { map: 'asd' }))
//            var url = parseUrl
            this.module.icinga.logger.info("Setting current map", map);
        }

    };

    Icinga.availableModules.nagvis = Nagvis;

}(Icinga));