(function() { "use strict"; // Consts // ///////////////////////////////////////////////////////////////////////// var EVENT_BRIDGE_OPEN_MESSAGE = "eventBridgeOpen", UPDATE_UI = "update_ui", LISTEN_TOGGLE = "listen_toggle", BAN = "ban", MUTE = "mute", GOTO = "goto", TOGGLE_EXPANDING_AUDIO = "toggleExpandingAudio", REFRESH = "refresh", TOGGLE_ALL_AVATARS = "toggleAllAvatars", SET_ACTIVE_MESSAGE = "setActive", SELECT_AVATAR = "selectAvatar", EVENTBRIDGE_SETUP_DELAY = 200; // Components // ///////////////////////////////////////////////////////////////////////// // Vue.component('options', { // props: { // users: { type: Array} // }, // template:` // // // // // // // //
// ` // }) Vue.component('options', { props: { ui: { isExpandingAudioEnabled: { type: Boolean }, isAllAvatarsInTopTenEnabled: { type: Boolean } } }, methods: { toggleExpandingAudio(){ EventBridge.emitWebEvent(JSON.stringify({ type: TOGGLE_EXPANDING_AUDIO })); }, toggleAllAvatars(){ EventBridge.emitWebEvent(JSON.stringify({ type: TOGGLE_ALL_AVATARS })); } }, template:`
Toggle Expanding Audio
Find 10 Loudest in Domain *will not mute all avatars
` }) Vue.component('people-table', { props: { users: { type: Array} }, methods: { refresh(){ EventBridge.emitWebEvent(JSON.stringify({ type: REFRESH })); } }, template:`
User Name Avg Audio Level
` }) Vue.component('user', { props: { user: { type: Object } }, methods: { selectAvatar(){ EventBridge.emitWebEvent(JSON.stringify({ type: SELECT_AVATAR, value: this.user })); } }, template:` {{ user.userName ? user.userName : user.displayName }} {{ user.avgAudioLevel }} {{ user.avgAudioLoudness }} ` }) Vue.component('user-methods', { props: { user: { type: Object} }, methods: { listenToggle(){ EventBridge.emitWebEvent(JSON.stringify({ type: LISTEN_TOGGLE, value: this.user })); }, ban(){ EventBridge.emitWebEvent(JSON.stringify({ type: BAN, value: this.user })); }, mute(){ EventBridge.emitWebEvent(JSON.stringify({ type: MUTE, value: this.user })); }, goto(){ EventBridge.emitWebEvent(JSON.stringify({ type: GOTO, value: this.user })); } }, template:` ` }) // App // ///////////////////////////////////////////////////////////////////////// var app = new Vue({ el: '#app', data: { settings: { ui: { currentDance: false, danceList: false } } } }); // Procedural // ///////////////////////////////////////////////////////////////////////// function onScriptEventReceived(message) { var data; try { data = JSON.parse(message); switch (data.type) { case UPDATE_UI: app.settings = data.value; break; default: } } catch (e) { console.log(e) return; } } function onLoad() { // Initial button active state is communicated via URL parameter. // isActive = location.search.replace("?active=", "") === "true"; setTimeout(function () { // Open the EventBridge to communicate with the main script. // Allow time for EventBridge to become ready. EventBridge.scriptEventReceived.connect(onScriptEventReceived); EventBridge.emitWebEvent(JSON.stringify({ type: EVENT_BRIDGE_OPEN_MESSAGE })); EventBridge.emitWebEvent(JSON.stringify({ type: SET_ACTIVE_MESSAGE, value: true })); }, EVENTBRIDGE_SETUP_DELAY); } // App // ///////////////////////////////////////////////////////////////////////// onLoad(); }());