-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
104 lines (86 loc) · 2.62 KB
/
app.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
/*global Blob*/
/*global URL*/
(function() {
return {
events: {
'app.created':'showTicketInfo',
'click .saveSettings': 'showTicketInfo',
'getTicketInfo.always': 'results',
'getTicketInfo.fail': 'this.showError'
},
requests: {
getTicketInfo: function(ticket_id){
return {
url: '/api/v2/tickets/' + ticket_id + '/audits.json',
type: 'GET',
dataType: 'json',
success: function(data) {return data;}
};
}
},
results: function(data){
var ip = data.audits[data.audits.length-1].metadata.system.ip_address;
var local = data.audits[data.audits.length-1].metadata.system.location;
var country = local.substring(local.lastIndexOf(',') + 2);
console.log("IP Address: " + ip);
console.log("Location: " + local);
console.log("Country: " + country);
},
showTicketInfo: function(){
var ticket_id = this.ticket().id();
console.log("Ticket ID: " + ticket_id);
this.ajax('getTicketInfo', ticket_id);
},
showError: function(){
this.switchTo('error');
console.log('showError is working');
},
makeTicketInfoRequest: function(){
this.ajax('getTicketInfo', ticket_id);
},
showScore: function() {
var sketchyEmails = [{
"ip":"103.13.232.232","value":"CNC"
},{
"ip":"103.225.168.222","value":"CNC"
},{
"ip":"103.228.200.37","value":"CNC"
}];
var ticket = this.ticket();
var ticket_id = ticket.id();
userEmail = ticket.requester().email();
console.log(ticket.requester());
console.log(userEmail);
if (this.$('#spamCheckbox').is(':checked')){
if (userEmail in sketchyEmails){
this.switchTo('spam');
}
}
if (this.$('#torCheckbox').is(':checked')){
if (userEmail in sketchyEmails){
this.switchTo('tor');
}
}
if (this.$('#regionCheckbox').is(':checked')) {
if (userEmail in sketchyEmails){
this.switchTo('region');
}
}
},
printSuspendedUsers: function(){
this.userIds = _.uniq(this.userIds);
this.userIds.forEach(function(x){
this.ajax('printSuspendedUsers', x);
}, this);
},
concatPrint: function(data, ticket_id){
var subdomain = this.currentAccount().subdomain();
data = data.replace('/images/zendesk-lotus-flower.png', imagePath);
this.tickets.push(data);
if(this.userIds.length === this.users.length){
this.createURL();
}
},
};
}());
//This is the