some nice additions

This commit is contained in:
sava 2020-03-28 00:22:28 +01:00
parent 023c9c02f3
commit 1d9e4fa598
5 changed files with 26 additions and 19 deletions

View File

@ -1,10 +1,4 @@
#content {
margin: 2vh;
margin-left: 13vw;
margin-right: 42.0vw;
}
.top { .top {
margin-top: 9vh; margin-top: 9vh;
} }

View File

@ -1,4 +1,5 @@
#kommentar { #kommentar {
font-size: 1.1rem; font-size: 1.1rem;
word-wrap: break-word;
} }

View File

@ -9,7 +9,7 @@ var list = function() {
html = '<br/>' html = '<br/>'
query.forEach(function(doc) { query.forEach(function(doc) {
book = doc.data() book = doc.data()
html += book.toHtml() html += book.toHtml(firebase.auth().currentUser)
}) })
$('#kommentarer').html(html) $('#kommentarer').html(html)
}).catch(function(error) { }).catch(function(error) {
@ -34,11 +34,14 @@ var add = function() {
}) })
} }
var remove = function(id) {
db.collection("gjestebok").doc(id)
.delete().then(function() {
list()
}).catch(function(error) {
alert("Error removing document: ", error)
})
}
list() list()
/*
$(document).ready(function() {
list(firebase.auth().currentUser)
})
*/

View File

@ -1,14 +1,16 @@
class Comment { class Comment {
constructor(name, message) { constructor(name, message, id=0) {
this.name = name, this.name = name,
this.message = message this.message = message,
this.cfid = id
} }
toString() { toString() {
return this.name+': '+this.message return this.name+': '+this.message
} }
toHtml() { toHtml(user) {
return '<p id="kommentar">'+this.name+': '+this.message+'</p>' return '<p id="kommentar">'+this.name+': '+this.message
+(user?' &nbsp; <a class="btn btn-primary" href="javascript: remove(\''+this.cfid+'\')">Slett</a>':'')+'</p>'
} }
} }
@ -23,7 +25,8 @@ commentConverter = {
const data = snapshot.data(options) const data = snapshot.data(options)
return new Comment( return new Comment(
data.navn, data.navn,
data.melding data.melding,
snapshot.id
) )
} }
} }

View File

@ -4,7 +4,13 @@ body {
color: rgb(218, 215, 210); color: rgb(218, 215, 210);
} }
li.right > ul { /* TODO: FIX! */ #content {
margin: 2vh;
margin-left: 13vw;
margin-right: 42.0vw;
}
li.right > ul {
align-content: right; align-content: right;
} }