-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_utilities.js
154 lines (136 loc) · 4.46 KB
/
search_utilities.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
import Key from '../config/keys';
export const getPlayerByName = gamertag => {
const playerByNameInit = {
method: 'get'
}
// let request = new Request(`https://api.pubg.com/shards/xbox/players?filter[playerNames]=${ gamertag }`, playerByNameInit);
let request = new Request(`/pubg/gamertag/${ gamertag }`, playerByNameInit)
return fetch(request).then(function(response) {
return response.json()
})
}
// window.getPlayerByName = getPlayerByName;
export const getMatch = (matchId) => {
const gameInit = {
method: 'get',
}
// let request = new Request(`https://api.pubg.com/shards/xbox/matches/${ matchId }`, gameInit);
let request = new Request(`/pubg/matches/${ matchId }`, gameInit)
return fetch(request).then(function(response) {
return response.json()
})
}
// window.getMatch = getMatch;
//
export const getTelemetry = (url) => {
const telemetryInit = {
method: 'get',
}
let request = new Request(`/pubg/telemetry/?url=${ url }`, telemetryInit);
return fetch(request).then(function(response) {
return response.json()
})
}
// window.getTelemetry = getTelemetry;
export const getOAuth = () => {
const oauthInit = {
method: 'get',
// scope: 'user:read:email'
}
let request = new Request(`/oauth`, oauthInit);
return fetch(request).then(function(response) {
return response.json()
})
}
// window.getOAuth = getOAuth;
export const getTwitchUser = gamertag => {
const twitchUserInit = {
method: 'get'
}
let request = new Request(`/twitch/${ gamertag }`, twitchUserInit);
return fetch(request).then(r => {
return r.json().then(json => {
return json
})
})
}
// window.getTwitchUser = getTwitchUser;
export const getVideos = userId => {
const twitchVideosInit = {
method: 'get',
}
let request = new Request(`/twitchvideos/${ userId }`, twitchVideosInit);
return fetch(request).then(function(response) {
return response.json()
})
}
// window.getVideos = getVideos;
export const getPubgVideos = videoId => {
const twitchPubgInit = {
method: 'get',
}
let request = new Request(`/pubgvideos/${ videoId }`, twitchPubgInit);
return fetch(request).then(function(response) {
return response.json()
})
}
// window.getPubgVideos = getPubgVideos;
export const timeGreaterThan = (t1, t2) => {
// debugger
let t3 = new Date(t1);
let t4 = new Date(t2);
if(t3 >= t4) {
return true
} else {
return false
}
}
export const timeGreaterThan2 = (t1, t2, seconds) => {
// debugger
let t3 = new Date(t1);
let t4 = new Date(t2);
t4.setHours(t4.getHours(), t4.getMinutes(), t4.getSeconds() + seconds);
if (t3 <= t4) {
return true
} else {
return false
}
// let hours = t4.getHours();
// let minutes = t4.getMinutes();
// let secs = t4.getSeconds();
// if(seconds + sec < 60) {
// t4.setHours(hours, minutes, seconds + secs)
// } else if(seconds + sec === 60) {
// t4.setHours(hours, minutes + 1, 0)
// } else if(seconds + sec > 60) {
// let newSecs = (seconds + sec) % 60;
// let newMinutes = ((seconds + sec) - newSecs) / 60;
// let min;
// let hours;
// if(newMinutes > 60) {
// min = newMinutes % 60;
// hours = (newMinutes - min) / 60;
// }
// }
}
export const timestamp = (t1, t2, seconds) => {
// debugger
let t3 = new Date(t1);
let t4 = new Date(t2);
t4.setHours(t4.getHours(), t4.getMinutes(), t4.getSeconds() + seconds);
let secs = ((t4 - t3) / 1000);
// let nT = t4.setHours(t4.getHours(), t4.getMinutes(), t4.getSeconds() - secs);
// let eventTimestamp = nT - (new Date(t2));
let t = new Date(null);
t.setSeconds((seconds - secs) - 10);
let a = t.toISOString().substr(11, 8).split(":");
return a[0] + "h" + a[1] + "m" + a[2] + "s"
}
export const timestamp2 = (t1, t2, seconds) => {
let t3 = new Date(t1);
let t4 = new Date(t2);
t4.setHours(t4.getHours(), t4.getMinutes(), t4.getSeconds() + seconds);
let secs = ((t4 - t3) / 1000);
let nT = t4.setHours(t4.getHours(), t4.getMinutes(), t4.getSeconds() - secs);
return ((nT - (new Date(t2))) / 1000) - 10;
}