Created
June 5, 2018 15:14
-
-
Save sonishc/f3f2b60d86f68d24b634c20586ebb3bd to your computer and use it in GitHub Desktop.
Na
This file contains hidden or 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
| $('#expression').keyup(function () { | |
| $('#display').text($(this).val()); | |
| }); | |
| function getText() { | |
| var test = document.getElementById("expression").value | |
| var exp_str = test.toUpperCase(); //.replace(/\s/g,''); | |
| var input_character = exp_str.split(""); | |
| var acces = null; | |
| var f_state_mashine = input_character; | |
| var current_state = 1; | |
| f_state_mashine.forEach(function(element) { | |
| alert(current_state); | |
| switch (current_state){ | |
| case 1 : | |
| if (element == 0 ){ | |
| current_state = 2; | |
| } | |
| else { | |
| current_state = 1; | |
| } | |
| break; | |
| case 2 : | |
| if (element == 0 ){ | |
| current_state = 3; | |
| } | |
| else { | |
| current_state = 1; | |
| } | |
| break; | |
| case 3 : | |
| if (element == 0 ){ | |
| current_state = 3; | |
| } | |
| else { | |
| current_state = 4; | |
| } | |
| break; | |
| case 4 : | |
| if (element == 0 ){ | |
| current_state = 1; | |
| } | |
| else { | |
| current_state = 5; | |
| } | |
| break; | |
| case 5 : | |
| if (element == 0 ){ | |
| current_state = 1; | |
| } | |
| else { | |
| current_state = 6; | |
| } | |
| break; | |
| case 6 : | |
| if (element == 0 ){ | |
| current_state = 7; | |
| acces = current_state; | |
| } | |
| else { | |
| current_state = 7; | |
| acces = current_state; | |
| } | |
| break; | |
| case 7 : | |
| if (element == 0 ){ | |
| current_state = 1; | |
| } | |
| else { | |
| current_state = 1; | |
| } | |
| ; | |
| break; | |
| } | |
| }); | |
| if (f_state_mashine.toString().match(/[a-zA-Z]/) || f_state_mashine.toString().match(/[2-9]/)) { | |
| alert('Символ не входить до алфавіту виразу доступний алфавіт {0,1}'); | |
| f_state_mashine = 'Помилка'; | |
| } | |
| else if (acces == 7) | |
| { | |
| acces = "Допустити"; | |
| } | |
| else acces= "Не допускати"; | |
| document.getElementById('result').innerHTML = "<h1>" + acces + "</h1>"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment