Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 7.49 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Texthooker</title>
  4.     <script src="https://cdn.rawgit.com/lingtalfi/simpledrag/master/simpledrag.js"></script>
  5.     <style type="text/css">
  6.  
  7.     body {
  8.         background-color: #202020;
  9.         color: #BCBCBC;
  10.         height: 100%;
  11.     }
  12.  
  13.     .container {
  14.         position:fixed;
  15.         top:3px;
  16.         right:5px;
  17.         display:inline-block;
  18.     }
  19.  
  20.     .panes-container {
  21.         display: flex;
  22.         width: 100%;
  23.         overflow: hidden;
  24.     }
  25.        
  26.     .left-pane {
  27.         width: 18%;
  28.         background: #202020;
  29.     }
  30.  
  31.     .panes-separator {
  32.         width: 2%;
  33.         background: red;
  34.         position: relative;
  35.         cursor: col-resize;
  36.     }
  37.  
  38.     .right-pane {
  39.         flex: auto;
  40.         background: #202020;
  41.     }
  42.  
  43.     .panes-container,
  44.     .left-pane,
  45.     .right-pane {
  46.         margin: 0;
  47.         padding: 0;
  48.         height: 100%;
  49.     }
  50.        
  51.        
  52.         .panes-separator{
  53.             background-color: #181818;
  54.             width: 20px;
  55.         }
  56.        
  57.     #counter {
  58.         background-color:rgba(25,25,25,0.8);
  59.         color:#9d9d9d;
  60.         font-size:.4em;
  61.         line-height:100%;
  62.         float:left;
  63.         padding-left:8px;
  64.         padding-right:8px;
  65.         padding-top:5px;
  66.         padding-bottom:5px;
  67.     }
  68.  
  69.     #remove_button {
  70.         background-color:rgba(25,25,25,0.8);
  71.         color:#9d9d9d;
  72.         font-size:.4em;
  73.         line-height:100%;
  74.         float:right;
  75.         margin-right:10px;
  76.         padding-left:8px;
  77.         padding-right:8px;
  78.         padding-top:5px;
  79.         padding-bottom:5px;
  80.         cursor:pointer;
  81.         cursor:hand;
  82.     }
  83.  
  84.     </style>
  85.    
  86. </head>
  87. <body>
  88.  
  89.  
  90.     <div class="panes-container">
  91.     <div class="left-pane" id="left-pane">
  92.         allo
  93.        
  94.     </div>
  95.     <div class="panes-separator" id="panes-separator"></div>
  96.     <div class="right-pane" id="right-pane">
  97.         aaaaa
  98.     </div>
  99. </div>
  100.  
  101.     <div class="container">
  102.  
  103.     <!-- This is the div used for the "remove last line" button. -->
  104.         <div id="remove_button" title="Remove last line">x</div>
  105.     <!-- End button div. -->
  106.  
  107.     <!-- This is the div used for the counter. -->
  108.         <div id="counter" title="No. of characters / No. of lines">0 / 0</div>
  109.     <!-- End counter div. -->
  110.         </div>
  111.  
  112.  
  113.         <!-- jQuery is needed for the page to run. You can change this to an offline version if you prefer. -->
  114.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
  115.  
  116.         <script>
  117.  
  118.         var leftPane = document.getElementById('left-pane');
  119.         var rightPane = document.getElementById('right-pane');
  120.         var paneSep = document.getElementById('panes-separator');
  121.  
  122.            
  123.         // The script below constrains the target to move horizontally between a left and a right virtual boundaries.
  124.         // - the left limit is positioned at 10% of the screen width
  125.         // - the right limit is positioned at 90% of the screen width
  126.         var leftLimit = 10;
  127.         var rightLimit = 90;
  128.  
  129.            
  130.  
  131.          $(document).ready(function(){
  132.  
  133.         //The text inserter/scroller and the counter begin here.
  134.  
  135.         //These are needed later.
  136.         oldlines = 0;
  137.         chars = 0;
  138.  
  139.         //This listens for a node (line) to be inserted.
  140.         document.addEventListener("DOMNodeInserted", function () {
  141.           //Counter begins here. Get the current number of lines first.
  142.           var lines = leftPane.length;
  143.  
  144.           //Second, confirm whether the node insertion was a new line.
  145.           //(Rikai also inserts and removes a node (a div).)
  146.           var isnew = lines - oldlines;
  147.           if ( isnew > 0 ){
  148.               //If it is a new line, do a character count of the line and add it to the running tally.
  149.               var i=lines-1
  150.               var newline = leftPane[i].innerHTML;
  151.               var linechars = newline.length;
  152.               newchars = chars + linechars;
  153.  
  154.               //Make the numbers look nice.
  155.               var charsdisp = newchars.toLocaleString();
  156.               var linesdisp = lines.toLocaleString();
  157.  
  158.               //Print the new counts into the counter.
  159.               jQuery('#counter').text(charsdisp+' / '+linesdisp);
  160.  
  161.               //Get ready for the next line.
  162.               oldlines = lines;
  163.               chars = newchars;
  164.  
  165.               //The counter ends here and the text-scroller is below.
  166.               //I've included it in the "if new line" statement.
  167.               //(That is, it won't run unless a new line was added.)
  168.               //Like this it won't autoscroll down every time Rikai is used.
  169.  
  170.               var LEEWAY = 200; // Amount of "leeway" pixels before latching onto the bottom.
  171.  
  172.               // Some obscene browser shit because making sense is for dweebs
  173.               var b = document.body;
  174.               var offset = b.scrollHeight - b.offsetHeight;
  175.               var scrollPos = (b.scrollTop+offset);
  176.               var scrollBottom = (b.scrollHeight - (b.clientHeight+offset));
  177.  
  178.               // If we are at the bottom, go to the bottom again.
  179.               if (scrollPos >= scrollBottom - LEEWAY) {
  180.                  window.scrollTo(0,document.body.scrollHeight);
  181.               }
  182.  
  183.           }; //This is the end of the "if new line" statement.
  184.  
  185.         }, false);
  186.  
  187.         //End of scroller and counter script.
  188.  
  189.  
  190.         //Beginning of "remove last line" script.
  191.  
  192.         //Listen for click.
  193.         document.getElementById("remove_button").addEventListener("click", function() {
  194.  
  195.             //Check whether there are any lines.
  196.             var remove_lines = leftPane.length;
  197.             if ( remove_lines > 0 ){
  198.  
  199.                 //If there are, find the last line and do a character count.
  200.                 var q = remove_lines - 1;
  201.                 var last = leftPane[q].innerHTML;
  202.                 var lastlen = last.length;
  203.  
  204.                 //Remove the last line.
  205.                 $('body').children('p:last').remove();
  206.  
  207.                 //Update the counter.
  208.                 var newch = chars - lastlen;
  209.                 var newchdisp = newch.toLocaleString();
  210.                 var newl = oldlines - 1;
  211.                 var newldisp = newl.toLocaleString();
  212.                 jQuery('#counter').text(newchdisp+' / '+newldisp);
  213.  
  214.                 //Prepare for next line.
  215.                 chars = newch;
  216.                 oldlines = newl;
  217.             };
  218.         });
  219.  
  220.         //End of "remove last line" script.
  221.  
  222.         });  
  223.            
  224.            
  225.            
  226.            
  227.            
  228.         paneSep.sdrag(function (el, pageX, startX, pageY, startY, fix) {
  229.  
  230.             fix.skipX = true;
  231.  
  232.             if (pageX < window.innerWidth * leftLimit / 100) {
  233.                pageX = window.innerWidth * leftLimit / 100;
  234.                fix.pageX = pageX;
  235.            }
  236.            if (pageX > window.innerWidth * rightLimit / 100) {
  237.                 pageX = window.innerWidth * rightLimit / 100;
  238.                 fix.pageX = pageX;
  239.             }
  240.  
  241.             var cur = pageX / window.innerWidth * 100;
  242.             if (cur < 0) {
  243.                cur = 0;
  244.            }
  245.            if (cur > window.innerWidth) {
  246.                 cur = window.innerWidth;
  247.             }
  248.  
  249.  
  250.             var right = (100-cur-2);
  251.             leftPane.style.width = cur + '%';
  252.             rightPane.style.width = right + '%';
  253.  
  254.         }, null, 'horizontal');
  255.  
  256.            
  257.            
  258.        
  259.         </script>
  260.  
  261. </body>
  262. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement