mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Node.js transition is completed!
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { LatLng } from "leaflet";
|
||||
import { setActiveCoalition } from "..";
|
||||
|
||||
export class SelectionScroll {
|
||||
#container: HTMLElement | null;
|
||||
@@ -8,26 +9,36 @@ export class SelectionScroll {
|
||||
this.#container = document.getElementById(id);
|
||||
this.#display = '';
|
||||
if (this.#container != null) {
|
||||
this.#container.querySelector("#coalition-switch")?.addEventListener('change', (e) => this.#onSwitch(e))
|
||||
this.#display = this.#container.style.display;
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
|
||||
show(x: number, y: number, options: any, callback: CallableFunction) {
|
||||
show(x: number, y: number, options: any, callback: CallableFunction, showCoalition: boolean) {
|
||||
/* Hide to remove buttons, if present */
|
||||
this.hide();
|
||||
|
||||
if (this.#container != null && options.length > 1) {
|
||||
if (this.#container != null && options.length >= 1) {
|
||||
this.#container.style.display = this.#display;
|
||||
this.#container.style.left = x - 110 + "px";
|
||||
this.#container.style.top = y - 110 + "px";
|
||||
|
||||
for (let optionID in options) {
|
||||
var node = document.createElement("div");
|
||||
node.classList.add("olympus-selection-scroll-element");
|
||||
node.appendChild(document.createTextNode(options[optionID]));
|
||||
this.#container.appendChild(node);
|
||||
node.addEventListener('click', () => callback(options[optionID]))
|
||||
var scroll = this.#container.querySelector(".olympus-selection-scroll");
|
||||
if (scroll != null)
|
||||
{
|
||||
for (let optionID in options) {
|
||||
var node = document.createElement("div");
|
||||
node.classList.add("olympus-selection-scroll-element");
|
||||
if (typeof options[optionID] === 'string' || options[optionID] instanceof String){
|
||||
node.appendChild(document.createTextNode(options[optionID]));
|
||||
node.addEventListener('click', () => callback(options[optionID]));
|
||||
}
|
||||
else {
|
||||
node.appendChild(document.createTextNode(options[optionID].tooltip));
|
||||
node.addEventListener('click', () => options[optionID].callback());
|
||||
}
|
||||
scroll.appendChild(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,8 +47,25 @@ export class SelectionScroll {
|
||||
if (this.#container != null) {
|
||||
this.#container.style.display = "none";
|
||||
var buttons = this.#container.querySelectorAll(".olympus-selection-scroll-element");
|
||||
for (let child of buttons) {
|
||||
this.#container.removeChild(child);
|
||||
var scroll = this.#container.querySelector(".olympus-selection-scroll");
|
||||
if (scroll != null)
|
||||
{
|
||||
for (let child of buttons) {
|
||||
scroll.removeChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#onSwitch(e: any) {
|
||||
if (this.#container != null) {
|
||||
if (e.currentTarget.checked) {
|
||||
document.documentElement.style.setProperty('--active-coalition-color', getComputedStyle(this.#container).getPropertyValue("--red-coalition-color"));
|
||||
setActiveCoalition("red");
|
||||
}
|
||||
else {
|
||||
document.documentElement.style.setProperty('--active-coalition-color', getComputedStyle(this.#container).getPropertyValue("--blue-coalition-color"));
|
||||
setActiveCoalition("blue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user