Created
January 27, 2017 18:40
-
-
Save aleckyann/df1725b569aca19c3e87401a4ad2cfc3 to your computer and use it in GitHub Desktop.
now working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onMessageClick(e) { | |
if(e.keyCode == 13) { | |
document.getElementById('enviaMensagem').click(); | |
} | |
} | |
if(sessionStorage.getItem('enterToSend') === 'true'){ | |
document.getElementById('enterToSend').setAttribute('checked', true); | |
document.getElementById('mensagem').addEventListener('keydown', onMessageClick); | |
} else { | |
document.getElementById('enterToSend').removeAttribute('checked'); //remove checked do checkbox | |
document.getElementById('mensagem').removeEventListener('keydown', onMessageClick); | |
} | |
function enterToSend(e){ | |
if(sessionStorage.getItem('enterToSend') === 'false'){//Enviar com enter! | |
sessionStorage.setItem('enterToSend', 'true'); | |
document.addEventListener('keydown', onMessageClick); | |
}else{ | |
document.removeEventListener('keydown', onMessageClick); //remove envento com enter | |
sessionStorage.setItem('enterToSend', 'false'); | |
} | |
} | |
(function initEnterToSend(){ | |
if(sessionStorage.getItem('enterToSend') === null){ | |
sessionStorage.setItem('enterToSend', 'false'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment