File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6363 const ed = document . getElementById ( 'ed' ) ;
6464 const ln = document . getElementById ( 'ln' ) ;
6565
66- // Bloquea añadir más líneas después de la 99 (Enter o paste)
6766 ed . addEventListener ( 'keydown' , ( e ) => {
6867 if ( e . key === 'Enter' ) {
6968 const currentLines = ed . value . split ( '\n' ) . length ;
7675 const sync = ( ) => {
7776 let lines = ed . value . split ( '\n' ) ;
7877
79- // Si se intenta pasar de 99 (por paste, etc.), cortamos automáticamente
8078 if ( lines . length > 99 ) {
8179 ed . value = lines . slice ( 0 , 99 ) . join ( '\n' ) ;
8280 lines = ed . value . split ( '\n' ) ;
8381 }
8482
8583 const count = lines . length ;
86- // Números con 2 dígitos (01, 02, ..., 99)
84+
8785 ln . textContent = Array . from ( { length : count } , ( _ , i ) =>
8886 String ( i + 1 ) . padStart ( 2 , '0' )
8987 ) . join ( '\n' ) ;
9088
91- // Sincronizamos el scroll
9289 ln . scrollTop = ed . scrollTop ;
9390 } ;
9491
95- // El evento 'input' cubre escribir, borrar y pegar
9692 ed . oninput = sync ;
9793 ed . onscroll = sync ;
9894
99- // Inicialización inmediata
10095 sync ( ) ;
10196 </ script >
10297
You can’t perform that action at this time.
0 commit comments