{# Play and pause are one button: panel.css shows whichever glyph the .playing class calls for. A room's drives its Spotify stream, the AVR's the film on the Zidoo plugged into it. #} {% macro play_button(role, label) -%} {%- endmacro %} {% macro host_toggle() -%} {%- endmacro %} {# The Spotify resume buttons with the host toggle in the middle of them. #} {% macro control_row(target, accounts) -%} {% set split = (accounts | length + 1) // 2 %}
{% for account in accounts %} {% if loop.index0 == split %}{{ host_toggle() }}{% endif %} {% endfor %} {# Fewer accounts than the midpoint means the loop never reached it. #} {% if accounts | length <= split %}{{ host_toggle() }}{% endif %}
{%- endmacro %} {% macro room_card(room, accounts=()) -%} {% set avr = room.kind == 'avr' %}

{{ room.label }}

{% if not avr %}
—
{% endif %} {% if avr %} {% else %} {{ control_row(room.key, accounts) }} {% endif %}
{%- endmacro %}
{% for room in rooms + [host] %} {{ room_card(room, spotify_accounts) }} {% endfor %}