86 lines
2.4 KiB
JavaScript
86 lines
2.4 KiB
JavaScript
var dur = 150
|
|
var drawerStatus = true
|
|
var wm = true
|
|
function drawer(){
|
|
if(window.innerWidth <= 1400){
|
|
if(drawerStatus){
|
|
$('.drawer').show('slide', {direction: 'left'}, dur)
|
|
$('.actionbar').before("<div class='overlay' onclick='drawer()'></div>")
|
|
$('.overlay').animate({"opacity":"0.4"}, dur)
|
|
drawerStatus = false
|
|
} else {
|
|
$('.drawer').hide('slide', {direction: 'left'}, dur)
|
|
$('.overlay').animate({"opacity":"0"}, dur, function callback (){
|
|
$('.overlay').remove()
|
|
})
|
|
drawerStatus = true
|
|
}
|
|
}
|
|
}
|
|
|
|
function encrypt(){
|
|
var input = $('#textarea').val()
|
|
if(wm){
|
|
$("#output").text(encryptWrittenMorseManager(input))
|
|
} else {
|
|
//TODO port the normal morse decode engine
|
|
$("#output").html(encryptNormalMorseManager(input))
|
|
}
|
|
$('#outputcard').fadeIn(dur)
|
|
}
|
|
|
|
function decrypt(){
|
|
var input = $('#textarea').val()
|
|
if(wm){
|
|
$('#output').text(decryptWrittenMorseManager(input))
|
|
} else {
|
|
//TODO port the normal morse decode engine
|
|
$("#output").text(decryptNormalMorseManager(input))
|
|
}
|
|
$('#outputcard').fadeIn(dur)
|
|
}
|
|
|
|
function writtenMorse(){
|
|
wm = true
|
|
$("#normalMorse").css({"color":"#000000"})
|
|
$("#writtenMorse").css({"color":"#03a9f4"})
|
|
drawer()
|
|
}
|
|
|
|
function normalMorse(){
|
|
wm = false
|
|
$("#normalMorse").css({"color":"#03a9f4"})
|
|
$("#writtenMorse").css({"color":"#000000"})
|
|
drawer()
|
|
}
|
|
|
|
function about(){
|
|
$("body").fadeOut(dur, function callback(){
|
|
window.location = "http://marcel-kapfer.de/writtenmorse"
|
|
})
|
|
}
|
|
|
|
function bug(){
|
|
$("body").fadeOut(dur, function callback(){
|
|
window.location = "https://github.com/mmk2410/morse-converter-web/issues"
|
|
})
|
|
}
|
|
|
|
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);
|
|
});
|
|
}
|