Showing
2 changed files
with
666 additions
and
0 deletions
static/yas-jssdk/1.0.14/yas-debug.js
0 → 100644
1 | +;(function() { | ||
2 | +var yas_jssdk_1014_src_config_debug, yas_jssdk_1014_src_cross_debug, yas_jssdk_1014_src_event_debug, yohojson2_100_json2_debug, yas_jssdk_1014_src_util_debug, yas_jssdk_1014_src_cookie_debug, yas_jssdk_1014_src_ya_debug, yas_jssdk_1014_yas_debug; | ||
3 | +yas_jssdk_1014_src_config_debug = function (exports) { | ||
4 | + exports = { | ||
5 | + version: '1.0', | ||
6 | + yasPath: '/web/', | ||
7 | + yasDomain: getDomain(), | ||
8 | + yasImgDomain: 'http://analytics.yhurl.com/yas.gif' | ||
9 | + }; | ||
10 | + function getDomain() { | ||
11 | + var domainArr = document.domain.split('.'); | ||
12 | + var length = domainArr.length; | ||
13 | + if (length > 1 && isNaN(domainArr[length - 1])) { | ||
14 | + return '.' + domainArr[length - 2] + '.' + domainArr[length - 1]; | ||
15 | + } else { | ||
16 | + return document.domain; | ||
17 | + } | ||
18 | + } | ||
19 | + return exports; | ||
20 | +}(); | ||
21 | +yas_jssdk_1014_src_cross_debug = function (exports) { | ||
22 | + /** | ||
23 | + * 跨域发送信息工具库 | ||
24 | + */ | ||
25 | + var config = yas_jssdk_1014_src_config_debug; | ||
26 | + var yasPath = config.yasPath; | ||
27 | + var yasImgDomain = config.yasImgDomain; | ||
28 | + //发送图片方式 | ||
29 | + exports.imgSend = function (param, callback) { | ||
30 | + var image = new Image(1, 1); | ||
31 | + image.src = yasImgDomain + yasPath + '?' + param; | ||
32 | + image.onload = function () { | ||
33 | + image.onload = null; | ||
34 | + if (callback) { | ||
35 | + callback(); | ||
36 | + } | ||
37 | + }; | ||
38 | + }; | ||
39 | + return exports; | ||
40 | +}({}); | ||
41 | +yas_jssdk_1014_src_event_debug = function (exports) { | ||
42 | + exports.addEventHandler = function (target, type, func) { | ||
43 | + if (target.addEventListener) | ||
44 | + target.addEventListener(type, func, false); | ||
45 | + else if (target.attachEvent) | ||
46 | + target.attachEvent('on' + type, func); | ||
47 | + else | ||
48 | + target['on' + type] = func; | ||
49 | + }; | ||
50 | + exports.removeEventHandler = function (target, type, func) { | ||
51 | + if (target.removeEventListener) | ||
52 | + target.removeEventListener(type, func, false); | ||
53 | + else if (target.detachEvent) | ||
54 | + target.detachEvent('on' + type, func); | ||
55 | + else | ||
56 | + delete target['on' + type]; | ||
57 | + }; | ||
58 | + return exports; | ||
59 | +}({}); | ||
60 | +yohojson2_100_json2_debug = function () { | ||
61 | + if (typeof JSON !== 'object') { | ||
62 | + JSON = {}; | ||
63 | + } | ||
64 | + (function () { | ||
65 | + 'use strict'; | ||
66 | + var rx_one = /^[\],:{}\s]*$/, rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, rx_four = /(?:^|:|,)(?:\s*\[)+/g, rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
67 | + function f(n) { | ||
68 | + return n < 10 ? '0' + n : n; | ||
69 | + } | ||
70 | + function this_value() { | ||
71 | + return this.valueOf(); | ||
72 | + } | ||
73 | + if (typeof Date.prototype.toJSON !== 'function') { | ||
74 | + Date.prototype.toJSON = function () { | ||
75 | + return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z' : null; | ||
76 | + }; | ||
77 | + Boolean.prototype.toJSON = this_value; | ||
78 | + Number.prototype.toJSON = this_value; | ||
79 | + String.prototype.toJSON = this_value; | ||
80 | + } | ||
81 | + var gap, indent, meta, rep; | ||
82 | + function quote(string) { | ||
83 | + rx_escapable.lastIndex = 0; | ||
84 | + return rx_escapable.test(string) ? '"' + string.replace(rx_escapable, function (a) { | ||
85 | + var c = meta[a]; | ||
86 | + return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
87 | + }) + '"' : '"' + string + '"'; | ||
88 | + } | ||
89 | + function str(key, holder) { | ||
90 | + var i, k, v, length, mind = gap, partial, value = holder[key]; | ||
91 | + if (value && typeof value === 'object' && typeof value.toJSON === 'function') { | ||
92 | + value = value.toJSON(key); | ||
93 | + } | ||
94 | + if (typeof rep === 'function') { | ||
95 | + value = rep.call(holder, key, value); | ||
96 | + } | ||
97 | + switch (typeof value) { | ||
98 | + case 'string': | ||
99 | + return quote(value); | ||
100 | + case 'number': | ||
101 | + return isFinite(value) ? String(value) : 'null'; | ||
102 | + case 'boolean': | ||
103 | + case 'null': | ||
104 | + return String(value); | ||
105 | + case 'object': | ||
106 | + if (!value) { | ||
107 | + return 'null'; | ||
108 | + } | ||
109 | + gap += indent; | ||
110 | + partial = []; | ||
111 | + if (Object.prototype.toString.apply(value) === '[object Array]') { | ||
112 | + length = value.length; | ||
113 | + for (i = 0; i < length; i += 1) { | ||
114 | + partial[i] = str(i, value) || 'null'; | ||
115 | + } | ||
116 | + v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']'; | ||
117 | + gap = mind; | ||
118 | + return v; | ||
119 | + } | ||
120 | + if (rep && typeof rep === 'object') { | ||
121 | + length = rep.length; | ||
122 | + for (i = 0; i < length; i += 1) { | ||
123 | + if (typeof rep[i] === 'string') { | ||
124 | + k = rep[i]; | ||
125 | + v = str(k, value); | ||
126 | + if (v) { | ||
127 | + partial.push(quote(k) + (gap ? ': ' : ':') + v); | ||
128 | + } | ||
129 | + } | ||
130 | + } | ||
131 | + } else { | ||
132 | + for (k in value) { | ||
133 | + if (Object.prototype.hasOwnProperty.call(value, k)) { | ||
134 | + v = str(k, value); | ||
135 | + if (v) { | ||
136 | + partial.push(quote(k) + (gap ? ': ' : ':') + v); | ||
137 | + } | ||
138 | + } | ||
139 | + } | ||
140 | + } | ||
141 | + v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; | ||
142 | + gap = mind; | ||
143 | + return v; | ||
144 | + } | ||
145 | + } | ||
146 | + if (typeof JSON.stringify !== 'function') { | ||
147 | + meta = { | ||
148 | + '\b': '\\b', | ||
149 | + '\t': '\\t', | ||
150 | + '\n': '\\n', | ||
151 | + '\f': '\\f', | ||
152 | + '\r': '\\r', | ||
153 | + '"': '\\"', | ||
154 | + '\\': '\\\\' | ||
155 | + }; | ||
156 | + JSON.stringify = function (value, replacer, space) { | ||
157 | + var i; | ||
158 | + gap = ''; | ||
159 | + indent = ''; | ||
160 | + if (typeof space === 'number') { | ||
161 | + for (i = 0; i < space; i += 1) { | ||
162 | + indent += ' '; | ||
163 | + } | ||
164 | + } else if (typeof space === 'string') { | ||
165 | + indent = space; | ||
166 | + } | ||
167 | + rep = replacer; | ||
168 | + if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { | ||
169 | + throw new Error('JSON.stringify'); | ||
170 | + } | ||
171 | + return str('', { '': value }); | ||
172 | + }; | ||
173 | + } | ||
174 | + if (typeof JSON.parse !== 'function') { | ||
175 | + JSON.parse = function (text, reviver) { | ||
176 | + var j; | ||
177 | + function walk(holder, key) { | ||
178 | + var k, v, value = holder[key]; | ||
179 | + if (value && typeof value === 'object') { | ||
180 | + for (k in value) { | ||
181 | + if (Object.prototype.hasOwnProperty.call(value, k)) { | ||
182 | + v = walk(value, k); | ||
183 | + if (v !== undefined) { | ||
184 | + value[k] = v; | ||
185 | + } else { | ||
186 | + delete value[k]; | ||
187 | + } | ||
188 | + } | ||
189 | + } | ||
190 | + } | ||
191 | + return reviver.call(holder, key, value); | ||
192 | + } | ||
193 | + text = String(text); | ||
194 | + rx_dangerous.lastIndex = 0; | ||
195 | + if (rx_dangerous.test(text)) { | ||
196 | + text = text.replace(rx_dangerous, function (a) { | ||
197 | + return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
198 | + }); | ||
199 | + } | ||
200 | + if (rx_one.test(text.replace(rx_two, '@').replace(rx_three, ']').replace(rx_four, ''))) { | ||
201 | + j = eval('(' + text + ')'); | ||
202 | + return typeof reviver === 'function' ? walk({ '': j }, '') : j; | ||
203 | + } | ||
204 | + throw new SyntaxError('JSON.parse'); | ||
205 | + }; | ||
206 | + } | ||
207 | + }()); | ||
208 | +}(); | ||
209 | +yas_jssdk_1014_src_util_debug = function (exports) { | ||
210 | + var config = yas_jssdk_1014_src_config_debug; | ||
211 | + var yasPath = config.yaPath; | ||
212 | + var yasDomain = config.yasDomain; | ||
213 | + exports.flashChecker = function () { | ||
214 | + var hasFlash = 0; | ||
215 | + var flashVersion = 0; | ||
216 | + var isIE = 0; | ||
217 | + var swf = null; | ||
218 | + if (isIE) { | ||
219 | + swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); | ||
220 | + if (swf) { | ||
221 | + hasFlash = 1; | ||
222 | + flashVersion = swf.GetVariable('$version'); | ||
223 | + } | ||
224 | + } else { | ||
225 | + if (navigator.plugins && navigator.plugins.length > 0) { | ||
226 | + swf = navigator.plugins['Shockwave Flash']; | ||
227 | + if (swf) { | ||
228 | + hasFlash = 1; | ||
229 | + flashVersion = swf.description.replace('Shockwave Flash', ''); | ||
230 | + } | ||
231 | + } | ||
232 | + } | ||
233 | + return { | ||
234 | + f: hasFlash, | ||
235 | + v: flashVersion | ||
236 | + }; | ||
237 | + }; | ||
238 | + exports.Hash = function (str) { | ||
239 | + var hash = 1, charCode = 0, idx; | ||
240 | + if (str) { | ||
241 | + hash = 0; | ||
242 | + for (idx = str.length - 1; idx >= 0; idx--) { | ||
243 | + charCode = str.charCodeAt(idx); | ||
244 | + hash = (hash << 6 & 268435455) + charCode + (charCode << 14); | ||
245 | + charCode = hash & 266338304; | ||
246 | + if (charCode !== 0) { | ||
247 | + hash = hash ^ charCode >> 21; | ||
248 | + } | ||
249 | + } | ||
250 | + } | ||
251 | + return hash; | ||
252 | + }; | ||
253 | + exports.Random = function () { | ||
254 | + return Math.round(Math.random() * 2147483647); | ||
255 | + }; | ||
256 | + exports.hashClientInfo = function () { | ||
257 | + var navigator = window.navigator; | ||
258 | + var history_length = window.history.length; | ||
259 | + var arr = [ | ||
260 | + navigator.appName, | ||
261 | + navigator.version, | ||
262 | + navigator.language, | ||
263 | + navigator.platform, | ||
264 | + navigator.userAgent, | ||
265 | + navigator.javaEnabled(), | ||
266 | + window.screen, | ||
267 | + window.screen.colorDepth, | ||
268 | + window.document.cookie ? window.document.cookie : '', | ||
269 | + window.document.referrer ? window.document.referrer : '' | ||
270 | + ]; | ||
271 | + navigator = arr.join(''); | ||
272 | + for (var len = navigator.length; history_length > 0;) { | ||
273 | + navigator += history_length-- ^ len++; | ||
274 | + } | ||
275 | + return exports.Hash(navigator); | ||
276 | + }; | ||
277 | + exports.merge = function (obj1, obj2) { | ||
278 | + var ret = {}; | ||
279 | + for (var attr in obj1) { | ||
280 | + ret[attr] = obj1[attr]; | ||
281 | + } | ||
282 | + for (var attr2 in obj2) { | ||
283 | + ret[attr2] = obj2[attr2]; | ||
284 | + } | ||
285 | + return ret; | ||
286 | + }; | ||
287 | + exports.genParam = function (obj) { | ||
288 | + var arr = []; | ||
289 | + for (var key in obj) { | ||
290 | + arr.push(key + '=' + obj[key]); | ||
291 | + } | ||
292 | + return arr.join('&'); | ||
293 | + }; | ||
294 | + exports.trim = function (text) { | ||
295 | + if (String.prototype.trim) { | ||
296 | + return text === null ? '' : String.prototype.trim.call(text); | ||
297 | + } else { | ||
298 | + var trimLeft = /^\s+/; | ||
299 | + var trimRight = /\s+$/; | ||
300 | + var ret = ''; | ||
301 | + if (text) { | ||
302 | + ret = text.toString().replace(trimLeft, ''); | ||
303 | + ret = ret.replace(trimRight, ''); | ||
304 | + return ret; | ||
305 | + } | ||
306 | + } | ||
307 | + }; | ||
308 | + exports.getGeo = function (callback) { | ||
309 | + if (window.navigator.geolocation) { | ||
310 | + var options = { enableHighAccuracy: true }; | ||
311 | + window.navigator.geolocation.getCurrentPosition(handleSuccess, handleError, options); | ||
312 | + } else { | ||
313 | + callback(false); | ||
314 | + } | ||
315 | + function handleSuccess(position) { | ||
316 | + var lng = position.coords.longitude; | ||
317 | + var lat = position.coords.latitude; | ||
318 | + callback(lat, lng); | ||
319 | + } | ||
320 | + function handleError(error) { | ||
321 | + callback(false); | ||
322 | + } | ||
323 | + }; | ||
324 | + return exports; | ||
325 | +}({}); | ||
326 | +yas_jssdk_1014_src_cookie_debug = function (exports) { | ||
327 | + var util = yas_jssdk_1014_src_util_debug; | ||
328 | + exports = function (name, value, options) { | ||
329 | + if (typeof value != 'undefined') { | ||
330 | + options = options || {}; | ||
331 | + if (value === null) { | ||
332 | + value = ''; | ||
333 | + options.expires = -1; | ||
334 | + } | ||
335 | + var expires = ''; | ||
336 | + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { | ||
337 | + var date; | ||
338 | + if (typeof options.expires == 'number') { | ||
339 | + date = new Date(); | ||
340 | + date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1000); | ||
341 | + } else { | ||
342 | + date = options.expires; | ||
343 | + } | ||
344 | + expires = '; expires=' + date.toUTCString(); | ||
345 | + } | ||
346 | + var path = options.path ? '; path=' + options.path : ''; | ||
347 | + var domain = options.domain ? '; domain=' + options.domain : ''; | ||
348 | + var secure = options.secure ? '; secure' : ''; | ||
349 | + document.cookie = [ | ||
350 | + name, | ||
351 | + '=', | ||
352 | + encodeURIComponent(value), | ||
353 | + expires, | ||
354 | + path, | ||
355 | + domain, | ||
356 | + secure | ||
357 | + ].join(''); | ||
358 | + } else { | ||
359 | + var cookieValue = null; | ||
360 | + if (document.cookie) { | ||
361 | + var cookies = document.cookie.split(';'); | ||
362 | + for (var i = 0; i < cookies.length; i++) { | ||
363 | + var cookie = util.trim(cookies[i]); | ||
364 | + if (cookie.substring(0, name.length + 1) == name + '=') { | ||
365 | + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); | ||
366 | + break; | ||
367 | + } | ||
368 | + } | ||
369 | + } | ||
370 | + return cookieValue; | ||
371 | + } | ||
372 | + }; | ||
373 | + return exports; | ||
374 | +}(); | ||
375 | +yas_jssdk_1014_src_ya_debug = function (exports) { | ||
376 | + var util = yas_jssdk_1014_src_util_debug; | ||
377 | + var cookies = yas_jssdk_1014_src_cookie_debug; | ||
378 | + var cross = yas_jssdk_1014_src_cross_debug; | ||
379 | + var ev = yas_jssdk_1014_src_event_debug; | ||
380 | + var config = yas_jssdk_1014_src_config_debug; | ||
381 | + yohojson2_100_json2_debug; | ||
382 | + var version = config.version; | ||
383 | + var yasPath = config.yaPath; | ||
384 | + var yasDomain = config.yasDomain; | ||
385 | + var appInfo = { | ||
386 | + h: document.domain, | ||
387 | + p: window.location.port, | ||
388 | + u: window.location.pathname, | ||
389 | + ft: 0, | ||
390 | + fst: 0, | ||
391 | + sv: '', | ||
392 | + ab: cookies('ab_5') || '' | ||
393 | + }; | ||
394 | + var VisitorId = getVisitorId(); | ||
395 | + var custInfo = { | ||
396 | + ak: '', | ||
397 | + cd: VisitorId.cid, | ||
398 | + vd: new Date().getTime() + VisitorId.cid, | ||
399 | + ud: '', | ||
400 | + rf: document.referrer, | ||
401 | + ckf: VisitorId.isNew | ||
402 | + }; | ||
403 | + var custOpInfo = { | ||
404 | + mp: '', | ||
405 | + ev: '', | ||
406 | + st: 0 | ||
407 | + }; | ||
408 | + var flash = util.flashChecker(); | ||
409 | + var browserInfo = { | ||
410 | + sr: window.screen.width + 'x' + window.screen.height, | ||
411 | + wr: window.screen.availWidth + 'x' + window.screen.availHeight, | ||
412 | + sd: window.screen.colorDepth, | ||
413 | + ln: window.navigator.language ? window.navigator.language : window.navigator.browserLanguage, | ||
414 | + sy: window.navigator.platform, | ||
415 | + ce: window.navigator.cookieEnabled, | ||
416 | + fv: flash.f ? flash.v : 0 | ||
417 | + }; | ||
418 | + var _yas = function (initTime, version, tid, uid, geo, selector) { | ||
419 | + custInfo.ak = tid; | ||
420 | + appInfo.sv = version; | ||
421 | + custInfo.ud = uid ? uid : ''; | ||
422 | + if (cookies('_yasgeo')) { | ||
423 | + var geoInfo = cookies('_yasgeo').split(','); | ||
424 | + custInfo.la = geoInfo[0]; | ||
425 | + custInfo.lo = geoInfo[1]; | ||
426 | + cookies('_yasgeo', null, { | ||
427 | + path: '/', | ||
428 | + domain: config.yasDomain, | ||
429 | + expires: 365 * 200 | ||
430 | + }); | ||
431 | + } | ||
432 | + var beginTime = new Date().getTime(); | ||
433 | + var sendFlag = null; | ||
434 | + var isOver3sSend = false; | ||
435 | + appInfo.ft = beginTime - initTime; | ||
436 | + ev.addEventHandler(window, 'load', function (e) { | ||
437 | + var endTime = new Date().getTime(); | ||
438 | + appInfo.fst = endTime - initTime; | ||
439 | + ev.removeEventHandler(window, 'load', arguments.callee); | ||
440 | + window.clearTimeout(sendFlag); | ||
441 | + if (!isOver3sSend) { | ||
442 | + send(); | ||
443 | + } | ||
444 | + }); | ||
445 | + sendFlag = window.setTimeout(function () { | ||
446 | + appInfo.fst = 0; | ||
447 | + appInfo.fse = '>3s'; | ||
448 | + isOver3sSend = true; | ||
449 | + send(); | ||
450 | + }, 3000); | ||
451 | + if (geo) { | ||
452 | + util.getGeo(function (lat, lng) { | ||
453 | + if (lat) { | ||
454 | + cookies('_yasgeo', lat + ',' + lng, { | ||
455 | + path: '/', | ||
456 | + domain: yasDomain, | ||
457 | + expires: 365 * 200 | ||
458 | + }); | ||
459 | + } | ||
460 | + }); | ||
461 | + } | ||
462 | + if (selector[0]) { | ||
463 | + for (var i = 0, length = selector.length; i < length; i++) { | ||
464 | + selector[i].setAttribute('yoho_index', i + 1); | ||
465 | + } | ||
466 | + } else { | ||
467 | + ev.addEventHandler(document, 'click', function (e) { | ||
468 | + e = e || window.event; | ||
469 | + var target = e.target || e.srcElement; | ||
470 | + if (target && (target.nodeName === 'A' || target.nodeName === 'IMG' && target.parentNode.nodeName === 'A')) { | ||
471 | + var pos = getMouseEventPosition(e); | ||
472 | + var str = pos.x + ',' + pos.y + ',' + e.type; | ||
473 | + var yoho_index = target.getAttribute('yoho_index') || target.parentNode.getAttribute('yoho_index'); | ||
474 | + if (yoho_index) { | ||
475 | + str += ',' + yoho_index; | ||
476 | + } | ||
477 | + cookies('_yasmp', str, { | ||
478 | + path: '/', | ||
479 | + domain: yasDomain, | ||
480 | + expires: 365 * 200 | ||
481 | + }); | ||
482 | + } | ||
483 | + ix = 0; | ||
484 | + }); | ||
485 | + } | ||
486 | + }; | ||
487 | + function send(callback) { | ||
488 | + var info = util.merge(appInfo, custInfo); | ||
489 | + info = util.merge(info, browserInfo); | ||
490 | + var mp = getMousePosition(); | ||
491 | + if (mp) { | ||
492 | + info = util.merge(info, mp); | ||
493 | + cookies('_yasmp', null, { | ||
494 | + path: '/', | ||
495 | + domain: config.yasDomain, | ||
496 | + expires: 365 * 200 | ||
497 | + }); | ||
498 | + } | ||
499 | + var _custjsonstr = cookies('_yascustjson'); | ||
500 | + if (_custjsonstr) { | ||
501 | + var custjson = JSON.parse(_custjsonstr); | ||
502 | + info = util.merge(info, custjson); | ||
503 | + cookies('_yascustjson', null, { | ||
504 | + path: '/', | ||
505 | + domain: config.yasDomain, | ||
506 | + expires: 365 * 200 | ||
507 | + }); | ||
508 | + } | ||
509 | + var param = util.genParam(info); | ||
510 | + callback = callback ? callback : function () { | ||
511 | + }; | ||
512 | + cross.imgSend(param, callback); | ||
513 | + var _yasev = cookies('_yasev'); | ||
514 | + if (_yasev) { | ||
515 | + cross.imgSend(_yasev, function () { | ||
516 | + cookies('_yasev', null, { | ||
517 | + path: '/', | ||
518 | + domain: config.yasDomain, | ||
519 | + expires: 365 * 200 | ||
520 | + }); | ||
521 | + }); | ||
522 | + } | ||
523 | + } | ||
524 | + function getVisitorId() { | ||
525 | + var cid = cookies('_yasvd'); | ||
526 | + if (cid) { | ||
527 | + return { | ||
528 | + cid: cid, | ||
529 | + isNew: 'N' | ||
530 | + }; | ||
531 | + } | ||
532 | + cid = util.Random() ^ util.hashClientInfo() & 2147483647; | ||
533 | + cookies('_yasvd', cid, { | ||
534 | + path: '/', | ||
535 | + domain: yasDomain, | ||
536 | + expires: 365 * 200 | ||
537 | + }); | ||
538 | + return { | ||
539 | + cid: cid, | ||
540 | + isNew: 'Y' | ||
541 | + }; | ||
542 | + } | ||
543 | + function getMousePosition() { | ||
544 | + var mp = cookies('_yasmp'); | ||
545 | + if (mp) { | ||
546 | + var mpObject = mp.split(','); | ||
547 | + if (mpObject.length === 3) { | ||
548 | + return { | ||
549 | + x: mpObject[0], | ||
550 | + y: mpObject[1], | ||
551 | + et: mpObject[2] | ||
552 | + }; | ||
553 | + } else if (mpObject.length === 4) { | ||
554 | + return { | ||
555 | + x: mpObject[0], | ||
556 | + y: mpObject[1], | ||
557 | + et: mpObject[2], | ||
558 | + ix: mpObject[3] | ||
559 | + }; | ||
560 | + } | ||
561 | + } | ||
562 | + return null; | ||
563 | + } | ||
564 | + function getMouseEventPosition(e) { | ||
565 | + var x = 0, y = 0; | ||
566 | + if (e.pageX || e.pageY) { | ||
567 | + x = e.pageX; | ||
568 | + y = e.pageY; | ||
569 | + } else if (e.clientX || e.clientY) { | ||
570 | + x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; | ||
571 | + y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; | ||
572 | + } | ||
573 | + x -= window.screen.width / 2; | ||
574 | + y = window.screen.height / 2 - y; | ||
575 | + return { | ||
576 | + x: x, | ||
577 | + y: y | ||
578 | + }; | ||
579 | + } | ||
580 | + var evTimes = 0; | ||
581 | + _yas.add = function (trackType, input, action, label, value) { | ||
582 | + if (evTimes > 3) { | ||
583 | + cross.imgSend(cookies('_yasev'), function () { | ||
584 | + cookies('_yasev', null, { | ||
585 | + path: '/', | ||
586 | + domain: config.yasDomain, | ||
587 | + expires: 365 * 200 | ||
588 | + }); | ||
589 | + evTimes = 0; | ||
590 | + _addEv2Cookies(trackType, input, action, label, value); | ||
591 | + }); | ||
592 | + } else { | ||
593 | + _addEv2Cookies(trackType, input, action, label, value); | ||
594 | + } | ||
595 | + }; | ||
596 | + function _addEv2Cookies(trackType, input, action, label, value) { | ||
597 | + var ev = cookies('_yasev'); | ||
598 | + if (ev) { | ||
599 | + ev += '&'; | ||
600 | + } else { | ||
601 | + ev = ''; | ||
602 | + } | ||
603 | + cookies('_yasev', ev + 'vd=' + custInfo.vd + '&t=' + trackType + '&i=' + input + '&l=' + label + '&v=' + value, { | ||
604 | + path: '/', | ||
605 | + domain: yasDomain, | ||
606 | + expires: 365 * 200 | ||
607 | + }); | ||
608 | + evTimes++; | ||
609 | + } | ||
610 | + _yas.sendMouseEvent = function (e, flag) { | ||
611 | + e = e || window.event; | ||
612 | + var pos = getMouseEventPosition(e); | ||
613 | + if (!flag) { | ||
614 | + cookies('_yasmp', pos.x + ',' + pos.y + ',' + e.type, { | ||
615 | + path: '/', | ||
616 | + domain: yasDomain, | ||
617 | + expires: 365 * 200 | ||
618 | + }); | ||
619 | + } else { | ||
620 | + var mp = { | ||
621 | + x: pos.x, | ||
622 | + y: pos.y, | ||
623 | + et: e.type | ||
624 | + }; | ||
625 | + var info = util.merge(appInfo, custInfo); | ||
626 | + info = util.merge(info, browserInfo); | ||
627 | + info = util.merge(info, mp); | ||
628 | + var param = util.genParam(info); | ||
629 | + cross.imgSend(param, function () { | ||
630 | + }); | ||
631 | + } | ||
632 | + }; | ||
633 | + _yas.sendCustomInfo = function (json, flag) { | ||
634 | + if (!flag) { | ||
635 | + var string = JSON.stringify(json); | ||
636 | + cookies('_yascustjson', string, { | ||
637 | + path: '/', | ||
638 | + domain: yasDomain, | ||
639 | + expires: 365 * 200 | ||
640 | + }); | ||
641 | + } else { | ||
642 | + var info = util.merge(appInfo, custInfo); | ||
643 | + info = util.merge(info, browserInfo); | ||
644 | + info = util.merge(info, json); | ||
645 | + var param = util.genParam(info); | ||
646 | + cross.imgSend(param, function () { | ||
647 | + }); | ||
648 | + } | ||
649 | + }; | ||
650 | + exports = _yas; | ||
651 | + return exports; | ||
652 | +}(); | ||
653 | +yas_jssdk_1014_yas_debug = function (exports) { | ||
654 | + var yasJssdk = yas_jssdk_1014_src_ya_debug; | ||
655 | + if (window.YohoAcquisitionObject) { | ||
656 | + var yas = window.YohoAcquisitionObject; | ||
657 | + if (window[yas].p) { | ||
658 | + yasJssdk.apply(this, window[yas].p); | ||
659 | + window[yas] = yasJssdk; | ||
660 | + } | ||
661 | + } | ||
662 | + exports = yasJssdk; | ||
663 | + return exports; | ||
664 | +}(); | ||
665 | +}()); |
static/yas-jssdk/1.0.14/yas.js
0 → 100644
1 | +!function(){var yas_jssdk_1014_src_config,yas_jssdk_1014_src_cross,yas_jssdk_1014_src_event,yohojson2_100_json2,yas_jssdk_1014_src_util,yas_jssdk_1014_src_cookie,yas_jssdk_1014_src_ya,yas_jssdk_1014_yas;yas_jssdk_1014_src_config=function(e){function n(){var e=document.domain.split("."),n=e.length;return n>1&&isNaN(e[n-1])?"."+e[n-2]+"."+e[n-1]:document.domain}return e={version:"1.0",yasPath:"/web/",yasDomain:n(),yasImgDomain:"http://analytics.yhurl.com/yas.gif"}}(),yas_jssdk_1014_src_cross=function(e){var n=yas_jssdk_1014_src_config,t=n.yasPath,r=n.yasImgDomain;return e.imgSend=function(e,n){var o=new Image(1,1);o.src=r+t+"?"+e,o.onload=function(){o.onload=null,n&&n()}},e}({}),yas_jssdk_1014_src_event=function(e){return e.addEventHandler=function(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t},e.removeEventHandler=function(e,n,t){e.removeEventListener?e.removeEventListener(n,t,!1):e.detachEvent?e.detachEvent("on"+n,t):delete e["on"+n]},e}({}),yohojson2_100_json2=function(){"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(e){return 10>e?"0"+e:e}function this_value(){return this.valueOf()}function quote(e){return rx_escapable.lastIndex=0,rx_escapable.test(e)?'"'+e.replace(rx_escapable,function(e){var n=meta[e];return"string"==typeof n?n:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,n){var t,r,o,a,i,s=gap,u=n[e];switch(u&&"object"==typeof u&&"function"==typeof u.toJSON&&(u=u.toJSON(e)),"function"==typeof rep&&(u=rep.call(n,e,u)),typeof u){case"string":return quote(u);case"number":return isFinite(u)?String(u):"null";case"boolean":case"null":return String(u);case"object":if(!u)return"null";if(gap+=indent,i=[],"[object Array]"===Object.prototype.toString.apply(u)){for(a=u.length,t=0;a>t;t+=1)i[t]=str(t,u)||"null";return o=0===i.length?"[]":gap?"[\n"+gap+i.join(",\n"+gap)+"\n"+s+"]":"["+i.join(",")+"]",gap=s,o}if(rep&&"object"==typeof rep)for(a=rep.length,t=0;a>t;t+=1)"string"==typeof rep[t]&&(r=rep[t],o=str(r,u),o&&i.push(quote(r)+(gap?": ":":")+o));else for(r in u)Object.prototype.hasOwnProperty.call(u,r)&&(o=str(r,u),o&&i.push(quote(r)+(gap?": ":":")+o));return o=0===i.length?"{}":gap?"{\n"+gap+i.join(",\n"+gap)+"\n"+s+"}":"{"+i.join(",")+"}",gap=s,o}}var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(e,n,t){var r;if(gap="",indent="","number"==typeof t)for(r=0;t>r;r+=1)indent+=" ";else"string"==typeof t&&(indent=t);if(rep=n,n&&"function"!=typeof n&&("object"!=typeof n||"number"!=typeof n.length))throw new Error("JSON.stringify");return str("",{"":e})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,n){var t,r,o=e[n];if(o&&"object"==typeof o)for(t in o)Object.prototype.hasOwnProperty.call(o,t)&&(r=walk(o,t),void 0!==r?o[t]=r:delete o[t]);return reviver.call(e,n,o)}var j;if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()}(),yas_jssdk_1014_src_util=function(e){{var n=yas_jssdk_1014_src_config;n.yaPath,n.yasDomain}return e.flashChecker=function(){var e=0,n=0,t=0,r=null;return t?(r=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),r&&(e=1,n=r.GetVariable("$version"))):navigator.plugins&&navigator.plugins.length>0&&(r=navigator.plugins["Shockwave Flash"],r&&(e=1,n=r.description.replace("Shockwave Flash",""))),{f:e,v:n}},e.Hash=function(e){var n,t=1,r=0;if(e)for(t=0,n=e.length-1;n>=0;n--)r=e.charCodeAt(n),t=(t<<6&268435455)+r+(r<<14),r=266338304&t,0!==r&&(t^=r>>21);return t},e.Random=function(){return Math.round(2147483647*Math.random())},e.hashClientInfo=function(){var n=window.navigator,t=window.history.length,r=[n.appName,n.version,n.language,n.platform,n.userAgent,n.javaEnabled(),window.screen,window.screen.colorDepth,window.document.cookie?window.document.cookie:"",window.document.referrer?window.document.referrer:""];n=r.join("");for(var o=n.length;t>0;)n+=t--^o++;return e.Hash(n)},e.merge=function(e,n){var t={};for(var r in e)t[r]=e[r];for(var o in n)t[o]=n[o];return t},e.genParam=function(e){var n=[];for(var t in e)n.push(t+"="+e[t]);return n.join("&")},e.trim=function(e){if(String.prototype.trim)return null===e?"":String.prototype.trim.call(e);var n=/^\s+/,t=/\s+$/,r="";return e?(r=e.toString().replace(n,""),r=r.replace(t,"")):void 0},e.getGeo=function(e){function n(n){var t=n.coords.longitude,r=n.coords.latitude;e(r,t)}function t(){e(!1)}if(window.navigator.geolocation){var r={enableHighAccuracy:!0};window.navigator.geolocation.getCurrentPosition(n,t,r)}else e(!1)},e}({}),yas_jssdk_1014_src_cookie=function(e){var n=yas_jssdk_1014_src_util;return e=function(e,t,r){if("undefined"==typeof t){var o=null;if(document.cookie)for(var a=document.cookie.split(";"),i=0;i<a.length;i++){var s=n.trim(a[i]);if(s.substring(0,e.length+1)==e+"="){o=decodeURIComponent(s.substring(e.length+1));break}}return o}r=r||{},null===t&&(t="",r.expires=-1);var u="";if(r.expires&&("number"==typeof r.expires||r.expires.toUTCString)){var c;"number"==typeof r.expires?(c=new Date,c.setTime(c.getTime()+24*r.expires*60*60*1e3)):c=r.expires,u="; expires="+c.toUTCString()}var f=r.path?"; path="+r.path:"",d=r.domain?"; domain="+r.domain:"",l=r.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(t),u,f,d,l].join("")}}(),yas_jssdk_1014_src_ya=function(e){function n(e){var n=i.merge(l,g);n=i.merge(n,v);var t=r();t&&(n=i.merge(n,t),s("_yasmp",null,{path:"/",domain:f.yasDomain,expires:73e3}));var o=s("_yascustjson");if(o){var a=JSON.parse(o);n=i.merge(n,a),s("_yascustjson",null,{path:"/",domain:f.yasDomain,expires:73e3})}var c=i.genParam(n);e=e?e:function(){},u.imgSend(c,e);var d=s("_yasev");d&&u.imgSend(d,function(){s("_yasev",null,{path:"/",domain:f.yasDomain,expires:73e3})})}function t(){var e=s("_yasvd");return e?{cid:e,isNew:"N"}:(e=i.Random()^2147483647&i.hashClientInfo(),s("_yasvd",e,{path:"/",domain:d,expires:73e3}),{cid:e,isNew:"Y"})}function r(){var e=s("_yasmp");if(e){var n=e.split(",");if(3===n.length)return{x:n[0],y:n[1],et:n[2]};if(4===n.length)return{x:n[0],y:n[1],et:n[2],ix:n[3]}}return null}function o(e){var n=0,t=0;return e.pageX||e.pageY?(n=e.pageX,t=e.pageY):(e.clientX||e.clientY)&&(n=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,t=e.clientY+document.body.scrollTop+document.documentElement.scrollTop),n-=window.screen.width/2,t=window.screen.height/2-t,{x:n,y:t}}function a(e,n,t,r,o){var a=s("_yasev");a?a+="&":a="",s("_yasev",a+"vd="+g.vd+"&t="+e+"&i="+n+"&l="+r+"&v="+o,{path:"/",domain:d,expires:73e3}),m++}var i=yas_jssdk_1014_src_util,s=yas_jssdk_1014_src_cookie,u=yas_jssdk_1014_src_cross,c=yas_jssdk_1014_src_event,f=yas_jssdk_1014_src_config,d=(f.version,f.yaPath,f.yasDomain),l={h:document.domain,p:window.location.port,u:window.location.pathname,ft:0,fst:0,sv:"",ab:s("ab_5")||""},p=t(),g={ak:"",cd:p.cid,vd:(new Date).getTime()+p.cid,ud:"",rf:document.referrer,ckf:p.isNew},_=i.flashChecker(),v={sr:window.screen.width+"x"+window.screen.height,wr:window.screen.availWidth+"x"+window.screen.availHeight,sd:window.screen.colorDepth,ln:window.navigator.language?window.navigator.language:window.navigator.browserLanguage,sy:window.navigator.platform,ce:window.navigator.cookieEnabled,fv:_.f?_.v:0},y=function(e,t,r,a,u,p){if(g.ak=r,l.sv=t,g.ud=a?a:"",s("_yasgeo")){var _=s("_yasgeo").split(",");g.la=_[0],g.lo=_[1],s("_yasgeo",null,{path:"/",domain:f.yasDomain,expires:73e3})}var v=(new Date).getTime(),y=null,m=!1;if(l.ft=v-e,c.addEventHandler(window,"load",function(){var t=(new Date).getTime();l.fst=t-e,c.removeEventHandler(window,"load",arguments.callee),window.clearTimeout(y),m||n()}),y=window.setTimeout(function(){l.fst=0,l.fse=">3s",m=!0,n()},3e3),u&&i.getGeo(function(e,n){e&&s("_yasgeo",e+","+n,{path:"/",domain:d,expires:73e3})}),p[0])for(var h=0,w=p.length;w>h;h++)p[h].setAttribute("yoho_index",h+1);else c.addEventHandler(document,"click",function(e){e=e||window.event;var n=e.target||e.srcElement;if(n&&("A"===n.nodeName||"IMG"===n.nodeName&&"A"===n.parentNode.nodeName)){var t=o(e),r=t.x+","+t.y+","+e.type,a=n.getAttribute("yoho_index")||n.parentNode.getAttribute("yoho_index");a&&(r+=","+a),s("_yasmp",r,{path:"/",domain:d,expires:73e3})}ix=0})},m=0;return y.add=function(e,n,t,r,o){m>3?u.imgSend(s("_yasev"),function(){s("_yasev",null,{path:"/",domain:f.yasDomain,expires:73e3}),m=0,a(e,n,t,r,o)}):a(e,n,t,r,o)},y.sendMouseEvent=function(e,n){e=e||window.event;var t=o(e);if(n){var r={x:t.x,y:t.y,et:e.type},a=i.merge(l,g);a=i.merge(a,v),a=i.merge(a,r);var c=i.genParam(a);u.imgSend(c,function(){})}else s("_yasmp",t.x+","+t.y+","+e.type,{path:"/",domain:d,expires:73e3})},y.sendCustomInfo=function(e,n){if(n){var t=i.merge(l,g);t=i.merge(t,v),t=i.merge(t,e);var r=i.genParam(t);u.imgSend(r,function(){})}else{var o=JSON.stringify(e);s("_yascustjson",o,{path:"/",domain:d,expires:73e3})}},e=y}(),yas_jssdk_1014_yas=function(e){var n=yas_jssdk_1014_src_ya;if(window.YohoAcquisitionObject){var t=window.YohoAcquisitionObject;window[t].p&&(n.apply(this,window[t].p),window[t]=n)}return e=n}()}(); |
-
Please register or login to post a comment