akus_schabanack #1

Merged
xziino merged 3 commits from akus_schabanack into main 2026-05-21 16:23:38 +02:00
6 changed files with 45 additions and 12 deletions
Showing only changes of commit 1753b1d2ee - Show all commits

View File

@ -15,7 +15,7 @@ $startTime = (float)($_POST['start_time'] ?? 0);
$endTime = (float)($_POST['end_time'] ?? 0);
$language = strtolower(trim($_POST['language'] ?? 'en'));
$language = in_array($language, ['en', 'de', 'fr', 'jp'], true) ? $language : 'en';
$translate = $language === 'en' ? 'false' : 'true';
$translate = 'true';
if (!$reportCode || !$fightId || !$endTime) { http_response_code(400); echo json_encode(['error' => 'Missing params']); exit; }

View File

@ -26,7 +26,7 @@ $startTime = (float)($_POST['start_time'] ?? 0);
$endTime = (float)($_POST['end_time'] ?? 0);
$language = strtolower(trim($_POST['language'] ?? 'en'));
$language = in_array($language, ['en', 'de', 'fr', 'jp'], true) ? $language : 'en';
$translate = $language === 'en' ? 'false' : 'true';
$translate = 'true';
if (!$reportCode || !$fightId || !$endTime) {
http_response_code(400);

View File

@ -17,6 +17,9 @@ $playerName = trim($_POST['player_name'] ?? '');
$eventType = trim($_POST['event_type'] ?? '');
$abilityId = (int)($_POST['ability_id'] ?? 0);
$limit = max(1, min(500, (int)($_POST['limit'] ?? 20)));
$language = strtolower(trim($_POST['language'] ?? 'en'));
$language = in_array($language, ['en', 'de', 'fr', 'jp'], true) ? $language : 'en';
$translate = 'true';
$startOffset = (float)($_POST['start_offset'] ?? 0) * 1000; // s → ms
$endOffset = isset($_POST['end_offset']) && $_POST['end_offset'] !== ''
? (float)$_POST['end_offset'] * 1000
@ -33,14 +36,24 @@ $queryEnd = min($queryEnd, $endTime);
$token = $_SESSION['access_token'];
function localized_graphql_uri(string $language): string {
$host = [
'de' => 'de.fflogs.com',
'fr' => 'fr.fflogs.com',
'jp' => 'ja.fflogs.com',
][$language] ?? 'www.fflogs.com';
return preg_replace('#https://[^/]+#', 'https://' . $host, GRAPHQL_URI);
}
function dbg_gql(string $query): array {
global $token;
$ch = curl_init(GRAPHQL_URI);
global $token, $language;
$acceptLanguage = $language === 'jp' ? 'ja' : $language;
$ch = curl_init(localized_graphql_uri($language));
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['query' => $query]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer ' . $token],
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer ' . $token, 'Accept-Language: ' . $acceptLanguage],
CURLOPT_SSL_VERIFYPEER => !DEV_MODE,
]);
$body = curl_exec($ch);
@ -85,6 +98,7 @@ $result = dbg_gql(<<<GQL
fightIDs: [$fightId],
dataType: $dataType,
$includeResources
translate: $translate,
startTime: $queryStart,
endTime: $queryEnd
) {

View File

@ -12,6 +12,8 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
}
$reportCode = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['report_code'] ?? '');
$language = strtolower(trim($_POST['language'] ?? 'en'));
$language = in_array($language, ['en', 'de', 'fr', 'jp'], true) ? $language : 'en';
if (strlen($reportCode) < 1) {
http_response_code(400);
@ -64,7 +66,17 @@ $payload = json_encode([
'variables' => ['reportCode' => $reportCode],
]);
$ch = curl_init(GRAPHQL_URI);
function localized_graphql_uri(string $language): string {
$host = [
'de' => 'de.fflogs.com',
'fr' => 'fr.fflogs.com',
'jp' => 'ja.fflogs.com',
][$language] ?? 'www.fflogs.com';
return preg_replace('#https://[^/]+#', 'https://' . $host, GRAPHQL_URI);
}
$acceptLanguage = $language === 'jp' ? 'ja' : $language;
$ch = curl_init(localized_graphql_uri($language));
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
@ -72,6 +84,7 @@ curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . $_SESSION['access_token'],
'Accept-Language: ' . $acceptLanguage,
],
CURLOPT_SSL_VERIFYPEER => !DEV_MODE,
]);

View File

@ -265,10 +265,7 @@
let allSameReportFights = [];
function populateRefFightSelect() {
const currentName = (window.App.fights ?? []).find(f => f.id === window.App.fightId)?.name;
const visible = allSameReportFights.filter(f =>
f.id !== window.App.fightId && (!currentName || f.name === currentName)
);
const visible = allSameReportFights.filter(f => f.id !== window.App.fightId);
refFightSelect.innerHTML = '<option value="">Kein Vergleich</option>';
visible.forEach(f => {
const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?');
@ -322,8 +319,7 @@
extFights = fights;
extReportCode = code;
const currentName = (window.App.fights ?? []).find(f => f.id === window.App.fightId)?.name;
const visibleExt = currentName ? fights.filter(f => f.name === currentName) : fights;
const visibleExt = fights;
refExtFightSelect.innerHTML = '<option value="">— Fight auswählen —</option>';
visibleExt.forEach(f => {
const hp = f.kill ? 'Kill' : (f.fightPercentage != null ? f.fightPercentage.toFixed(2) + '%' : '?');

View File

@ -72,6 +72,9 @@ document.addEventListener('DOMContentLoaded', () => {
window.App.language = normalizeLanguage(languageSelect.value);
localStorage.setItem('ff14-mitigator-language', window.App.language);
setUrlState({ language: window.App.language });
if (window.App.reportCode) {
loadReport(window.App.reportCode, window.App.fightId);
}
});
const codeInput = form.elements['report_code'];
@ -98,6 +101,10 @@ document.addEventListener('DOMContentLoaded', () => {
outputCard.style.display = 'block';
}
function openAnalysisTab() {
document.querySelector('.tabs .tab[data-tab="analysis"]')?.click();
}
function selectFight(id, updateUrl = true) {
const fight = allFights.find(f => f.id === id);
if (!fight) return false;
@ -298,6 +305,9 @@ document.addEventListener('DOMContentLoaded', () => {
if (initialUrlState.reportCode) {
form.elements['report_code'].value = initialUrlState.reportCode;
loadReport(initialUrlState.reportCode, initialUrlState.fightId).then(() => {
if (initialUrlState.fightId) {
openAnalysisTab();
}
if (initialUrlState.compareFightId) {
window.analysisTab?.selectSharedCompare?.(initialUrlState.compareFightId, initialUrlState.compareReportCode);
}