<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?> <script type="text/javascript"> $("textarea").keyup(function () { caesar(); }); $("input").keyup(function () { caesar(); }); $("input").change(function () { caesar(); }); $(window).keydown(function (a) { if (a.keyCode == 13) { a.preventDefault(); return false } }); var caesar = function () { var f = $('#text-input').val(); var d = $('#shift-key').val(); if (d == "") { d = 0 } else { d = parseInt(d) % 26 } var e = ""; if ($('#decrypt').is(":checked")) { d *= -1; } console.log(d); for (var c = 0; c < f.length; c++) { var a = f.charCodeAt(c); if (a >= 97 && a <= 122) { e += String.fromCharCode(((a - 97 + d + 26) % 26) + 97) } else { if (a >= 65 && a <= 90) { e += String.fromCharCode(((a - 65 + d + 26) % 26) + 65) } else { e += String.fromCharCode(a) } } } $('#text-output').val(e); }; $('#encrypt').change(function() { $('#text-input-label').text('<?= lang('encrypter_text') ?>'); $('#text-input').attr('placeholder', '<?= lang('encrypter_text2') ?>'); $('#text-output-label').text('<?= lang('encrypter_output') ?>'); $('#text-output').attr('placeholder', '<?= lang('encrypter_output') ?>'); }); $('#decrypt').change(function() { $('#text-input-label').text('<?= lang('decrypter_text') ?>'); $('#text-input').attr('placeholder', '<?= lang('decrypter_text2') ?>'); $('#text-output-label').text('<?= lang('decrypter_output') ?>'); $('#text-output').attr('placeholder', '<?= lang('decrypter_output') ?>'); }); </script>