66 */
77
88import { make_tooltip } from '../terms/word_status' ;
9+ import { getAnnotation } from '../core/text_config' ;
10+ import { getDelimiter } from '../core/language_config' ;
911
1012/**
1113 * Helper to safely get an HTML attribute value as a string.
@@ -30,37 +32,6 @@ export function getAttrElement(el: HTMLElement, attr: string): string {
3032 return el . getAttribute ( attr ) || '' ;
3133}
3234
33- // Type definitions
34- interface LwtLanguage {
35- id : number ;
36- dict_link1 : string ;
37- dict_link2 : string ;
38- translator_link : string ;
39- delimiter : string ;
40- rtl : boolean ;
41- }
42-
43- interface LwtText {
44- id : number ;
45- reading_position : number ;
46- annotations : Record < string , [ unknown , string , string ] > ;
47- }
48-
49- interface LwtSettings {
50- jQuery_tooltip : boolean ;
51- hts : number ;
52- word_status_filter : string ;
53- annotations_mode : number ;
54- }
55-
56- interface LwtDataGlobal {
57- language : LwtLanguage ;
58- text : LwtText ;
59- settings : LwtSettings ;
60- }
61-
62- declare const LWT_DATA : LwtDataGlobal ;
63-
6435/**
6536 * Add annotations to a word.
6637 */
@@ -70,13 +41,15 @@ export function word_each_do_text_text(
7041 const wid = getAttr ( this , 'data_wid' ) ;
7142 if ( wid !== '' ) {
7243 const order = getAttr ( this , 'data_order' ) ;
73- if ( order in LWT_DATA . text . annotations ) {
74- if ( wid === LWT_DATA . text . annotations [ order ] [ 1 ] ) {
75- const ann = LWT_DATA . text . annotations [ order ] [ 2 ] ;
44+ const annotation = getAnnotation ( order ) ;
45+ if ( annotation ) {
46+ if ( wid === annotation [ 1 ] ) {
47+ const ann = annotation [ 2 ] ;
48+ const delimiter = getDelimiter ( ) ;
7649 const re = new RegExp (
77- '([' + LWT_DATA . language . delimiter + '][ ]{0,1}|^)(' +
50+ '([' + delimiter + '][ ]{0,1}|^)(' +
7851 ann . replace ( / [ - / \\ ^ $ * + ? . ( ) | [ \] { } ] / g, '\\$&' ) + ')($|[ ]{0,1}[' +
79- LWT_DATA . language . delimiter + '])' ,
52+ delimiter + '])' ,
8053 ''
8154 ) ;
8255 const dataTrans = getAttr ( this , 'data_trans' ) ;
@@ -88,14 +61,13 @@ export function word_each_do_text_text(
8861 }
8962 }
9063 }
91- if ( ! LWT_DATA . settings . jQuery_tooltip ) {
92- this . title = make_tooltip (
93- this . textContent || '' ,
94- getAttr ( this , 'data_trans' ) ,
95- getAttr ( this , 'data_rom' ) ,
96- getAttr ( this , 'data_status' ) || '0'
97- ) ;
98- }
64+ // Native tooltips are always used (jQuery tooltips removed)
65+ this . title = make_tooltip (
66+ this . textContent || '' ,
67+ getAttr ( this , 'data_trans' ) ,
68+ getAttr ( this , 'data_rom' ) ,
69+ getAttr ( this , 'data_status' ) || '0'
70+ ) ;
9971}
10072
10173/**
@@ -111,15 +83,17 @@ export function mword_each_do_text_text(
11183 const wid = getAttr ( this , 'data_wid' ) ;
11284 if ( wid !== '' ) {
11385 const order = parseInt ( getAttr ( this , 'data_order' ) || '0' , 10 ) ;
86+ const delimiter = getDelimiter ( ) ;
11487 for ( let j = 2 ; j <= 16 ; j = j + 2 ) {
11588 const index = ( order + j ) . toString ( ) ;
116- if ( index in LWT_DATA . text . annotations ) {
117- if ( wid === LWT_DATA . text . annotations [ index ] [ 1 ] ) {
118- const ann = LWT_DATA . text . annotations [ index ] [ 2 ] ;
89+ const annotation = getAnnotation ( index ) ;
90+ if ( annotation ) {
91+ if ( wid === annotation [ 1 ] ) {
92+ const ann = annotation [ 2 ] ;
11993 const re = new RegExp (
120- '([' + LWT_DATA . language . delimiter + '][ ]{0,1}|^)(' +
94+ '([' + delimiter + '][ ]{0,1}|^)(' +
12195 ann . replace ( / [ - / \\ ^ $ * + ? . ( ) | [ \] { } ] / g, '\\$&' ) + ')($|[ ]{0,1}[' +
122- LWT_DATA . language . delimiter + '])' ,
96+ delimiter + '])' ,
12397 ''
12498 ) ;
12599 const dataTrans = getAttr ( this , 'data_trans' ) ;
@@ -133,14 +107,13 @@ export function mword_each_do_text_text(
133107 }
134108 }
135109 }
136- if ( ! LWT_DATA . settings . jQuery_tooltip ) {
137- this . title = make_tooltip (
138- getAttr ( this , 'data_text' ) ,
139- getAttr ( this , 'data_trans' ) ,
140- getAttr ( this , 'data_rom' ) ,
141- getAttr ( this , 'data_status' ) || '0'
142- ) ;
143- }
110+ // Native tooltips are always used (jQuery tooltips removed)
111+ this . title = make_tooltip (
112+ getAttr ( this , 'data_text' ) ,
113+ getAttr ( this , 'data_trans' ) ,
114+ getAttr ( this , 'data_rom' ) ,
115+ getAttr ( this , 'data_status' ) || '0'
116+ ) ;
144117 }
145118}
146119
0 commit comments