-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_math.js
More file actions
21 lines (19 loc) · 787 Bytes
/
load_math.js
File metadata and controls
21 lines (19 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let spreadsheet_loaded = false;
if (window.o_spreadsheet && !spreadsheet_loaded) {
const ev = new CustomEvent("loadMath", { detail: { isSpreadsheet: !!window.o_spreadsheet } });
document.dispatchEvent(ev);
spreadsheet_loaded = true;
}
// Create an observer instance linked to the callback function
const observer = new MutationObserver((mutationList, observer) => {
if (window.o_spreadsheet && !spreadsheet_loaded) {
const ev = new CustomEvent("loadMath", { detail: { isSpreadsheet: !!window.o_spreadsheet } });
document.dispatchEvent(ev);
spreadsheet_loaded = true;
}
});
observer.observe(document, {
childList: true, // observe direct children
subtree: true, // and lower descendants too
characterDataOldValue: true // pass old data to callback
});