@@ -644,51 +644,31 @@ if (document.readyState === 'complete' || document.readyState !== 'loading' && !
644
644
'\n FROM patient_diagnosis) A LEFT JOIN ' +
645
645
'\n (SELECT icd9_code, icd9_description FROM icd9_mapping) B' +
646
646
'\n ON A.diagnosis_code = B.icd9_code;' ;
647
-
648
- var _buffer ;
649
- function countLines ( textarea ) {
650
- if ( _buffer == null ) {
651
- _buffer = document . createElement ( 'textarea' ) ;
652
- _buffer . style . border = 'none' ;
653
- _buffer . style . height = '0' ;
654
- _buffer . style . overflow = 'hidden' ;
655
- _buffer . style . padding = '0' ;
656
- _buffer . style . position = 'absolute' ;
657
- _buffer . style . left = '0' ;
658
- _buffer . style . top = '0' ;
659
- _buffer . style . zIndex = '-1' ;
660
- document . body . appendChild ( _buffer ) ;
661
- }
662
- let cs = window . getComputedStyle ( textarea ) ;
663
- let pl = parseInt ( cs . paddingLeft ) ;
664
- let pr = parseInt ( cs . paddingRight ) ;
665
- let lh = parseInt ( cs . lineHeight ) ;
666
- if ( isNaN ( lh ) ) lh = parseInt ( cs . fontSize ) ;
667
- _buffer . style . width = ( textarea . clientWidth - pl - pr ) + 'px' ;
668
- _buffer . style . font = cs . font ;
669
- _buffer . style . letterSpacing = cs . letterSpacing ;
670
- _buffer . style . whiteSpace = cs . whiteSpace ;
671
- _buffer . style . wordBreak = cs . wordBreak ;
672
- _buffer . style . wordSpacing = cs . wordSpacing ;
673
- _buffer . style . wordWrap = cs . wordWrap ;
674
-
675
- _buffer . value = textarea . value ;
676
-
677
- let result = Math . floor ( _buffer . scrollHeight / lh ) ;
678
- if ( result == 0 ) result = 1 ;
679
- return result ;
680
- }
681
- var onFirstLoad = true ;
682
- var lineCountCache = 0 ;
683
- var outArrCache = new Array ( ) ;
684
- async function line_counter ( ) {
685
- let lineCount = codeEditor . value . split ( '\n' ) . length ;
647
+ /*
648
+ SELECT patient_id,diagnosis_code,icd9_description
649
+ FROM
650
+ (SELECT patient_id, diagnosis_code FROM patient_diagnosis) A LEFT JOIN (SELECT icd9_code, icd9_description FROM icd9_mapping) B
651
+ ON A.diagnosis_code = B.icd9_code;
652
+ */
653
+ const codeEditorWidth = document . querySelector ( '#codeEditor' ) . clientWidth ;
654
+ const lineCounterWidth = document . querySelector ( '#lineCounter' ) . clientWidth ;
655
+ const codeEditorEditableWidth = codeEditorWidth - lineCounterWidth - 5 ;
656
+
657
+ function line_counter ( ) {
658
+ let lines = codeEditor . value . split ( '\n' ) ;
659
+ let lineCount = lines . length ;
686
660
let outarr = new Array ( ) ;
687
- for ( var x = 0 ; x < lineCount ; x ++ ) {
688
- outarr [ x ] = ( x + 1 ) + '.' ;
661
+ for ( let x = 0 ; x < lineCount ; x ++ ) {
662
+ if ( ( lines [ x ] . length * 8 ) + 5 > codeEditorEditableWidth ) {
663
+ outarr . push ( `${ parseInt ( x + 1 ) } .` ) ;
664
+ let nbWrap = Math . floor ( ( ( lines [ x ] . length * 8 ) + 5 ) / codeEditorEditableWidth ) ;
665
+ for ( let y = 0 ; y < nbWrap ; y ++ ) {
666
+ outarr . push ( ' ' ) ;
667
+ }
668
+ } else {
669
+ outarr . push ( `${ parseInt ( x + 1 ) } .` ) ;
670
+ }
689
671
}
690
- await Promise . resolve ( outarr ) ;
691
- lineCountCache = lineCount ;
692
672
lineCounter . value = outarr . join ( '\n' ) ;
693
673
}
694
674
codeEditor . addEventListener ( 'scroll' , ( ) => {
0 commit comments