forked from x/icebergs
add tutor
This commit is contained in:
parent
95ef705c49
commit
fd324e5f14
@ -14,7 +14,7 @@ func init() {
|
||||
web.Index.Register(Index, &web.Frame{},
|
||||
HEADER, FOOTER,
|
||||
IFRAME, FAVOR,
|
||||
MESSAGE,
|
||||
MESSAGE, TUTOR,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,8 @@ Volcanos(chat.ONIMPORT, {
|
||||
}); can.page.style(can, carte._target, html.TOP, event.y) },
|
||||
}) }) },
|
||||
_window: function(can, item, cb) { if (!item.index) { return }
|
||||
item.height = can.ConfHeight()-125, item.width = can.ConfWidth()-200, item.left = (can.ConfWidth()-item.width)/2, item.top = 25
|
||||
if (can.ConfWidth() > 1400) { item.width = can.base.Min(can.ConfWidth()-600, 640, 1400), item.left = (can.ConfWidth()-item.width)/2 }
|
||||
if (can.ConfWidth() < 1000) { item.width = can.ConfWidth(), item.left = 0 }
|
||||
if (can.ConfHeight() > 800) { item.height = can.base.Min(can.ConfHeight()-200, 320, 800), item.top = 50 }
|
||||
if (can.user.isMobile) { item.height = can.ConfHeight()-125, item.top = 25, item.width = can.ConfWidth(), item.left = 0 }
|
||||
item.height = can.base.Max(html.DESKTOP_HEIGHT, item.height), item.width = can.base.Max(html.DESKTOP_WIDTH, item.width)
|
||||
item.height = can.base.Max(html.DESKTOP_HEIGHT, can.ConfHeight()-125), item.width = can.base.Max(html.DESKTOP_WIDTH, can.ConfWidth())
|
||||
item.left = (can.ConfWidth()-item.width)/2, item.top = (can.ConfHeight()-item.height-125)/4+25
|
||||
item.type = html.PLUGIN, item.style = {left: item.left, top: item.top, height: item.height, width: item.width}
|
||||
can.onappend.plugin(can, item, function(sub) { can.onappend.style(can, html.FLOAT, sub._target), can.ondetail.select(can, sub._target)
|
||||
can.page.style(can, sub._target, html.HEIGHT, item.height, html.WIDTH, item.width)
|
||||
|
24
core/chat/tutor.go
Normal file
24
core/chat/tutor.go
Normal file
@ -0,0 +1,24 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
)
|
||||
|
||||
const TUTOR = "tutor"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TUTOR: {Name: "tutor zone id auto", Help: "向导", Actions: mdb.ZoneAction(
|
||||
mdb.SHORT, "zone", mdb.FIELD, "time,zone", mdb.FIELDS, "time,id,type,name,text",
|
||||
), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.ZoneSelect(m, arg...); len(arg) == 0 {
|
||||
m.Push(mdb.TIME, m.Time()).Push(mdb.ZONE, "_current")
|
||||
} else {
|
||||
m.Action(cli.PLAY)
|
||||
}
|
||||
m.Display("")
|
||||
}},
|
||||
})
|
||||
}
|
42
core/chat/tutor.js
Normal file
42
core/chat/tutor.js
Normal file
@ -0,0 +1,42 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
if (can.Option(mdb.ZONE) == "_current") {
|
||||
can._root.Footer.db.tutor.Table(function(value) { msg.Push(value) }), msg.PushAction("show")
|
||||
}
|
||||
msg.Dump(can)
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONACTION, {
|
||||
play: function(can) {
|
||||
can.core.Next(can._msg.Table(), function(value, next, index) {
|
||||
can.onaction.show(can, value.type, value.text), can.onmotion.delay(can, next, 3000)
|
||||
can.onmotion.select(can, can.page.SelectOne(can, can._output, "tbody"), html.TR, index)
|
||||
}, function() {
|
||||
can.user.toastSuccess(can, "play done")
|
||||
})
|
||||
},
|
||||
show: function(can, type, text) {
|
||||
switch (type) {
|
||||
case "storm": var ls = text.split(",")
|
||||
can._root.River.onaction.action({}, can._root.River, ls[0], ls[1])
|
||||
break
|
||||
case "theme":
|
||||
can._root.Header.onimport.theme(can._root.Header, text, {})
|
||||
break
|
||||
case "remove":
|
||||
can.page.Select(can, document.body, text, function(target) {
|
||||
can.page.Remove(can, target)
|
||||
})
|
||||
break
|
||||
case "click":
|
||||
can.page.Select(can, document.body, text, function(target) {
|
||||
target.click()
|
||||
can.page.ClassList.add(can, target, "picker")
|
||||
can.onmotion.delay(can, function() {
|
||||
can.page.ClassList.del(can, target, "picker")
|
||||
}, 3000)
|
||||
})
|
||||
break
|
||||
}
|
||||
},
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user