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.