mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Embedded javascript plugins (#1393)
This commit is contained in:
22
pkg/plugin/js/util.go
Normal file
22
pkg/plugin/js/util.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package js
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
func sleepFunc(call otto.FunctionCall) otto.Value {
|
||||
arg := call.Argument(0)
|
||||
ms, _ := arg.ToInteger()
|
||||
|
||||
time.Sleep(time.Millisecond * time.Duration(ms))
|
||||
return otto.UndefinedValue()
|
||||
}
|
||||
|
||||
func AddUtilAPI(vm *otto.Otto) {
|
||||
util, _ := vm.Object("({})")
|
||||
util.Set("Sleep", sleepFunc)
|
||||
|
||||
vm.Set("util", util)
|
||||
}
|
||||
Reference in New Issue
Block a user