diff --git a/index.html b/index.html index 64d6348..e86df0a 100644 --- a/index.html +++ b/index.html @@ -11,8 +11,8 @@ - - + + @@ -32,8 +32,8 @@
- ENCODE - DECODE + ENCRYPT + DECRYPT
diff --git a/js/engine/EncodeWrittenMorse.js b/js/engine/DecryptWrittenMorse.js similarity index 95% rename from js/engine/EncodeWrittenMorse.js rename to js/engine/DecryptWrittenMorse.js index 27e6299..e4dfe25 100644 --- a/js/engine/EncodeWrittenMorse.js +++ b/js/engine/DecryptWrittenMorse.js @@ -1,4 +1,4 @@ -function encodeWrittenMorseManager(inputMessage) { +function decryptWrittenMorseManager(inputMessage) { if(inputMessage === ""){ return "Please enter at least one character"; } else { @@ -6,7 +6,13 @@ function encodeWrittenMorseManager(inputMessage) { inputMessage = inputMessage.substring(0, message.length() - 1); } // Variables - var input = inputMessage.toUpperCase() + "#"; + var input = inputMessage.toUpperCase(); + if(input.endsWith('#') == false){ + input = input + "#"; + } + while(input.indexOf('\n') != -1){ + input = input.replace("\n","") + } var inputToSign = input; var output = ""; var d = 0; diff --git a/js/engine/DecodeWrittenMorse.js b/js/engine/EncryptWrittenMorse.js similarity index 98% rename from js/engine/DecodeWrittenMorse.js rename to js/engine/EncryptWrittenMorse.js index 1cd6df2..6da01b5 100644 --- a/js/engine/DecodeWrittenMorse.js +++ b/js/engine/EncryptWrittenMorse.js @@ -1,4 +1,4 @@ -function decodeWrittenMorseManager(message) { +function encryptWrittenMorseManager(message) { if(message == ""){ return "Please enter at least one character" } else { @@ -7,6 +7,9 @@ function decodeWrittenMorseManager(message) { } // Variables var input = message.toUpperCase() + while(input.indexOf('\n') != -1){ + input = input.replace("\n","") + } var output = "" if (input == "LETTERSPACE") { output = "#" diff --git a/js/web/web.js b/js/web/web.js index 6a29e72..af1fce6 100644 --- a/js/web/web.js +++ b/js/web/web.js @@ -18,10 +18,10 @@ function drawer(){ } } -function encode(){ +function encrypt(){ var input = $('#textarea').val() if(wm){ - $("#output").text(encodeWrittenMorseManager(input)) + $("#output").text(encryptWrittenMorseManager(input)) } else { //TODO port the normal morse decode engine $("#output").text("The normal morse engine is not ported jet.") @@ -29,10 +29,10 @@ function encode(){ $('#outputcard').fadeIn(dur) } -function decode(){ +function decrypt(){ var input = $('#textarea').val() if(wm){ - $('#output').text(decodeWrittenMorseManager(input)) + $('#output').text(decryptWrittenMorseManager(input)) } else { //TODO port the normal morse decode engine $("#output").text("The normal morse engine is not ported jet.") @@ -59,3 +59,21 @@ function about(){ window.location = "http://marcel-kapfer.de/writtenmorse" }) } + +window.onload = function() { + var t = document.getElementsByTagName('textarea')[0]; + var offset= !window.opera ? (t.offsetHeight - t.clientHeight) : (t.offsetHeight + parseInt(window.getComputedStyle(t, null).getPropertyValue('border-top-width'))) ; + + var resize = function(t) { + t.style.height = 'auto'; + t.style.height = (t.scrollHeight + offset ) + 'px'; + } + + t.addEventListener && t.addEventListener('input', function(event) { + resize(t); + }); + + t['attachEvent'] && t.attachEvent('onkeyup', function() { + resize(t); + }); +} diff --git a/res/css/main.css b/res/css/main.css index 290d3f9..f22ad69 100644 --- a/res/css/main.css +++ b/res/css/main.css @@ -84,16 +84,19 @@ body { box-shadow: 0px 0px 2px 2px #cecece; display: inline-block; margin: 16px; - float: left; } + float: left; + height: auto; } .input { width: 100%; resize: none; border: 0px; - height: 100px; + height: auto; + min-height: 100px; font-family: "Roboto", sans-serif; font-size: 16px; - padding: 20px; } + padding: 20px; + clear: both; } .carddivider { width: 100%; } diff --git a/res/css/main.sass b/res/css/main.sass index 203651f..40526a7 100644 --- a/res/css/main.sass +++ b/res/css/main.sass @@ -21,6 +21,12 @@ $card-padding: 20px -ms-box-shadow: $horizontal $vertical $blur $spread $color box-shadow: $horizontal $vertical $blur $spread $color +=hyphens($value) + -moz-hyphens: $value + -ms-hyphens: $value + -webkit-hyphens: $value + hyphens: $value + body font-family: $font-stack background: $body-color @@ -101,15 +107,18 @@ body display: inline-block margin: 16px float: left + height: auto .input width: 100% resize: none border: 0px - height: 100px + height: auto + min-height: 100px font-family: $font-stack font-size: 16px padding: $card-padding + clear: both .carddivider @extend .drawerdivider @@ -140,10 +149,7 @@ body z-index: 30 #output - -moz-hyphens: auto - -ms-hyphens: auto - -webkit-hyphens: auto - hyphens: auto + +hyphens(auto) word-wrap: break-word