aboutsummaryrefslogtreecommitdiff
path: root/webAO/dom
diff options
context:
space:
mode:
Diffstat (limited to 'webAO/dom')
-rw-r--r--webAO/dom/areaClick.ts5
-rw-r--r--webAO/dom/updatePlayerAreas.ts16
2 files changed, 20 insertions, 1 deletions
diff --git a/webAO/dom/areaClick.ts b/webAO/dom/areaClick.ts
index 1b0fe52..e217c2c 100644
--- a/webAO/dom/areaClick.ts
+++ b/webAO/dom/areaClick.ts
@@ -1,15 +1,18 @@
import { client } from '../client'
+import { updatePlayerAreas } from './updatePlayerAreas'
/**
* Triggered when an item on the area list is clicked.
* @param {HTMLElement} el
*/
export function area_click(el: HTMLElement) {
- const area = client.areas[el.id.substr(4)].name;
+ const area = client.areas[el.id.substring(4)].name;
client.sender.sendMusicChange(area);
const areaHr = document.createElement("div");
areaHr.className = "hrtext";
areaHr.textContent = `switched to ${el.textContent}`;
document.getElementById("client_log")!.appendChild(areaHr);
+ client.area = Number(el.id.substring(4));
+ updatePlayerAreas(client.area);
}
window.area_click = area_click; \ No newline at end of file
diff --git a/webAO/dom/updatePlayerAreas.ts b/webAO/dom/updatePlayerAreas.ts
new file mode 100644
index 0000000..d2ec076
--- /dev/null
+++ b/webAO/dom/updatePlayerAreas.ts
@@ -0,0 +1,16 @@
+import { client } from '../client'
+import { area_click } from './areaClick';
+/**
+ * Triggered when someone switches areas
+ * @param {Number} ownarea
+ */
+export function updatePlayerAreas(ownarea: number) {
+ for (let i=0; i < client.areas.length; i++) {
+ if (i===ownarea)
+ for (let classelement of Array.from(document.getElementsByClassName(`area${i}`) as HTMLCollectionOf<HTMLElement>))
+ classelement.style.display = "";
+ else
+ for (let classelement of Array.from(document.getElementsByClassName(`area${i}`) as HTMLCollectionOf<HTMLElement>))
+ classelement.style.display = "none";
+ }
+} \ No newline at end of file