discord-client/parcel/vue/auth/dialog.vue

187 lines
5.0 KiB
Vue
Raw Normal View History

2018-03-21 17:44:27 +00:00
<template>
<div class='dialog'>
2018-03-22 17:15:57 +00:00
<div class='header' @click='minipop = !minipop' :data-open='minipop?1:0'>
<div class='title'>{{ gs.content.cbuf.label }}</div>
2018-03-21 17:44:27 +00:00
</div>
<div class='body'>
2018-03-28 15:25:30 +00:00
<div v-show='minipop' class='minipopup'>
2018-03-28 19:52:45 +00:00
<span class='special sa' @click='gs.popup.show(`channel.invite`); minipop=false'>Invite people</span>
<span data-icon='create' @click='gs.popup.show(`channel.create`); minipop=false'>Create channel</span>
<span class ='invalid-h' data-icon='remove' @click='gs.popup.show(`channel.remove`); minipop=false'>Remove channel</span>
<span data-icon='category' @click='gs.popup.show(`room.create`); minipop=false'>Create room</span>
<span data-icon='edit' @click='gs.popup.show(`username.change`); minipop=false'>Change nickname</span>
<span data-icon='password' @click='gs.popup.show(`password.change`); minipop=false'>Change password</span>
2018-03-28 19:52:45 +00:00
<span class='sb invalid-h' data-icon='leave' @click='gs.popup.show(`channel.leave`); minipop=false'>Leave channel</span>
<span class='sb invalid' data-icon='logout' @click='gs.auth.token=null; gs.refresh()'>Logout</span>
2018-03-28 15:25:30 +00:00
</div>
<div v-for='(rooms, type) in gs.room' v-if='type[0] != `_`'>
<div class='toggle'
:data-toggle='rooms.visible?1:0'
2018-03-22 17:15:57 +00:00
@click='rooms.visible=!rooms.visible'>
{{ type }} <span>rooms</span>
</div>
2018-03-22 19:03:29 +00:00
<div class='add' @click='gs.popup.show(`room.create`)' data-title='Create channel'></div>
<ul>
<li v-for='r in rooms.list'
:class='rooms.current==r.id?`active`:``'
:data-type='r.type'
@click='gs.room.nav(r.type, r.id)'>{{ r.name }}
<span class='rem' @click="gs.popup.show('room.remove'); gs.popup.get('room.remove').data=r"></span>
</li>
</ul>
</div>
</div>
<div class='footer' :data-connected='gs.audio_conn'>
<canvas ref='audio_canvas' width='1000' height='1000'></canvas>
<div class='text-container'>
<!-- Audio connection status -->
<div class='status'>{{ gs.audio_conn === 0
? `Connecting...`
: ( gs.audio_conn === 1
? `Listening`
: `Voice Connected` ) }}</div>
<!-- Current room/user -->
<div class='room'>{{ gs.room.get('text') ? gs.room.get('text').name : '?' }} / {{ gs.auth.user.username }}</div>
</div>
<!-- Logout from current audio room -->
<div class='audio-close' @click='gs.room.nav(`voice`, null)'></div>
</div>
2018-03-21 17:44:27 +00:00
</div>
</template><script>
export default {
name: 'dialog-',
data(){ return {
gs: gs.get,
minipop: false
}; },
2018-03-28 15:25:30 +00:00
methods: {
/* (1) Draw WAVE on canvas from a buffer
*
* @buffer<Uint8Array> Data buffer
*
---------------------------------------------------------*/
draw_wave(buffer=[]){
/* (0) Exit if empty buffer */
if( !(buffer instanceof Uint8Array) || buffer.length <= 0 )
return;
/* (1) Get <canvas> context + shortcuts */
let can = this.$refs.audio_canvas;
let ctx = can.getContext('2d', { antialias: false, depth: false });
/* (2) Adjust dimensions */
can.width = buffer.length;
can.height = 256;
let precision = 1; // bigger -> less precise
/* (3) Erase previous drawing */
ctx.clearRect(0, 0, can.width, can.height);
/* (4) Begin tracing */
ctx.beginPath();
ctx.moveTo(0, can.height-buffer[0]);
/* (5) Trace through each value */
for( let i = precision ; i < buffer.length ; i+=precision )
ctx.lineTo(i, can.height-buffer[i]);
/* (6) End tracing */
ctx.lineWidth = 7;
ctx.strokeStyle = '#44484f';
ctx.stroke();
},
/* (1) Draw FREQ on canvas from a buffer
*
* @buffer<Uint8Array> Data buffer
*
---------------------------------------------------------*/
draw_freq(buffer=[]){
/* (0) Exit if empty buffer */
if( !(buffer instanceof Uint8Array) || buffer.length <= 0 )
return;
/* (1) Get <canvas> context + shortcuts */
let can = this.$refs.audio_canvas;
let ctx = can.getContext('2d', { antialias: false, depth: false });
/* (2) Adjust dimensions */
can.width = buffer.length;
can.height = 256;
let precision = 1; // bigger -> less precise
/* (3) Erase previous drawing */
ctx.clearRect(0, 0, can.width, can.height);
ctx.lineWidth = 1;
/* (4) Trace through each value */
for( let i = precision ; i < buffer.length ; i+=precision ){
ctx.beginPath();
ctx.strokeStyle = '#44484f';
ctx.moveTo(i, can.height);
ctx.lineTo(i, can.height-buffer[i]);
ctx.stroke();
}
}
},
mounted(){
/* (1) By default DRAW FREQUENCY */
this.gs.audioManager.freq_drawer = this.draw_freq;
/* (2) Create toggle method */
this.gs.toggleDrawStyle = function(){
// currently WAVE
if( this.gs.audioManager.wave_drawer instanceof Function ){
this.gs.audioManager.wave_drawer = null;
this.gs.audioManager.freq_drawer = this.draw_freq;
}else{
this.gs.audioManager.wave_drawer = this.draw_wave;
this.gs.audioManager.freq_drawer = null;
}
}.bind(this);
2018-03-28 15:25:30 +00:00
}
2018-03-21 17:44:27 +00:00
}
</script>