Почему этот редирект / функция возвращает, если оператор не работает? - PullRequest
0 голосов
/ 14 марта 2019

Я работаю на терминале FAKE FRONT END. Это если заявление не работает для меня. Я использую https://codepen.io. Это использует HTML CSS и Js. Перенаправление / функция возвращают, если инструкция написана в js.

if (cmd == "pswd:********") {
   location.href = "http://google.com";
   return "Password Correct, Authorized as admin"
 }

Скажите, пожалуйста, почему это не работает?

Обратите внимание, что этот Js действительно тесно работает с HTML, а HTML тесно работает с CSS

Вот остаток JS:

// setup vars
var currentLine = "";
var typeSpeed = 70;
var pauseLength = 1000;
var Admin = false;

// get ref to DOM Elements
var cursor = $("#cursor");
var animate = $(".animate");
var input = $("#inputcmd");
var output = $("#output");

// set up Event Listeners
input.keypress(keypressInput);
$("#terminal-window").click(openKeyboard);

// hide text so we can animate it
animate.each(function(index) {
  $(this).addClass("hide");
});

// make first call to printCharaters() for animation
var temp = setTimeout(printCharaters, typeSpeed);

// this function animates printing of text inside DOMS with the .animate class.
function printCharaters() {
  // check if current line array is empty
  if (currentLine.length == 0) {
    // stop cursor from blinking
    cursor.removeClass("blink");

    // get first line of text and add it to an array
    currentLine = animate.first().text().split("");
    currentLine = currentLine.reverse();

    // remove text from dom and unhide element
    animate.first().html("");
    animate.first().removeClass("hide");
    cursor.appendTo(animate.first());
  }

  // animate typing
  animate.first().append(currentLine.pop()).append(cursor);

  // check if we just popped the last element of the array off
  if (currentLine.length == 0) {
    // remove animated DOM Element from animation
    animate.first().removeClass("animate");
    // get new list of DOM Elements to animate
    animate = $(".animate");
    // make cursor blink at the end-of-line.
    cursor.addClass("blink");

    // Animate next DOM Element if any remain
    if (animate.length > 0) {
      setTimeout(printCharaters, pauseLength);
    } else {
      // all text in the DOM Elements have been animated
      input.after(cursor);
      input.focus();
    }
  } else {
    // Animate next character in DOM Element
    setTimeout(printCharaters, typeSpeed);
  }
}

function keypressInput(e) {
  // received enter key, send cmd and clear input
  if (e.keyCode == 13) {
    var command = input.text();
    output.html(proccessCMD(command));
    input.html("");
    e.preventDefault();
  }
}

