Guest User

For TigerBoy

a guest
May 2nd, 2015
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.23 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>For TigerBoy</title>
  5.     <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
  6.     <link rel="stylesheet" href="http://cdn.jsdelivr.net/semantic-ui/1.12.1/semantic.min.css">
  7.     <script src="http://cdn.jsdelivr.net/semantic-ui/1.12.1/semantic.min.js"></script>
  8. </head>
  9. <body style="width: 100%; overflow: scroll;">
  10.  
  11. <div class="ui centered grid">
  12.    
  13.     <div class="thirteen wide column" >
  14.        
  15.     <h1 style="margin: 30px 0;">Code Replace<small> for TigerBoy</small></h1>
  16.  
  17.     <form class="ui form">
  18.  
  19.         <div class="field" style="margin-top: 30px">
  20.             <label>Where to replace (Code)</label>
  21.             <textarea id="code"></textarea>
  22.         </div>
  23.  
  24.         <div class="ui grid">
  25.            
  26.             <div class="eight wide column">
  27.                 <div class="field">
  28.                     <label>Variables</label>
  29.                     <textarea id="vars"></textarea>
  30.                 </div>
  31.             </div>
  32.  
  33.             <div class="eight wide column">
  34.                 <div class="field">
  35.                     <label>To Replace</label>
  36.                     <input type="text" id="toReplace" placeholder="">
  37.                 </div>
  38.                 <div class="ui primary fluid button" onclick="javascript:nextVar();">
  39.                     Process Next Variable
  40.                 </div>
  41.                 <p>Processed Variable: <label id="processedVar"></label></p>
  42.                 <p>Next Variable: <label id="nextVar"></label></p>
  43.             </div>
  44.  
  45.         </div>
  46.  
  47.         <div class="field" style="margin-top: 30px">
  48.             <label>Replaced</label>
  49.             <textarea id="replaced"></textarea>
  50.         </div>
  51.     </form>
  52.    
  53.     </div>
  54.  
  55. </div>
  56.  
  57. <script type="text/javascript">
  58.    
  59.     var code = null;
  60.     var variables = null;
  61.     var toReplace = null;
  62.     var replaced = null;
  63.     var actualLine = 0;
  64.  
  65.     $(function(){
  66.         code = $('#code');
  67.         variables = $('#vars');
  68.         toReplace = $('#toReplace');
  69.         replaced = $('#replaced');
  70.     });
  71.  
  72.     function nextVar(){
  73.         var inLines = variables.val().split('\n');
  74.         if (inLines.length > actualLine){
  75.             $('#processedVar').html(inLines[actualLine]);
  76.             if (inLines.length > (actualLine + 1)){
  77.                 $('#nextVar').html(inLines[actualLine + 1]);
  78.             }
  79.             var actualVar = inLines[actualLine];
  80.             var myStr = code.val();
  81.             while (myStr.indexOf(toReplace.val()) != -1){
  82.                 myStr = myStr.replace(toReplace.val(), actualVar);
  83.             }
  84.             replaced.val(myStr);
  85.             ++actualLine;
  86.         }
  87.     }
  88.  
  89. </script>
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment