mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt chat.div
This commit is contained in:
parent
d63400810b
commit
3c80826682
6
frame.js
6
frame.js
@ -214,11 +214,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
||||
, "", action)})
|
||||
return meta
|
||||
},
|
||||
_output: function(can, meta, event, cmds, cb, silent) {
|
||||
var msg = can.request(event); can.page.Select(can, can._output, "div.control .args", function(item) {
|
||||
item.name && item.value && msg.Option(item.name, item.value)
|
||||
})
|
||||
|
||||
_output: function(can, meta, event, cmds, cb, silent) { var msg = can.request(event)
|
||||
if (msg.Option("_handle") != "true" && cmds && cmds[0] == ctx.ACTION && can.onaction[cmds[1]]) {
|
||||
return msg.Option("_handle", "true"), can.core.CallFunc(can.onaction[cmds[1]], {event: event, can: can, msg: msg, cmd: cmds[1]})
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, meta,
|
||||
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE, kit.MDB_TYPE, aaa.LOGIN])
|
||||
},
|
||||
share: function(event, can, arg) {
|
||||
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE].concat(arg))
|
||||
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE].concat(arg||[]))
|
||||
},
|
||||
usernick: function(event, can) {
|
||||
can.user.input(event, can, [{name: aaa.USERNICK, value: can.Conf(aaa.USERNAME)}], function(ev, button, data, list, args) {
|
||||
|
@ -210,9 +210,9 @@ Volcanos("ondetail", {help: "菜单交互", list: ["共享群组", "添加用户
|
||||
"保存参数": function(event, can, button, river, storm) {
|
||||
can.search(event, ["Action.onexport.args"], function(item, next, index, array) {
|
||||
var msg = can.request({}, {hash: storm, id: item.dataset.id})
|
||||
var toast = can.user.toast(can, (index+1)+"/"+array.length, "保存参数", 10000, (index+1)/array.length)
|
||||
can.run(msg._event, [river, chat.TOOL, ctx.ACTION, mdb.MODIFY, cli.ARG, item.dataset.args], function(msg) {
|
||||
can.user.toast(can, (index+1)+"/"+array.length, "保存参数", 10000, (index+1)/array.length)
|
||||
next()
|
||||
toast.close(), next()
|
||||
})
|
||||
})
|
||||
},
|
||||
|
@ -3,40 +3,24 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
||||
can._meta = can.base.Obj(meta.text, {meta: {name: meta.name}, list: []})
|
||||
can.base.isFunc(cb) && cb(msg)
|
||||
|
||||
can.ui = can.page.Appends(can, target, [{type: "table", list: [{type: "tr", list: [
|
||||
var width = can.Conf("width")-260, height = can.Conf("height")-100
|
||||
if (location.pathname.indexOf("/chat/cmd") == 0) {
|
||||
width = window.innerWidth, height = window.innerHeight
|
||||
can.page.Modify(can, target, {style: {width: width, height: height}})
|
||||
}
|
||||
|
||||
can.ui = can.page.Appends(can, target, [{view: ["layout", "table"], list: [{type: "tr", list: [
|
||||
{type: "td", list: [{view: "project"}]},
|
||||
{type: "td", list: [{view: "display"}]},
|
||||
{type: "td", list: [{view: "profile"}]},
|
||||
]}] }])
|
||||
]}] }]), can.ui.project._fieldset = can.ui.display
|
||||
|
||||
can.ui.project._fieldset = can.ui.display
|
||||
can.onimport._item(can, can._meta, can.ui.project).click()
|
||||
if (location.pathname.indexOf("/chat/cmd") == 0) {
|
||||
|
||||
}
|
||||
can.onimport._item(can, can._meta, can.ui.project, width).click()
|
||||
},
|
||||
_field: function(can, meta, target) {
|
||||
var field = can.onappend.field(can, "layout", {width: meta.width, height: meta.height}, target).fieldset
|
||||
can.page.Modify(can, field, {style: can.base.Copy({}, meta, "width", "height")})
|
||||
can.page.ClassList.add(can, field, meta.style)
|
||||
meta.index && can.run(event, [ctx.ACTION, ctx.COMMAND, meta.index], function(msg) {
|
||||
can.onappend._init(can, {
|
||||
feature: can.base.Obj(msg.Append("meta")),
|
||||
inputs: can.base.Obj(msg.Append("list")),
|
||||
width: meta.width, height: meta.height,
|
||||
args: meta.args,
|
||||
}, ["/plugin/state.js"], function(sub) {
|
||||
can.page.Modify(can, sub._output, {style: {width: meta.width}})
|
||||
sub.run = function(event, cmds, cb) {
|
||||
can.run(event, [ctx.ACTION, cli.RUN, meta.index].concat(cmds), cb, true)
|
||||
}
|
||||
}, target, field)
|
||||
}, true)
|
||||
return field
|
||||
},
|
||||
_item: function(can, node, target) {
|
||||
_item: function(can, node, target, width) {
|
||||
width = node.meta.width||width
|
||||
var ui = can.page.Append(can, target, [{view: ["item", "div", node.meta.name]}, {view: ["list"]}])
|
||||
ui.list._fieldset = can.onimport._field(can, node.meta, target._fieldset)
|
||||
ui.list._fieldset = can.onimport._field(can, node.meta, target._fieldset, width)
|
||||
|
||||
var msg = can.request({}); msg.Push(node.meta, "", true)
|
||||
ui.item.onclick = function(event) {
|
||||
@ -44,19 +28,40 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
||||
can.current = ui.item, can.onmotion.clear(can, can.ui.profile)
|
||||
can.onappend.table(can, msg, function(value, key, index, line, array) {
|
||||
return {text: [value, "td"], ondblclick: function(event) {
|
||||
can.onmotion.modifys(can, event.target, function(event, value, old) {
|
||||
node.meta[key == "value"? line.key: key] = value
|
||||
key == "value" && can.onmotion.modifys(can, event.target, function(event, value, old) {
|
||||
node.meta[line.key] = value
|
||||
})
|
||||
}}
|
||||
}, can.ui.profile)
|
||||
}
|
||||
ui.item._add = function(data) {
|
||||
node.list.push(data)
|
||||
can.onimport._item(can, data, ui.list)
|
||||
|
||||
ui.item._add = function(data) { node.list.push(data)
|
||||
can.onimport._item(can, data, ui.list, width)
|
||||
}
|
||||
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list) })
|
||||
if (node.meta.style == "left") { width = width / node.list.length }
|
||||
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
|
||||
return ui.item
|
||||
},
|
||||
_field: function(can, meta, target, width) {
|
||||
var size = {width: width, height: meta.height}
|
||||
var field = can.onappend.field(can, "layout", {}, target).fieldset
|
||||
can.page.ClassList.add(can, field, meta.style)
|
||||
can.page.Modify(can, field, {style: size})
|
||||
|
||||
meta.index && can.run(event, [ctx.ACTION, ctx.COMMAND, meta.index], function(msg) {
|
||||
can.onappend._init(can, can.base.Copy({
|
||||
feature: can.base.Obj(msg.Append("meta")),
|
||||
inputs: can.base.Obj(msg.Append("list")),
|
||||
args: meta.args,
|
||||
}, size), ["/plugin/state.js"], function(sub) {
|
||||
can.page.Modify(can, sub._output, {style: size})
|
||||
sub.run = function(event, cmds, cb) {
|
||||
can.run(event, [ctx.ACTION, cli.RUN, meta.index].concat(cmds), cb, true)
|
||||
}
|
||||
}, target, field)
|
||||
}, true)
|
||||
return field
|
||||
},
|
||||
}, ["/plugin/local/chat/div.css"])
|
||||
Volcanos("onaction", {help: "操作数据", list: [],
|
||||
"添加": function(event, can) {
|
||||
@ -70,10 +75,7 @@ Volcanos("onaction", {help: "操作数据", list: [],
|
||||
}, true)
|
||||
},
|
||||
"预览": function(event, can) {
|
||||
can.page.Modify(can, can.ui.display, {style: {
|
||||
position: "fixed", left: 0, top: 0, "z-index": 10, "background": "gray",
|
||||
width: window.innerWidth, height: window.innerHeight,
|
||||
}})
|
||||
can.run(event, [ctx.ACTION, "生成链接"], function() {}, true)
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
@ -93,7 +93,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
||||
var figure = can.onfigure[value.shape]
|
||||
var data = figure.draw(event, can, value.point, value.style)
|
||||
can.core.Item(value.style, function(key, value) { data[key] = value })
|
||||
return can.onfigure._push(can, data, value.shape, can.group||can.svg)
|
||||
var item = can.onfigure._push(can, data, value.shape, can.group||can.svg)
|
||||
value._init && value._init(item)
|
||||
return item
|
||||
},
|
||||
|
||||
ondblclick: function(event, can) {
|
||||
|
@ -48,9 +48,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
||||
can.run(event, (cmds && can.onengine[cmds[0]]? []: [ctx.ACTION, "story", data.type, data.name, data.text]).concat(cmds), cb, true)
|
||||
}
|
||||
|
||||
can.page.Modify(can, sub._output, {style: {"max-width": item.width}})
|
||||
sub.Conf("width", item.width=can.Conf("width")-20)
|
||||
can.onengine.listen(can, "onaction_resize", function(width, height) {
|
||||
can.page.Modify(can, sub._output, {style: {"max-width": sub.Conf("width", item.width=width-60)}})
|
||||
can.page.Modify(can, sub._output, {style: {"max-width": sub.Conf("width", item.width=width-80)}})
|
||||
})
|
||||
}, can._output, target)
|
||||
},
|
||||
|
@ -51,99 +51,90 @@ Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "趋势图
|
||||
},
|
||||
"趋势图": function(event, can) {
|
||||
var space = 10
|
||||
var view = parseInt(can.Action("height"))
|
||||
var max = parseInt(can.Conf("width"))-2*space
|
||||
var step = parseInt(max / (can.list.length+1))||2
|
||||
|
||||
var height = view + space * 2
|
||||
var width = can.list.length * step + space * 2
|
||||
can.draw.svg.Val("width", width-space*2+5)
|
||||
can.draw.svg.Val("height", height)
|
||||
|
||||
function scale(y) { return (y - can.min)/(can.max - can.min)*view }
|
||||
var width = parseInt(can.Conf("width"))
|
||||
var height = parseInt(can.Action("height"))
|
||||
var step = parseInt((width-2*space) / can.list.length)
|
||||
|
||||
can.onmotion.clear(can, can.draw.svg)
|
||||
can.draw.svg.Val("height", height)
|
||||
can.draw.svg.Val("width", width)
|
||||
|
||||
function scale(y) { return (y - can.min)/(can.max - can.min)*(height-2*space) }
|
||||
function order(index, x, y) { return {x: space+step*index+x, y: height-space-scale(y)} }
|
||||
|
||||
can.core.Next(can.list, function(line, next, index) { can.Status(line, ["date", "text", "add", "del"])
|
||||
can.draw.onimport.draw({}, can.draw, {
|
||||
shape: "line", point: [
|
||||
{x: space/2+step*index+step/4, y: space/2+view-scale(line.min)},
|
||||
{x: space/2+step*index+step/4, y: space/2+view-scale(line.max)},
|
||||
order(index, step/2, line.min), order(index, step/2, line.max),
|
||||
], style: {
|
||||
"stroke-width": 1, "stroke": line.begin < line.close? "white": "black",
|
||||
},
|
||||
})
|
||||
|
||||
line.view = can.draw.onimport.draw({}, can.draw, line.begin < line.close? {
|
||||
can.draw.onimport.draw({}, can.draw, {
|
||||
shape: "rect", point: [
|
||||
{x: space/2+step*index, y: space/2+view-scale(line.begin)},
|
||||
{x: space/2+step*index+step/2, y: space/2+view-scale(line.close)},
|
||||
], style: {
|
||||
"stroke-width": 1, "stroke": "white", "fill": "white", "rx": 0, "ry": 0,
|
||||
},
|
||||
}: {
|
||||
shape: "rect", point: [
|
||||
{x: space/2+step*index, y: space/2+view-scale(line.close)},
|
||||
{x: space/2+step*index+step/2, y: space/2+view-scale(line.begin)},
|
||||
], style: {
|
||||
"stroke-width": 1, "stroke": "black", "fill": "black", "rx": 0, "ry": 0,
|
||||
order(index, step/4, line.close), order(index, step/4*3, line.begin),
|
||||
], style: can.base.Copy({"stroke-width": 1, "rx": 0, "ry": 0}, line.begin < line.close? {
|
||||
"stroke": "white", "fill": "white",
|
||||
}: {
|
||||
"stroke": "black", "fill": "black",
|
||||
}),
|
||||
_init: function(view) {
|
||||
can.core.Item(can.ondetail, function(key, value) {
|
||||
if (key.indexOf("on") == 0 && can.base.isFunc(value)) {
|
||||
view[key] = function(event) { value(event, can, line) }
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
can.core.Item(can.ondetail, function(key, value) {
|
||||
if (key.indexOf("on") == 0 && can.base.isFunc(value)) {
|
||||
line.view[key] = function(event) { value(event, can, line) }
|
||||
}
|
||||
})
|
||||
can.core.Timer(parseInt(can.Action("speed")), next)
|
||||
})
|
||||
},
|
||||
"柱状图": function(event, can) {
|
||||
var space = 10
|
||||
var view = parseInt(can.Action("height"))
|
||||
var max = parseInt(can.Conf("width"))-2*space
|
||||
var step = parseInt(max / can.list.length)||2
|
||||
|
||||
var max = {}
|
||||
var height = 0; can.core.List(can.msg.append, function(key, which) {
|
||||
height += view + 2*space
|
||||
|
||||
max[key] = 0, can.core.List(can.data, function(value, index) {
|
||||
if ((parseInt(value[key])||0) > max[key]) {
|
||||
max[key] = parseInt(value[key])||0
|
||||
var max = {}, min = {}
|
||||
can.core.List(can.msg.append, function(key, which) {
|
||||
can.core.List(can.data, function(value, index) {
|
||||
var v = parseInt(value[key])||0; if (index == 0) {
|
||||
max[key] = v, min[key] = v
|
||||
return
|
||||
}
|
||||
if (v > max[key]) { max[key] = v }
|
||||
if (v < min[key]) { min[key] = v }
|
||||
})
|
||||
})
|
||||
|
||||
var width = can.list.length*step + 2*space
|
||||
can.draw.svg.Val("height", height+2*space)
|
||||
can.draw.svg.Val("width", width)
|
||||
var space = 10
|
||||
var width = parseInt(can.Conf("width"))
|
||||
var height = parseInt(can.Action("height"))
|
||||
var step = parseInt((width-2*space) / can.list.length)
|
||||
|
||||
can.onmotion.clear(can, can.draw.svg)
|
||||
can.core.List(can.msg.append, function(key, which) { var y = (space*2+view)*(which+1)
|
||||
can.draw.onimport.draw({}, can.draw, {
|
||||
shape: "text", point: [
|
||||
{x: width/2, y: y+space},
|
||||
], style: {
|
||||
"font-size": 20,
|
||||
"stroke-width": 0, "stroke": "red", "fill": "red", inner: key,
|
||||
},
|
||||
})
|
||||
can.draw.svg.Val("height", height)
|
||||
can.draw.svg.Val("width", width)
|
||||
|
||||
can.core.Next(can.data, function(line, next, index) {
|
||||
line.view = can.draw.onimport.draw({}, can.draw, {
|
||||
function scale(key, y) { return (y - min[key])/(max[key] - min[key])*(height-2*space) }
|
||||
function order(index, key, x, y) { return {x: space+step*index+x, y: space+scale(key, y)} }
|
||||
|
||||
var width = (step-4)/can.msg.append.length
|
||||
can.core.List(can.msg.append, function(key, which) {
|
||||
max[key] != min[key] && can.core.Next(can.data, function(line, next, index) {
|
||||
var y = scale(key, parseFloat(line[key]))
|
||||
y && can.draw.onimport.draw({}, can.draw, {
|
||||
shape: "rect", point: [
|
||||
{x: space+step*index, y: y},
|
||||
{x: space+step*index+step/4, y: y-parseInt(line[key])/(max[key]||1)*view}
|
||||
order(index, key, width*which+2, 0), order(index, key, width*which+2+width, y),
|
||||
], style: {
|
||||
"stroke-width": 1, "stroke": "white", "fill": "white", "rx": 0, "ry": 0,
|
||||
},
|
||||
_init: function(view) {
|
||||
can.core.Item(can.ondetail, function(key, value) {
|
||||
if (key.indexOf("on") == 0 && can.base.isFunc(value)) {
|
||||
view[key] = function(event) { value(event, can, line) }
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
can.core.Item(can.ondetail, function(key, value) {
|
||||
if (key.indexOf("on") == 0 && can.base.isFunc(value)) {
|
||||
line.view[key] = function(event) { value(event, can, line) }
|
||||
}
|
||||
})
|
||||
can.core.Timer(parseInt(can.Action("speed")), next)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user