https://www.giallorossi.net/wp-content/plugins/gr-comment-limit/assets/gr-comment-limit.js?ver=1.0.2
1( function () { 2 'use strict'; 3 4 var max = parseInt( grCL.max, 10 ); 5 var message = grCL.message; 6 7 document.addEventListener( 'DOMContentLoaded', function () { 8 var textarea = document.getElementById( 'comment' ); 9 if ( ! textarea ) return; 10 11 var form = textarea.closest( 'form' ); 12 if ( ! form ) return; 13 14 // --- Crea contatore --- 15 var counter = document.createElement( 'p' ); 16 counter.id = 'gr-cl-counter'; 17 counter.style.cssText = [ 18 'font-size: 12px', 19 'margin: 6px 0 0', 20 'transition: color .2s', 21 ].join( ';' ); 22 textarea.parentNode.insertBefore( counter, textarea.nextSibling ); 23 24 // --- Crea messaggio di errore (nascosto) --- 25 var errorBox = document.createElement( 'p' ); 26 errorBox.id = 'gr-cl-error'; 27 errorBox.style.cssText = [ 28 'display: none', 29 'color: #cc0000', 30 'font-size: 13px', 31 'font-weight: bold', 32 'margin: 8px 0 0', 33 ].join( ';' ); 34 errorBox.textContent = message; 35 counter.insertAdjacentElement( 'afterend', errorBox ); 36 37 function update() { 38 var len = textarea.value.length; 39 var left = max - len; 40 41 if ( left >= 0 ) { 42 counter.textContent = left + ' caratteri rimanenti su ' + max; 43 counter.style.color = left <= max * 0.1 ? '#e65c00' : '#888'; 44 errorBox.style.display = 'none'; 45 } else { 46 counter.textContent = Math.abs( left ) + ' caratteri in eccesso (limite: ' + max + ')'; 47 counter.style.color = '#cc0000'; 48 errorBox.style.display = 'block'; 49 } 50 } 51 52 // Aggiornamento in tempo reale 53 textarea.addEventListener( 'input', update ); 54 update(); 55 56 // Blocca il submit se oltre il limite 57 form.addEventListener( 'submit', function ( e ) { 58 if ( textarea.value.length > max ) { 59 e.preventDefault(); 60 textarea.focus(); 61 errorBox.style.display = 'block'; 62 errorBox.scrollIntoView( { behavior: 'smooth', block: 'nearest' } ); 63 } 64 } ); 65 } ); 66} )();
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.