1 |
- (function (name, context, definition) { if (typeof module !== 'undefined' && module.exports) { module.exports = definition() } else if (typeof define === 'function' && define.amd) { define(definition) } else { context[name] = definition() } })('adwojs', this, function () { 'use strict'; var adwojs = function (options) { var xhtp = null, req = "http://jss.adwo.com/js/js", url = req + "?callback=adwo"; this._fa = 0, this._pw = 0, this._ph = 0, this._dw = 320, this._dh = 50, this._af = true, this._so = true, this._dawx = false, this._danwx = false, this._diwx = false, this._dinwx = false, this._amaurl = "http://ama.adwo.com/trackapp/advTract/tractEventJsonP.action", this._ts = null; this.request = function (arg) { this.createxhr(); xhtp.onreadystatechange = this.callhandle; xhtp.open("POST", url, true); xhtp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;"); xhtp.send(arg) }, this.createxhr = function () { if (window.ActiveXObject) { xhtp = new ActiveXObject("Microsoft.XMLHTTP") } else if (window.XMLHttpRequest) { xhtp = new XMLHttpRequest() } }, this.callhandle = function () { if (xhtp.readyState == 4) { if (xhtp.status == 200) { var data = eval("(" + xhtp.responseText + ")"); if (data.resultcode == 1) { var ua = navigator.userAgent; var _fh = (ua.indexOf('iPad') > -1) ? '110' : '50'; data.ts && adwojs.ut.set_cookie("mz_ts", data.ts, 365, "/"); data.md && adwojs.ut.set_cookie("mz_md", data.md, 365, "/"); var _f = document.createElement("iframe"); var _n = "ifradwo" + options.eid; _f.name = _f.id = _n; _f.setAttribute("frameborder", "0"); _f.scrolling = "no"; _f.height = _fh; _f.width = '100%'; var d = document.getElementById(options.eid); (d) ? d.appendChild(_f) : document.body.appendChild(_f); var iframe = window.frames[_n]; iframe.document.open(); iframe.document.write(data.ad.content); iframe.document.close() } } } }, this.store = function (n, v) { var c = ""; if (adwojs.ut.get_cookie(n) != null) { admuid = adwojs.ut.get_cookie('mz_id') } else { admuid && adwojs.ut.set_cookie("mz_id", admuid, 365, "/") } }, this.blnflash = function () { try { if (navigator.plugins) { for (var i = 0; i < navigator.plugins.length; i++) { if (navigator.plugins[i].name.toLowerCase().indexOf("shockwave flash") != -1) { this._fa = 1 } } } } catch (e) { this._fa = -1 } }, this.getwandh = function () { if (window.innerWidth) this._pw = window.innerWidth; else if ((document.body) && (document.body.clientWidth)) this._pw = document.body.clientWidth; if (window.innerHeight) this._ph = window.innerHeight; else if ((document.body) && (document.body.clientHeight)) this._ph = document.body.clientHeight; if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) { this._pw = document.documentElement.clientWidth; this._ph = document.documentElement.clientHeight } }, this.userId = function () { var keys = []; keys.push(navigator.userAgent); keys.push(navigator.language); keys.push(screen.colorDepth); keys.push(typeof (window.openDatabase)); keys.push(navigator.cpuClass); keys.push(navigator.platform); keys.push(navigator.doNotTrack); return keys.join('_') }, this.minwandh = function (e) { var obj = parent, minAw = new Array(), minAh = new Array(), minw = 320, minh = 50; try { if (obj != top) { while (true) { var obj_n = obj.window.document.body.getElementsByTagName("iframe")[0]; (obj_n.width != "") ? minAw.push(parseInt(obj_n.width)) : minAw.push(obj.window.innerWidth); (obj_n.height != "") ? minAh.push(parseInt(obj_n.height)) : minAh.push(obj.window.innerHeight); if (obj == top) { break } obj = obj.parent } } else { var s = document.getElementById(e); if (s != null) { obj = s.parentNode; if (obj.nodeName != "BODY") { while (true) { if (obj == null) { break } if (obj.nodeName != "#document" || obj.nodeName != "HTML" || obj.nodeName != "BODY") { if (obj.style != null && obj.style.width != '') { minAh.push(obj.style.height.replace(/px/, "")); minAw.push(obj.style.width.replace(/px/, "")) } } obj = obj.parentNode } } else { if (s.style != null && s.style.width != '') { minAh.push(s.style.height.replace(/px/, "")); minAw.push(s.style.width.replace(/px/, "")) } } } } if (minAw.length > 0 && minAh.length > 0) { minw = Math.min.apply(null, minAw); minh = Math.min.apply(null, minAh) } } catch (e) { } if (isNaN(minw) || minw == 'undefined' || minw == null || minw == '') { minw = 320 } if (isNaN(minh) || minh == 'undefined' || minh == null || minh == '') { minh = 50 } return minw + "_" + minh }; if (typeof options == 'object') { this.eid = options.eid; var u = navigator.userAgent; if ((!!u.match(/AppleWebKit.*Mobile.*/)) && (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1)) { this.pid = options.aid; this.dn = 'Android'; this.android = true } else if ((!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) && (u.indexOf('iPhone') > -1 || u.indexOf('iPad') > -1)) { this.pid = options.pid; this.dn = (u.indexOf('iPad') > -1) ? 'iPad' : 'iPhone'; this.ios = true } else { this.pid = options.aid + "_" + options.pid; this.dn = "other"; this.other = true } this.bt = options.bt; this.width = options.width; this.height = options.height; this.af = options.af; this.so = options.so; this.dawx = options.dawx; this.danwx = options.danwx; this.diwx = options.diwx; this.dinwx = options.dinwx } }; adwojs.ut = { get_cookie: function (b) { var g = document.cookie.split(";"); var c = ""; var e = ""; var f = ""; var d = false; var a = ""; for (a = 0; a < g.length; a++) { c = g[a].split("="); e = c[0].replace(/^\s+|\s+$/g, ""); if (e == b) { d = true; if (c.length > 1) { f = unescape(c[1].replace(/^\s+|\s+$/g, "")) } return f; break } c = null; e = "" } if (!d) { return null } }, set_cookie: function (c, e, a, h, d, g) { var b = new Date(); b.setTime(b.getTime()); if (a) { a = a * 1000 * 60 * 60 * 24 } var f = new Date(b.getTime() + (a)); document.cookie = c + "=" + escape(e) + ((a) ? ";expires=" + f.toGMTString() : "") + ((h) ? ";path=" + h : "") + ((d) ? ";domain=" + d : "") + ((g) ? ";secure" : "") }, del_cookie: function (a, c, b) { if (_mz_get_cookie(a)) { document.cookie = a + "=" + ((c) ? ";path=" + c : "") + ((b) ? ";domain=" + b : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT" } }, run_cmscallback: function () { if (typeof this._ts === 'undefined') return; document.getElementsByTagName("head")[0].removeChild(this._ts); this._ts = null }, get_urlpm: function (n) { var _v = ""; if (window.location.search != "") { try { var urlParamters = '{"' + window.location.search.replace(/^\?/, '').replace(/&/g, '","').replace(/=/g, '":"') + '"}'; var result = JSON.parse(urlParamters); for (var attr in result) { if (attr == n) { _v = result[attr]; break } } } catch (e) { _v = "e" } } return _v } }; adwojs.prototype = { sendcms: function (a, b) { try { var _d = new Date(); var url = this._amaurl + "?prgid="; url += a + "&callback=adwojs.ut.run_cmscallback&cmsp=" + b + "&d=" + _d.getTime(); this._ts = document.createElement("script"); this._ts.type = "text/javascript"; this._ts.src = url; document.getElementsByTagName("head")[0].appendChild(this._ts) } catch (e) { } }, ca: function (a, b) { return (a != 'undefined' && a != null && typeof a == 'boolean') ? a : b }, cb: function (a, b) { return (a != 'undefined' && parseInt(a) > 0) ? a : b }, cc: function (a) { return a ? 1 : 0 }, cd: function (a, b, c, d) { return ((a << 12) & 0xF000) + ((b << 8) & 0x0F00) + ((c << 4) & 0x00F0) + d }, send: function () { this.blnflash(); this.getwandh(); this._dw = this.cb(this.width, this._dw); this._dh = this.cb(this.height, this._dh); this._af = this.ca(this.af, this._af); this._so = this.ca(this.so, this._so); this._dawx = this.ca(this.dawx, this._dawx); this._danwx = this.ca(this.danwx, this._danwx); this._diwx = this.ca(this.diwx, this._diwx); this._dinwx = this.ca(this.dinwx, this._dinwx); var timestamp = Date.parse(new Date()); var admuid = (adwojs.ut.get_cookie('mz_id') != null) ? adwojs.ut.get_cookie('mz_id') : this.mumtohash(this.userId() + timestamp, 31); admuid && adwojs.ut.set_cookie("mz_id", admuid, 365, "/"); var sts = (adwojs.ut.get_cookie('mz_ts') != null) ? adwojs.ut.get_cookie('mz_ts') : 0; var smd = (adwojs.ut.get_cookie('mz_md') != null) ? adwojs.ut.get_cookie('mz_md') : ""; var scount = (adwojs.ut.get_cookie('mz_scount') != null) ? parseInt(adwojs.ut.get_cookie('mz_scount')) + 1 : 0; adwojs.ut.set_cookie("mz_scount", scount, 365, "/"); var urlname = encodeURIComponent(window.location.href); var paw = (window.screen.availWidth != 'undefined') ? window.screen.availWidth : 0; var pah = (window.screen.availHeight != 'underfined') ? window.screen.availHeight : 0; var ua = window.navigator.userAgent.toLowerCase(); var wx = (ua.match(/MicroMessenger/i) == 'micromessenger') ? true : false; var ck = (document.cookie === '') ? false : true; var _conf = this.cd(this.cc(this._dawx), this.cc(this._danwx), this.cc(this._diwx), this.cc(this._dinwx)); console.log(_conf); if (this.other) return; var d = { pid: this.pid, muid: admuid, sv: 16, sw: this._dw, sh: this._dh, url: encodeURIComponent(urlname), pw: this._pw, ph: this._ph, minwh: this.minwandh(this.eid), ts: timestamp, paw: paw, pah: pah, bt: this.bt, af: this._af, so: this._so, blnwx: wx, ck: ck, conf: _conf, flash: this._fa, dn: this.dn, scount: scount, sts: sts, smd: smd }; var sendurl = "data=" + JSON.stringify(d), bs = false; if (this.android) { if (wx) { if (!this._dawx) bs = true } else { if (!this._danwx) bs = true } }; if (this.ios) { if (wx) { if (!this._diwx) bs = true } else { if (!this._dinwx) bs = true } }; if (bs) { this.sendcms(this.pid, adwojs.ut.get_urlpm("cmsp")); this.request(sendurl) } }, mumtohash: function (key, seed) { var remainder, bytes, h1, h1b, c1, c2, k1, i; remainder = key.length & 3; bytes = key.length - remainder; h1 = seed; c1 = 0xcc9e2d51; c2 = 0x1b873593; i = 0; while (i < bytes) { k1 = ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(++i) & 0xff) << 8) | ((key.charCodeAt(++i) & 0xff) << 16) | ((key.charCodeAt(++i) & 0xff) << 24); ++i; k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; k1 = (k1 << 15) | (k1 >>> 17); k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)) } k1 = 0; switch (remainder) { case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; case 1: k1 ^= (key.charCodeAt(i) & 0xff); k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; k1 = (k1 << 15) | (k1 >>> 17); k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; h1 ^= k1 } h1 ^= key.length; h1 ^= h1 >>> 16; h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; h1 ^= h1 >>> 13; h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; h1 ^= h1 >>> 16; return h1 >>> 0 } }; return adwojs });
|