function proccessCMD(cmd) {
  cmd = cmd.trim().toLowerCase();
  //there is only one command here. But you get the idea. Plug in your API call here.
  //commands for basic users
  if (cmd == "--help") {
    return "try these command types: ls, cd ip, vpn, ping, date, time, cal, data, su, termlink_shutdown, termlink_boot, server, wi-fi, file, chat, reload, clear";
  }
  if (cmd == "ls /") {
    return "bin | src | lib | lib64 | dev | sbin"
  }
  if (cmd == "ls /bin") {
    return "license.txt | runtime | trash | archived"
  }
  if (cmd == "ls /bin /license") {
    return "This terminal may be shutdown at an unexpected time. We are not liable for amy damages. If you violate this terminal we can take you to a court of our choice. If you have any questions email us at ******.********@gmail.com. Thank you for using this terminal Terminal owned and operated by Nathan Schmitt"
  }
  if (cmd =="ls /bin /runtime") {
    return "runtime exception error! To debug type debug.exe"
  }
  if (cmd == "debug.exe") {
    return 'debuger loading....................................Complete --> Posabilities for an unexpected error: Failed to compile bootstrap files, your terminal sesion ended, your wi-fi has been disconnected, you have entered an incorrect or old command. "The computer is usualy not the problem, but is more likely you or your internet of things" --Bob Peeters. Some commands start or end with slashes. WHITE SPACE DOES COUNT AS AN IMPUT -All errors have been reported'
  }
  if (cmd == "ls /bin /trash") {
    return 'you must enter your admin password to view trash type "su" to enter admin terminal'
  }
  if (cmd == "ssid/pswd:") {
    return "you must be logged in as an admin to use this command!"
  }
  if (cmd == "shutdown") {
    return "you must be logged in as an admin to use this command!"
  }
  if (cmd == "ls /lib") {
    return "Librarry: you must be logged in as an admin to use this command! Use The 'file' or 'lib64' to acsess the non-admin librarry"
  }
  if (cmd == "ls /lib64") {
    return "your lib64: Readme.txt Lisence.txt Runtime.exe ls / cd home cd /create.  your shared lib64:[you have not shared any of your personal files to the public, use Termlink Pro to acsess the share option]  Public lib64: [Kittens.txt] [fun.txt] [why.txt] [termlink.txt] [termlinkPro.txt] Privatelib: you must be logged in as an admin to use this command! **use the file command to acsess lib64 files**"
  }
  if (cmd == "ls /sbin") {
    return "you must be logged in as an admin to use the sbin command"
  }
  if (cmd == "ls /dev") {
    return "terminal development by Nathan Schmitt the src is codepen.io. The terminal is not completed and is still in indev stages, shutdowns are to be expeted in the next month. Thank you for choosing FBI termlink"
  }
  if (cmd == "ls /bin /archived") {
    return "you must be logged in as an admin to use the sbin command"
  }
  if (cmd =="cd /") {
    return "cd /home cd /su cd /server"
  }
  if (cmd == "cd /home") {
    return "destanation reached [directory:'home']"
  }
  if (cmd == "cd /su") {
    return "you must be logged in as an admin to use this command"
  }
  if (cmd == "cd /server") {
    return "you are on server 1. Use termlink pro to get onto any server port! our terminal has 84 ports to choose from. Use 'cd /port' to chose your port. To see full server information you must be logged in as and admin"
  }
  if (cmd == "cd /port") {
    return "make a termlink pro acount today!"
  }
  if (cmd == "clear") {
    return " "
  }
  if (cmd == "reload") {
    return "reload succsessfull"
  }
  if (cmd == "ip") {
    return "ip adress fetching is blocked by your system adminastrator"
  }
  if (cmd == "vpn") {
    return "it seems you do not have a valid vpn"
  }
  if (cmd == "ping") {
    return "[100 packets sent] [87 packets pinged [13 packet loss]"
  }
  if (cmd == "Data") {
    return "server data could not be found on this server [server 1]"
  }
  if (cmd == "termlink_boot") {
  return "boot-up completed in 0.0243785 seconds"
}
if (cmd == "termlink_shutdown") {
  return "you are not allowed to do what you just did"
}
if (cmd == "wi-fi") {
  return "your router does not allow fetching of this data"
}
if (cmd == "file") {
  return "file /readme.txt file/ runtime.exe file/ lisence.txt file /kittens.txt file /myfiles"
}
//su verification
 if (cmd == "su") {
    return "Enter [SSID:YourSSID] to login. Enter 'SSID/PSWD:' to see SSID and Password."
 }
 if (cmd == "SSID:****") {
   return "Enter [PSWD:YourPSWD] to login."
 }
 if (cmd == "pswd:********") {
   location.href = "http://google.com";
   return "Password Correct, Authorized as admin"
 }

  //unkown commands
  return`Your command: [ ${cmd} ] is an unkown command. Some commands need a slash to function, Try[ ${cmd} /] If this fails type '--help' or '--list' for a list of commands or type debug.exe to help us resolve this server issue`

}
//open iOS keyboard
function openKeyboard(){
  input.focus();
}

Возвращает Cmd в HTML:

<div id="terminal-window">
  <span id="cursor"></span>
  <p>
    <span class="animate">FBI (TM) TERMLINK PROTOCOL INSTANTIATING</span>
  </p>
  <p>
    <span class="animate">PASSWORD REQUIRED</span>
  </p>
  <span class="animate">[Enter Password]>>></span>
  <span class="animate">******************************--Geust Password saved</span>
  <p>
  </p>
  <span class="animate">...</span><span class="animate">Acsess Granted!</span>
  <p>
  </p>
  <span class="animate"> To login as admin type "su"</span>
  <p>
  </p>
  <span class="animate"> (Termlink Terminal owned and operated by Nathan Schmittt) copyright(c) 2019 Termlink LLC</span>

  <p>
  </p>
  <span class="animate">[Enter Command]>>></span><span autofocus contenteditable="true" id="inputcmd"></span>
  <p><span id="output"></span></p>
</div>
<div class="scanlines"></div>

CSS просто -webkit-, что не важно для этого вопроса.

Только код подтверждения (JS):

//su verification
 if (cmd == "su") {
    return "Enter [SSID:YourSSID] to login. Enter 'SSID/PSWD:' to see SSID and Password."
 }
 if (cmd == "SSID:****") {
   return "Enter [PSWD:YourPSWD] to login."
 }
 if (cmd == "pswd:********") {
   location.href = "http://google.com";
   return "Password Correct, Authorized as admin"
 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...