Reorganized FileStructure and added Cookie-Banner
This commit is contained in:
parent
182662e2e0
commit
8e131d3ee4
36
out/css/cookie.css
Normal file
36
out/css/cookie.css
Normal file
@ -0,0 +1,36 @@
|
||||
.cookie-banner{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
|
||||
box-sizing: border-box;
|
||||
width: 100vw;
|
||||
height: min-content;
|
||||
|
||||
background-color: white;
|
||||
border-top: 1px solid black;
|
||||
|
||||
padding: .75rem 2rem;
|
||||
z-index: 2500;
|
||||
}
|
||||
|
||||
.cookie-banner button {
|
||||
display: inline;
|
||||
height: 2.5rem;
|
||||
padding: .5rem 1rem;
|
||||
margin: 0;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.cookie-banner * {
|
||||
margin-right: 1rem !important;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.cookie-banner > :first-child {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.cookie-banner > :last-child {
|
||||
margin-right: 0 !important;
|
||||
}
|
589
out/css/pc.css
Normal file
589
out/css/pc.css
Normal file
@ -0,0 +1,589 @@
|
||||
/* COLORS */
|
||||
.pc .addressbus {
|
||||
background-color: var(--color-addressbus);
|
||||
color: var(--color-addressbus-text);
|
||||
}
|
||||
|
||||
.pc .databus {
|
||||
background-color: var(--color-databus);
|
||||
color: var(--color-databus-text);
|
||||
}
|
||||
|
||||
.pc .ram {
|
||||
background-color: var(--color-ram);
|
||||
color: var(--color-ram-text);
|
||||
}
|
||||
|
||||
.pc .cu {
|
||||
background-color: var(--color-cu);
|
||||
color: var(--color-cu-text);
|
||||
}
|
||||
|
||||
.pc .alu {
|
||||
background-color: var(--color-alu);
|
||||
color: var(--color-alu-text);
|
||||
}
|
||||
|
||||
.pc .section h1.header {
|
||||
background-color: var(--color-header);
|
||||
color: var(--color-header-text);
|
||||
}
|
||||
|
||||
|
||||
/* TABLE COLORS */
|
||||
.pc .ram .scroller table thead.head th {
|
||||
background-color: var(--color-table-ram-head);
|
||||
color: var(--color-table-ram-head-text);
|
||||
}
|
||||
|
||||
.pc .cu .scroller table thead.head th {
|
||||
background-color: var(--color-table-cu-head);
|
||||
color: var(--color-table-cu-head-text);
|
||||
}
|
||||
|
||||
.pc .scroller table tr td {
|
||||
background-color: var(--color-table-row);
|
||||
color: var(--color-table-text);
|
||||
border-bottom: 1px solid var(--color-table-border);
|
||||
}
|
||||
|
||||
.pc .scroller table tr:nth-child(even) td{
|
||||
background-color: var(--color-table-row-alt);
|
||||
}
|
||||
|
||||
.pc .scroller table tr.empty td {
|
||||
color: var(--color-table-text-empty);
|
||||
}
|
||||
|
||||
.pc .ram .scroller table tr.current td {
|
||||
background-color: var(--color-table-ram-highlight);
|
||||
color: var(--color-table-ram-highlight-text);
|
||||
}
|
||||
|
||||
.pc .cu .scroller table tr.current td {
|
||||
background-color: var(--color-table-cu-highlight);
|
||||
color: var(--color-table-cu-highlight-text);
|
||||
}
|
||||
|
||||
|
||||
.pc button,
|
||||
.pc .button{
|
||||
text-transform: none !important;
|
||||
font-weight: 600;
|
||||
height: 2.5em;
|
||||
line-height: 1em;
|
||||
margin: 0;
|
||||
vertical-align: top;
|
||||
padding: 0.25em 2em;
|
||||
}
|
||||
|
||||
/* CONTROLS COLORS */
|
||||
.controls button, .controls .button {
|
||||
/* background-color: whitesmoke; */
|
||||
color: var(--color-controls-button-text);
|
||||
border-color: var(--color-controls-button-border);
|
||||
}
|
||||
.controls button:hover, .controls .button:hover{
|
||||
color: var(--color-controls-button-text-hover);
|
||||
}
|
||||
|
||||
.pc .controls .checker::before {
|
||||
border: 1px solid var(--color-controls-button-border);
|
||||
}
|
||||
|
||||
.pc .controls .checker.checked::before {
|
||||
color: var(--color-controls-button-text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* FORMATTING STUFF */
|
||||
|
||||
.pc {
|
||||
/*height: 400px;
|
||||
height: 99vh;*/
|
||||
|
||||
box-sizing: border-box;
|
||||
|
||||
padding: 1em;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: auto auto auto;
|
||||
/* grid-template-columns: max-content auto max-content; */
|
||||
gap: 9px;
|
||||
}
|
||||
|
||||
.pc .grid-fullwidth{
|
||||
grid-column: 1 / span 3;
|
||||
}
|
||||
|
||||
.pc .section {
|
||||
min-height: 25em;
|
||||
max-height: calc(80vh - 8em);
|
||||
min-width: 20%;
|
||||
|
||||
box-sizing: border-box;
|
||||
padding: 2.5em 1em 1em 1em;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
position: relative;
|
||||
/*top: 0;
|
||||
left: 0;*/
|
||||
}
|
||||
|
||||
.pc .section h1.header {
|
||||
font-size: 1.2em;
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 4px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.pc .row {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.pc .scroller {
|
||||
overflow-x: auto;
|
||||
overflow-y: scroll;
|
||||
|
||||
/*position: relative;*/
|
||||
|
||||
/* max-height: 60%; */
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
width: 100%;
|
||||
margin: 1em 0 0 0;
|
||||
}
|
||||
|
||||
.pc .scroller:last-child {
|
||||
margin-bottom: -1em;
|
||||
}
|
||||
|
||||
.pc .scroller table {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pc .scroller table thead.head {
|
||||
position: sticky;
|
||||
top: -2px;
|
||||
left: 0;
|
||||
height: 1em;
|
||||
padding: 1em;
|
||||
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.pc .scroller table thead th {
|
||||
position: -webkit-sticky;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.pc .scroller table thead.head.shrunk {
|
||||
height: .5rem;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.pc .scroller table thead.head th {
|
||||
padding: 12px 4px 12px 15px;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.pc .scroller table thead.head.shrunk th {
|
||||
padding-top: .2em;
|
||||
padding-bottom: .2em;
|
||||
}
|
||||
|
||||
.pc .scroller table .num {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.pc .scroller table td:first-child,
|
||||
.pc .scroller table td:last-child {
|
||||
padding: 12px 15px;
|
||||
}
|
||||
|
||||
.pc .scroller table tr.empty td {
|
||||
padding: 3px 15px;
|
||||
}
|
||||
|
||||
.pc .scroller table tbody button:last-child {
|
||||
text-decoration: none;
|
||||
text-transform: none;
|
||||
height: max-content;
|
||||
line-height: 2em;
|
||||
font-weight: normal;
|
||||
font-size: inherit;
|
||||
padding: 0px 10px;
|
||||
}
|
||||
|
||||
.pc .scroller tr:first-child td{
|
||||
padding-top: 1.5rem !important;
|
||||
}
|
||||
|
||||
th.address {
|
||||
width: 5rem;
|
||||
padding-left: 8px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.pc input[type=number] {
|
||||
margin: 0 .5em 0 0;
|
||||
padding: 0 .25em;
|
||||
height: 2.5rem;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.pc input[type=number].instruction {
|
||||
width: 5em !important;
|
||||
}
|
||||
|
||||
.pc input[type=number].address {
|
||||
width: 7em !important;
|
||||
}
|
||||
|
||||
|
||||
/* CONTROLS */
|
||||
.pc .controls > :not(:last-child) {
|
||||
margin-right: 0.75em;
|
||||
}
|
||||
|
||||
.pc .controls .checker {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
||||
.pc .controls .checker label {
|
||||
display: inline;
|
||||
/*font-size: 0.8em;*/
|
||||
white-space: initial;
|
||||
white-space: break-spaces;
|
||||
text-transform: none;
|
||||
width: 6em;
|
||||
width: min-content;
|
||||
vertical-align: middle;
|
||||
line-height: .9em;
|
||||
|
||||
margin: 0;
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pc .controls input[type=checkbox]{
|
||||
display: none;
|
||||
margin-left: -1em;
|
||||
margin-right: 1em;
|
||||
opacity: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.pc .controls .checker::before{
|
||||
content: "✔";
|
||||
display: inline-block;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
color: rgba(0,0,0,0);
|
||||
border-radius: 4px;
|
||||
vertical-align: middle;
|
||||
margin: 0 .5em 0 -1em;
|
||||
|
||||
line-height: 1.8rem;
|
||||
font-size: 1.4em;
|
||||
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* END CONTROLS */
|
||||
|
||||
/* RAM */
|
||||
|
||||
.pc .ram .scroller {
|
||||
/* height: 100%; */
|
||||
/* padding: 0.2em; */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pc .ram .scroller table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pc .ram input[type=number] {
|
||||
background-color: var(--color-table-ram-select);
|
||||
color: var(--color-table-ram-select-text);
|
||||
border-color: var(--color-table-ram-select-border);
|
||||
}
|
||||
|
||||
.pc .ram table tr td:nth-child(2){
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.pc .ram .scroller table tbody button:last-child{
|
||||
background-color: var(--color-table-ram-select);
|
||||
color: var(--color-table-ram-select-text);
|
||||
border-color: var(--color-table-ram-select-border);
|
||||
}
|
||||
|
||||
|
||||
/* CONTROL UNIT */
|
||||
|
||||
.pc .cu p {
|
||||
margin: 0 0 .2em 0;
|
||||
}
|
||||
|
||||
.pc .cu .scroller table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pc .cu .input-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 0 0 .5em 0;
|
||||
}
|
||||
|
||||
.pc .cu .input-row:last-child {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pc .cu input {
|
||||
color: var(--color-cu-text);
|
||||
border-color: var(--color-cu-text);
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pc .cu input[type=number] {
|
||||
width: 12.5em;
|
||||
}
|
||||
|
||||
.pc .cu label {
|
||||
display: inline;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.pc .cu select{
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
|
||||
background-color: var(--color-table-cu-select);
|
||||
color: var(--color-table-cu-select-text);
|
||||
border: 1px solid var(--color-table-cu-select-border);
|
||||
}
|
||||
|
||||
.pc .cu .scroller table tbody button:last-child {
|
||||
background-color: var(--color-table-cu-select);
|
||||
color: var(--color-table-cu-select-text);
|
||||
border: 1px solid var(--color-table-cu-select-border);
|
||||
}
|
||||
|
||||
.pc .cu button,
|
||||
.pc .cu .button {
|
||||
height: 2.5rem;
|
||||
box-sizing: border-box;
|
||||
|
||||
color: var(--color-cu-text);
|
||||
border-color: var(--color-cu-text);
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* ALU */
|
||||
.pc .alu input, .pc .alu .button, .pc .alu button{
|
||||
color: var(--color-alu-text);
|
||||
border-color: var(--color-alu-text);
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pc .alu button {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.pc .alu button:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* BUSSES */
|
||||
|
||||
.pc .databus,
|
||||
.pc .addressbus{
|
||||
/*position: relative;*/
|
||||
text-align: left;
|
||||
|
||||
margin: 0;
|
||||
padding: .75em .5em;
|
||||
}
|
||||
|
||||
.pc .databus .label,
|
||||
.pc .addressbus .label {
|
||||
/* position: absolute; */
|
||||
/* left: .5em; */
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.pc .addressbus input {
|
||||
color: var(--color-addressbus-text);
|
||||
border-color: var(--color-addressbus-text);
|
||||
background-color: var(--color-addressbus);
|
||||
}
|
||||
|
||||
.pc .databus input {
|
||||
color: var(--color-databus-text);
|
||||
border-color: var(--color-databus-text);
|
||||
background-color: var(--color-databus);
|
||||
}
|
||||
|
||||
.pc .addressbus {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.pc .databus {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
/* ARROWS */
|
||||
.pc .arrow {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
width: 3rem;
|
||||
height: 5rem;
|
||||
|
||||
/* transform: rotate(90deg) translate(1.5rem, 2.5rem) ; */
|
||||
transform: translate(0, 3rem);
|
||||
z-index: 100;
|
||||
|
||||
font-size: 0.5em;
|
||||
color: var(--color-arrow-text);
|
||||
background-color: var(--color-arrow);
|
||||
}
|
||||
|
||||
.pc .arrow.down {
|
||||
left: 25%;
|
||||
}
|
||||
|
||||
.pc .arrow.up {
|
||||
left: 75%;
|
||||
transform: rotate(180deg) translate(0, -4.5rem);
|
||||
}
|
||||
.pc .arrow.up > :nth-child(1){
|
||||
/* transform: rotate(90deg) translate(0rem, 2rem); */
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.pc .arrow.up.arrow2 {
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
.pc .arrow.top {
|
||||
bottom: auto;
|
||||
top: -6rem;
|
||||
}
|
||||
|
||||
|
||||
.pc .arrow > :nth-child(1) {
|
||||
font-size: 1.2em;
|
||||
line-height: 1.1em;
|
||||
font-weight: 600;
|
||||
color: var(--color-arrow-text) !important;
|
||||
background-color: var(--color-arrow) !important;
|
||||
border-color: var(--color-arrow-text) !important;
|
||||
text-transform: none;
|
||||
padding: 2px 10px;
|
||||
margin: 0;
|
||||
/* transform: rotate(-90deg) translate(0rem, -2rem); */
|
||||
|
||||
white-space: normal;
|
||||
height: min-content;
|
||||
}
|
||||
|
||||
.pc .arrow > :nth-child(1) *{
|
||||
color: var(--color-arrow-text);
|
||||
display: block;
|
||||
white-space: break-spaces;
|
||||
}
|
||||
|
||||
.pc .arrow > :nth-child(1):hover, .pc .arrow > :nth-child(1) *:hover {
|
||||
color: var(--color-arrow-text-hover);
|
||||
}
|
||||
|
||||
.pc .arrow > :nth-child(2) {
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
border-left: 2.5rem solid transparent;
|
||||
border-right: 2.5rem solid transparent;
|
||||
border-top: 2rem solid var(--color-arrow);
|
||||
border-bottom: 0rem solid transparent;
|
||||
|
||||
position: absolute;
|
||||
left: -1rem;
|
||||
bottom: -2rem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* MODALS */
|
||||
.modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
|
||||
box-sizing: border-box;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.modal.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.modal-card {
|
||||
z-index: 1500;
|
||||
display: block;
|
||||
width: 40em;
|
||||
min-width: 45vw;
|
||||
min-height: 5em;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
|
||||
padding: 2.5em 2em 1em 2em;
|
||||
|
||||
background-color: var(--color-modal);
|
||||
color: var(--color-modal-text);
|
||||
}
|
||||
|
||||
.modal > :first-child {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
background-color: var(--color-modal-shadow);
|
||||
}
|
||||
|
||||
.modal .modal-close {
|
||||
position: absolute;
|
||||
top: .5em;
|
||||
right: .5em;
|
||||
|
||||
}
|
||||
|
||||
.modal .modal-close::before {
|
||||
content: "❌";
|
||||
cursor: pointer;
|
||||
}
|
||||
|
10
out/icon/cross.svg
Normal file
10
out/icon/cross.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Cross" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
|
||||
<path d="M14.348,14.849c-0.469,0.469-1.229,0.469-1.697,0L10,11.819l-2.651,3.029c-0.469,0.469-1.229,0.469-1.697,0
|
||||
c-0.469-0.469-0.469-1.229,0-1.697l2.758-3.15L5.651,6.849c-0.469-0.469-0.469-1.228,0-1.697c0.469-0.469,1.228-0.469,1.697,0
|
||||
L10,8.183l2.651-3.031c0.469-0.469,1.228-0.469,1.697,0c0.469,0.469,0.469,1.229,0,1.697l-2.758,3.152l2.758,3.15
|
||||
C14.817,13.62,14.817,14.38,14.348,14.849z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 835 B |
@ -16,6 +16,7 @@
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<link rel="stylesheet" href="css/normalize.css" />
|
||||
<link rel="stylesheet" href="css/skeleton.css" />
|
||||
<link rel="stylesheet" href="css/cookie.css" />
|
||||
<link rel="stylesheet" href="css/colors-light.css">
|
||||
<link rel="stylesheet" href="css/colors-dark.css">
|
||||
<link rel="stylesheet" href="css/pc.css" />
|
||||
@ -380,8 +381,9 @@
|
||||
|
||||
<!-- End Document
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<script src="elm.js"></script>
|
||||
<script src="pc.js"></script>
|
||||
<script src="script.js"></script>
|
||||
<script src="js/elm.js"></script>
|
||||
<script src="js/cookie.js"></script>
|
||||
<script src="js/pc.js"></script>
|
||||
<script src="js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
65
out/js/cookie.js
Normal file
65
out/js/cookie.js
Normal file
@ -0,0 +1,65 @@
|
||||
// Check if cookie banner has been accepted by running cookieAccepted()
|
||||
|
||||
// Please import cookie.css!!!!
|
||||
|
||||
function __cookie_internal_addBanner__(){
|
||||
let banner = document.createElement("div");
|
||||
let text = document.createElement("div");
|
||||
let link_datenschutz = document.createElement("a");
|
||||
let button_accept = document.createElement("button");
|
||||
let button_deny = document.createElement("button");
|
||||
|
||||
banner.classList.add("cookie-banner");
|
||||
|
||||
text.innerText =
|
||||
"In order for this computer to keep it's data after reloading,\
|
||||
this page uses cookies and localStorage. ";
|
||||
|
||||
link_datenschutz.href = "https://yokta.de/i/datenschutz.html";
|
||||
link_datenschutz.innerText = "Privacy Policy";
|
||||
link_datenschutz.target = "_blank";
|
||||
text.appendChild( link_datenschutz );
|
||||
|
||||
button_accept.innerText = "I'm ok with that"
|
||||
button_deny.innerText = "Not on my watch!"
|
||||
|
||||
button_accept.addEventListener("click", (message) => {
|
||||
localStorage.setItem("cookie", "accepted");
|
||||
let parent = message.target.parentElement;
|
||||
document.body.removeChild(parent);
|
||||
});
|
||||
button_deny.addEventListener("click", (message) => {
|
||||
let parent = message.target.parentElement;
|
||||
document.body.removeChild(parent);
|
||||
});
|
||||
|
||||
|
||||
banner.appendChild( text );
|
||||
banner.appendChild( button_accept );
|
||||
banner.appendChild( button_deny );
|
||||
|
||||
document.body.appendChild(banner);
|
||||
}
|
||||
|
||||
// Returns true if cookies are accepted
|
||||
function cookieAccepted() {
|
||||
let maybe_cookie_status = localStorage.getItem("cookie");
|
||||
let cookie_status = 0; // 0 = not answered, 1 = accepted, 2 = denied
|
||||
|
||||
if( maybe_cookie_status == null ) cookie_status = 0;
|
||||
else if(maybe_cookie_status == "accepted") cookie_status = 1;
|
||||
else cookie_status = 2;
|
||||
|
||||
if (cookie_status == 1) return true;
|
||||
if (cookie_status == 0) {
|
||||
let maybe_banner = document.getElementsByClassName("cookie-banner")[0];
|
||||
if(maybe_banner == undefined){
|
||||
__cookie_internal_addBanner__();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
cookieAccepted();
|
89
out/js/pc.js
Normal file
89
out/js/pc.js
Normal file
@ -0,0 +1,89 @@
|
||||
// Init Elm
|
||||
var app = Elm.Main.init({
|
||||
node: document.getElementById("elm"),
|
||||
// flags: Date.now()
|
||||
});
|
||||
|
||||
// Dom Objects
|
||||
let pc = document.getElementsByClassName("pc")[0];
|
||||
let pc_ram = pc.getElementsByClassName("ram")[0];
|
||||
let pc_cu = pc.getElementsByClassName("cu")[0];
|
||||
let pc_alu = pc.getElementsByClassName("alu")[0];
|
||||
|
||||
let pc_ram_scroller = pc_ram.getElementsByClassName("scroller")[0];
|
||||
let pc_cu_scroller = pc_cu.getElementsByClassName("scroller")[0];
|
||||
|
||||
let control_autoscroll = document.getElementById("enableScrolling");
|
||||
|
||||
// Methods
|
||||
function scrollToCurrent(){
|
||||
if( control_autoscroll.checked == false ) return;
|
||||
|
||||
let current_ram = pc_ram.getElementsByClassName("current")[0];
|
||||
let current_uCode = pc_cu.getElementsByClassName("current")[0];
|
||||
|
||||
if( pc.scrollIntoViewIfNeeded == undefined ){
|
||||
if( typeof current_ram != "undefined"){
|
||||
current_ram.scrollIntoView({behavior: "smooth", block: "nearest"});
|
||||
}
|
||||
if( typeof current_uCode != "undefined"){
|
||||
current_uCode.scrollIntoView({behavior: "smooth", block: "nearest"});
|
||||
}
|
||||
}else{
|
||||
if( typeof current_ram != "undefined"){
|
||||
current_ram.scrollIntoViewIfNeeded({behavior: "smooth", block: "nearest"});
|
||||
}
|
||||
if( typeof current_uCode != "undefined"){
|
||||
current_uCode.scrollIntoViewIfNeeded({behavior: "smooth", block: "nearest"});
|
||||
}
|
||||
}
|
||||
|
||||
// pc.scrollIntoView();
|
||||
}
|
||||
|
||||
|
||||
function shrinkTableHead(scroll){
|
||||
let scroller = scroll.target;
|
||||
let pos = scroller.scrollTop;
|
||||
let thead = scroller.getElementsByClassName("head")[0];
|
||||
|
||||
if( pos > 70 ){
|
||||
thead.classList.add("shrunk");
|
||||
}else if (pos < 40){
|
||||
thead.classList.remove("shrunk");
|
||||
}
|
||||
thead.classList.add("shrunk");
|
||||
|
||||
}
|
||||
|
||||
function loadStorage() {
|
||||
let content = localStorage.getItem("pc_data");
|
||||
if( typeof content == "string" ){
|
||||
app.ports.localStorageRecieve.send( content );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Load last state of pc
|
||||
loadStorage();
|
||||
|
||||
// EVENT LISTENERS
|
||||
pc_ram_scroller.addEventListener("scroll", shrinkTableHead);
|
||||
pc_cu_scroller.addEventListener("scroll", shrinkTableHead);
|
||||
|
||||
// Recieve Elm updates via ports
|
||||
app.ports.sendUUpdate.subscribe( (message) => {
|
||||
// console.log("Update: ", message);
|
||||
scrollToCurrent();
|
||||
|
||||
// Make sure that even when the calculation takes longer it will scroll correctly
|
||||
setTimeout( scrollToCurrent, 100 );
|
||||
} );
|
||||
|
||||
// Recieve LocalSession Updates via Ports
|
||||
app.ports.localStorageSend.subscribe( (message) => {
|
||||
// console.log("localSessionSend: ", message);
|
||||
if( cookieAccepted() )
|
||||
localStorage.setItem("pc_data", message);
|
||||
} );
|
26
out/js/script.js
Normal file
26
out/js/script.js
Normal file
@ -0,0 +1,26 @@
|
||||
let text_de = document.getElementById("langDE");
|
||||
let text_en = document.getElementById("langEN");
|
||||
|
||||
let btn_changeToDe = document.getElementById("langPickerDE");
|
||||
let btn_changeToEn = document.getElementById("langPickerEN");
|
||||
|
||||
let lang = (typeof document.documentElement.lang == "string") ? document.documentElement.lang: "en"
|
||||
|
||||
|
||||
function changeLang(lang){
|
||||
if(lang == "de"){
|
||||
text_de.classList.remove("hidden");
|
||||
text_en.classList.add("hidden");
|
||||
}else{
|
||||
text_en.classList.remove("hidden");
|
||||
text_de.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
btn_changeToEn.addEventListener("click", () => { changeLang("en") } );
|
||||
btn_changeToDe.addEventListener("click", () => { changeLang("de") } );
|
||||
|
||||
|
||||
|
||||
// Do stuff on loading
|
||||
changeLang( lang );
|
Loading…
x
Reference in New Issue
Block a user