26 lines
546 B
JavaScript
26 lines
546 B
JavaScript
let wiRes = {}
|
|
let wiCounter = 0
|
|
|
|
class wi {
|
|
static get res(){ return wiRes }
|
|
static set res(v){ wiRes = v}
|
|
static get c(){ return wiCounter }
|
|
static set c(v){ wiCounter = v }
|
|
|
|
static register(fun) {
|
|
const index = this.c++;
|
|
this.res[index] = fun;
|
|
return `wi.call(${index});`
|
|
}
|
|
static call(id) {
|
|
this.res[id]();
|
|
}
|
|
static reset(){
|
|
this.res = {}
|
|
this.c = 0
|
|
}
|
|
static publishFunction(name, fun){
|
|
window[name] = fun
|
|
return `${name}`
|
|
}
|
|
} |