blob: b8537db5d59d8fd9cf7e5e911ca6c5709d40d600 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import { Name } from './name.js'
export default {
components: { Name },
props: ['tags'],
data: ()=> ({
message: ''
}),
methods: {
messageObjects(objects) {
return objects.filter(o=>
'message' in o &&
'timestamp' in o &&
typeof o.message == 'string' &&
typeof o.timestamp == 'number')
.sortBy('timestamp')
},
sendMessage() {
if (!this.message) return
this.$graffitiUpdate({
message: this.message,
timestamp: Date.now(),
_tags: this.tags
})
this.message = ''
}
},
template: `
<graffiti-objects :tags="tags" v-slot="{objects}">
<ul v-for="object in messageObjects(objects)">
<li>
<name :of="object._by"></name>
{{ object.message }}
<template v-if="object._by==$graffitiID.value">
<button @click="object.message+='!!';object._update()">
‼️
</button>
<button @click="object._remove()">
❌
</button>
</template>
</li>
</ul>
</graffiti-objects>
<form @submit.prevent="sendMessage">
<input v-model="message">
<input type="submit" value="Submit"/>
</form>`
}
|