Game_Logic

Black Market CMD (WIP)

Jun 25th, 2022 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. var cmenu = document.createElement("p"); document.body.appendChild(cmenu); cmenu.outerHTML=`<div hidden id="xyncmd"><div style="color:white;background:black; width: 700px;height: 400px;"><a>⠀Command Prompt (Black Market)</a><div>————————————————————————————————————————————</div><div>Cameron Windows [Version 10.0.19044.1766]</div><div>(c) Cameron Corporation. All rights reserved.</div>
  2. ⠀
  3. <div style="font-size:50; color:green;"><big id="output"></big></div></div><div id="divinput" style="background:black;color:white;width: 700px;">⠀&gt;⠀<input id="cmdinput" style="background:black;color:white;width: 670px;" placeholder="Enter command here..."></div></div>`;
  4.  
  5. var cmd = document.getElementById("xyncmd").outerHTML;
  6. // Make the DIV element draggable:
  7.  
  8. function dragElement(elmnt) {
  9. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  10. if (document.getElementById(elmnt.id + "header")) {
  11. // if present, the header is where you move the DIV from:
  12. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  13. } else {
  14. // otherwise, move the DIV from anywhere inside the DIV:
  15. elmnt.onmousedown = dragMouseDown;
  16. }
  17.  
  18. function dragMouseDown(e) {
  19. e = e || window.event;
  20. e.preventDefault();
  21. // get the mouse cursor position at startup:
  22. pos3 = e.clientX;
  23. pos4 = e.clientY;
  24. document.onmouseup = closeDragElement;
  25. // call a function whenever the cursor moves:
  26. document.onmousemove = elementDrag;
  27. }
  28.  
  29. function elementDrag(e) {
  30. e = e || window.event;
  31. e.preventDefault();
  32. // calculate the new cursor position:
  33. pos1 = pos3 - e.clientX;
  34. pos2 = pos4 - e.clientY;
  35. pos3 = e.clientX;
  36. pos4 = e.clientY;
  37. // set the element's new position:
  38. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  39. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  40. }
  41.  
  42. function closeDragElement() {
  43. // stop moving when mouse button is released:
  44. document.onmouseup = null;
  45. document.onmousemove = null;
  46. }
  47. };
  48.  
  49. window.addEventListener("keydown",checkKeyPressed,false)
  50.  
  51. function checkKeyPressed(evt) {
  52. if (evt.keyCode == "13") {
  53. testforcmd();
  54. };
  55. };
  56.  
  57. window.addEventListener("keyup",checkKeyPressedd,false)
  58.  
  59. function checkKeyPressedd(evt) {
  60. if (evt.keyCode == "88") {
  61. showcmd();
  62. };
  63. };
  64.  
  65. function showcmd() { document.getElementById("xyncmd").outerHTML = `<div id="xyncmd"><div style="color:white;background:black; width: 700px;height: 400px;"><a>⠀Command Prompt (Black Market)</a><div>————————————————————————————————————————————</div><div>Cameron Windows [Version 10.0.19044.1766]</div><div>(c) Cameron Corporation. All rights reserved.</div><div>(i) Type help for known commands.</div>
  66. ⠀
  67. <div style="font-size:50; color:green;"><big id="output"></big></div></div><div id="divinput" style="background:black;color:white;width: 700px;">⠀&gt;⠀<input id="cmdinput" style="background:black;color:white;width: 670px;" placeholder="Enter command here..."></div></div>`; };
  68.  
  69. function testforcmd() { var command = document.getElementById("cmdinput").value; if (command == "help") { document.getElementById("output").innerHTML = `Current Commands: help | addmoney | darkmodeon | darkmodeoff | close`; document.getElementById("cmdinput").value=""; return; }; if (command == "darkmodeon") { document.getElementsByClassName("row")[0].style = "background: #333"; document.getElementsByClassName("panel-body")[0].style = "background: #444"; document.getElementById("cmdinput").value=""; darkmodeon(); return }; if (command == "darkmodeoff") { document.getElementsByClassName("row")[0].style = "background: #eee"; document.getElementsByClassName("panel-body")[0].style = "background: #eee"; document.getElementById("cmdinput").value=""; darkmodeoff(); return; }; if (command == "close") { document.getElementById("xyncmd").outerHTML=`<div hidden id="xyncmd"><div style="color:white;background:black; width: 700px;height: 400px;"><a>⠀Command Prompt (Black Market)</a><div>————————————————————————————————————————————</div><div>Cameron Windows [Version 10.0.19044.1766]</div><div>(c) Cameron Corporation. All rights reserved.</div>
  70. ⠀
  71. <div style="font-size:50; color:green;"><big id="output"></big></div></div><div id="divinput" style="background:black;color:white;width: 700px;">⠀&gt;⠀<input id="cmdinput" style="background:black;color:white;width: 670px;" placeholder="Enter command here..."></div></div>`; document.getElementById("cmdinput").value=""; return; }; if (command.replace("addmoney ","") >= 0) { var finalcash = command.replace("addmoney ",""); gainMoney(Number(finalcash)); document.getElementById("output").innerHTML = `Successfully added `+command.replace("addmoney ","")+` to your money.`; document.getElementById("cmdinput").value=""; }; }; function darkmodeon() { document.getElementsByClassName("panel-body")[1].style="background:#444;"; document.getElementsByClassName("panel panel-default")[1].style="background:#444;";document.body.style=document.body.style+";color:#9f9;background:#333;"; };
Add Comment
Please, Sign In to add comment