89 lines
4.0 KiB
Plaintext
89 lines
4.0 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><%= title %></title>
|
|
<!--<link rel='stylesheet' href='/stylesheets/style.css' />-->
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
|
|
<meta name="theme-color" content="#7952b3">
|
|
<link href="/stylesheets/dashboard.css" rel="stylesheet">
|
|
<script>
|
|
function uuidv4() {
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
return v.toString(16);
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<%- include('header.ejs') %>
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<%- include('sidebar.ejs') %>
|
|
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
|
|
<%- include('breadcrumb.ejs', {breadcrumb: breadcrumb}) %>
|
|
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
|
<h2><%= title %></h2>
|
|
</div>
|
|
|
|
<form class="row g-3">
|
|
<div>
|
|
<label for="file-selector-id" class="form-label">Open Key</label>
|
|
<input class="form-control" type="file" id="file-selector-id" multiple>
|
|
</div>
|
|
<div>
|
|
<button onclick="openKey()" type="button" class="btn btn-primary">Open Key</button>
|
|
</div>
|
|
<div id="alert">
|
|
</div>
|
|
</form>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
myKey = {};
|
|
const fileSelector = document.getElementById('file-selector-id');
|
|
fileSelector.addEventListener('change', (event) => {
|
|
const fileList = event.target.files;
|
|
console.log(fileList);
|
|
readKeyFile(fileList[0]);
|
|
});
|
|
|
|
function readKeyFile(file) {
|
|
if(file.type && !file.type.startsWith('text/')) {
|
|
console.log('File is not a text file');
|
|
return;
|
|
}
|
|
const reader = new FileReader();
|
|
reader.addEventListener('load', (event) => {
|
|
key = event.target.result;
|
|
console.log(key);
|
|
myKey = JSON.parse(key);
|
|
});
|
|
reader.readAsText(file);
|
|
}
|
|
|
|
function openKey() {
|
|
if(typeof(Storage) !== 'undefined') {
|
|
localStorage.setItem('privateKey', myKey.privateKey);
|
|
localStorage.setItem('publicKey', myKey.publicKey);
|
|
localStorage.setItem('fingerprint', myKey.fingerprint);
|
|
if(localStorage.getItem('fingerprint') !== 'undefined') {
|
|
document.getElementById('alert').innerHTML = '<div class="alert alert-success" role="alert">Key opened successfully. Fingerprint: ' + localStorage.getItem('fingerprint') + '</div>';
|
|
} else {
|
|
document.getElementById('alert').innerHTML = '<div class="alert alert-danger" role="alert">Key not opened. Try again.</div>';
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
</script>
|
|
<script src="/javascripts/openpgp.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script><script src="/javascripts/dashboard.js"></script>
|
|
</body>
|
|
</html>
|