From c6791d78dc93b32a32921f887054f958d9418f8f Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 21 Jan 2024 21:18:17 +0800 Subject: [PATCH] add chat.script --- base/mdb/mdb.go | 1 - core/chat/script.go | 3 +-- core/chat/script.js | 14 ++++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index dda1f386..a4e87b06 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -37,7 +37,6 @@ func _mdb_select(m *ice.Message, cb Any, key string, value Map, fields []string, if m.FieldsIsDetail() { m.Push(ice.FIELDS_DETAIL, value) } else { - m.Debug("what %v %v", value, val) m.Push(key, value, fields, val) } default: diff --git a/core/chat/script.go b/core/chat/script.go index a129106f..cee4deb1 100644 --- a/core/chat/script.go +++ b/core/chat/script.go @@ -12,8 +12,7 @@ func init() { Index.MergeCommands(ice.Commands{ SCRIPT: {Name: "script zone id auto", Help: "脚本化", Icon: "script.png", Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Name: "insert zone space index"}, - }, mdb.ImportantZoneAction(mdb.FIELDS, "time,id,space,index,play,status"), - ), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ImportantZoneAction(mdb.FIELDS, "time,id,space,index,play,status,style")), Hand: func(m *ice.Message, arg ...string) { if mdb.ZoneSelect(m.Options(mdb.CACHE_LIMIT, "30"), arg...).Display(""); len(arg) == 0 { m.PushAction(cli.RECORD, mdb.REMOVE).Action(mdb.CREATE, cli.STOP) } else { diff --git a/core/chat/script.js b/core/chat/script.js index 12236572..6eeec5b3 100644 --- a/core/chat/script.js +++ b/core/chat/script.js @@ -12,19 +12,21 @@ Volcanos(chat.ONACTION, { enable: function(event, can, msg) { can.runAction(event, mdb.MODIFY, [mdb.STATUS, mdb.ENABLE]) }, disable: function(event, can, msg) { can.runAction(event, mdb.MODIFY, [mdb.STATUS, mdb.DISABLE]) }, stop: function(event, can, msg) { can.misc.sessionStorage(can, SCRIPT_ZONE, ""), can.Update(event) }, - play: function(event, can) { can.core.Next(can._msg.Table(), function(value, next, index) { - can.Status(cli.STEP, index), can.user.toastProcess(can, `${value.index} ${value.play} ${index} / ${can._msg.Length()}`) + play: function(event, can) { var begin = new Date().getTime(); can.core.Next(can._msg.Table(), function(value, next, index, list) { + can.Status(cli.STEP, index), can.Status(cli.COST, can.base.Duration((new Date().getTime()-begin))) + can.user.toastProcess(can, `${can.core.Keys(value.space, value.index)} ${value.play} ${index}/${can._msg.Length()}`, "", index*100/list.length) var tr = can.page.Select(can, can._output, html.TR)[1]; can.onmotion.select(can, tr.parentNode, html.TR, index) value.status == mdb.DISABLE? next(): can.onaction.preview({}, can, can.request({}, value), next) - }, function() { can.user.toastSuccess(can) }) }, + }, function(list) { can.Status(cli.STEP, list.length), can.Status(cli.COST, can.base.Duration((new Date().getTime()-begin))), can.user.toastSuccess(can) }) }, preview: function(event, can, msg, next) { - can.onappend.plugin(can, {space: msg.Option(web.SPACE), index: msg.Option(ctx.INDEX)}, function(sub) { var done = false + can.onappend.plugin(can, {space: msg.Option(web.SPACE), index: msg.Option(ctx.INDEX), style: msg.Option(ctx.STYLE)}, function(sub) { var done = false function action(skip) { sub.Update(sub.request({}, {_handle: ice.TRUE}), [ctx.ACTION, msg.Option(cli.PLAY)], function(msg) { - sub.onimport._process(sub, msg) || msg.Length() == 0 && msg.Result() == "" || can.onappend._output(sub, msg), next && next() }) } + sub.onimport._process(sub, msg) || msg.Length() == 0 && msg.Result() == "" || can.onappend._output(sub, msg), next && next() + }) } can.onmotion.delay(can, function() { if (done || sub._auto) { return } done = true, action() }, 300) sub.onexport.output = function() { if (done) { return } done = true, action(true) can.page.style(can, sub._output, html.HEIGHT, "", html.MAX_HEIGHT, "") - }, can.onmotion.scrollIntoView(can, sub._target) + }, can.onmotion.delay(can, function() { can.onmotion.scrollIntoView(can, sub._target) }, 300) }) }, })