File size: 1,020 Bytes
07bbbbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {fixHeightSetup} from './fixHeight';
import {HighlightAllOccurrencesOfString, highlightSetup} from './highlight';
import {wordPickerSetup} from './wordPicker';

export interface IframeGlobals {
    profileId: number;
    entryNo: number;
}

export function getIframeGlobals(cur_win: Window): IframeGlobals {
    return (cur_win as any).iframeGlobals as IframeGlobals;
}

export function iframeSetup(
    iframe: HTMLIFrameElement,
    profileId: number,
    entryNo: number,
    highlight?: string
  ): void {
    console.debug("Initializing iframe for profile_id:", profileId, "entry_no:", entryNo, "highlight:", highlight);
    let iframeGlobals: IframeGlobals = {
        profileId:profileId,
        entryNo:entryNo
    };
    (iframe.contentWindow as any).iframeGlobals = iframeGlobals;
    fixHeightSetup(iframe);
    highlightSetup(iframe);
    wordPickerSetup(iframe);
    // clickHandlerSetup(iframe);
    if (highlight) {
        HighlightAllOccurrencesOfString(iframe, highlight, 100, false);
    }
  }