-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.85a4fa.js
7521 lines (6100 loc) · 204 KB
/
main.85a4fa.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "./";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
__webpack_require__(1);
__webpack_require__(11);
var _viewer = __webpack_require__(14);
var _viewer2 = _interopRequireDefault(_viewer);
var _share = __webpack_require__(24);
var _share2 = _interopRequireDefault(_share);
var _aside = __webpack_require__(27);
var _aside2 = _interopRequireDefault(_aside);
var _util = __webpack_require__(28);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// 边缘
// 图片查看器
// 样式
(0, _util.addLoadEvent)(function () {
_share2.default.init();
_viewer2.default.init();
_aside2.default.init();
});
// 分享
// 上报
/***/ }),
/* 1 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 2 */,
/* 3 */,
/* 4 */,
/* 5 */,
/* 6 */,
/* 7 */,
/* 8 */,
/* 9 */,
/* 10 */,
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var jsCookie = __webpack_require__(12);
__webpack_require__(13);
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);return null;
}
// 统计用,开发者不需要理会
if (window.BJ_REPORT) {
BJ_REPORT.init({
id: 1
});
BJ_REPORT.init({
id: 1,
uin: window.location.origin,
combo: 0,
delay: 1000,
url: "//litten.me:9005/badjs/",
ignore: [/Script error/i],
random: 1,
repeat: 500000,
onReport: function onReport(id, errObj) {},
ext: {}
});
// iframe不上报
var host = window.location.host;
var isNotFrame = top === window;
var isNotLocal = !(/localhost/i.test(host) || /127.0.0.1/i.test(host) || /0.0.0.0/i.test(host));
isNotFrame && isNotLocal && BJ_REPORT.report('yilia-' + window.location.host);
// 来源上报
var from = getQueryString('f');
var fromKey = 'yilia-from';
if (from) {
isNotFrame && BJ_REPORT.report('from-' + from);
// 种cookie
jsCookie.set(fromKey, from);
} else {
if (document.referrer.indexOf(window.location.host) >= 0) {
// 取cookie
from = jsCookie.get(fromKey);
from && isNotFrame && BJ_REPORT.report('from-' + from);
} else {
// 清cookie
jsCookie.remove(fromKey);
}
}
}
module.exports = {
init: function init() {}
};
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
* JavaScript Cookie v2.2.0
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(function (factory) {
var registeredInModuleLoader = false;
if (true) {
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
registeredInModuleLoader = true;
}
if (true) {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init (converter) {
function api (key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}
if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}
stringifiedAttributes += '=' + attributes[attributeName];
}
return (document.cookie = key + '=' + value + stringifiedAttributes);
}
// Read
if (!key) {
result = {};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');
if (!this.json && cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}
if (key === name) {
result = cookie;
break;
}
if (!key) {
result[name] = cookie;
}
} catch (e) {}
}
return result;
}
api.set = api;
api.get = function (key) {
return api.call(api, key);
};
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};
api.withConverter = init;
return api;
}
return init(function () {});
}));
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
/*!
* @module report
* @author kael, chriscai
* @date @DATE
* Copyright (c) 2014 kael, chriscai
* Licensed under the MIT license.
*/
var BJ_REPORT = (function(global) {
if (global.BJ_REPORT) return global.BJ_REPORT;
var _log_list = [];
var _log_map = {};
var _config = {
id: 0, // 上报 id
uin: 0, // user id
url: "", // 上报 接口
offline_url: "", // 离线日志上报 接口
offline_auto_url: "", // 检测是否自动上报
ext: null, // 扩展参数 用于自定义上报
level: 4, // 错误级别 1-debug 2-info 4-error
ignore: [], // 忽略某个错误, 支持 Regexp 和 Function
random: 1, // 抽样 (0-1] 1-全量
delay: 1000, // 延迟上报 combo 为 true 时有效
submit: null, // 自定义上报方式
repeat: 5 , // 重复上报次数(对于同一个错误超过多少次不上报),
offlineLog : false,
offlineLogExp : 5, // 离线日志过期时间 , 默认5天
offlineLogAuto : false, //是否自动询问服务器需要自动上报
};
var Offline_DB = {
db : null,
ready : function (callback){
var self = this;
if(!window.indexedDB || !_config.offlineLog ){
_config.offlineLog = false;
return callback();
}
if(this.db){
setTimeout(function (){
callback(null , self );
},0);
return;
}
var version= 1;
var request=window.indexedDB.open("badjs" , version);
if(!request){
_config.offlineLog = false;
return callback();
}
request.onerror=function(e){
callback(e);
_config.offlineLog = false;
console.log("indexdb request error");
return true;
};
request.onsuccess=function(e){
self.db = e.target.result;
setTimeout(function (){
callback(null , self);
},500);
};
request.onupgradeneeded=function(e){
var db=e.target.result;
if(!db.objectStoreNames.contains('logs')){
db.createObjectStore('logs', { autoIncrement: true });
}
};
},
insertToDB : function (log){
var store= this.getStore();
store.add(log);
},
addLog : function (log){
if(!this.db){
return ;
}
this.insertToDB(log);
},
addLogs : function (logs){
if(!this.db){
return;
}
for(var i = 0;i < logs.length ; i++){
this.addLog( logs[i]);
}
},
getLogs : function (opt , callback ){
if(!this.db){
return;
}
var store= this.getStore();
var request = store.openCursor();
var result = [];
request.onsuccess = function (event) {
var cursor = event.target.result;
if (cursor ) {
if(cursor.value.time >= opt.start && cursor.value.time <= opt.end && cursor.value.id == opt.id && cursor.value.uin == opt.uin){
result.push(cursor.value);
}
//# cursor.continue
cursor["continue"]();
}else {
callback(null , result);
}
};
request.onerror = function (e){
callback(e);
return true;
};
},
clearDB : function (daysToMaintain){
if(!this.db){
return;
}
var store= this.getStore();
if (!daysToMaintain) {
store.clear();
return ;
}
var range = (Date.now() - (daysToMaintain || 2) * 24 * 3600 * 1000);
var request = store.openCursor();
request.onsuccess = function (event) {
var cursor = event.target.result;
if (cursor && (cursor.value.time < range || !cursor.value.time)) {
store["delete"](cursor.primaryKey);
cursor["continue"]();
}
};
},
getStore: function (){
var transaction=this.db.transaction("logs",'readwrite');
return transaction.objectStore("logs");
},
};
var T = {
isOBJByType: function (o, type) {
return Object.prototype.toString.call(o) === "[object " + (type || "Object") + "]";
},
isOBJ: function (obj) {
var type = typeof obj;
return type === "object" && !!obj;
},
isEmpty: function (obj) {
if (obj === null) return true;
if (T.isOBJByType(obj, "Number")) {
return false;
}
return !obj;
},
extend : function (src , source){
for(var key in source){
src[key] = source[key];
}
return src;
},
processError: function (errObj) {
try {
if (errObj.stack) {
var url = errObj.stack.match("https?://[^\n]+");
url = url ? url[0] : "";
var rowCols = url.match(":(\\d+):(\\d+)");
if (!rowCols) {
rowCols = [0, 0, 0];
}
var stack = T.processStackMsg(errObj);
return {
msg: stack,
rowNum: rowCols[1],
colNum: rowCols[2],
target: url.replace(rowCols[0], ""),
_orgMsg : errObj.toString()
};
} else {
//ie 独有 error 对象信息,try-catch 捕获到错误信息传过来,造成没有msg
if (errObj.name && errObj.message && errObj.description) {
return {
msg: JSON.stringify(errObj)
};
}
return errObj;
}
} catch (err) {
return errObj;
}
},
processStackMsg: function (error) {
var stack = error.stack
.replace(/\n/gi, "")
.split(/\bat\b/)
.slice(0, 9)
.join("@")
.replace(/\?[^:]+/gi, "");
var msg = error.toString();
if (stack.indexOf(msg) < 0) {
stack = msg + "@" + stack;
}
return stack;
},
isRepeat : function(error) {
if (!T.isOBJ(error)) return true;
var msg = error.msg;
var times = _log_map[msg] = (parseInt(_log_map[msg], 10) || 0) + 1;
return times > _config.repeat;
}
};
var orgError = global.onerror;
// rewrite window.oerror
global.onerror = function(msg, url, line, col, error) {
var newMsg = msg;
if (error && error.stack) {
newMsg = T.processStackMsg(error);
}
if (T.isOBJByType(newMsg, "Event")) {
newMsg += newMsg.type ?
("--" + newMsg.type + "--" + (newMsg.target ?
(newMsg.target.tagName + "::" + newMsg.target.src) : "")) : "";
}
report.push({
msg: newMsg,
target: url,
rowNum: line,
colNum: col,
_orgMsg : msg
});
_process_log();
orgError && orgError.apply(global, arguments);
};
var _report_log_tostring = function(error, index) {
var param = [];
var params = [];
var stringify = [];
if (T.isOBJ(error)) {
error.level = error.level || _config.level;
for (var key in error) {
var value = error[key];
if (!T.isEmpty(value)) {
if (T.isOBJ(value)) {
try {
value = JSON.stringify(value);
} catch (err) {
value = "[BJ_REPORT detect value stringify error] " + err.toString();
}
}
stringify.push(key + ":" + value);
param.push(key + "=" + encodeURIComponent(value));
params.push(key + "[" + index + "]=" + encodeURIComponent(value));
}
}
}
// msg[0]=msg&target[0]=target -- combo report
// msg:msg,target:target -- ignore
// msg=msg&target=target -- report with out combo
return [params.join("&"), stringify.join(","), param.join("&")];
};
var _offline_buffer = [];
var _save2Offline = function(key , msgObj ) {
msgObj = T.extend({id : _config.id , uin : _config.uin , time : new Date - 0} , msgObj);
if(Offline_DB.db){
Offline_DB.addLog(msgObj);
return ;
}
if(!Offline_DB.db && !_offline_buffer.length){
Offline_DB.ready(function (err , DB){
if(DB){
if(_offline_buffer.length){
DB.addLogs(_offline_buffer);
_offline_buffer = [];
}
}
});
}
_offline_buffer.push(msgObj);
};
var _autoReportOffline = function (){
var script = document.createElement("script");
script.src = _config.offline_auto_url || _config.url.replace(/badjs$/ , "offlineAuto") + "?id="+_config.id + "&uin="+_config.uin;
window._badjsOfflineAuto = function (isReport){
if(isReport){
BJ_REPORT.reportOfflineLog();
}
};
document.head.appendChild(script);
};
var submit_log_list = [];
var comboTimeout = 0;
var _submit_log = function() {
clearTimeout(comboTimeout);
if(!submit_log_list.length){
return ;
}
var url =_config._reportUrl + submit_log_list.join("&") + "&count=" + submit_log_list.length + "&_t=" + (+new Date);
if (_config.submit) {
_config.submit(url);
} else {
var _img = new Image();
_img.src = url;
}
comboTimeout = 0;
submit_log_list = [];
};
var _process_log = function(isReportNow) {
if (!_config._reportUrl) return;
var randomIgnore = Math.random() >= _config.random;
while (_log_list.length) {
var isIgnore = false;
var report_log = _log_list.shift();
//有效保证字符不要过长
report_log.msg = (report_log.msg + "" || "").substr(0,500);
// 重复上报
if (T.isRepeat(report_log)) continue;
var log_str = _report_log_tostring(report_log, submit_log_list.length);
if (T.isOBJByType(_config.ignore, "Array")) {
for (var i = 0, l = _config.ignore.length; i < l; i++) {
var rule = _config.ignore[i];
if ((T.isOBJByType(rule, "RegExp") && rule.test(log_str[1])) ||
(T.isOBJByType(rule, "Function") && rule(report_log, log_str[1]))) {
isIgnore = true;
break;
}
}
}
if (!isIgnore) {
_config.offlineLog && _save2Offline( "badjs_" + _config.id + _config.uin, report_log );
if(!randomIgnore && report_log.level != 20){
submit_log_list.push(log_str[0]);
_config.onReport && (_config.onReport(_config.id, report_log));
}
}
}
if (isReportNow) {
_submit_log(); // 立即上报
} else if (!comboTimeout) {
comboTimeout = setTimeout(_submit_log, _config.delay); // 延迟上报
}
};
var report = global.BJ_REPORT = {
push: function(msg) { // 将错误推到缓存池
var data = T.isOBJ(msg) ? T.processError(msg) : {
msg: msg
};
// ext 有默认值, 且上报不包含 ext, 使用默认 ext
if (_config.ext && !data.ext) {
data.ext = _config.ext;
}
// 在错误发生时获取页面链接
// https://github.com/BetterJS/badjs-report/issues/19
if (!data.from) {
data.from = location.href;
}
if(data._orgMsg){
var _orgMsg = data._orgMsg;
delete data._orgMsg;
data.level = 2;
var newData = T.extend({} , data);
newData.level = 4;
newData.msg = _orgMsg ;
_log_list.push(data);
_log_list.push(newData);
}else {
_log_list.push(data);
}
_process_log();
return report;
},
report: function(msg , isReportNow) { // error report
msg && report.push(msg);
isReportNow && _process_log(true);
return report;
},
info: function(msg) { // info report
if (!msg) {
return report;
}
if (T.isOBJ(msg)) {
msg.level = 2;
} else {
msg = {
msg: msg,
level: 2
};
}
report.push(msg);
return report;
},
debug: function(msg) { // debug report
if (!msg) {
return report;
}
if (T.isOBJ(msg)) {
msg.level = 1;
} else {
msg = {
msg: msg,
level: 1
};
}
report.push(msg);
return report;
},
reportOfflineLog : function (){
if (!window.indexedDB){
BJ_REPORT.info("unsupport offlineLog");
return ;
}
Offline_DB.ready(function (err , DB){
if(!DB){
return;
}
var startDate = new Date - 0 - _config.offlineLogExp* 24 * 3600 * 1000;
var endDate = new Date - 0;
DB.getLogs( {
start : startDate,
end : endDate,
id : _config.id ,
uin : _config.uin
} , function (err , result){
var iframe = document.createElement("iframe");
iframe.name = "badjs_offline_"+(new Date -0 );
iframe.frameborder = 0;
iframe.height = 0;
iframe.width = 0;
iframe.src = "javascript:false;";
iframe.onload = function (){
var form = document.createElement("form");
form.style.display = "none";
form.target = iframe.name ;
form.method = "POST";
form.action = _config.offline_url || _config.url.replace(/badjs$/ , "offlineLog");
form.enctype.method = 'multipart/form-data';
var input = document.createElement("input");
input.style.display = "none";
input.type = "hidden";
input.name = "offline_log";
input.value = JSON.stringify({logs : result , userAgent : navigator.userAgent , startDate : startDate , endDate : endDate , id :_config.id , uin:_config.uin});
iframe.contentDocument.body.appendChild(form);
form.appendChild(input);
form.submit();
setTimeout(function (){
document.body.removeChild(iframe);
},10000);
iframe.onload = null;
};
document.body.appendChild(iframe);
});
});
},
offlineLog : function (msg){
if (!msg) {
return report;
}
if (T.isOBJ(msg)) {
msg.level = 20;
} else {
msg = {
msg: msg,
level: 20
};
}
report.push(msg);
return report;
},
init: function(config) { // 初始化
if (T.isOBJ(config)) {
for (var key in config) {
_config[key] = config[key];
}
}
// 没有设置id将不上报
var id = parseInt(_config.id, 10);
if (id) {
// set default report url and uin
if (/qq\.com$/gi.test(location.hostname)) {
if (!_config.url) {
_config.url = "//badjs2.qq.com/badjs";
}
if (!_config.uin) {
_config.uin = parseInt((document.cookie.match(/\buin=\D+(\d+)/) || [])[1], 10);
}
}
_config._reportUrl = (_config.url || "/badjs") +
"?id=" + id +
"&uin=" + _config.uin +
// "&from=" + encodeURIComponent(location.href) +
"&";
}
// if had error in cache , report now
if (_log_list.length) {
_process_log();
}
// init offline
if(!Offline_DB._initing){
Offline_DB._initing = true;
Offline_DB.ready(function (err , DB){
if(DB){
setTimeout(function (){
DB.clearDB(_config.offlineLogExp );
setTimeout(function (){
_config.offlineLogAuto && _autoReportOffline();
},5000);
},1000);
}
});
}
return report;
},
__onerror__: global.onerror
};
typeof console !== "undefined" && console.error && setTimeout(function() {
var err = ((location.hash || "").match(/([#&])BJ_ERROR=([^&$]+)/) || [])[2];
err && console.error("BJ_ERROR", decodeURIComponent(err).replace(/(:\d+:\d+)\s*/g, "$1\n"));
}, 0);
return report;
}(window));
if (true) {
module.exports = BJ_REPORT;
}
;(function(global) {
if (!global.BJ_REPORT) {
console.error("please load bg-report first");
return;
}
var _onthrow = function(errObj) {
global.BJ_REPORT.push(errObj);
};
var tryJs = {};
global.BJ_REPORT.tryJs = function(throwCb) {
throwCb && (_onthrow = throwCb);
return tryJs;
};
// merge
var _merge = function(org, obj) {
for (var key in obj) {
org[key] = obj[key];
}
};
// function or not
var _isFunction = function(foo) {
return typeof foo === "function";
};
var timeoutkey;
var cat = function(foo, args) {
return function() {
try {
return foo.apply(this, args || arguments);
} catch (error) {
_onthrow(error);
//some browser throw error (chrome) , can not find error where it throw, so print it on console;
if (error.stack && console && console.error) {
console.error("[BJ-REPORT]", error.stack);
}
// hang up browser and throw , but it should trigger onerror , so rewrite onerror then recover it
if (!timeoutkey) {
var orgOnerror = global.onerror;
global.onerror = function() {};
timeoutkey = setTimeout(function() {
global.onerror = orgOnerror;
timeoutkey = null;
}, 50);
}
throw error;
}
};
};
var catArgs = function(foo) {
return function() {
var arg, args = [];
for (var i = 0, l = arguments.length; i < l; i++) {
arg = arguments[i];
_isFunction(arg) && (arg = cat(arg));
args.push(arg);
}
return foo.apply(this, args);
};
};
var catTimeout = function(foo) {
return function(cb, timeout) {
// for setTimeout(string, delay)
if (typeof cb === "string") {
try {