function hb_qrcode_url(url) { var url_pos = url.indexOf('#hb_qrcode'); if (url_pos > 5) { } else { url += '#hb_qrcode'; } return encodeURIComponent(url); } function hb_qrcode_show(a, url) { url = url ? url : location.href; document.getElementById(a).innerHTML = ''; } if (location.href == 'https://bbs.0513.org/thread-4390324-1-1.html' || location.href == 'https://bbs.0513.org/thread-4390324-1-1.html?mobile=2') { var is_test = 'Y'; } else { var is_test = null; } (function () { var bu = 'https://qr.0513.org/js/qrcode/'; var mt = { u: bu + 'view', q: bu + 'img', api: bu + 'api', s: bu + 'share', }, u = null, id = '1', uvn = 'Qr_uvt_1'; var def_s_img = 'https://www.0513.org/images/hao.png'; var head = document.getElementsByTagName('head')[0]; mt.cookie = {}; mt.cookie.set = function(f, a, b) { var e; b.D && (e = new Date, e.setTime(e.getTime() + b.D * 1000)); document.cookie = f + "=" + a + (b.domain ? "; domain=" + b.domain : "") + (b.path ? "; path=" + b.path : "") + (e ? "; expires=" + e.toGMTString() : "") + (b.ec ? "; secure" : "") } mt.cookie.get = function(f) { return (f = RegExp("(^| )" + f + "=([^;]*)(;|$)").exec(document.cookie)) ? f[2] : u } mt.log = function(a, b) { var e = new Image; e.onload = function() { e.onload = u; b && b(a) } e.src = a } mt.html = function(a, b) { document.getElementById(a).innerHTML = b; } mt.qrcode = function (a) { mt.html(a, ''); } mt.format = function(data) { var arr = []; for(var name in data) { arr.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name])); }; // 添加一个随机数,防止缓存 arr.push('v=' + Math.random()); return arr.join('&'); } mt.ajax = function(params) { params = params || {}; params.data = params.data || {}; var callbackName = params.jsonp; // 设置传递给后台的回调参数名 params.data['callback'] = callbackName; var data = mt.format(params.data); var script = document.createElement('script'); head.appendChild(script); //创建jsonp回调函数 window[callbackName] = function(res) { head.removeChild(script); clearTimeout(script.timer); window[callbackName] = null; params.success && params.success(res); }; //发送请求 script.src = params.url + '?' + data; //为了得知此次请求是否成功,设置超时处理 if (params.time) { script.timer = setTimeout(function() { window[callbackName] = null; head.removeChild(script); params.error && params.error({ message: '超时' }); }, time); } } var c_uvt = mt.cookie.get(uvn); mt.pdata = { id: id, u: location.href, t: document.title, r: document.referrer, uvt: c_uvt, }; mt.ajax({ url: mt.u, jsonp: 'jsonpQrViewback', data: mt.pdata, success:function(res){ if (res.code == 200 && res.uvt && res.uvt != '' && res.uvt != c_uvt) { mt.cookie.set(uvn, res.uvt, {D:31536000, domain:document.domain, path:'/'}); } }, error: function(error) {} }); if (document.getElementById('qr_code')) mt.qrcode('qr_code'); if (document.getElementById('qr_code_show')) mt.qrcode('qr_code_show'); })();