-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
99 lines (77 loc) · 2 KB
/
Copy pathlogger.js
File metadata and controls
99 lines (77 loc) · 2 KB
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
window.Logger = ( function( $ ){
"use strict";
var Handler = function( unique, googleConfig ){
var inst = new Cls();
inst.construct( unique, googleConfig );
return inst;
}
var Cls = function(){
$.extend( this, {
construct : function( unique, googleConfig ){
this.store = {
unique : unique,
thread : Math.ceil( new Date().getTime() / 1000 ) + "-" + Math.ceil(Math.random() * 100),
log : [],
offset : new Date().getTimezoneOffset()
};
this.googleConfig = googleConfig;
this.config();
},
config : function(){
var self = this;
this.responseUrl = "https://docs.google.com/forms/d/" + this.googleConfig.id + "/formResponse?";
this.buildQueryString = function( values ){
var str = "";
var y = 0;
var fields = self.googleConfig.fields;
for(var x in fields){
if( y > 0 ){
str += "&";
}
str += fields[x] + "=" + encodeURIComponent( values[x] );
y++;
}
return str;
}
},
log : function( msg, level ){
this.store.log.push({
message : msg,
level : (level || "info").toUpperCase(),
userAgent : window.navigator ? window.navigator.userAgent : "",
threadId : this.store.thread,
dump : ""
});
this.put();
if( window.console && window.console.log && level == "info" ){
console.log( level.toUpperCase(), ":", msg );
}
},
get : function(){
return this.store;
},
getLogs : function(){
return this.store.log;
},
error : function( msg ){
this.log( msg, "error" );
},
warn : function( msg ){
this.log( msg, "warn" );
},
info : function( msg ){
this.log( msg, "info" );
},
put : function(){
var obj = this.store.log[this.store.log.length - 1];
var putUrl = this.responseUrl + this.buildQueryString( obj );
var img = $("<img />").attr( "src", putUrl );
$("body").append( img );
setTimeout( function(){
img.remove();
}, 100 );
}
});
}
return Handler;
})( jQuery );