This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
ajax.js
269 lines (268 loc) · 11.8 KB
/
ajax.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
function getCharacterInfo(cID,uID,vCode){
var array={action:"character", cID:cID, uID:uID,vCode:vCode};
$.ajax({
type: 'POST',
url: 'ajax.php?t='+new Date().getTime(),
data: array,
async: true,
success: function(data,textStatus,XHR){
returnValue = $.parseJSON(data);
if (returnValue.result == "success") {
$("#isk"+returnValue.id).html(returnValue.balance);
$("#sp"+returnValue.id).html(returnValue.sptotal);
$("#bday"+returnValue.id).html(returnValue.dob);
if($("#tIsk").html()!="")
totalIsk=parseFloat($("#tIsk").html().replace(/,/g,""));
else
totalIsk=0;
addIsk=parseFloat(returnValue.balance.replace(/,/g,""));
totalIsk+=addIsk;
$("#tIsk").html(numberWithCommas(totalIsk));
if($("#tSp").html()!="")
totalSp=parseFloat($("#tSp").html().replace(/,/g,""));
else
totalSp=0;
addSp=parseFloat(returnValue.sptotal.replace(/,/g,""));
totalSp+=addSp;
$("#tSp").html(numberWithCommas(totalSp));
}else{
$("#infobar").after("<div data-alert class='alert-box alert'>Failed to load character data<a href='#' class='close'>×</a></div>");
}
}
});
}
function numberWithCommas(x) {
x= x.toFixed(2);
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
$(document).ready(function(){
$("#redFlag").click(function(e){
var hiddenSection = $('#redFlagBox').parents('section.hidden');
hiddenSection.fadeIn()
// unhide section.hidden
.css({ 'display':'block' })
// set to full screen
.css({ width: $(window).width() + 'px', height: $(window).height() + 'px' })
.css({ top:($(window).height() - hiddenSection.height())/2 + 'px',
left:($(window).width() - hiddenSection.width())/2 + 'px' })
// greyed out background
.css({ 'background-color': 'rgba(0,0,0,0.5)' })
.appendTo('body');
// console.log($(window).width() + ' - ' + $(window).height());
$('span.close').click(function(){ $(hiddenSection).fadeOut(); });
});
$("#ssoSelectButton").click(function(e){
var hiddenSection = $('#ssoSelect').parents('section.hidden');
hiddenSection.fadeIn()
// unhide section.hidden
.css({ 'display':'block' })
// set to full screen
.css({ width: $(window).width() + 'px', height: $(window).height() + 'px' })
.css({ top:($(window).height() - hiddenSection.height())/2 + 'px',
left:($(window).width() - hiddenSection.width())/2 + 'px' })
// greyed out background
.css({ 'background-color': 'rgba(0,0,0,0.5)' })
.appendTo('body')
.children()
.css("height","360px");
// console.log($(window).width() + ' - ' + $(window).height());
$('span.close').click(function(){ $(hiddenSection).fadeOut(); });
});
$("#evePraisal").click(function(e){
var hiddenSection = $('#evePraisalBox').parents('section.hidden');
hiddenSection.fadeIn()
// unhide section.hidden
.css({ 'display':'block' })
// set to full screen
.css({ width: $(window).width() + 'px', height: $(window).height() + 'px' })
.css({ top:($(window).height() - hiddenSection.height())/2 + 'px',
left:($(window).width() - hiddenSection.width())/2 + 'px' })
// greyed out background
.css({ 'background-color': 'rgba(0,0,0,0.5)' })
.appendTo('body');
// console.log($(window).width() + ' - ' + $(window).height());
$('span.close').click(function(){ $(hiddenSection).fadeOut(); });
});
$("#corpHistory").click(function(e){
var hiddenSection = $('#corpHistoryBox').parents('section.hidden');
hiddenSection.fadeIn()
// unhide section.hidden
.css({ 'display':'block' })
// set to full screen
.css({ width: $(window).width() + 'px', height: $(window).height() + 'px' })
.css({ top:($(window).height() - hiddenSection.height())/2 + 'px',
left:($(window).width() - hiddenSection.width())/2 + 'px' })
// greyed out background
.css({ 'background-color': 'rgba(0,0,0,0.5)' })
.appendTo('body');
// console.log($(window).width() + ' - ' + $(window).height());
$('span.close').click(function(){ $(hiddenSection).fadeOut(); });
});
$("#saveRedFlag").click(function(e){
var hiddenSection = $('#redFlagBox').parents('section.hidden');
var array={action:"redFlag", characters:$("#redFlagBox").val()};
$.ajax({
type: 'POST',
url: 'ajax.php?t=' + new Date().getTime(),
data: array,
async: true,
success: function (data, textStatus, XHR) {
$(hiddenSection).fadeOut();
location.reload();
}
});
});
$("#generateSSOLink").click(function(e){
var hiddenSection = $('#ssoSelect').parents('section.hidden');
var scopes = [];
$('input[name="scopes"]:checked').each(function(){scopes.push($(this).val())});
var array={action:"ssoLogin", scopes:scopes};
$.ajax({
type: 'POST',
url: 'ajax.php?t=' + new Date().getTime(),
data: array,
async: true,
success: function (data, textStatus, XHR) {
data=$.parseJSON(data);
window.location.href=data.url;
}
});
});
$("#changeMessageFormatting").click(function(e){
var val=true;
if($(this).val()=="Formatted"){
val=false;
}
var array={action:"changeMailFormat",val:val};
$.ajax({
type: 'POST',
url: 'ajax.php?t=' + new Date().getTime(),
data: array,
context: $(this),
async: true,
success: function (data, textStatus, XHR) {
if($(this).val()=="Formatted"){
$(this).val("Unformatted");
}else{
$(this).val("Formatted");
}
}
});
});
$(".messageRow").click(function(e) {
if(!$(this).next("tr").hasClass("messageBody")){
$(".messageBody").remove();
$.ajax({
type: 'GET',
url: $(this).attr("href")+"&ajax=true",
context: $(this),
async: true,
success: function (data, textStatus, XHR) {
data= $.parseJSON(data);
if(data.result=="success"){
$(this).after("<tr class=\"messageBody\"><td colspan='4'>"+data.body+"</td></tr>" );
}
},
error:function (data, textStatus, XHR) {
location.href=$(this).attr("href");
},
fail: function (data, textStatus, XHR) {
location.href=$(this).attr("href");
}
});
}else {
$(".messageBody").remove();
}
});
$(".editKey").click(function(e) {
e.preventDefault();
$("#keyInfoBox").show();
$("#saveKey").attr("keyID",$(this).attr("keyID"));
$(".fadeDiv").show();
$("#keyName").val($(this).parent().parent().find(".keyName").text());
$("#notes").val($(this).parent().parent().find(".keyNotes").text());
$("#keyName").attr("changed",false);
$("#notes").attr("changed",false);
});
$(".fadeDiv").click(function(e){
$(".floating_login_div").hide();
$(".fadeDiv").hide();
})
$(".exitbutton").click(function(e){
$(this).parent().hide();
$(".fadeDiv").hide();
})
$("#saveKey").click(function(e){
$(".floating_login_div").hide();
$(".fadeDiv").hide();
var id=$(this).attr("keyID");
var array={
action:"editKey",
keyID:id,
name:false,
notes:false
};
if($("#keyName").attr("changed")=="true"){
array['name']=$("#keyName").val();
}
if($("#notes").attr("changed")=="true"){
array['notes']=$("#notes").val();
}
$.ajax({
type: 'POST',
url: 'ajax.php?t=' + new Date().getTime(),
data: array,
context:$(this),
async: true,
success: function (data, textStatus, XHR) {
data= $.parseJSON(data);
var id=$(this).attr("keyID");
if(data.result=="success") {
if($("#keyName").attr("changed")=="true") {
$("tr[keyID='"+id+"']").find(".keyName").text($("#keyName").val());
$("#keyName").val("")
$("#keyName").attr("changed",false);
}
if($("#notes").attr("changed")=="true") {
$("tr[keyID='"+id+"']").find(".keyNotes").text($("#notes").val());
$("#notes").val("")
$("#notes").attr("changed",false);
}
}else{
alert("Error Editting Key");
}
}
});
});
$("#keyName").change(function(){
$("#keyName").attr("changed",true);
});
$("#notes").change(function(){
$("#notes").attr("changed",true);
});
$("body").on("click",".removeKey",function(e){
e.preventDefault();
var id=$(this).attr("keyID");
var array={action:"removeKey", keyID:id};
$.ajax({
type: 'POST',
url: 'ajax.php?t=' + new Date().getTime(),
data: array,
context: $(this),
async: true,
success: function (data, textStatus, XHR) {
data= $.parseJSON(data);
if(data.result=="success") {
if($(this).parent().parent().is("tr")) {
$(this).parent().parent().remove();
}else{
alert("Key Removed");
$(this).remove();
}
}else{
alert("Error Removing Key");
}
}
});
});
});