156 lines
4.6 KiB
HTML
156 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<header>
|
|
<link href="bootstrap-5.0.2-dist/css/bootstrap.min.css" rel="stylesheet" ></link>
|
|
<script src="bootstrap-5.0.2-dist/js/bootstrap.bundle.min.js" ></script>
|
|
<meta charset="utf-8">
|
|
</header>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<form class="needs-validation" id = "sample">
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class = "form-label" for="name">
|
|
Name of Preparation Protocol
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="text" name="name" id = "name"
|
|
placeholder="e.g. my favourite protocol">
|
|
</input>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<label class="form-label" for="sample_size">
|
|
Sample size [uL]
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="number"
|
|
id = "Sample_Size" name="sample_size" value=40>
|
|
</input>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<label class = "form-label" for="main_dilution">
|
|
Main dilution
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="text" id = "Main_Dilution" name="main_dilution"
|
|
placeholder="e.g. 1:5">
|
|
</input>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<label class = "form-label" for="setteling_time">
|
|
Setteling time [s]
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="number" id="Setteling_Time"
|
|
name="setteling_time" value=15>
|
|
</input>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<label class="form-label" for="prep-notes">
|
|
Notes
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<textarea class="form-control" name="prep-notes" id="Prep_Notes"
|
|
placeholder="Notes about the preparation"
|
|
rows="1" cols="60">
|
|
</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class = "form-check-label" for="default">
|
|
This should be the default preparation setup
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-check-input" type="checkbox" id = "Default" name="default">
|
|
</input>
|
|
</div>
|
|
</div>
|
|
<button class="btn btn-primary float-end" type="submit">submit</button>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
|
|
var db;
|
|
let openRequest = indexedDB.open("my_db");
|
|
|
|
openRequest.onerror = function() {
|
|
console.error("Error", openRequest.error);
|
|
};
|
|
|
|
openRequest.onsuccess = function() {
|
|
db = openRequest.result;
|
|
// continue working with database using db object
|
|
};
|
|
|
|
const form = document.getElementById("sample");
|
|
form.addEventListener("submit", add);
|
|
|
|
|
|
function add(event){
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
let prep_protocol = {
|
|
"name" : document.getElementById("name").value,
|
|
"Sample_Size" : document.getElementById("Sample_Size").value,
|
|
"Main_Dilution" : document.getElementById("Main_Dilution").value,
|
|
"Setteling_Time" : document.getElementById("Setteling_Time").value,
|
|
"Prep_Notes" : document.getElementById("Prep_Notes").value
|
|
}
|
|
let transaction = db.transaction(["prep_protocol"], "readwrite");
|
|
let objectStore = transaction.objectStore("prep_protocol");
|
|
let add_request = objectStore.add(prep_protocol); // (3)
|
|
let id_of_setup = 0;
|
|
add_request.onsuccess = (event) => {
|
|
console.log("All done!");
|
|
id_of_setup = event.target.result;
|
|
if (document.getElementById("Default").checked){
|
|
let my_default = {"id" : 1, "prep_setup" : id_of_setup};
|
|
let next_transaction = db.transaction(["defaults"], "readwrite");
|
|
let next_objectStore = next_transaction.objectStore("defaults");
|
|
let add_next_request = next_objectStore.put(my_default);
|
|
transaction.oncomplete = () => {
|
|
console.log("All done!");
|
|
};
|
|
transaction.onerror = () => {
|
|
console.log("something went wrong");
|
|
// Don't forget to handle errors!
|
|
};
|
|
}
|
|
};
|
|
transaction.onerror = (event) => {
|
|
console.log("something went wrong");
|
|
// Don't forget to handle errors!
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</html>
|