diff --git a/css/style.css b/css/style.css index 4797814..3edf2ba 100644 --- a/css/style.css +++ b/css/style.css @@ -1 +1 @@ -*{-webkit-box-sizing:border-box;box-sizing:border-box}body{font-size:1.4rem;margin:0;display:block;position:relative;padding:0;overflow:hidden}body a,body b,body button:not(.editbutton),body p,body span{color:red}body .designer{display:none}body .edittools{position:fixed;z-index:999;display:inline-block;top:0;right:0;height:auto;width:auto}body .edittools .addblock{display:none}body .edittools,body .edittools button{font-size:1.5rem}body .edittools button{border:0;background:transparent}body .edittools button:hover{background:rgba(255,255,255,0.4)}body main{height:100vh;width:100%;z-index:20;margin:0;padding:0;display:inline-block}body .block{position:absolute;display:inline-block;padding:0.2rem}body .block div{display:inline-block;position:relative}body,body *{font-family:-apple-system,system-ui,"Helvetica Neue","Helvetica","Segoe UI","Segoe UI Variable","Roboto","Tahoma","Ubuntu",sans-serif}body.editing{min-height:calc(100vh + 80px);overflow:auto}body.editing code{background-color:orange}body.editing select{max-width:100%;width:100%;overflow:hidden}body.editing #designer{display:inline-block;position:sticky;height:auto;width:100%;background:rgba(255,255,255,0.5);bottom:0;padding:1.2rem;-webkit-box-sizing:border-box;box-sizing:border-box;border:0;margin:0;overflow:hidden}body.editing .block{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body.editing .block>div .editdiv{display:none}body.editing .block .editdiv{position:absolute;height:calc(100% + 20px / 2);width:100%;top:-10px;background-color:rgba(255,0,0,0.2);outline:1px solid red;border-top:10px solid blue;-webkit-box-sizing:border-box;box-sizing:border-box}body.editing .block .editdiv>button{padding:0;position:absolute;display:inline-block;top:-10px;height:20px;width:20px;border:0}body.editing .block .editdiv>button,body.editing .block .editdiv>button *{font-size:20px;text-align:center;line-height:1}body.editing .block .editdiv>button.dragger{cursor:move;left:0;background:lime}body.editing .block .editdiv>button.resizer{display:none}body.editing .block .editdiv>button.designer{left:20px;background:purple}body.editing .block .editdiv>button.remover{left:40px;background:red}body.editing .edittools .addblock{display:inline-block} \ No newline at end of file +*{-webkit-box-sizing:border-box;box-sizing:border-box}html{background:#000}body{font-size:1.4rem;margin:0;display:block;position:relative;padding:0;overflow:hidden}body a,body b,body button:not(.editbutton),body p,body span{color:#ffff00aa}body .designer{display:none}body main{height:100vh;width:100%;z-index:20;margin:0;padding:0;display:inline-block;position:relative;overflow:hidden}body .block{position:absolute;display:inline;padding:0.2rem;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body .block div{display:inline-block;position:relative}body,body *{font-family:-apple-system,system-ui,"Helvetica Neue","Helvetica","Segoe UI","Segoe UI Variable","Roboto","Tahoma","Ubuntu",sans-serif}body .edittools{position:fixed;z-index:999;display:inline-block;top:0;right:0;height:auto;width:auto}body .edittools,body .edittools button{font-size:1.75rem;line-height:1;padding:0}body .edittools button{border:0;background:transparent;height:3rem;width:3rem}body .edittools button:hover{background:rgba(255,255,255,0.2);color:#ff0}body .edittools .addblock{display:none}body.editing{min-height:calc(100vh + 80px);overflow:auto}body.editing code{background-color:orange}body.editing select{max-width:100%;width:100%;overflow:hidden}body.editing #designer{display:block;z-index:21;position:sticky;height:auto;width:100%;background:rgba(255,255,255,0.5);bottom:0;padding:1.2rem;-webkit-box-sizing:border-box;box-sizing:border-box;border:0;margin:0;overflow:hidden}body.editing .block>div .editdiv{display:none}body.editing .block .editdiv{position:absolute;height:calc(100%);width:100%;background-color:rgba(255,0,0,0.2);outline:1px solid #ff0;-webkit-box-sizing:border-box;box-sizing:border-box}body.editing .block .editdiv>button{padding:0;position:absolute;display:inline-block;height:24px;width:24px;border:0;z-index:9}body.editing .block .editdiv>button,body.editing .block .editdiv>button *{font-size:24px;text-align:center;line-height:1}body.editing .block .editdiv>button.dragger{cursor:move;left:0;background:lime}body.editing .block .editdiv>button.resizer{display:none}body.editing .block .editdiv>button.designer{left:24px;background:purple}body.editing .block .editdiv>button.remover{left:48px;background:red}body.editing .edittools .addblock{display:inline-block} \ No newline at end of file diff --git a/css/style.scss b/css/style.scss index d2c71fe..642e469 100644 --- a/css/style.scss +++ b/css/style.scss @@ -1,9 +1,13 @@ -$editbuttonSize: 20px; +$editbuttonSize: 24px; * { box-sizing: border-box; } +html { + background: #000; +} + body { font-size: 1.4rem; margin: 0; @@ -12,13 +16,41 @@ body { padding: 0; overflow: hidden; p,b,a,span,button:not(.editbutton) { - color:red; + color:#ffff00aa; } - .designer { + .designer { // Don't display the designer when not in editing mode display: none; } + main { + height: 100vh; + width: 100%; + z-index: 20; + margin: 0; + padding: 0; + display: inline-block; + position: relative; + overflow: hidden; + } + + .block { + position: absolute; + display: inline; + padding: .2rem; + user-select: none; + + div { + display: inline-block; + position: relative; + } + + } + &,* { + font-family: -apple-system, system-ui, 'Helvetica Neue', 'Helvetica', 'Segoe UI', 'Segoe UI Variable', 'Roboto', 'Tahoma', 'Ubuntu', sans-serif; + } + + .edittools { position: fixed; z-index: 999; @@ -28,134 +60,121 @@ body { height: auto; width: auto; - .addblock { - display: none; - } &,button { - font-size: 1.5rem; + font-size: 1.75rem; + line-height: 1; + padding: 0; } + button { border: 0; background: transparent; + height: 3rem; + width: 3rem; &:hover { - background: rgba(255,255,255,.4); + background: rgba(255,255,255,.2); + color: #ff0; } } - } - main { - height: 100vh; - width: 100%; - z-index: 20; - margin: 0; - padding: 0; - display: inline-block; - } - .block { - position: absolute; - display: inline-block; - padding: .2rem; - div { - display: inline-block; - position: relative; + .addblock { + display: none; } } - &,* { - font-family: -apple-system, system-ui, 'Helvetica Neue', 'Helvetica', 'Segoe UI', 'Segoe UI Variable', 'Roboto', 'Tahoma', 'Ubuntu', sans-serif; - } } -body.editing { // When in editing mode - min-height: calc(100vh + 80px); - overflow: auto; - code { - background-color: orange; - } - select { - max-width: 100%; - width: 100%; - overflow: hidden; - } - #designer { - display: inline-block; - position: sticky; - height: auto; - width: 100%; - background: rgba(255,255,255,.5); - bottom: 0; - padding: 1.2rem; - box-sizing: border-box; - border: 0; - margin: 0; - overflow: hidden; - } - .block { - user-select: none; - &>div { - .editdiv { - display: none; - } + + +// Editing: + +body { + &.editing { + min-height: calc(100vh + 80px); + overflow: auto; + + code { + background-color: orange; + } + + select { + max-width: 100%; + width: 100%; + overflow: hidden; } - .editdiv { - position: absolute; - height: calc(100% + #{$editbuttonSize} / 2); + + #designer { + display: block; + z-index: 21; + position: sticky; + height: auto; width: 100%; - top: -($editbuttonSize / 2); - background-color: rgba(255,0,0,.2); - outline: 1px solid red; - border-top: ($editbuttonSize / 2) solid blue; + background: rgba(255,255,255,.5); + bottom: 0; + padding: 1.2rem; box-sizing: border-box; - >button { - padding:0; - position: absolute; - display: inline-block; - top:-($editbuttonSize / 2); - height: $editbuttonSize; - width: $editbuttonSize; - border:0; - &,* { - font-size: $editbuttonSize; - text-align: center; - line-height: 1; - } - &.dragger { - cursor: move; - left: 0; - background: lime; - } - &.resizer { + border: 0; + margin: 0; + overflow: hidden; + } + + .block { + &>div { + .editdiv { display: none; - // &.smaller { - // left: 1 * $editbuttonSize; - // background: orange; - // } - // &.bigger { - // left: 2 * $editbuttonSize; - // background: orangered; - // } } + } - &.designer { - left: 1 * $editbuttonSize; - background: purple; - } - &.remover { - left: 2 * $editbuttonSize; - background: red; + .editdiv { + position: absolute; + height: calc(100%); + width: 100%; + background-color: rgba(255,0,0,.2); + outline: 1px solid #ff0; + box-sizing: border-box; + >button { + padding: 0; + position: absolute; + display: inline-block; + height: $editbuttonSize; + width: $editbuttonSize; + border:0; + z-index: 9; + &,* { + font-size: $editbuttonSize; + text-align: center; + line-height: 1; + } + &.dragger { + cursor: move; + left: 0; + background: lime; + } + &.resizer { + display: none; + } + + &.designer { + left: 1 * $editbuttonSize; + background: purple; + } + + &.remover { + left: 2 * $editbuttonSize; + background: red; + } } } - } - } - .edittools { - .addblock { - display: inline-block; + .edittools { + .addblock { + display: inline-block; + } } } -} \ No newline at end of file +} diff --git a/js/edit.js b/js/edit.js index 225b567..39117a0 100644 --- a/js/edit.js +++ b/js/edit.js @@ -6,16 +6,16 @@ if(config.edit == true) { // Only load edit tools if we want to edit document.body.classList.add("editing"); - window.setTimeout(function() { // Make sure we don't end up with this pasted everywhere by waiting until everything else is rendered + window.setTimeout(function() { // Make sure we don't end up with this pasted everywhere by waiting a duration of 0 for(let myTemplate of templates) { myTemplate.innerHTML = document.getElementById("block-edit").innerHTML + myTemplate.innerHTML; } - }, config.ticktime); + }, 0); function drag(which) { if(mouseClick == true) { - which.style.left = mousePos[0] + "px"; - which.style.top = mousePos[1] + "px"; + which.style.left = mousePos[0] - 12 + "px"; // 12 is half the size of one edit button + which.style.top = mousePos[1] - 12 + "px"; // 12 is half the size of one edit button // which.style.top = mousePos[1] - (which.offsetHeight / 2) + "px"; if(which.id) { @@ -77,6 +77,8 @@ if(config.edit == true) { // Only load edit tools if we want to edit console.log(which); designerApplyTo = which.id; + console.log(which); + // document.getElementById("designer").style.left = config.clock1[designerApplyTo].position[0]; // document.getElementById("designer").style.top = -60 + parseInt(config.clock1[designerApplyTo].position[1]) + "px"; } @@ -90,7 +92,6 @@ if(config.edit == true) { // Only load edit tools if we want to edit spawnBlock(config.clock1[designerApplyTo]); // Respawn saveConfig(); - } diff --git a/js/scripts.js b/js/scripts.js index 84b627e..c41a5be 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -61,26 +61,36 @@ function spawnBlock(which) { clock.appendChild(newElement); // Append block to clock frame } + + + +function handleString(whichString) { + for(var j = 0; j < whichString.split("|").length; j++) { + whichString = whichString.replace("|" + whichString.split("|")[1] + "|", tick(whichString.split("|")[1])); // Replace variables with actual value + } + return whichString; +} + +// Ticking + window.setInterval(function() { + generalTick() +}, config.ticktime) + +function generalTick() { // Ticks everything; Similar to tick() functions in other programs for(let myElement of document.getElementsByClassName("block")) { // Tick the blocks var myTempInnerHTML = document.getElementById(myElement.getAttribute("template")).innerHTML; for(var j = 0; j < myElement.getAttribute("variables"); j++) { myTempInnerHTML = myTempInnerHTML.replace("|" + myTempInnerHTML.split("|")[1] + "|", tick(myTempInnerHTML.split("|")[1])); // Replace variables with actual value } - myElement.innerHTML = myTempInnerHTML; } - time = new Date(); -}, config.ticktime) +} + +generalTick(); // Initial tick so we don't see the template strings when loading the page -function handleString(whichString) { - for(var j = 0; j < whichString.split("|").length; j++) { - whichString = whichString.replace("|" + whichString.split("|")[1] + "|", tick(whichString.split("|")[1])); // Replace variables with actual value - } - return whichString; -} function tick(which) { // Render template values var result = "";