summaryrefslogtreecommitdiff
path: root/localwebsite/htdocs/assets/app.js
blob: c08490f08841d80c3dd54b4aea87d061772a02f9 (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
55
56
57
58
59
60
61
62
var ajax = {
    get: function(url, data) {
        if (typeof data == 'object') {
            var index = 0;
            for (var key in data) {
                var val = data[key];
                url += index === 0 && url.indexOf('?') === -1 ? '?' : '&';
                url += encodeURIComponent(key) + '=' + encodeURIComponent(val);
            }
        }
        return this.raw(url);
    },

    post: function(url, body) {
        var opts = {
            method: 'POST'
        };
        if (body)
            opts.body = body;
        return this.raw(url, opts);
    },

    raw: function(url, options) {
        if (!options)
            options = {}

        return fetch(url, Object.assign({
            headers: {
                'X-Requested-With': 'XMLHttpRequest',
            }
        }, options))
        .then(resp => {
            return resp.json()
        })
    }
};

function extend(a, b) {
    return Object.assign(a, b);
}

function ge(id) {
    return document.getElementById(id);
}

(function() {
    var ua = navigator.userAgent.toLowerCase();
    window.browserInfo = {
        version: (ua.match(/.+(?:me|ox|on|rv|it|ra|ie)[\/: ]([\d.]+)/) || [0,'0'])[1],
        //opera: /opera/i.test(ua),
        msie: (/msie/i.test(ua) && !/opera/i.test(ua)) || /trident/i.test(ua),
        mozilla: /firefox/i.test(ua),
        android: /android/i.test(ua),
        mac: /mac/i.test(ua),
        samsungBrowser: /samsungbrowser/i.test(ua),
        chrome: /chrome/i.test(ua),
        safari: /safari/i.test(ua),
        mobile: /iphone|ipod|ipad|opera mini|opera mobi|iemobile|android/i.test(ua),
        operaMini: /opera mini/i.test(ua),
        ios: /iphone|ipod|ipad|watchos/i.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1),
    };
})();