Hugo go go go
Made a hugo setup from scratch to generate a static blog and portfolio webpage. The old stuff may still be found in static/old.
This commit is contained in:
51
static/old/it1/bibliotek/bibliotek.js
Normal file
51
static/old/it1/bibliotek/bibliotek.js
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
var db = firebase.firestore()
|
||||
|
||||
var list = function(user) {
|
||||
db.collection("bibliotek")
|
||||
.withConverter(bookConverter)
|
||||
.get()
|
||||
.then(function(query) {
|
||||
$('#books').html('<br/>')
|
||||
query.forEach(function(doc) {
|
||||
book = doc.data()
|
||||
book.toHtml($('#books'))
|
||||
})
|
||||
}).catch(function(error) {
|
||||
$('#books').html('<h3>Kunne ikke hente bøker!</h3><br/><p>'+error+'</p>')
|
||||
$('#books').css('color', 'red')
|
||||
})
|
||||
}
|
||||
|
||||
var add = function() {
|
||||
db.collection("bibliotek")
|
||||
.withConverter(bookConverter)
|
||||
.add(new Book(
|
||||
$('#title')[0].value,
|
||||
$('#author')[0].value,
|
||||
$('#publisher')[0].value,
|
||||
$('#rating')[0].value,
|
||||
$('#published')[0].value
|
||||
)).then(function() {
|
||||
$('#status').html('<p>La til bok '+$('#title')[0].value+'!</p>')
|
||||
$('#status').css('color', 'green')
|
||||
list()
|
||||
}).catch(function() {
|
||||
$('#status').html('<p>Problem med å legge til bok '+$('#title')[0].value+'!</p>')
|
||||
$('#status').css('color', 'red')
|
||||
})
|
||||
}
|
||||
|
||||
var remove = function(id) {
|
||||
db.collection("bibliotek").doc(id)
|
||||
.delete().then(function() {
|
||||
list()
|
||||
}).catch(function(error) {
|
||||
alert("Error removing document: ", error)
|
||||
})
|
||||
}
|
||||
|
||||
firebase.auth().onAuthStateChanged(function(user) {
|
||||
list(user)
|
||||
})
|
||||
|
48
static/old/it1/bibliotek/index.html
Normal file
48
static/old/it1/bibliotek/index.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Firebase basert bibliotek</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="../main.css">
|
||||
<link rel="stylesheet" href="../css/form.css">
|
||||
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-app.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-auth.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-firestore.js"></script>
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="../js/init-firebase.js"></script>
|
||||
<script type="text/javascript" src="../js/converters/bok.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" id="navbar" src="../js/navbar.js"></script>
|
||||
<div id="content">
|
||||
<form action="#" method="POST" id="form" class="top">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col"><input type="name" class="form-control" id="title" placeholder="Tittel"></div>
|
||||
<div class="col"><input type="name" class="form-control" id="author" placeholder="Forfatter"></div>
|
||||
</div>
|
||||
<input type="name" class="form-control" id="publisher" placeholder="Forlag">
|
||||
<select type="number" class="form-control form-control-sm" id="rating" placeholder="Terningkast">
|
||||
<option>1</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
<option>5</option>
|
||||
<option>6</option>
|
||||
</select>
|
||||
<label>Utgitt</label>
|
||||
<input type="date" class="form-control" id="published" placeholder="Utgitt">
|
||||
</div>
|
||||
<a type="submit" class="btn btn-primary" href="javascript: add()">Legg til</a>
|
||||
</form>
|
||||
<div id="status">
|
||||
<p> </p>
|
||||
</div>
|
||||
<a type="submit" class="btn btn-primary" href="javascript: list(firebase.auth().currentUser)">Hent bøker</a>
|
||||
<div id="books">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="bibliotek.js"></script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user