commit
292b123f5a
After Width: | Height: | Size: 409 B |
After Width: | Height: | Size: 510 B |
After Width: | Height: | Size: 348 B |
@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<div v-if="content.msgtype==='m.text'" v-html="parseMessage(content.body)"/>
|
||||
<div v-else-if="content.msgtype==='m.notice'" class="notice" v-html="parseMessage(content.body)"/>
|
||||
<div v-else-if="content.msgtype==='m.image'" class="image">
|
||||
<img :src="getSource(content.url)" :alt="content.body" :class="`${compact?'compact':''}`"/><br>
|
||||
{{content.body}}
|
||||
</div>
|
||||
<div v-else-if="content.msgtype==='m.file'" :class="`file ${compact?'compact':''}`">
|
||||
<a :href="getSource(content.url)" target="_blank">
|
||||
<div class="fileContent">
|
||||
<icon
|
||||
title="file"
|
||||
ic="./sym/ic_attach_file_white.svg"
|
||||
class="download"
|
||||
/>
|
||||
<div class="filename">
|
||||
{{content.filename || getSource(content.url)}}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<div class="text">
|
||||
{{content.body}}
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="content.msgtype==='m.audio'" :class="`audio ${compact?'compact':''}`">
|
||||
<audio controls :class="`${compact?'compact':''}`">
|
||||
<source :src="getSource(content.url)" :type="content.mimetype">
|
||||
your browser doesn't support audio
|
||||
</audio><br>
|
||||
{{content.body}}
|
||||
</div>
|
||||
<div v-else-if="content.msgtype==='m.video'" :class="`video ${compact?'compact':''}`">
|
||||
<video controls :class="`${compact?'compact':''}`">
|
||||
<source :src="getSource(content.url)" :type="content.mimetype">
|
||||
your browser doesn't support video
|
||||
</video><br>
|
||||
{{content.body}}
|
||||
</div>
|
||||
<div v-else class="italic">unsupported message type {{content.msgtype}}</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getMediaUrl} from '@/lib/getMxc';
|
||||
import {parseMessage} from '@/lib/eventUtils';
|
||||
import Icon from '@/components/icon';
|
||||
|
||||
export default {
|
||||
name: 'eventContent',
|
||||
components: {Icon},
|
||||
props: {
|
||||
content: Object,
|
||||
compact: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSource(url){
|
||||
return url.includes('mxc')?getMediaUrl(url):url;
|
||||
},
|
||||
parseMessage
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.file{
|
||||
max-width: 30rem;
|
||||
.fileContent{
|
||||
position: relative;
|
||||
background-color: #1d1d1d;
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.5rem;
|
||||
min-height: 3rem;
|
||||
.filename{
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
margin-left: 4rem;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.download{
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
.compact{
|
||||
max-width: 20rem;
|
||||
}
|
||||
}
|
||||
.image{
|
||||
width: 100%;
|
||||
img{
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
max-height: 35rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.compact{
|
||||
max-width: 8rem;
|
||||
max-height: 8rem;
|
||||
}
|
||||
}
|
||||
.video{
|
||||
width: 100%;
|
||||
video{
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
max-height: 35rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.compact{
|
||||
max-width: 8rem;
|
||||
max-height: 8rem;
|
||||
}
|
||||
}
|
||||
.audio{
|
||||
audio{
|
||||
max-width: 100%;
|
||||
}
|
||||
.compact{
|
||||
max-width: 16rem;
|
||||
max-height: 8rem;
|
||||
}
|
||||
}
|
||||
.italic{
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<div class="fileUpload">
|
||||
<icon
|
||||
title="upload media"
|
||||
class="leftBtn attachFile"
|
||||
ic="./sym/ic_attach_file_white.svg"
|
||||
@click.native="$refs.fileInput.click()"
|
||||
/>
|
||||
<input
|
||||
type="file" id="fileInput" ref="fileInput"
|
||||
@change="setFile({file: $refs.fileInput.files[0]})"
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import icon from '@/components/icon';
|
||||
|
||||
export default {
|
||||
name: 'soundRecorder',
|
||||
components: {
|
||||
icon
|
||||
},
|
||||
props:{
|
||||
onChange: Function
|
||||
},
|
||||
methods: {
|
||||
setFile({file}){
|
||||
this.readFile(file).then(blob => {
|
||||
blob.name = file.name;
|
||||
this.onChange({blob})
|
||||
});
|
||||
},
|
||||
readFile(file){
|
||||
return new Promise(resolve => {
|
||||
let reader = new FileReader();
|
||||
reader.onerror = console.error;
|
||||
reader.onload = async event => {
|
||||
resolve(await (await fetch(event.target.result)).blob());
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.fileUpload{
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
.leftBtn{
|
||||
background-color: unset;
|
||||
height: 2.5rem;
|
||||
width: 2.5rem;
|
||||
box-shadow: none;
|
||||
}
|
||||
#fileInput{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,34 @@
|
||||
<template>
|
||||
<div class="questionBox">
|
||||
<p class="text">{{question}}</p>
|
||||
<textbtn text="yes" @click.native="callback(true)"/>
|
||||
<textbtn text="no" @click.native="callback(false)"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import textbtn from '@/components/textbtn';
|
||||
export default {
|
||||
name: 'popupQuestion',
|
||||
components: {textbtn},
|
||||
props:{
|
||||
question: String,
|
||||
callback: Function
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.questionBox{
|
||||
position: absolute;
|
||||
width: auto;
|
||||
background-color: #1d1d1d;
|
||||
box-shadow: 6px 6px 10px #111;
|
||||
border-radius: 1.5rem;
|
||||
.text{
|
||||
position: relative;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="recorder">
|
||||
<icon
|
||||
v-if="!isRecording"
|
||||
title="record voice"
|
||||
class="recordBtn start"
|
||||
ic="./sym/ic_mic_white.svg"
|
||||
@click.native="startRecording()"
|
||||
ref="startRecord"
|
||||
/>
|
||||
<div v-else class="voiceMeterContainer">
|
||||
<div class="voiceMeter" ref="voiceMeter"></div>
|
||||
<icon
|
||||
title="record voice"
|
||||
class="recordBtn stop"
|
||||
ic="./sym/ic_mic_white.svg"
|
||||
@click.native="stopRecording()"
|
||||
ref="stopRecord"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import icon from '@/components/icon';
|
||||
import Recorder from 'recorder-js';
|
||||
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
|
||||
export default {
|
||||
name: 'soundRecorder',
|
||||
components: {
|
||||
icon
|
||||
},
|
||||
props: {
|
||||
onStart: {
|
||||
type: Function,
|
||||
default: ()=>{}
|
||||
},
|
||||
onStop: {
|
||||
type: Function,
|
||||
default: ()=>{}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
startRecording(){
|
||||
this.onStart();
|
||||
navigator.mediaDevices.getUserMedia({audio: true})
|
||||
.then(stream => {
|
||||
this.recorder.init(stream);
|
||||
this.recorder.start().then(()=>this.isRecording=true);
|
||||
})
|
||||
.catch(err => console.log('unable to get stream', err));
|
||||
},
|
||||
stopRecording(){
|
||||
this.recorder.stop()
|
||||
.then(({blob}) => {
|
||||
blob.name = `Recording-${new Date().toISOString()}.${blob.type.split('/')[1]}`;
|
||||
this.onStop({blob});
|
||||
this.isRecording=false;
|
||||
});
|
||||
},
|
||||
setVoiceMeter(value){
|
||||
if (!this.$refs.stopRecord) return;
|
||||
this.$refs.voiceMeter.style.height = `calc(3rem + ${value/4}px`;
|
||||
this.$refs.voiceMeter.style.width = `calc(3rem + ${value/4}px`;
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
recorder: new Recorder(audioContext, {
|
||||
onAnalysed: data => this.setVoiceMeter(data.lineTo)
|
||||
}),
|
||||
isRecording: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.recordBtn{
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
bottom: 0.25rem;
|
||||
background-color: #1d1d1d;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.recordBtn.stop{
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #c63e3e;
|
||||
box-shadow: none;
|
||||
}
|
||||
.voiceMeter{
|
||||
position: absolute;
|
||||
background-color: #fff;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%,-50%);
|
||||
border-radius: 50%;
|
||||
box-shadow: 3px 3px 10px #111;
|
||||
}
|
||||
.voiceMeterContainer{
|
||||
position: absolute;
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
bottom: 0.25rem;
|
||||
right: 1rem;
|
||||
}
|
||||
.recorder{
|
||||
height: 100%;
|
||||
width: 8rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
Loading…
Reference in new issue