PageSourceSearch

https://www.weekendhk.com/wp-content/plugins/ad-inserter/js/detectmobilebrowser.js?ver=1.5.5

js weekendhk.com collected 2026-09-24 20:24:40 UTC 2,467 bytes, 83 lines download raw bytes

1//NMGAd
2;(function($, window) {
3	
4    'use strict'
5
6	window.NMGAd = window.NMGAd || function(config) {
7		var data = config['html'];
8		var cla = config['cla'];
9		NMGAd.type = NMGAd.gettype();
10		$(document).ready(function() { //当dom结构完后才执行广告渲染
11			NMGAd.loadAd(data, cla);
12			window.getDeviceInfo = NMGAd.getvalue;
13			$(document).triggerHandler('adinsert');	
14 		});
15		$(document).on('render.post', function() { //click read more 按钮时执行广告渲染
16			NMGAd.loadAd(data, cla);
17		});
18		$(window).on('orientationchange', function() { //当页面屏幕改变的时候重新执行广告渲染 
19			NMGAd.loadAd(data, cla);	
20		});
21  	};
22
23  	NMGAd.type = {};
24
25	NMGAd.loadAd = function(data, cla) {
26		var detect = NMGAd.gettype();   //获取当前设备类型
27    	var deviceList = {  
28			desktop: ['desktop', 'desktop and tablet', 'desktop and phone', 'all'],
29			mobile: ['phone', 'mobile', 'desktop and phone', 'all'],
30			tablet: ['mobile', 'tablet', 'desktop and tablet', 'all']
31		};
32		$(".code-block[data-render!='true']").each(function(name, value) { 
33	    	var str = value.className,
34	    		cla;
35    		cla = str.split(" ");  //获取需要的class
36    		var mid_cla = cla[1];
37	    	if (typeof mid_cla != 'undefined') {
38	    		var type = $(this).attr('data-type');
39			    if ($.inArray(type, deviceList[detect.device]) !== -1) {
40			    	$(this).html(data[mid_cla]);
41			    }
42		        if ($.trim($(this).html())) {
43					$(this).attr('data-render', 'true');
44				}	
45	    	} else {
46	    		console.log('Missing className');
47	    	}
48	    });
49	};
50
51	NMGAd.gettype = function() {  // 获取设备类型
52		var Detect = new Object(); 
53			Detect.device = {};
54			Detect.orientation = {};
55		var md = new MobileDetect(window.navigator.userAgent.toLowerCase());
56		if (md.mobile()) {
57			if (md.phone()) {
58				Detect.device = 'mobile';
59				NMGAd.getchange(Detect);
60			} else if (md.tablet()) {
61				Detect.device = 'tablet';
62				NMGAd.getchange(Detect);
63			}
64		} else {
65			Detect.device = 'desktop';
66			Detect.orientation = '';
67		}
68		return Detect;
69	};
70
71    NMGAd.getchange = function(Detect) {
72    	//依据宽和高的大小比较判断,宽小于高为竖屏,宽大与高就是横屏。		    
73        //landscape 横屏  portrait 竖屏
74    	Detect.orientation = window.innerWidth > window.innerHeight ? 'landscape' : 'portrait';
75    };
76
77   	NMGAd.getvalue = function() {
78		return NMGAd.type;
79	};
80  		  
81    new NMGAd(NMGAdload);
82   
83}(jQuery, window));

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.