-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (41 loc) · 1.62 KB
/
script.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Display different example check images at the bottom of the layout
* depending on the class label selected
*/
const IMG_ID = 'img_uniq'
// TODO: use your own keys and values here for label lookup and data objects to display
const imagesRoot = '/static/custom-scripts/custom-scripts/show_different_images_based_on_label_selected/img'
const images = {
'Addressee': `${imagesRoot}/demo-addressee.jpg`,
'Account number': `${imagesRoot}/demo-routing-number.png`,
'Routing number': `${imagesRoot}/demo-routing-number.png`,
'Signature': `${imagesRoot}/demo-sign.jpg`,
'Amount': `${imagesRoot}/demo-amount.jpg`,
'Watermark': `${imagesRoot}/demo-watermark.png`,
'Date': `${imagesRoot}/demo-date.png`,
'Correction': `${imagesRoot}/demo-correction.jpg`,
}
function appendCheckImg() {
let imageEl = window[IMG_ID]
if (!imageEl) {
imageEl = document.createElement('img');
imageEl.id = IMG_ID
const labelingInterface = document.querySelector('.lsf-main-view__annotation');
if (labelingInterface) {
labelingInterface.insertAdjacentElement('beforeend', imageEl);
} else {
console.error('Labeling interface element not found.');
}
}
// `label` is an actual tag name from config
const labels = LSI.annotation.names.get('label').children
// If you will have more Labels in a future adjust the logic
document.querySelectorAll('.lsf-label_clickable').forEach(
(lbl, index) => lbl.addEventListener('click', () => {
const src = images[labels[index].value]
// if there are no images with this key image will just have an empty src
imageEl.src = src
})
)
}
appendCheckImg();