1(function ($) { 2 $.fn.extend({ 3 limit: function () { 4 var $this = $(this); 5 var interval; 6 var limit = $this.attr('maxlength'); 7 var limitTextBox = $this.parent().find('.limitTextBoxBar'); 8 var limitTextBoxInner = limitTextBox.find('.limitTextBoxBarInner'); 9 var limitTextBoxInfoWrpr = limitTextBox.find('.limitTextBoxBarInfoWrpr'); 10 11 limitTextBoxInner.html(" "); 12 13 $this.focus(function () { 14 interval = window.setInterval(applyLimit, 100); 15 }) 16 17 $this.blur(function () { 18 clearInterval(interval); 19 applyLimit(); 20 }); 21 22 applyLimit(); 23 24 function getNewLineCount(text) { 25 var newLineMatch = text.match(/\n/g); 26 27 if (newLineMatch) 28 return newLineMatch.length; 29 30 return 0; 31 } 32 33 function applyLimit() { 34 var val = $this.val(); 35 var valClean = val.replace(/\r\n?|\n/g, "\r\n"); 36 var length = valClean.length; 37 var diff = limit - length; 38 var originalscroll = $this.scrollTop(); 39 40 if (length > limit) { 41 if (valClean.substring(valClean.length - 1) == '\n') { 42 valClean = valClean.substring(0, limit - 1); 43 } else { 44 valClean = valClean.substring(0, limit); 45 } 46 valClean = valClean.replace(/\r\n/g, "\n"); 47 $this.val(valClean); 48 $this.scrollTop(originalscroll); 49 } 50 51 if (limitTextBoxInner.html() != limit - length) { 52 var percent = Math.round(100 - (diff / limit) * 100); 53 limitTextBoxInner.css('width', percent + '%'); 54 } 55 56 if (diff < 0) 57 diff = 0; 58 59 limitTextBoxInfoWrpr.html(diff + ' character' + (diff != 1 ? 's' : '') + ' left'); 60 } 61 } 62 }); 63})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.