aboutsummaryrefslogtreecommitdiffstats
path: root/index.js
blob: ccfe99e1bb360fc0b1f80de1ae079bd431f84323 (plain) (blame)
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
// @ts-check
import Translate from './Translate.js'
import { createMenu, createDropDown, createEditorWidget } from './create.js'

const translate = new Translate("http://localhost:5000")

/**
 * Debounce
 * @param {(...args: any[]) => any} func 
 * @param {Number} timeout 
 * @returns {(...args:any[]) => void} 
 */

export function debounce(func, timeout) {
	var timer
	return function (...args) {
		clearTimeout(timer)
		timer = setTimeout(() => {
			func.apply(this, args)
		}, timeout)
	}
}
 /**
  * The Main Function
  */
async function main() {
	const menu = createMenu()
	const { source, target } = await createDropDown(menu, translate)
	await createEditorWidget(translate, source, target)
}

window.addEventListener("load", main)