diff --git a/landingPage.html b/landingPage.html index e223da6..02d8f80 100644 --- a/landingPage.html +++ b/landingPage.html @@ -1,56 +1,90 @@ + TarkovLab - API Terminal - - - + + + - - + + - + +
-
- TarkovLab + TarkovLab API TERMINAL
@@ -967,10 +1446,42 @@ -
-
SYS: ONLINE
-
SECURE: YES
-
TIME: 00:00:00
+
+ + + + +
@@ -982,14 +1493,49 @@ -------------------------------------------------------- -->
- + + +
+
+ Explorer + Build Query +
+ +
+ + + +
+ +
+ +
+ + +
+
+
GraphQL Editor Input Query
- +
Presets: @@ -1024,7 +1570,8 @@
SIZE: N/A
-
// Enter query and execute to view API output.
+
// Enter query and execute to view API output.
@@ -1036,17 +1583,19 @@ -------------------------------------------------------- -->
- +
Tasks Active ledger
- +
- - + + ${fieldName} + ${childType} + + +
+ ${buildExplorerFieldsHTML(childType, path, depth + 1)} +
+ `; + } + + return ` +
+ +
`; + }).join(''); + } + + function buildExplorerTree() { + document.getElementById('explorer-tree').innerHTML = buildExplorerFieldsHTML('Quest', '', 0); + } + + function onExplorerCheck(e) { + const cb = e.target; + const node = cb.closest('.explorer-node'); + let parentNode = cb.closest('.explorer-children'); + while (parentNode) { + const parentDetails = parentNode.closest('.explorer-node'); + if (!parentDetails) break; + const parentCheckbox = parentDetails.querySelector(':scope > summary input[type="checkbox"]'); + if (cb.checked && parentCheckbox) parentCheckbox.checked = true; + parentNode = parentDetails.parentElement.closest('.explorer-children'); + } + } + + function onExplorerOperationChange() { + const op = document.getElementById('explorer-operation').value; + document.getElementById('explorer-id-input').classList.toggle('d-none', op !== 'quest'); + document.getElementById('explorer-trader-input').classList.toggle('d-none', op !== 'questsByTrader'); + } + + function clearExplorerSelection() { + document.querySelectorAll('#explorer-tree input[type="checkbox"]').forEach(cb => cb.checked = false); + } + + function buildSelectionSetFromPaths(paths) { + const tree = {}; + paths.forEach(p => { + const parts = p.split('.'); + let node = tree; + parts.forEach(part => { + node[part] = node[part] || {}; + node = node[part]; + }); + }); + + function stringify(node, indent) { + const pad = ' '.repeat(indent); + return Object.keys(node).map(key => { + const children = node[key]; + if (Object.keys(children).length === 0) { + return `${pad}${key}`; + } + return `${pad}${key} {\n${stringify(children, indent + 1)}\n${pad}}`; + }).join('\n'); + } + + return stringify(tree, 2); + } + + function generateExplorerQuery() { + const checked = Array.from(document.querySelectorAll('#explorer-tree input[type="checkbox"]:checked')) + .map(cb => cb.dataset.path); + + if (checked.length === 0) { + alert('Select at least one field in the explorer tree.'); + return; + } + + const selectionSet = buildSelectionSetFromPaths(checked); + const op = document.getElementById('explorer-operation').value; + let query; + + if (op === 'quests') { + query = `query ExplorerQuery {\n quests {\n${selectionSet}\n }\n}`; + } else if (op === 'quest') { + const id = document.getElementById('explorer-id-input').value || 1; + query = `query ExplorerQuery {\n quest(id: ${id}) {\n${selectionSet}\n }\n}`; + } else { + const trader = document.getElementById('explorer-trader-input').value || 0; + query = `query ExplorerQuery {\n questsByTrader(trader: ${trader}) {\n${selectionSet}\n }\n}`; + } + + queryEditor.setValue(query); + } - + + \ No newline at end of file