|
|
@ -1,5 +1,8 @@ |
|
|
|
const fflog = "https://www.fflogs.com:443/v1/report/fights/"; |
|
|
|
const fflogsBase = "https://www.fflogs.com:443/v1/report/"; |
|
|
|
const fflogsFightsAPI = fflogsBase + "fights/" |
|
|
|
const fflogsEventsAPI = fflogsBase + "events/" |
|
|
|
const api = "?api_key="; |
|
|
|
// ?end=1591130148287&sourceid=5
|
|
|
|
|
|
|
|
var indexViewModel; |
|
|
|
var classColors = { |
|
|
@ -20,6 +23,9 @@ var classColors = { |
|
|
|
"Dancer": "#ceb8ab", |
|
|
|
"Machinist": "#6c6433", |
|
|
|
"Barde": "#6d8432" |
|
|
|
}; |
|
|
|
|
|
|
|
var offensiveCooldowns = { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
@ -32,6 +38,8 @@ $(() => { |
|
|
|
self.logID = ko.observable(localStorage.getItem("fflogid")); |
|
|
|
self.fights = ko.observableArray(); |
|
|
|
self.friendlies = ko.observableArray(); |
|
|
|
self.enemies = ko.observableArray(); |
|
|
|
self.casts = ko.observableArray(); |
|
|
|
self.displayFightPicker = ko.observable(false); |
|
|
|
self.selectedFight = ko.observable(); |
|
|
|
|
|
|
@ -40,6 +48,7 @@ $(() => { |
|
|
|
|
|
|
|
self.fights(log["fights"]); |
|
|
|
self.friendlies(log["friendlies"]); |
|
|
|
self.enemies(log["enemies"]); |
|
|
|
self.displayFightPicker(true); |
|
|
|
}; |
|
|
|
|
|
|
@ -56,24 +65,74 @@ $(() => { |
|
|
|
localStorage.setItem("fflogid", self.logID()); |
|
|
|
}; |
|
|
|
|
|
|
|
self.fightChanged = function() { |
|
|
|
self.fightChanged = async function() { |
|
|
|
console.log("Fight has changed to ",self.selectedFight()); |
|
|
|
var casts = await fetchCasts(self.selectedFight()); |
|
|
|
|
|
|
|
self.casts(casts); |
|
|
|
console.log("self",self.casts()); |
|
|
|
}; |
|
|
|
|
|
|
|
self.textColor = function(job) { |
|
|
|
console.log(job.type) |
|
|
|
return classColors[job.type]; |
|
|
|
}; |
|
|
|
|
|
|
|
self.actorIDToName = function(id) { |
|
|
|
for(var actor of self.friendlies()) { |
|
|
|
if(id == actor.id) { |
|
|
|
return actor.name; |
|
|
|
} |
|
|
|
} |
|
|
|
for(var actor of self.enemies()) { |
|
|
|
if(id == actor.id) { |
|
|
|
return actor.name; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
}; |
|
|
|
}; |
|
|
|
indexViewModel = new IndexViewModel(); |
|
|
|
ko.applyBindings(indexViewModel); |
|
|
|
}); |
|
|
|
|
|
|
|
async function fetchCasts(fight) { |
|
|
|
let baseUrl = fflogsEventsAPI + "casts/" + indexViewModel.logID() + api + indexViewModel.apiKey() + "&translate=true" + "&end=" + fight.end_time; |
|
|
|
let start_time = fight.start_time; |
|
|
|
let result = []; |
|
|
|
|
|
|
|
let snip = {}; |
|
|
|
do { |
|
|
|
let url = baseUrl + "&start=" + start_time; |
|
|
|
console.log("Requesting "+url); |
|
|
|
snip = await fetchCastSnippet(url); |
|
|
|
for(var e of snip.events) { |
|
|
|
result.push(e); |
|
|
|
} |
|
|
|
//result = result.concat(snip.events);
|
|
|
|
start_time = snip.nextPageTimestamp; |
|
|
|
} while(snip.nextPageTimestamp) |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
async function fetchCastSnippet(url) { |
|
|
|
var res = await fetch(url); |
|
|
|
if (!res.ok) { |
|
|
|
console.log(res); |
|
|
|
throw Error(res.text); |
|
|
|
} |
|
|
|
var casts = await res.json(); |
|
|
|
|
|
|
|
console.log(casts); |
|
|
|
return casts; |
|
|
|
} |
|
|
|
|
|
|
|
// API request um JSON zu erhalten
|
|
|
|
async function fetchLog(fightId) { |
|
|
|
let url = fflog + fightId + api + indexViewModel.apiKey(); |
|
|
|
async function fetchLog(logId) { |
|
|
|
let url = fflogsFightsAPI + logId + api + indexViewModel.apiKey(); |
|
|
|
|
|
|
|
console.log("Fetching log "+fightId); |
|
|
|
console.log("Requesting "+logId); |
|
|
|
var res = await fetch(url); |
|
|
|
if (!res.ok) { |
|
|
|
console.log(res); |
|
|
|