PageSourceSearch

https://www.pill.gv.at/system/statV.1789655742/JavaScript/mobileAppdetector.defer.js

js pill.gv.at collected 2026-10-02 21:01:26 UTC 11,600 bytes, 268 lines download raw bytes

1function mobileAppDetector(alloptions) {
2    //    mobileApp(alloptions.mobileApps[0]);
3    if (alloptions.mobileApps) {
4        for (var i = 0; i < alloptions.mobileApps.length; i++) {
5            mobileApp(alloptions.mobileApps[i]);
6        }
7    }
8}
9
10
11
12function mobileApp(options) {
13    var baseName = 'mobileappdetector-';
14    var checkbox = false;
15    //------- setCookie -------
16    function setCookie(redirekt, chkhidenextdays) {
17        //document.cookie = baseName + options.name + '=' + escape(redirekt.toString());
18        if (redirekt) {
19            if (options.cookietime && chkhidenextdays)
20                settingCookie(baseName + options.Id, escape(redirekt.toString()), options.cookietime);
21            else
22                settingCookie(baseName + options.Id, escape(redirekt.toString()));
23        }
24        return redirekt;
25    }
26
27
28    function settingCookie(name, value, expires, path, domain, secure) {
29        var gem2goPromptCookie = "";
30        gem2goPromptCookie = name + "=" + escape(value) + "; ";
31
32        if (expires) {
33            expires = setExpiration(expires);
34            gem2goPromptCookie += "expires=" + expires + "; ";
35        }
36        //if (path) {
37        gem2goPromptCookie += "path=/; ";
38        //}
39        if (domain) {
40            gem2goPromptCookie += "domain=" + domain + "; ";
41        }
42        if (secure) {
43            gem2goPromptCookie += "secure; ";
44        }
45        document.cookie = gem2goPromptCookie;
46    }
47
48    function setExpiration(cookieLife) {
49        var today = new Date();
50        var expr = new Date(today.getTime() + cookieLife * 24 * 60 * 60 * 1000);
51        return expr.toGMTString();
52    }
53
54    //------- getCookie -------
55    function getCookie() {
56        var name = baseName + options.Id;
57        var cookies = document.cookie.split(';');
58        var eqsPos;
59
60        for (var i = 0; i < cookies.length; ++i) {
61            eqsPos = cookies[i].search('=');
62
63            if (cookies[i].substr(0, eqsPos).replace(/^\s+|\s+jQ/g, '') == name) {
64                return unescape(cookies[i].substr(eqsPos + 1));
65            }
66        }
67    }
68
69    //-------  -------
70    function install() {
71        if (options.install) {
72
73            if (options.install(options.variants[v]) === false) return otherwise();
74        }
75        else if (!options.variants[v].install) return otherwise();
76        else {
77            var URL = options.urlSchema + "://" + (options.deeplink ? options.deeplink + "&" : "home?") + "gnr=" + options.gnr;
78            //window.location.href = options.variants[v].install;
79
80            if (navigator.userAgent.match(/Windows Phone/)) {
81                setTimeout(function () {
82                    if (!document.webkitHidden)
83                        window.location = options.variants[v].install;
84                }, 25);
85
86                window.location = URL;
87            }
88            else if (navigator.userAgent.match(/Android/)) {
89
90                /*if (navigator.userAgent.match(/Chrome/)) {
91
92                    // Jelly Bean with Chrome browser
93                    setTimeout(function () {
94                        if (!document.webkitHidden)
95                            window.location = options.variants[v].install;
96                    }, 1000);
97
98                    window.location = URL;
99
100                } */
101                if (!navigator.userAgent.match(/Firefox/)) {
102                    window.location = "intent://" + (options.deeplink ? options.deeplink + "&" : "home?") + "gnr=" + options.gnr + "#Intent;scheme=" + options.urlSchema + ";package=" + options.variants[v].install.replace("market://details?id=", "") + ";launchFlags=268435456;end";
103                }
104                else {
105
106                    // Older Android browser
107                    var iframe = document.createElement("iframe");
108                    iframe.style.border = "none";
109                    iframe.style.width = "1px";
110                    iframe.style.height = "1px";
111                    var t = setTimeout(function () {
112                        window.location = options.variants[v].install;
113                    }, 1000);
114                    iframe.onload = function () { clearTimeout(t) };
115                    iframe.src = URL;
116                    document.body.appendChild(iframe);
117
118                }
119
120            } else if (navigator.userAgent.match(/iPhone|iPad|iPod/)) {
121
122                // IOS
123                setTimeout(function () {
124                    if (!document.webkitHidden)
125                        window.location = options.variants[v].install;
126                }, 25);
127
128                window.location = URL;
129
130            }
131
132        }
133
134        if (options.deeplink == null)
135            setCookie(true, true);
136    }
137
138    //-------  -------
139    function start() {
140        if (options.start) {
141            if (options.start(options.variants[v]) === false) return otherwise();
142        }
143        else if (!options.variants[v].start) return otherwise();
144        else window.location.href = options.variants[v].start;
145    }
146
147    //-------  -------
148    function otherwise() {
149        setCookie(false);
150        if (options.otherwise) options.otherwise();
151    }
152
153    //------- prompt -------
154    function prompt(v) {
155        function invertColor(color, mirror) {
156            try {
157                var inv = (parseInt((color || '0').replace('#', ''), 16) ^ (mirror || 0xffffff)).toString(16);
158
159                return '#000000'.substr(0, 7 - inv.length) + inv;
160            }
161            catch (e) { return color; }
162        }
163
164        options.addClass = (options.addClass ? ' ' + options.addClass : '');
165        function className(name) {
166            return baseName + name + options.addClass;
167        }
168
169        if (!document.getElementById("mobileappcss")) {
170            var css = document.createElement('style');
171            css.type = "text/css";
172            css.id = "mobileappcss";
173            var landscape = options.variants[v].landscape !== undefined ? options.variants[v].landscape : options.landscape;
174
175            var cssText = "." + baseName + "window { margin: 0; position: relative; z-index: 2147483647; text-align: left; line-height: normal; width: 100%; height: auto; padding: 0.75em; box-sizing: border-box; border-bottom: 1px solid rgba(0, 0, 0, 0.2); display: flex; flex-wrap: wrap;align-items: flex-start; background-color:#fff;}";
176            cssText += "." + baseName + "window ." + baseName + "close { top: 0.75em; right: 0.75em; position: absolute; padding: 0; cursor: pointer; color: rgba(0, 0, 0, 0.3); }";
177            cssText += "." + baseName + "window ." + baseName + "image { width: 50px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3)); }";
178            cssText += "." + baseName + "window ." + baseName + "textWrapper { padding-left: 1em; }";
179            cssText += "." + baseName + "window ." + baseName + "headline {font-weight: bold; font-size: .9em; margin:0; color: #333; }";
180            cssText += "." + baseName + "window ." + baseName + "text { font-size: .8em; line-height: 1.5; color: #6E7070; margin: 0.25em 0; }";
181            cssText += "." + baseName + "window a." + baseName + "install { display: block; width: 100%; text-align: center; border: 1px solid #cccc; border-radius: 5px; padding: 0.5em 0.75em; margin: 0.75em 0 0 0;color: #6E7070; animation: 200ms all linear; font-weight: bold; text-decoration: none; font-size: 0.9em;}";
182            cssText += "." + baseName + "window a." + baseName + "install:hover, ." + baseName + "window a." + baseName + "install:focus { text-decoration: none; color: #333; background-color: #ccc; }";
183
184            if (css.styleSheet) css.styleSheet.cssText = cssText; else css.innerHTML = cssText;
185
186            var head = document.getElementsByTagName('head')[0];
187
188            for (var c = 0; c < head.children.length && head.children[c].type != css.type; ++c);    // detect first style element
189
190            if (c < head.children.length) head.insertBefore(css, head.children[c]);     // insert before first style element, if some
191            else head.appendChild(css);                                                 // else append
192        }
193        var modalWindow =
194        {
195            close: function (id) {
196                var element = document.getElementById(id);
197                if (element) {
198                    element.remove();
199                }
200                if (document.querySelectorAll(".mobileappdetector-window").length <= 0) {
201                    document.getElementById("mobileappcss").remove();
202                }
203            },
204            open: function () {
205                var modal = '';
206                //modal += '<div class="' + className('overlay') + '"></div>';
207
208                modal += '<div id="' + options.Id + '" class="' + className('window') + '" role="dialog" aria-label="' + options.arialabel + '">';
209                modal += '<a href="#" class="' + className('close') + '">';
210                modal += '<span aria-hidden="true" class="fas fa-times-circle"></span>';
211                modal += '<span class="sr-only">' + options.closetext + '</span>';
212                modal += '</a>';
213                if (options.image) modal += '<div class="' + className('logo-app') + '"><img class="' + className('image') + '" src="' + options.image + '" alt="' + options.imagealt + '"></img></div>';
214                modal += '<div class="' + className('textWrapper') + '">';
215                modal += '<span class="' + className('headline') + '">' + options.header + '</span>';
216                modal += '<p class="' + className('text') + '">' + options.text + '</p>';
217                modal += '</div>';
218                modal += '<a href="#" class="' + className('install') + '">' + (options.prompt) + '</a>';
219                modal += '</div>';
220                if (document.querySelector('.mobilemenudiv > nav')) {
221                    document.querySelector('.mobilemenudiv > nav').insertAdjacentHTML('afterend', modal);
222                } else {
223                    document.getElementById('header').insertAdjacentHTML('beforebegin', modal);
224                }
225                document.querySelector("#" + options.Id + ' .' + baseName + 'close').onclick = function () {
226                    modalWindow.close(options.Id);
227                    setCookie(true, true);
228                };
229
230                document.querySelector("#" + options.Id + ' .' + baseName + 'install').onclick = function () {
231                    modalWindow.close(options.Id);
232                    install();
233                };
234            }
235        };
236
237        modalWindow.open();
238    }
239
240
241    function create(htmlStr) {
242        var frag = document.createDocumentFragment(),
243            temp = document.createElement('div');
244        temp.innerHTML = htmlStr;
245        while (temp.firstChild) {
246            frag.appendChild(temp.firstChild);
247        }
248        return frag;
249    }
250
251    var cookie = getCookie();
252
253    if (cookie != false.toString()) {
254        var agent = navigator.userAgent.toLowerCase();
255
256        for (var v = 0; v < options.variants.length; ++v) {
257            if (agent.search(options.variants[v].agent.toLowerCase()) >= 0) {
258                if (!cookie) prompt(v);
259                else start();
260
261                return;
262            }
263        }
264    }
265    //otherwise();
266}
267if(typeof mobAppSettings !== 'undefined')
268    mobileAppDetector(mobAppSettings);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.