From 1d9e4fa59896c81e9232a420cd476159ab347394 Mon Sep 17 00:00:00 2001 From: sava Date: Sat, 28 Mar 2020 00:22:28 +0100 Subject: [PATCH] some nice additions --- it1/css/form.css | 6 ------ it1/css/gjestebok.css | 1 + it1/gjestebok/gjestebok.js | 17 ++++++++++------- it1/js/converters/kommentar.js | 13 ++++++++----- it1/main.css | 8 +++++++- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/it1/css/form.css b/it1/css/form.css index 815a6ea..81d7267 100644 --- a/it1/css/form.css +++ b/it1/css/form.css @@ -1,10 +1,4 @@ -#content { - margin: 2vh; - margin-left: 13vw; - margin-right: 42.0vw; -} - .top { margin-top: 9vh; } diff --git a/it1/css/gjestebok.css b/it1/css/gjestebok.css index 31a9f3d..366922b 100644 --- a/it1/css/gjestebok.css +++ b/it1/css/gjestebok.css @@ -1,4 +1,5 @@ #kommentar { font-size: 1.1rem; + word-wrap: break-word; } diff --git a/it1/gjestebok/gjestebok.js b/it1/gjestebok/gjestebok.js index 978d8ac..6cca7e5 100644 --- a/it1/gjestebok/gjestebok.js +++ b/it1/gjestebok/gjestebok.js @@ -9,7 +9,7 @@ var list = function() { html = '
' query.forEach(function(doc) { book = doc.data() - html += book.toHtml() + html += book.toHtml(firebase.auth().currentUser) }) $('#kommentarer').html(html) }).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() -/* -$(document).ready(function() { - list(firebase.auth().currentUser) -}) -*/ - diff --git a/it1/js/converters/kommentar.js b/it1/js/converters/kommentar.js index 721473b..ddb8036 100644 --- a/it1/js/converters/kommentar.js +++ b/it1/js/converters/kommentar.js @@ -1,14 +1,16 @@ class Comment { - constructor(name, message) { + constructor(name, message, id=0) { this.name = name, - this.message = message + this.message = message, + this.cfid = id } toString() { return this.name+': '+this.message } - toHtml() { - return '

'+this.name+': '+this.message+'

' + toHtml(user) { + return '

'+this.name+': '+this.message + +(user?'   Slett':'')+'

' } } @@ -23,7 +25,8 @@ commentConverter = { const data = snapshot.data(options) return new Comment( data.navn, - data.melding + data.melding, + snapshot.id ) } } diff --git a/it1/main.css b/it1/main.css index 7383d54..39da3f6 100644 --- a/it1/main.css +++ b/it1/main.css @@ -4,7 +4,13 @@ body { 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; }