From 5e07b2dc21daf7a694a0f4a4bfa3fc0529ecd1e5 Mon Sep 17 00:00:00 2001 From: PeterTheOne Date: Sat, 4 Mar 2017 20:50:08 +0100 Subject: [PATCH] fix bugy key buttons --- web/css/style.css | 21 ++++++------ web/js/script.js | 84 ++++++++++++++++++++--------------------------- 2 files changed, 47 insertions(+), 58 deletions(-) diff --git a/web/css/style.css b/web/css/style.css index 1aaeff0..1d952f0 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -42,16 +42,17 @@ pre a:hover { color: #5cb85c; } -a.key { - font-family: KeyCaps; - font-size: 30pt; - color:black; - background-color:white; - padding:0; - margin:3px; +.keydiv { + float: right; + margin-right: 40%; + color: #5cb85c; + overflow: hidden; } -div.keydiv { - float:right; margin-right:40%; - color:black; +a.key { + font-family: KeyCaps; + font-size: 3em; + line-height: 2em; + padding: 0; + margin: 3px; } diff --git a/web/js/script.js b/web/js/script.js index 9dc9465..a78e694 100644 --- a/web/js/script.js +++ b/web/js/script.js @@ -14,34 +14,29 @@ function printLine(element, text, delay) { ) } -var keydiv; +var $keys; function addButtons(element) { var delay = defaultDelay; globalDelay += delay; setTimeout( function() { - keydiv = document.createElement("div"); - keydiv.setAttribute("class","keydiv"); - var keyY = document.createElement("a"); - keyY.setAttribute("class","key"); - keyY.append(document.createTextNode("Y")) - $(keyY).click(chooseYes); - var keyN = document.createElement("a"); - keyN.setAttribute("class","key"); - keyN.append(document.createTextNode("N")); - $(keyN).click(chooseNo); - keydiv.append(keyY); - keydiv.append(keyN); - element.append(keydiv); - window.scrollTo(0,document.body.scrollHeight); + $keys = $('
'); + var $keyY = $('Y'); + var $keyN = $('N'); + $keyY.click(chooseYes); + $keyN.click(chooseNo); + $keys.append($keyY); + $keys.append($keyN); + element.append($keys); + window.scrollTo(0, document.body.scrollHeight); }, globalDelay ) } function removeButtons() { - if (keydiv) { - keydiv.parentElement.removeChild(keydiv); + if ($keys) { + $keys.remove(); } } @@ -63,40 +58,40 @@ function chooseYes() { clearInterval(blinkIntervalId); $('body').off('keypress touchstart'); removeButtons(); - $output = $('.output4'); + var $output = $('.output4'); printLine($output, ' Great! We\'ll see you at the party then.'); printLine($output, ' expect DJ Music, Food, Tschunk, Games and more'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' 2017-03-18 from 18:00 till it\'s over'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' Find the place:'); printLine($output, ' realraum, Brockmanngasse 15, 8010 Graz'); printLine($output, ' http://osm.org/go/0Iz~oIpTW?m=&node=668061696'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' Save the date:'); printLine($output, ' https://plus.google.com/u/0/events/cqiq6003lok2qd9jcqmh4u4p8d4'); printLine($output, ' https://10.r3.at/10r3.ics'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' Get more Info:'); printLine($output, ' https://wiki.realraum.at/unterkunft'); printLine($output, ' idle at irc://irc.oftc.net/#realraum'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' https://github.com/realraum/telme10'); - printLine($output, ''); + printLine($output, '', 0); } function chooseNo() { clearInterval(blinkIntervalId); $('body').off('keypress'); removeButtons(); - $output = $('.output4'); + var $output = $('.output4'); globalDelay = 0; printLine($output, ' Sorry to hear! You\'re missing out on a great experience.'); - printLine($output, ''); - printLine($output, ' https://github.com/realraum/telme10'); - printLine($output, ''); + printLine($output, '', 0); + printLine($output, ' https://github.com/realraum/telme10'); + printLine($output, '', 0); } var blinkIntervalId; @@ -148,27 +143,27 @@ $(function () { printLine($output, 'Connected to 10.r3.at.'); printLine($output, 'Escape character is \'^]\'.'); - printLine($output, ''); - printLine($output, ''); + printLine($output, '', 0); + printLine($output, '', 0); for (var i = 0; i < logoBW72.length; i++) { printLine($output, logoBW72[i], 10); } - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' Hello!'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' Did you know: realraum will be celebrating its 10th birthday', 1000); printLine($output, ' on the 18th of March 2017?'); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' you should come by!', 1000); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' fun fun fun!', 3000); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' come to the party ... we mean it!', 3000); - printLine($output, ''); + printLine($output, '', 0); printLine($output, ' you have now 5s to decide:'); $output = $('.output2'); @@ -194,14 +189,14 @@ $(function () { var underscore = true; blinkIntervalId = setInterval(function () { globalDelay = 0; - var underscorelem = document.getElementById("underscore"); - if (underscorelem){ + var $underscoreElem = $('#underscore'); + if ($underscoreElem){ //console.log('interval!'); if (underscore) { - underscorelem.style="visibility:hidden;"; + $underscoreElem.hide(); underscore = false; } else { - underscorelem.style="visibility:visible;"; + $underscoreElem.show(); underscore = true; } } @@ -228,7 +223,7 @@ $(function () { input += 'o'; } if (event.which === 8 && input.length > 0) { - input = input.substring(0,input.length-1); + input = input.substring(0, input.length - 1); } $("#textinput").text(input); if ((event.which === 13) && (input === 'y' || input === 'yes')) { @@ -242,11 +237,4 @@ $(function () { globalDelay ); - - - - - - - });