-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
116 lines (106 loc) · 3.18 KB
/
client.js
File metadata and controls
116 lines (106 loc) · 3.18 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"use strict";
function getData() {
$.ajax({
type: 'GET',
url: document.URL + "test",
success: function(res){
//console.log(res);
for(let p of res.result){
let carball = null;
let playtime = 0;
try{
//console.log(p.user.response.players[0].personaname);
if(p.recent.response.games != null){
for(let g of p.recent.response.games){
if(g.name == "Rocket League"){
carball = g;
break;
}
}
}
playtime = carball.playtime_2weeks/60;
}
catch(err){}
let obj = {
Player: p.user.response.players[0].personaname,
Playtime: Math.ceil(playtime*100)/100
};
if(playtime < 6){
obj._rowVariant = 'danger';
}
else if(playtime >= 6 && playtime <= 10){
obj._rowVariant = 'warning';
}
else{
obj._rowVariant = 'success'
}
app.tData.push(obj);
}
//console.log(app.tData);
sortData();
//console.log(app.tData);
}
});
};
function sortData(){
function checkSorted(){
for(let i = 1; i < app.tData.length; i++){
if(app.tData[i].Playtime < app.tData[i-1].Playtime){
return false;
}
}
return true;
}
do{
for(let i = 1; i < app.tData.length; i++){
if(app.tData[i].Playtime < app.tData[i-1].Playtime){
let temp0 = JSON.parse(JSON.stringify(app.tData[i-1]));
let temp1 = JSON.parse(JSON.stringify(app.tData[i]));
app.tData[i] = temp0;
app.tData[i-1] = temp1;
}
}
}
while(!checkSorted());
}
function sendFile(){
let f = document.querySelector('#replay');
console.log(f.files);
/*$.ajax({
type: 'POST',
url: document.URL + "ball",
data: JSON.stringify({
file: f.files[0]
}),
success: function(res){
console.log(res);
}
});*/
let form = new FormData();
console.log(form);
form.append('myFile',f.files[0]);
//console.log(form.entries());
fetch('/ball',{method:'POST',body:form}).then(res=>
res.json()
).then((data)=>{
console.log(data);
});
}
function stealTest(){
fetch('/steal',{method:'GET'});
}
/// https://html-online.com/articles/get-url-parameters-javascript/
function getUrlVars() {
let vars = {};
let parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function getUrlParam(parameter, defaultvalue){
let urlparameter = defaultvalue;
if(window.location.href.indexOf(parameter) > -1){
urlparameter = getUrlVars()[parameter];
}
return urlparameter;
}