basj i buksa, biblioteket e oppegående

This commit is contained in:
sava 2020-03-26 02:30:12 +01:00
parent 5ca75569ad
commit f7970ddb6b
7 changed files with 112 additions and 24 deletions

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>My humble github.io page</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">
</head>

View File

@ -0,0 +1,27 @@
#content {
margin: 2vh;
}
#content > * {
margin-top: 9vh;
margin-left: 13vw;
margin-right: 42.0vw;
}
#status {
margin-top: 1vh;
}
#form {
width: 25%;
}
#form > div > * {
margin-bottom: 1vh;
}
#form > div > label {
margin-bottom: 0.33vh;
}

View File

@ -1,4 +1,15 @@
db = init().firestore()
bibliotekcoll = db.collection("bibliotek")
var add = function() {
db.collection("bibliotek").add({
tittel: $('#title')[0].value,
forfatter: $('#author')[0].value,
forlag: $('#publisher')[0].value,
terningkast: $('#rating')[0].value,
utgitt: $('#published')[0].value
}).then(function() {
$('#status').html('<p style="color: green;">La til bok '+$('#title').value+'!</p>')
}).catch(function() {
$('#status').html('<p style="color: red;">Problem med å legge til bok '+$('#title').value+'!</p>')
})
}

View File

@ -2,16 +2,41 @@
<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">
<script defer src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/7.11.0/firebase-firestore.js"></script>
<link rel="stylesheet" href="/it1/bibliotek/bibliotek.css">
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.11.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="/it1/init-firebase.js"></script>
</head>
<bod>
<iframe id="navbar" width="100%" height="60px" src="/it1/navbar/navbar.html" style="border: 0px"></iframe>
<body>
<script type="text/javascript" id="navbar" src="/it1/navbar/navbar.js"></script>
<div id="content">
<form></form>
<form action="#" method="POST" id="form">
<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>
</div>
<script type="text/javascript" src="/it1/bibliotek/bibliotek.js"></script>
</bod>
</body>
</html>

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>Simple firebase logon</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="/it1/main.css">
<!--
@ -11,16 +12,17 @@
-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>
<bod>
<iframe id="navbar" width="100%" height="60px" src="/it1/navbar/navbar.html" style="border: 0px"></iframe>
<body>
<!-- <iframe id="navbar" width="100%" height="60px" src="/it1/navbar/navbar.html" style="border: 0px"></iframe> -->
<script type="text/javascript" id="navbar" src="/it1/navbar/navbar.js"></script>
<div id="content">
<h3 style="margin: 3vh">Denne siden inneholder ting jeg har laget med firebase i IT1!</h3>
<br />
<ul id="oppgaver">
<li>
<h5><a href="/it1/bibliotek/index.html">Bibliotek</a></h5>
<h5><a href="/it1/bibliotek/">Bibliotek</a></h5>
</li>
</ul>
</div>
</bod>
</body>
</html>

View File

@ -1,6 +1,5 @@
var init = function() {
var firebaseConfig = {
firebase.initializeApp({
apiKey: "AIzaSyAhU3F-De17VAsUgpRjj25f48QiXycorD4",
authDomain: "it1-heimdal-vgs.firebaseapp.com",
databaseURL: "https://it1-heimdal-vgs.firebaseio.com",
@ -8,6 +7,6 @@ var init = function() {
storageBucket: "it1-heimdal-vgs.appspot.com",
messagingSenderId: "206703382262",
appId: "1:206703382262:web:be48f32d11a15fa28f26d7"
}
return firebase.initializeApp(firebaseConfig)
}
})
var db = firebase.firestore()

23
it1/navbar/navbar.js Normal file
View File

@ -0,0 +1,23 @@
$('#navbar').parent().html(`
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<a class="navbar-brand" target="_top" href="/it1/index.html">IT1 firebase stuff</a> <!-- href="/it1/index.html" -->
<!-- <ul class="navbar-nav">
<li class="nav-item right">
<a class="nav-link" target="_top" href="/it1/about.html">About</a>
</li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item right">
<a class="nav-link">Simple login here later</a>
</li>
<li class="nav-item right" style="visibility: hidden">
<a class="nav-link" target="_top" href="/logout">Logout</a>
</li>
<li class="nav-item right" id="register-btn">
<a class="nav-link" target="_top" href="/register">Register</a>
</li>
<li class="nav-item right" id="login-btn">
<a class="nav-link" target="_top" href="/login">Login</a>
</li>
</ul> -->
</nav>`)