PageSourceSearch

https://forum.liberty-unleashed.co.uk/mobiquo/smartbanner/appbanner.js

js liberty-unleashed.co.uk collected 2026-10-01 16:18:11 UTC 13,547 bytes, 373 lines download raw bytes

1
2var app_ios_id_default = '307880732';      // Tapatalk 1, 585178888 for Tapatalk 2
3var app_ios_hd_id_default = '307880732';   // Tapatalk 1, 481579541 for Tapatalk HD
4var app_android_id_default = 'com.quoord.tapatalkpro.activity';
5var app_android_hd_id_default = 'com.quoord.tapatalkHD';
6
7var byo_ios_enable = false;
8var byo_android_enable = false;
9var byo_kindle_enable = false;
10
11if (empty(is_mobile_skin))
12    var is_mobile_skin = 0;
13
14if (empty(app_ios_id)) {
15    var app_ios_id = app_ios_id_default;
16    var app_ios_hd_id = app_ios_hd_id_default;
17} else if (app_ios_id != app_ios_id_default) {
18    byo_ios_enable = true;
19    var app_ios_hd_id = app_ios_id;
20} else
21    var app_ios_hd_id = app_ios_hd_id_default;
22
23
24if (app_ios_id == '-1')
25{
26    var app_ios_url = '-1';
27    var app_ios_hd_url = '-1';
28}
29else
30{
31    var app_ios_url = 'https://itunes.apple.com/us/app/id'+app_ios_id;
32    var app_ios_hd_url = 'https://itunes.apple.com/us/app/id'+app_ios_hd_id;
33}
34
35// compatibility code
36if (!empty(app_android_url)) app_android_id = app_android_url;
37
38if (empty(app_android_id)) {
39    var app_android_id = app_android_id_default;
40    var app_android_hd_id = app_android_hd_id_default;
41} else {
42    // compatibility code
43    if (app_android_id.match(/details\?id=/i)) {
44        var app_android_id = /details\?id=([^\s,&]+)/.exec(app_android_id)[1];
45    }
46    
47    if (app_android_id != app_android_id_default) {
48        byo_android_enable = true;
49        var app_android_hd_id = app_android_id;
50    } else
51        var app_android_hd_id = app_android_hd_id_default;
52}
53
54if (app_android_id == '-1') {
55    var app_android_url = '-1';
56    var app_android_hd_url = '-1';
57} else {
58    var app_android_url = "market://details?id="+app_android_id;
59    var app_android_hd_url = "market://details?id="+app_android_hd_id;
60}
61
62if (empty(app_kindle_url)) {
63    var app_kindle_url = "http://www.amazon.com/gp/mas/dl/android?p=com.quoord.tapatalkpro.activity";
64    var app_kindle_hd_url = "http://www.amazon.com/gp/mas/dl/android?p=com.quoord.tapatalkHD";
65} else {
66    byo_kindle_enable = true;
67    var app_kindle_hd_url = app_kindle_url;
68}
69
70if (empty(app_name))
71    var app_name = "Tapatalk";
72
73if (empty(app_location_url)){
74    var app_location_url = "tapatalk://";
75    var app_location_url_byo = "tapatalk-byo://";
76} else {
77    var app_location_url_byo = app_location_url.replace('tapatalk://', 'tapatalk-byo://');
78}
79
80if (empty(app_forum_name))
81    var app_forum_name = "this forum";
82
83if (empty(app_banner_message))
84    var app_banner_message = "Follow {your_forum_name} <br /> with {app_name} for [os_platform]";
85
86
87// Support native iOS Smartbanner
88var native_ios_banner = false;
89if (app_ios_id != '-1' && navigator.userAgent.match(/Safari/i) != null &&
90    (navigator.userAgent.match(/CriOS/i) == null && window.Number(navigator.userAgent.
90substr(navigator.userAgent.indexOf('OS ') + 3, 3).replace('_', '.')) >= 6))
91{
92    banner_location_url = byo_ios_enable ? app_location_url_byo : app_location_url;
93    
94    if (navigator.userAgent.match(/iPad/i) != null)
95    {
96        document.write('<meta name="apple-itunes-app" content="app-id='+app_ios_hd_id+', app-argument='+banner_location_url+', affiliate-data=partnerId=30&siteID=w5J2vu1UnxA" />');
97        native_ios_banner = true;
98    }
99    else if (navigator.userAgent.match(/iPod|iPhone/i) != null)
100    {
101        document.write('<meta name="apple-itunes-app" content="app-id='+app_ios_id+', app-argument='+banner_location_url+', affiliate-data=partnerId=30&siteID=w5J2vu1UnxA" />');
102        native_ios_banner = true;
103    }
104}
105
106// for those forum system which can not add js in html body
107if (!empty(functionCallAfterWindowLoad)) addWindowOnload(tapatalkDetect)
108
109var bannerLoaded = false
110
111function tapatalkDetect()
112{
113    var standalone = navigator.standalone // Check if it's already a standalone web app or running within a webui view of an app (not mobile safari)
114    if (empty(functionCallAfterWindowLoad)) addtrack();
115    
116    // work only when browser support cookie
117    if (!navigator.cookieEnabled 
118        || bannerLoaded
119        || standalone
120        || document.cookie.indexOf("banner-closed=true") >= 0 
121        || native_ios_banner)
122        return
123    
124    bannerLoaded = true
125    
126    app_banner_message = app_banner_message.replace(/\{your_forum_name\}/gi, app_forum_name);
127    app_banner_message = app_banner_message.replace(/\{app_name\}/gi, app_name);
128    
129    var app_install_url = '';
130    if (navigator.userAgent.match(/iPhone|iPod/i)) {
131        app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'iPhone');
132        app_install_url = app_ios_url;
133        
134        banner_location_url = byo_ios_enable ? app_location_url_byo : app_location_url;
135    }
136    else if (navigator.userAgent.match(/iPad/i)) {
137        app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'iPad');
138        app_install_url = app_ios_hd_url;
139        
140        banner_location_url = byo_ios_enable ? app_location_url_byo : app_location_url;
141    }
142    else if (navigator.userAgent.match(/Silk/)) {
143        app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'Kindle');
144        if (navigator.userAgent.match(/Android 2/i)) {
145            app_install_url = app_kindle_url;
146        } else {
147            app_install_url = app_kindle_hd_url;
148        }
149        banner_location_url = byo_kindle_enable ? app_location_url_byo : app_location_url;
150    }
151    else if (navigator.userAgent.match(/Android/i)) {
152        if(navigator.userAgent.match(/mobile/i)) {
153            app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'Android');
154            app_install_url = app_android_url ;
155        }
156        else {
157            app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'Android');
158            app_install_url = app_android_hd_url;
159        }
160        banner_location_url = byo_android_enable ? app_location_url_byo : app_location_url;
161    }
162    else if (navigator.userAgent.match(/IEMobile|Windows Phone/i)) {
163        app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'Windows Phone');
164        app_install_url = "http://www.windowsphone.com/s?appid=913ffd61-3ba0-435c-a894-9d3ec7e78d6e";
165        banner_location_url = app_location_url;
166    }
167    else if (navigator.userAgent.match(/BlackBerry/i)) {
168        app_banner_message = app_banner_message.replace(/\[os_platform\]/gi, 'BlackBerry');
169        app_install_url = "http://appworld.blackberry.com/webstore/content/46654?lang=en";
170        banner_location_url = app_location_url;
171    }
172    else
173        return
174    
175    
176    if (app_install_url == '-1') return
177    
178    htmlElement = document.getElementsByTagName("html")[0]
179    origHtmlMargin = parseFloat(htmlElement.style.marginTop)
180    if ( isNaN(origHtmlMargin)) origHtmlMargin = 0
181    
182    var bannerScale = document.body.clientWidth / window.screen.width
183    
184    if (bannerScale < 1 || (is_mobile_skin && navigator.userAgent.match(/mobile/i))) bannerScale = 1;
185        
186    // mobile portrait mode may need bigger scale
187    if (window.innerWidth < window.innerHeight)
188    {
189        if (bannerScale < 2 && !is_mobile_skin && document.body.clientWidth > 600) {
190            bannerScale = 2
191        } else if (bannerScale > 2.8) {
192            bannerScale = 2.8
193        }
194    }
195    else
196    {
197        if (navigator.userAgent.match(/mobile/i) && bannerScale < 1.5 && !is_mobile_skin && document.body.clientWidth > 600) {
198            bannerScale = 1.5
199        } else if (bannerScale > 2) {
200            bannerScale = 2
201        }
202    }
203    
204    
205    bodyItem = document.body
206    appBanner = document.createElement("div")
207    appBanner.id = "mobile_banner"
208    appBanner.className = "mobile_banner banner_format_handset banner_device_android banner_theme_light mobile_banner_animate"
209    appBanner.innerHTML = 
210                    '<div class="mobile_banner_inner">'+
211                        '<span class="mobile_banner_icon"></span>'+
212                        '<div class="mobile_banner_body">'+
213                            '<h3 class="mobile_banner_heading">'+app_banner_message+'</h3>'+
214                        '</div>'+
215                        '<div class="mobile_banner_controls">'+
216                            '<a class="mobile_banner_button chrome white mobile_banner_open" href="'+banner_location_url+'" id="mobile_banner_open">'+'Open in app'+'</a>'+
217                            '<a class="mobile_banner_button chrome blue mobile_banner_install" href="'+app_install_url+'" id="mobile_banner_install">'+'Install'+'</a>'+
218                            '<a class="mobile_banner_close" href="#" onclick="closeBanner()" id="mobile_banner_close">x</a>'+
219                        '</div>'+
220                    '</div>'
221    bodyItem.insertBefore(appBanner, bodyItem.firstChild)
222    
223    if (bannerScale > 1) {
224        appBanner.style.fontSize = (8*bannerScale)+"px"
225    }
226    
227    bannerHeight = getWH(appBanner, 'height', true)
228    bannerTop = (origHtmlMargin+bannerHeight)+"px"
229    htmlElement.style.marginTop = bannerTop
230    
231    if (getComputedStyle(bodyItem, null).position !== 'static')
232        appBanner.style.top = '-'+bannerTop
233    
234    addWindowOnload(resetBannerTop)
235}
236
237function addWindowOnload(func)
238{
239    if (typeof window.onload != 'function') {
240        window.onload = func;
241    } else {
242        var oldonload = window.onload;
243        window.onload = function() {
244            oldonload();
245            func();
246        }
247    }
248}
249
250function resetBannerTop()
251{
252    if (getComputedStyle(bodyItem, null).position !== 'static' || document.getElementById('google_translate_element'))
253        appBanner.style.top = '-'+bannerTop
254}
255
256function closeBanner()
257{
258    bodyItem.removeChild( appBanner )
259    htmlElement.style.marginTop = origHtmlMargin+"px"
260    setBannerCookies('banner-closed', 'true', 90)
261}
262
263function setBannerCookies(name, value, exdays)
264{
265    var exdate = new Date();
266    exdate.setDate(exdate.getDate()+exdays);
267    value=escape(value)+((exdays==null)?'':'; expires='+exdate.toUTCString());
268    document.cookie=name+'='+value+'; path=/;';
269}
270
271function empty(a){
272    if(typeof(a) == "undefined" || a == '') {
273        return true;
274    }
275    if(a == '0' || a == false) {
276        return true;
277    }
278    return false;
279}
280
281function addtrack()
282{
283    document.write('<img src="https://activate.tapatalk.com/i.gif?host='+window.location.host+'" style="display:none;" border="0" >');
284}
285
286/* to get element outer height */
287
288var defView = document.defaultView;
289
290var getStyle = defView && defView.getComputedStyle ?
291    function( elem ) {
292      return defView.getComputedStyle( elem, null );
293    }
294    :
295    function( elem ) {
296      return elem.currentStyle;
297    };
298
299function hackPercentMargin( elem, computedStyle, marginValue ) {
300    if ( marginValue.indexOf('%') === -1 ) {
301        return marginValue;
302    }
303
304    var elemStyle = elem.style,
305        originalWidth = elemStyle.width,
306        ret;
307
308    // get measure by setting it on elem's width
309    elemStyle.width = marginValue;
310    ret = computedStyle.width;
311    elemStyle.width = originalWidth;
312
313    return ret;
314}
315
316function getWH( elem, measure, isOuter )
317{
318    // Start with offset property
319    var isWidth = measure !== 'height',
320        val = isWidth ? elem.offsetWidth : elem.offsetHeight,
321        dirA = isWidth ? 'Left' : 'Top',
322        dirB = isWidth ? 'Right' : 'Bottom',
323        computedStyle = getStyle( elem ),
324        paddingA = parseFloat( computedStyle[ 'padding' + dirA ] ) || 0,
325        paddingB = parseFloat( computedStyle[ 'padding' + dirB ] ) || 0,
326        borderA = parseFloat( computedStyle[ 'border' + dirA + 'Width' ] ) || 0,
327        borderB = parseFloat( computedStyle[ 'border' + dirB + 'Width' ] ) || 0,
328        computedMarginA = computedStyle[ 'margin' + dirA ],
329        computedMarginB = computedStyle[ 'margin' + dirB ],
330        marginA, marginB;
331
332    var tmpDiv = document.createElement('div');
333    tmpDiv.style.marginTop = '1%';
334    bodyItem.appendChild( tmpDiv );
335    var supportsPercentMargin = getStyle( tmpDiv ).marginTop !== '1%';
336    bodyItem.removeChild( tmpDiv );
337
338    if ( !supportsPercentMargin ) {
339        computedMarginA = hackPercentMargin( elem, computedStyle, computedMarginA );
340        computedMarginB = hackPercentMargin( elem, computedStyle, computedMarginB );
341    }
342
343    marginA = parseFloat( computedMarginA ) || 0;
344    marginB = parseFloat( computedMarginB ) || 0;
345
346    if ( val > 0 ) {
347
348        if ( isOuter ) {
349            // outerWidth, outerHeight, add margin
350            val += marginA + marginB;
351        } else {
352            // like getting width() or height(), no padding or border
353            val -= paddingA + paddingB + borderA + borderB;
354        }
355
356    } else {
357
358        // Fall back to computed then uncomputed css if necessary
359        val = computedStyle[ measure ];
360        if ( val < 0 || val === null ) {
361            val = elem.style[ measure ] || 0;
362        }
363        // Normalize "", auto, and prepare for extra
364        val = parseFloat( val ) || 0;
365        
366        if ( isOuter ) {
367            // Add padding, border, margin
368            val += paddingA + paddingB + marginA + marginB + borderA + borderB;
369        }
370    }
371
372    return val;
373}

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.