From: Christian Heller Date: Wed, 25 Nov 2020 00:49:00 +0000 (+0100) Subject: Minor refactor. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/%7Broute%7D?a=commitdiff_plain;h=5d8136bee6c1cf821f07255ecf23acdc0766ac84;p=plomrogue2 Minor refactor. --- diff --git a/rogue_chat.html b/rogue_chat.html index 9f24d82..2a41e0a 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -1346,49 +1346,12 @@ document.getElementById("help").onclick = function() { tui.show_help = true; tui.full_refresh(); }; -document.getElementById("switch_to_play").onclick = function() { - tui.switch_mode('play'); - tui.full_refresh(); -}; -document.getElementById("switch_to_study").onclick = function() { - tui.switch_mode('study'); - tui.full_refresh(); -}; -document.getElementById("switch_to_chat").onclick = function() { - tui.switch_mode('chat'); - tui.full_refresh(); -}; -document.getElementById("switch_to_password").onclick = function() { - tui.switch_mode('password'); - tui.full_refresh(); -}; -document.getElementById("switch_to_edit").onclick = function() { - tui.switch_mode('edit'); - tui.full_refresh(); -}; -document.getElementById("switch_to_write").onclick = function() { - tui.switch_mode('write'); - tui.full_refresh(); -}; -document.getElementById("switch_to_annotate").onclick = function() { - tui.switch_mode('annotate'); - tui.full_refresh(); -}; -document.getElementById("switch_to_portal").onclick = function() { - tui.switch_mode('portal'); - tui.full_refresh(); -}; -document.getElementById("switch_to_admin_enter").onclick = function() { - tui.switch_mode('admin'); - tui.full_refresh(); -}; -document.getElementById("switch_to_control_pw_type").onclick = function() { - tui.switch_mode('control_pw_type'); - tui.full_refresh(); -}; -document.getElementById("switch_to_control_tile_type").onclick = function() { - tui.switch_mode('control_tile_type'); - tui.full_refresh(); +for (const switchEl of document.querySelectorAll('[id^="switch_to_"]')) { + const mode = switchEl.id.slice("switch_to_".length); + switchEl.onclick = function() { + tui.switch_mode(mode); + tui.full_refresh(); + } }; document.getElementById("toggle_map_mode").onclick = function() { if (tui.map_mode == 'terrain') {