From ddc0bbe98a0f2466eb4108dc1e8ba305de3fad3f Mon Sep 17 00:00:00 2001 From: Azur-Azabache Date: Thu, 2 Nov 2017 05:01:57 -0500 Subject: [PATCH 1/3] =?UTF-8?q?A=C3=B1adiendo=20arreglos=20EsLint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 29 +++++++++++++++++++++++++++++ JS/app.js | 28 ++++++++++++++++++++++++++++ index.html | 11 +++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .eslintrc create mode 100644 JS/app.js create mode 100644 index.html diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..fbb5dc3 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,29 @@ +{ + "parserOptions": { + "ecmaVersion": 6 + }, + "rules": { + "keyword-spacing": 1, + "space-before-function-paren": [1, "never"], + "eqeqeq": 1, + "space-infix-ops": 1, + "comma-spacing": 1, + "brace-style": 1, + "no-multiple-empty-lines": 1, + "camelcase": 1, + "func-call-spacing": 1, + "key-spacing": 1, + "semi": 1, + "no-floating-decimal": 1, + "no-multi-spaces": 1, + "object-property-newline": 1, + "padded-blocks": [1, "never"], + "space-before-blocks": 1, + "space-in-parens": 1, + "spaced-comment": 1, + "quotes": [1, "single"], + "id-length": [1, { "exceptions": ["i", "j", "x"] }], + "indent": [1, 2], + "no-array-constructor": 1 + } +} diff --git a/JS/app.js b/JS/app.js new file mode 100644 index 0000000..cafd561 --- /dev/null +++ b/JS/app.js @@ -0,0 +1,28 @@ +var phrase = prompt('Ingresa la frase a decodificar'); +var newarray = []; +var unicode = []; + +function cipher(str) { + var array = phrase.split(''); + for (i = 0; i <= array.length - 1;i++) { + unicode.push(phrase.charCodeAt(i)); + } + + for (i = 0; i <= unicode.length - 1; i++) { + newarray.push((unicode[i] - 65 + 33) % 26 + 65); + } + return newarray; +} +var arr = cipher(phrase); +function decipher(array2) { + var arr2 = []; + for (i = 0; i <= array2.length - 1; i++) { + arr2.push(String.fromCharCode(array2[i])); + return arr2; + } + if (isNaN(phrase) === false) { + 'Ingrese una frase por favor'; + } else { + } +} +decipher(arr); diff --git a/index.html b/index.html new file mode 100644 index 0000000..d04b3bd --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + +Cifrado Cesar + + + + + + From 4abeef7805b64a56028746603a3af64b7597619d Mon Sep 17 00:00:00 2001 From: Azur_Azabache Date: Fri, 26 Jan 2018 01:42:45 -0500 Subject: [PATCH 2/3] update --- JS/app.js | 59 ++++++++++++++++++++++++++++-------------------------- index.html | 18 ++++++++++++----- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/JS/app.js b/JS/app.js index cafd561..842a175 100644 --- a/JS/app.js +++ b/JS/app.js @@ -1,28 +1,31 @@ -var phrase = prompt('Ingresa la frase a decodificar'); -var newarray = []; -var unicode = []; - -function cipher(str) { - var array = phrase.split(''); - for (i = 0; i <= array.length - 1;i++) { - unicode.push(phrase.charCodeAt(i)); - } - - for (i = 0; i <= unicode.length - 1; i++) { - newarray.push((unicode[i] - 65 + 33) % 26 + 65); - } - return newarray; -} -var arr = cipher(phrase); -function decipher(array2) { - var arr2 = []; - for (i = 0; i <= array2.length - 1; i++) { - arr2.push(String.fromCharCode(array2[i])); - return arr2; - } - if (isNaN(phrase) === false) { - 'Ingrese una frase por favor'; - } else { - } -} -decipher(arr); +$(document).ready(function() { +$('#text').focus(); +//Funcion para Codificar + $('#code').on('click', function cipher() { + let str = $('#text').val(); + let unicode; + let word; + let newPhrase= ''; + for (i = 0; i <= str.length - 1; i++) { + unicode = str.charCodeAt(i); + word = (unicode - 97 + 33) % 26 + 97; + let neWord = String.fromCharCode(word); + newPhrase = newPhrase.concat(neWord); + } + return document.write('Tu frase codificada es: ' + newPhrase); + }); +//Función para Decodificar + $('#decode').on('click', function decipher() { + let str2 = $('#text').val(); + let unicode2; + let word2; + let newPhrase2 = ''; + for (var i = 0; i <= str2.length - 1; i++) { + unicode2 = str2.charCodeAt(i); + word2 = (unicode2 + 97 + 33) % 26 + 97; + let neWord2 = String.fromCharCode(word2); + newPhrase2 = newPhrase2.concat(neWord2); + } + return document.write('Tu frase decodificada es: ' + newPhrase2) ; + }); +}); diff --git a/index.html b/index.html index d04b3bd..93a69d0 100644 --- a/index.html +++ b/index.html @@ -1,11 +1,19 @@ - + - -Cifrado Cesar + + + + Cifrado - +
+ Mensaje: + + + +
+ + - From c1913f3952286302ece52b7d105067288869f398 Mon Sep 17 00:00:00 2001 From: Azur_Azabache Date: Fri, 26 Jan 2018 01:44:50 -0500 Subject: [PATCH 3/3] update2 --- JS/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JS/app.js b/JS/app.js index 842a175..5a21f63 100644 --- a/JS/app.js +++ b/JS/app.js @@ -2,7 +2,7 @@ $(document).ready(function() { $('#text').focus(); //Funcion para Codificar $('#code').on('click', function cipher() { - let str = $('#text').val(); + const str = $('#text').val(); let unicode; let word; let newPhrase= ''; @@ -16,7 +16,7 @@ $('#text').focus(); }); //Función para Decodificar $('#decode').on('click', function decipher() { - let str2 = $('#text').val(); + const str2 = $('#text').val(); let unicode2; let word2; let newPhrase2 = '';