From 5f6d51abbf731e4d5d9b9f5e8633c137325681aa Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 11 May 2021 23:42:23 +0200 Subject: Moving js side slightly towards more libarary-like model --- derelict.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/derelict.js b/derelict.js index 53358d6..155df23 100644 --- a/derelict.js +++ b/derelict.js @@ -205,8 +205,7 @@ function processKillmails(obj, killmails, icon) { toggleAll() } -function init() { - const container = document.getElementById("container") +export function init({id, container, toolbar}) { const renderer = new THREE.WebGLRenderer({antialias: true}) const renderer2d = new CSS2DRenderer() @@ -218,13 +217,12 @@ function init() { container.appendChild(renderer.domElement) container.appendChild(renderer2d.domElement) - const url = new URL(window.location.href) const loader = new THREE.TextureLoader() const skybox = loader.loadAsync("https://i.imgur.com/rDGOLFC.jpg") // TODO: Don't use imgur as CDN. let icon = loadWreckIcon() - fetch(url.pathname.replace("view", "battles")) + fetch(`/battles/${id}`) .then(response => response.json()) .then(killmails => { const url = km => `${ESI}/killmails/${km.id}/${km.hash}/?datasource=tranquility` @@ -237,5 +235,3 @@ function init() { icon.then(icon => processKillmails({skybox, renderer, renderer2d, container}, killmails, icon)) }) } - -init() -- cgit v1.1