summaryrefslogtreecommitdiff
path: root/js/codeq/core.js
blob: f13a019cb74cf5330c3a7b2e9eb44ece75acc843 (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
window.siteDefinition = { logLevel: 'debug' }; // for debug purposes

window.codeq = {
    /**
     * XML namespaces.
     */
    ns: {
        svg: 'http://www.w3.org/2000/svg'
    },

    noOnlineStatus: !('onLine' in navigator),

    /**
     * REST API URL prefix.
     */
    urlPrefix: '/codeq/',

    /**
     * Returns the number of Unicode code points in the given string.
     *
     * @param s {string}
     * @returns {number}
     */
    codePointCount: function (s) {
        var n = 0, i, code;
        for (i = s.length - 1; i >= 0; i--) {
            code = s.charCodeAt(i);
            if ((code >= 0xd800) && (code < 0xe000)) i++;
            n++;
        }
        return n;
    }
};