mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add some
This commit is contained in:
parent
c233f75a13
commit
0ba1d4dbe5
11
frame.js
11
frame.js
@ -456,7 +456,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
can.user.trans(can, kit.Dict(target.name, target.value))
|
||||
return {type: html.BUTTON, name: target.name, value: target.value, style: _style}
|
||||
})
|
||||
function run(event, button) { can.run(can.request(event, value, can.Option())._event, [ctx.ACTION, button]), can.onkeymap.prevent(event) }
|
||||
function run(event, button) { button && can.run(can.request(event, value, can.Option())._event, [ctx.ACTION, button]), can.onkeymap.prevent(event) }
|
||||
if (list.length <= limit) {
|
||||
target.onclick = function(event) { run(event, event.target.name) }
|
||||
} else {
|
||||
@ -615,6 +615,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
if (can.page.ClassList.has(can, target, "disable")) { return } can.page.ClassList.add(can, target, "disable")
|
||||
can.misc.Event(event, can, function(msg) { can.Update(can.request(event, can.Option()), [ctx.ACTION, target.name], function(msg) {
|
||||
can.page.ClassList.del(can, target, "disable")
|
||||
can.page.ClassList.del(can, can._fields, "form")
|
||||
can.page.ClassList.del(can, can._fields, "output")
|
||||
var sup = can._fields? can.sup: can; if (sup.onimport._process(sup, msg)) { return }
|
||||
}) })
|
||||
}
|
||||
@ -753,7 +755,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
},
|
||||
|
||||
plugin: function(can, meta, cb, target, field) {
|
||||
meta = meta||{}, meta.index = meta.index||can.core.Keys(meta.ctx, meta.cmd)||ice.CAN_PLUGIN, meta._space = meta._space||can.ConfSpace()
|
||||
meta = meta||{}, meta.index = meta.index||can.core.Keys(meta.ctx, meta.cmd)||"can._notfound", meta._space = meta._space||can.ConfSpace()
|
||||
var res = {}; function _cb(sub, meta, skip) { kit.proto(res, sub), cb && cb(sub, meta, skip) }
|
||||
if (meta.inputs && meta.inputs.length > 0 || meta.meta) { can.onappend._plugin(can, {meta: meta.meta, list: meta.list}, meta, _cb, target, field); return res }
|
||||
function _plugin(_meta) { var value = can.onengine.plugin(can, _meta.index)
|
||||
@ -761,8 +763,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
value.meta && value.meta._init && value.meta._init(sub, meta), _cb(sub, meta, skip)
|
||||
}, target, field); return true }
|
||||
} if (_plugin(meta)) { return res }
|
||||
can.runAction(can.request({}, meta._commands, {_method: http.GET, pod: meta.space, _failure: function() {
|
||||
return can.misc.isDebug(can) && can.misc.Warn("not found", meta.index), _plugin({type: meta.type, index: "can._notfound", args: [meta.index, meta.space]})
|
||||
can.runAction(can.request({}, meta._commands, {_method: http.GET, pod: meta.space, _failure: function(msg) {
|
||||
return can.misc.isDebug(can) && can.misc.Warn("not found", meta.index), _plugin({msg: msg, type: meta.type, index: "can._notfound", args: [meta.index, meta.space]})
|
||||
}})._caller(), ctx.COMMAND, [meta.index], function(msg) { if (msg.Length() == 0) { return msg._failure() }
|
||||
msg.Table(function(value) { value._prefix = msg["_prefix"], can.onappend._plugin(can, value, meta, _cb, target, field) })
|
||||
}); return res
|
||||
@ -784,6 +786,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
}
|
||||
}
|
||||
}, sub._index = value.index||meta.index, can.base.isFunc(cb) && cb(sub, meta, skip)
|
||||
meta._init && (meta._init(sub))
|
||||
if (meta.style == html.FLOAT || value.style == html.FLOAT) { can.onmotion.float(sub) }
|
||||
}, target||can._output, field)
|
||||
},
|
||||
|
@ -511,7 +511,7 @@ fieldset>div.action div.item.button:last-child { margin-right:var(--button-margi
|
||||
fieldset.input.date.float>div.action div.item.button:last-child { margin-right:0; }
|
||||
// fieldset>div.action div.item.select:not(.button) { border-bottom:var(--box-notice3); }
|
||||
fieldset>div.action div.item:not(.state) { box-shadow:var(--input-box-shadow); }
|
||||
fieldset>div.action>div.tabs:not(.state) { box-shadow:var(--legend-box-shadow); }
|
||||
fieldset>div.action>div.tabs:not(.state).select { box-shadow:var(--legend-box-shadow); }
|
||||
fieldset>div.action>div.cmds:not(.state) { box-shadow:var(--legend-box-shadow); }
|
||||
fieldset>div.output.card>div.item { box-shadow:var(--th-box-shadow); border:var(--plugin-border); border-radius:var(--plugin-radius); }
|
||||
fieldset>div.output.card>div.item:hover { box-shadow:var(--notice-box-shadow); }
|
||||
@ -608,6 +608,7 @@ div.item.select._icon:hover i:first-child { color:unset; }
|
||||
div.item.text>input { width:var(--input-width); height:var(--action-height); }
|
||||
div.item.text.id>input { width:80px; }
|
||||
div.item.text.url>input { width:var(--river-width); }
|
||||
div.item.text.port>input { width:80px; }
|
||||
div.item.text.line>input { width:80px; }
|
||||
div.item.text.limit>input { width:var(--button-width); }
|
||||
div.item.text.offend>input { width:var(--button-width); }
|
||||
|
@ -92,8 +92,10 @@ Volcanos("misc", {
|
||||
isDebug: function() { return msg.Option(log.DEBUG) == ice.TRUE },
|
||||
}); return msg },
|
||||
Inputs: function(can, msg, cmds, cb, meta) {
|
||||
var event = msg._event
|
||||
if (msg.Option(ice.MSG_HANDLE) != ice.TRUE && cmds && cmds[0] == ctx.ACTION && meta.feature[cmds[1]]) {
|
||||
var msg = can.request(event, {action: cmds[1]})
|
||||
// var msg = can.request(event, {action: cmds[1]})
|
||||
msg.Option(ctx.ACTION, cmds[1])
|
||||
var action = meta.feature[cmds[1]]; if (can.base.isFunc(action)) { cb = cb||function() { can.Update() }
|
||||
return action.list && action.list.length > 0? can.user.input(event, can, action.list, function(data) {
|
||||
can.core.CallFunc(action, {can: can, msg: can.request(event, data), arg: cmds.slice(2), cb: cb})
|
||||
|
@ -8,7 +8,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { var river = can.Conf(chat.R
|
||||
can.user.info.nodetype == web.SERVER && item._command == web.DREAM && (list = [river, storm, item._command])
|
||||
can.user.info.nodetype == web.WORKER && item._command == web.WORD && (list = [river, storm, item._command])
|
||||
}
|
||||
can.onappend.plugin(can, item, function(sub, meta, skip) { if (meta.index == "can._notfound" && !can.misc.isDebug(can)) { return skip || next() }
|
||||
can.onappend.plugin(can, item, function(sub, meta, skip) {
|
||||
if (can.base.isIn(meta.index, "can._notfound")) { sub.Conf(ctx.INDEX, msg.detail[index+3]) }
|
||||
sub.run = function(event, cmds, cb) { return can.run(can.request(event, {pod: meta.pod||meta.space}), (can.base.beginWith(meta.index, "can.")? [meta.index]: [river, storm, meta.id||meta.index]).concat(cmds), cb) }
|
||||
sub.onexport.output = function() { msg.Length() > 1 && can.onexport.isauto(can) && can.page.style(can, sub._output, html.HEIGHT, "", html.MAX_HEIGHT, ""), can.onaction.layout(can, list[3]) }
|
||||
can.onaction.layout(can, list[3]), can.onimport._tabs(can, sub, meta), can._plugins = (can._plugins||[]).concat([sub])
|
||||
@ -198,7 +199,7 @@ Volcanos(chat.ONKEYMAP, {
|
||||
})
|
||||
Volcanos(chat.ONPLUGIN, {
|
||||
_plugin: shy("插件", [mdb.NAME, ice.LIST, ice.BACK]), _filter: shy("表格", [ice.LIST, html.FILTER]),
|
||||
_notfound: shy("缺失", [ctx.INDEX, web.SPACE, ice.LIST], function(can, msg, arg) { msg.Echo("not found "+arg[0]+" "+arg[1]) }),
|
||||
_notfound: shy("缺失", [ctx.INDEX, web.SPACE, ice.LIST], function(can, msg, arg, sub) { msg.Echo("not found "+(arg[0]||sub.ConfIndex())+" "+(arg[1]||can.ConfSpace())) }),
|
||||
layout: shy("界面布局", {_init: function(can) { can.Option(chat.LAYOUT, can.getAction(chat.LAYOUT)) }}, ["layout:select=auto,tabs,tabview,horizon,vertical,grid,free,flow,page", ctx.RUN], function(can, msg, arg) { can.onaction.layout(can, arg[0]) }),
|
||||
})
|
||||
})()
|
||||
|
@ -39,10 +39,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.page.requireModules
|
||||
{background: "#d5cfcf3b", foreground: cli.BLACK, cursor: cli.BLUE}
|
||||
) },
|
||||
_connect: function(can, item, output, tabs, text) {
|
||||
var term = new Terminal({
|
||||
fontSize: html.CODE_FONT_SIZE,
|
||||
tabStopWidth: 4, cursorBlink: true, theme: can.onimport._theme(can, item),
|
||||
})
|
||||
var term = new Terminal({fontSize: html.CODE_FONT_SIZE, tabStopWidth: 4, cursorBlink: true, theme: can.onimport._theme(can, item)})
|
||||
term._item = item, term._output = output, output._term = term, output._tabs || (tabs? (output._tabs = tabs): can.onimport._tabs(can, item, output))
|
||||
var fitAddon = new FitAddon.FitAddon(); term.loadAddon(fitAddon), term._fit = fitAddon, can.onmotion.delay(can, function() { fitAddon.fit() })
|
||||
term.onTitleChange(function(title) { can.onexport.title(can, term, title) }), can.onexport.title(can, term, item.name)
|
||||
@ -51,25 +48,27 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.page.requireModules
|
||||
term.onCursorMove(function() { can.onexport.term(can, term) })
|
||||
term.loadAddon(new WebLinksAddon.WebLinksAddon())
|
||||
can.onmotion.clear(can, output), term.open(output), term.focus()
|
||||
can.onengine.listen(can, chat.ONTHEMECHANGE, function() {
|
||||
term.selectAll(), can.onimport._connect(can, item, output, tabs, can.base.trimSuffix(term.getSelection(), lex.NL))
|
||||
})
|
||||
can.onengine.listen(can, chat.ONTHEMECHANGE, function() { term.selectAll(), can.onimport._connect(can, item, output, tabs, can.base.trimSuffix(term.getSelection(), lex.NL)) })
|
||||
can.page.style(can, output, html.BACKGROUND_COLOR, term._publicOptions.theme.background||cli.BLACK)
|
||||
can.current = term
|
||||
output.onclick = function() { output._tabs._current = output, term.focus(), can.onexport.term(can, term)
|
||||
can.current = term
|
||||
can.page.Select(can, can._fields, html.DIV_OUTPUT, function(target) { can.page.ClassList.set(can, target, html.SELECT, target == output) })
|
||||
}; return can.db = can.db||{}, can.db[item.hash] = term
|
||||
},
|
||||
_resize: function(can, term, size) { can.runAction(can.request({}, size, term._item), web.RESIZE, [], function(msg) {
|
||||
if (msg.IsErr()) { can.misc.Warn(msg.Result()) }
|
||||
can.onexport.term(can, term)
|
||||
can.onexport.term(can, term); if (msg.IsErr()) { can.misc.Warn(msg.Result()) }
|
||||
}) },
|
||||
_input: function(can, term, data) {
|
||||
can.runAction(can.request({}, {rows: term.rows, cols: term.cols}, term._item), html.INPUT, [btoa(data)], function(msg) {
|
||||
if (msg.IsErr()) { can.misc.Warn(msg.Result()) }
|
||||
}), can._output = term._output
|
||||
},
|
||||
input: function(can, msg, hash, text) { var arg = msg.detail.slice(1); arg = [hash||arg[0], text||arg[1]]
|
||||
term = can.db[arg[0]]||can.current, can.onimport._input(can, term, arg[1])
|
||||
},
|
||||
grow: function(can, msg, hash, text) { var arg = msg.detail.slice(1); arg = [hash||arg[0], text||arg[1]]
|
||||
term = can.db[arg[0]]; arg[1] == "~~~end~~~"? can.onaction.delete(can, term._output): term.write(arg[1]); msg.Option(ice.LOG_DISABLE, ice.TRUE)
|
||||
term = can.db[arg[0]]||can.current; arg[1] == "~~~end~~~"? can.onaction.delete(can, term._output): term.write(arg[1]); msg.Option(ice.LOG_DISABLE, ice.TRUE)
|
||||
},
|
||||
layout: function(can) { function show(target, height, width) { var list = can.page.SelectChild(can, target, can.page.Keys(html.DIV_OUTPUT, html.DIV_LAYOUT))
|
||||
var h = height/list.length, w = width; if (can.page.ClassList.has(can, target, html.FLEX)) { h = height, w = width/list.length } if (target == can._fields) { h = height, w = width }
|
||||
|
@ -1,12 +1,43 @@
|
||||
Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.page.requireDraw(can, function() { can.list = can.onimport._data(can, msg, can.Conf(mdb.FIELD)||mdb.VALUE)
|
||||
can.core.List(can.list, function(item) { msg.Push("weight", parseInt(item.span*100/360)+"%").Push(cli.COLOR, '<span style="background-color:'+item.color+'"> </span>') })
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg, cb) { can.page.requireDraw(can, function() { can.db.delay = 50
|
||||
can.list = can.onimport._data(can, msg, can.Conf(mdb.FIELD)||msg.append[1]||mdb.VALUE)
|
||||
can.core.List(can.list, function(item) { msg.Push("weight", item.value.weight = parseInt(item.span*100/360)+"%").Push(cli.COLOR, '<span style="background-color:'+item.color+'"> </span>') })
|
||||
can.onaction.list = [], can.ui.display = can.page.Append(can, can._output, [html.DISPLAY])._target
|
||||
can.onappend.table(can, msg, null, can.ui.display), can.page.Select(can, can.ui.display, html.TR, function(tr, index) {
|
||||
can.page.Modify(can, tr, {onmouseenter: function(event) { can._draw(index-1) }})
|
||||
can.onappend.table(can, msg, null, can.ui.display), can.page.Select(can, can.ui.display, html.TR, function(tr, index) { can.ui.table = tr.parentNode
|
||||
can.page.Modify(can, tr, {onmouseenter: function(event) { can._draw(can.db.which = index-1) }})
|
||||
}), can.base.isFunc(cb) && cb(msg), can.onappend._status(can, msg.append)
|
||||
}) },
|
||||
_data: function(can, msg, field) { var list = []
|
||||
var color = ["#3300FF", "#2196F3", "#4CAF50", "#CDDC39", "#FFEB3B", "#9C27B0", "#795548", "#607D8B", "#CC33FF"]
|
||||
var color = [
|
||||
"#8085e9",
|
||||
"#95a2ff",
|
||||
"#73abf5",
|
||||
"#3cb9fc",
|
||||
"#0082fc",
|
||||
"#87e885",
|
||||
"#90ed7d",
|
||||
"#22ed7c",
|
||||
"#05f8d6",
|
||||
"#cb9bff",
|
||||
"#bf19ff",
|
||||
"#f47a75",
|
||||
"#fa8080",
|
||||
"#f7a35c",
|
||||
"#ffc076",
|
||||
"#f9e264",
|
||||
"#fae768",
|
||||
"#5f45ff",
|
||||
"#02cdff",
|
||||
"#0090ff",
|
||||
"#854cff",
|
||||
"#09b0d3",
|
||||
"#1d27c9",
|
||||
"#765005",
|
||||
"#314976",
|
||||
"#009db2",
|
||||
"#024b51",
|
||||
"#0780cf",
|
||||
]
|
||||
var total = 0; msg.Table(function(value) { total += can.onimport._parseInt(can, value[field]) })
|
||||
var begin = 0; msg[cli.COLOR] = [], msg["weight"] = [], msg.Table(function(value, index) {
|
||||
list.push({span: can.onimport._parseInt(can, value[field])/total*360, color: color[index%color.length], value: value})
|
||||
@ -15,16 +46,19 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.page.requireDraw(ca
|
||||
_draw: function(can, x, y, r, margin, which) { if (which == can._last) { return } can._last = which
|
||||
if (can.list.length == 1) { return can.onimport.draw(can, {shape: svg.CIRCLE, points: [{x: x, y: y}, {x: x, y: y+r}], style: {fill: cli.BLUE}}) }
|
||||
function pos(x, y, r, angle) { angle -= 90; return [x + r * Math.cos(angle * Math.PI / 180), y + r * Math.sin(angle * Math.PI / 180)] }
|
||||
function pie(x, y, r, begin, span, color, cb) { can.onimport.draw(can, {shape: svg.PATH, style: kit.Dict(
|
||||
function pie(x, y, r, begin, span, color, title, cb) { can.onimport.draw(can, {shape: svg.PATH, style: kit.Dict(
|
||||
svg.STROKE, color, svg.FILL, color, "d", can.base.joins([
|
||||
["M", x, y], ["L"].concat(pos(x, y, r, begin)), ["A", r, r, "0", span>180? "1": "0", "1"].concat(pos(x, y, r, begin+span)), ["Z"]
|
||||
], lex.SP, mdb.FS),
|
||||
), onmouseenter: function(event) { can.base.isFunc(cb) && cb(event) } }) }
|
||||
can.onmotion.clear(can, can.ui.svg), can.ui.svg.Value(mdb.COUNT, 0)
|
||||
var begin = 0; can.core.List(can.list, function(item, index) { var p = index==which? pos(x, y, margin, begin+item.span/2): [x, y]
|
||||
pie(p[0], p[1], r, begin, item.span, item.color, function(event) { can.onimport._draw(can, x, y, r, margin, index) }), begin += item.span
|
||||
index == which && can.Status(item.value)
|
||||
}), can.onimport.layout(can)
|
||||
var begin = 0; can.core.Next(can.list, function(item, next, index) { var p = index==which? pos(x, y, margin*4, begin+item.span/2): [x, y]
|
||||
pie(p[0], p[1], r, begin, item.span, item.color, item.name||item.command, function(event) { can.onimport._draw(can, x, y, r, margin, can.db.which = index) }), begin += item.span
|
||||
index == which && (can.db.current = item.value)
|
||||
can.onmotion.select(can, can.ui.table, html.TR, index), can.Status(item.value), can.onmotion.delay(can, next, can.db.delay)
|
||||
}, function() {
|
||||
can.onmotion.select(can, can.ui.table, html.TR, which), can.Status(can.db.current), can.db.delay = 0
|
||||
})
|
||||
},
|
||||
_parseInt: function(can, value) { value = value.toLowerCase()
|
||||
if (can.base.endWith(value, "m")) { return parseInt(value)*1000000 }
|
||||
@ -34,10 +68,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.page.requireDraw(ca
|
||||
return parseInt(value)
|
||||
},
|
||||
layout: function(can) { if (!can.ui || !can.ui.svg) { return }
|
||||
var height = can.base.Max(can.ConfHeight(), can.ConfWidth()/2), margin = 10, r = height/2-2*margin;
|
||||
// can.page.style(can, can.ui.display, html.HEIGHT, can.ConfHeight()-can.ui.svg.Val(html.HEIGHT))
|
||||
can.page.style(can, can.ui.display, html.WIDTH, can.ConfWidth()-height)
|
||||
can.ui.svg.Val(html.HEIGHT, height), can.ui.svg.Val(html.WIDTH, height)
|
||||
can._draw = function(which) { can.onimport._draw(can, height/2-margin/2, can.ConfHeight()/2-margin/2, r, margin, which) }, can._draw(0)
|
||||
var height = can.base.Max(can.ConfHeight(), can.ConfWidth()/2), margin = 10, r = height/2-5*margin
|
||||
can.page.style(can, can.ui.display, html.WIDTH, can.ConfWidth()-height), can.ui.svg.Val(html.HEIGHT, height), can.ui.svg.Val(html.WIDTH, height)
|
||||
can._draw = function(which) { can.onimport._draw(can, height/2-margin/2, can.ConfHeight()/2-margin/2, r, margin, which) }, can._draw(can.db.which||0)
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user