Advertisement
Guest User

Minecraft Command Replace

a guest
May 1st, 2015
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6.     <input type="text" id="IN" placeholder="Paste command here!" onchange="processCMD();">&nbsp;&nbsp;&nbsp;Min:
  7.     <input type="text" id="bot" value="1" style="width:30px;" onchange="processCMD();"> Max:
  8.     <input type="text" id="top" value="30" style="width:30px;" onchange="processCMD();">
  9.     <p id="OUT"></p>
  10.     <script>
  11.         var n, b, t, elem, accept, text, IN, OUT = document.getElementById("OUT");
  12.        
  13.         function update(tag) {
  14.             n = Number(document.getElementById(tag).value);
  15.             return(n);
  16.         }
  17.        
  18.         function processCMD() {
  19.             userIN = document.getElementById("IN").value;
  20.             modIN = userIN;
  21.             modIN = modIN.replace(/ID=\d+/g, 'ID=x');
  22.             modIN = modIN.replace(/ID_min=\d+/g, 'ID_min=x');
  23.             text = modIN + "<hr>";
  24.             b = update("bot");
  25.             t = update("top") + 1;
  26.            
  27.             for(i=b;i<t;i++) {
  28.                 cmd = modIN;
  29.                 cmd = cmd.replace(/ID=x/g, 'ID=' + i);
  30.                 cmd = cmd.replace(/ID_min=x/g, 'ID_min=' + i);
  31.                 text += "<span id='"+ i +"' data-clicked='' onmouseover='this.style.background=\"lightgreen\"' onmouseout='removeColour("+ i +");' onclick='copyPrompt("+ i +");'>"+ cmd +"</span><br>";
  32.             }
  33.             OUT.innerHTML = text;
  34.         }
  35.        
  36.         function removeColour(id) {
  37.             elem = document.getElementById(id);
  38.             if(elem.getAttribute("data-clicked") == "true") {
  39.                 elem.style.background = "#F75D59";
  40.             } else {
  41.                 elem.style.background = "none";
  42.             }
  43.         }
  44.        
  45.         function copyPrompt(id) {
  46.             elem = document.getElementById(id);
  47.             accept = prompt("Copy "+ id +" to clipboard: Ctrl+C, Enter", elem.innerHTML);
  48.             if (accept != null) {
  49.                 setTimeout(function(){elem.style.background = "#F75D59"; elem.setAttribute("data-clicked", "true");}, 1);
  50.             }
  51.         }
  52.     </script>
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement