script dry
This commit is contained in:
parent
de3440d715
commit
b15416afbf
1 changed files with 30 additions and 27 deletions
|
|
@ -54,17 +54,10 @@ class Script extends Widget {
|
|||
|
||||
if (this.getProp('event') === 'value') {
|
||||
|
||||
try {
|
||||
this.script = scriptVm.compile(this.getProp('script'), {
|
||||
id: '',
|
||||
value: 0
|
||||
})
|
||||
} catch(err) {
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
this.script = ()=>{}
|
||||
}
|
||||
this.compile({
|
||||
id: '',
|
||||
value: 0
|
||||
})
|
||||
|
||||
} else if (this.getProp('event') === 'keyboard' && this.getProp('keyBinding')) {
|
||||
|
||||
|
|
@ -76,22 +69,32 @@ class Script extends Widget {
|
|||
|
||||
})
|
||||
|
||||
try {
|
||||
this.script = scriptVm.compile(this.getProp('script'), {
|
||||
type: '',
|
||||
key: '',
|
||||
code: 0,
|
||||
ctrl: false,
|
||||
shift: false,
|
||||
alt: false,
|
||||
meta: false,
|
||||
})
|
||||
} catch(err) {
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
this.script = ()=>{}
|
||||
}
|
||||
this.compile({
|
||||
type: '',
|
||||
key: '',
|
||||
code: 0,
|
||||
ctrl: false,
|
||||
shift: false,
|
||||
alt: false,
|
||||
meta: false,
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
compîle(context) {
|
||||
|
||||
try {
|
||||
|
||||
this.script = scriptVm.compile(this.getProp('script'), context)
|
||||
|
||||
} catch(err) {
|
||||
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
this.script = ()=>{}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue