Game_Logic

Black Market CMD (WIP)

Jun 25th, 2022 (edited)
129
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. <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>`;
  3.  
  4. var cmd = document.getElementById("xyncmd").outerHTML;
  5. // Make the DIV element draggable:
  6.  
  7. function dragElement(elmnt) {
  8. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  9. if (document.getElementById(elmnt.id + "header")) {
  10. // if present, the header is where you move the DIV from:
  11. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  12. } else {
  13. // otherwise, move the DIV from anywhere inside the DIV:
  14. elmnt.onmousedown = dragMouseDown;
  15. }
  16.  
  17. function dragMouseDown(e) {
  18. e = e || window.event;
  19. e.preventDefault();
  20. // get the mouse cursor position at startup:
  21. pos3 = e.clientX;
  22. pos4 = e.clientY;
  23. document.onmouseup = closeDragElement;
  24. // call a function whenever the cursor moves:
  25. document.onmousemove = elementDrag;
  26. }
  27.  
  28. function elementDrag(e) {
  29. e = e || window.event;
  30. e.preventDefault();
  31. // calculate the new cursor position:
  32. pos1 = pos3 - e.clientX;
  33. pos2 = pos4 - e.clientY;
  34. pos3 = e.clientX;
  35. pos4 = e.clientY;
  36. // set the element's new position:
  37. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  38. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  39. }
  40.  
  41. function closeDragElement() {
  42. // stop moving when mouse button is released:
  43. document.onmouseup = null;
  44. document.onmousemove = null;
  45. }
  46. };
  47.  
  48. window.addEventListener("keydown",checkKeyPressed,false)
  49.  
  50. function checkKeyPressed(evt) {
  51. if (evt.keyCode == "13") {
  52. testforcmd();
  53. };
  54. };
  55.  
  56. window.addEventListener("keyup",checkKeyPressedd,false)
  57.  
  58. function checkKeyPressedd(evt) {
  59. if (evt.keyCode == "88") {
  60. showcmd();
  61. };
  62. };
  63.  
  64. 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>
  65. <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>`; };
  66.  
  67. 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>
  68. <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