1
0
forked from x/volcanos
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-05-31 02:34:52 +08:00
parent bbd9ed606b
commit 8f3c12ee99
18 changed files with 485 additions and 385 deletions

View File

@ -1,4 +1,5 @@
Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) {
Volcanos(chat.ONENGINE, {
_init: function(can, meta, list, cb, target) {
can.Option = function() {}, can.run = function(event, cmds, cb) { var msg = can.request(event); cmds = cmds||[]; return (can.onengine[cmds[0]]||can.onengine._remote)(event, can, msg, can, cmds, cb) }
can.core.Next(list, function(item, next) { item.type = chat.PANEL
can.onappend._init(can, item, item.list, function(sub) { can[item.name] = sub, sub.db = {}, sub.ui = {}, sub.db._boot = can.misc._time()
@ -70,7 +71,8 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) {
return can.core.List(can.onengine.listen.meta[name], function(cb) { can.core.CallFunc(cb, {event: msg._event, msg: msg}) }).length, msg
},
})
Volcanos(chat.ONDAEMON, {_init: function(can, name, type, cbs) { if (can.user.isLocalFile) { return }
Volcanos(chat.ONDAEMON, {
_init: function(can, name, type, cbs) { if (can.user.isLocalFile) { return }
return can.misc.WSS(can, {type: type||web.PORTAL, name: name||can.misc.Search(can, cli.DAEMON)||""}, function(event, msg, cmd, arg, cb) {
if (cbs && can.core.CallFunc(cbs, {event: event, msg: msg, cmd: cmd, arg: arg, cb: cb})) { return }
var sub = can.ondaemon._list[can.core.Keys(msg[ice.MSG_TARGET])]||can;
@ -134,7 +136,8 @@ Volcanos(chat.ONDAEMON, {_init: function(can, name, type, cbs) { if (can.user.is
}), can.ondaemon._online(can, 30000)
}, delay) },
})
Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
Volcanos(chat.ONAPPEND, {
_init: function(can, meta, list, cb, target, field) {
meta.index && (meta.name = meta.index), meta.name = can.core.Split(meta.name||"", "\t .\n").pop()||can.Conf(mdb.NAME)
field = field||can.onappend.field(can, meta.type, meta, target)._target
meta.style == html.OUTPUT && can.onappend.style(can, html.OUTPUT, field)
@ -277,7 +280,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
run(event, item.name||item.value)
}, item._init = item._init||function(target) { item.action && can.onappend.figure(sub, item, target, function(_sub, value) { can.Update() })
if (item.type == html.BUTTON && can.page.isIconInput(can, item.name)) { can.onappend.icons(can, target, item.name) }
}), item), "", action)
}), item),
"", action)
})
var _can = can._fields? can.sup: can
can.isCmdMode() || can.base.beginWith(can.ConfIndex(), "can.", "web.chat.macos.") ||
@ -295,7 +299,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
title: key == "_space"? "": can.user.trans(can, key), onclick: function(event) {
can.onengine.signal(can, "onevent", can.request(event, {_type: html.ACTION, action: key}))
var cb = _can.onaction[value]; cb && _can.onaction[value](event, _can, value, _can.sub)
}}
}
}
}).concat(can.Conf("_plugin_action")||[])
); return meta
},
@ -330,14 +335,17 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
sub._trans = can.base.Copy(can.base.Copy(sub._trans||{}, can._trans), can.core.Value(sub, [chat.ONACTION, chat._TRANS]))
if (sub.onimport && can.base.isArray(sub.onimport.list) && sub.onimport.list.length > 0) {
can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: can.page.inputs(can, sub.onimport.list, html.TEXT) })
}
can.page.ClassList.del(can, sub._fields, html.FORM), delete(can._status._cache), delete(can._status._cache_key)
sub._output.className = html.OUTPUT
} can.onmotion.toggle(can, can._action, true), delete(can._status._cache), delete(can._status._cache_key)
// can.page.ClassList.del(can, sub._fields, html.FORM)
// sub._output.className = html.OUTPUT
// can.onappend.style(can, sub._args.style, can._output)
// can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
// sub.isCmdMode() && sub.onexport.title(sub, sub.ConfIndex())
can.onmotion.toggle(can, can._action, true)
can.onexport._output(sub, msg), sub.Mode() != ice.MSG_RESULT && can.onmotion.clear(can, output)
can._output_old = can._output, can._output = sub._output = sub._target = output = can.page.insertBefore(can, [html.OUTPUT], can._status)
can.page.style(can, can._output, "visibility", "hidden")
can.page.style(can, can._output, "position", "fixed")
if (sub.Mode() == ice.MSG_RESULT) { can._output.innerHTML = can._output_old.innerHTML }
can.onexport._output(sub, msg)
can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) {
if (action !== false) { can.onkeymap._build(sub)
var list = can.base.Obj(msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), [])||[]
@ -352,7 +360,10 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
can.onimport.size(can, can.ConfHeight(), can.ConfWidth(), can.Conf("_auto"), can.Mode())
can.isCmdMode() && can.page.style(can, can._output, html.HEIGHT, sub.ConfHeight())
can.onexport.output(sub, msg); if (can.Conf("_output")) { can.Conf("_output")(sub, msg) }
} msg.Defer(), can.base.isFunc(cb) && cb(msg), can.page.style(can, can._target, "visibility", ""), can.page.style(can, can._output, "visibility", "")
} msg.Defer(), can.base.isFunc(cb) && cb(msg), can.page.style(can, can._target, "visibility", ""),
can._output.scrollTop = can._output_old.scrollTop, can._output.scrollLeft = can._output_old.scrollLeft
can.page.style(can, can._output, "visibility", ""), can.page.Remove(can, can._output_old)
can.page.style(can, can._output, "position", "")
}, target: output}), msg.Defer()
})
},
@ -490,12 +501,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
}
},
_filter: function(can) {
can.page.insertBefore(can, can.onappend.filter(can, can._action, can.ui.content||can._output).parentNode,
(can.page.SelectOne(can, can._action, "div.item._space")||{}).nextSibling, can._action)
can.page.insertBefore(can, can.onappend.filter(can, can._action, can.ui.content||can._output).parentNode, (can.page.SelectOne(can, can._action, "div.item._space")||{}).nextSibling, can._action)
},
filter: function(can, target, output) { output = output||can.ui.content||target
return can.onappend.input(can, {type: html.TEXT, name: web.FILTER, icon: icon.SEARCH, placeholder: "search in n items", onkeydown: function() {}, onkeyup: function(event) {
var value = event.currentTarget? event.currentTarget.value: ""
if (can.sub && can.sub.onaction && can.sub.onaction.filter && can.sub.onaction.filter(event, can.sub, value)) {
return
}
if (event.key == code.ENTER) {
can.page.Select(can, output, html.DIV_ITEM+":not(.hide)", function(target) { target.click() })
} else if (event.key == code.ESCAPE) { event.currentTarget.value = "", event.currentTarget.blur()
@ -915,7 +928,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
})
},
})
Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||can._root._target; var height = can.page.height(), width = can.page.width()
Volcanos(chat.ONLAYOUT, {
_init: function(can, target) { target = target||can._root._target; var height = can.page.height(), width = can.page.width()
can.page.SelectChild(can, target, can.page.Keys(html.FIELDSET_HEAD, html.FIELDSET_FOOT), function(field) { height -= field.offsetHeight })
can.page.SelectChild(can, target, html.FIELDSET_LEFT, function(field) {
can.page.styleHeight(can, field, height)
@ -974,7 +988,8 @@ Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||can._ro
return layout
},
})
Volcanos(chat.ONMOTION, {_init: function(can, target) {
Volcanos(chat.ONMOTION, {
_init: function(can, target) {
target.onclick = function(event) {
if (can.page.tagis(event.target, html.SELECT, html.INPUT, html.TEXTAREA)) { return }
if (can.page.tagis(event.target, html.A) && can.user.isWebview) { return event.shiftKey? window.outopen(event.target.href): can.user.open(event.target.href) }
@ -1067,8 +1082,7 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) {
}
}).length == 0)
}) },
tableFilter: function(can, target, value) {
can.page.Select(can, target, html.TR, function(tr, index) {
tableFilter: function(can, target, value) { can.page.Select(can, target, html.TR, function(tr, index) {
index > 0 && can.page.ClassList.set(can, tr, html.HIDDEN, can.page.Select(can, tr, html.TD, function(td) { if (td.innerText.toLowerCase().indexOf(value.toLowerCase()) > -1) { return td } }) == 0)
}) },
delayResize: function(can, target, key) {

View File

@ -368,4 +368,5 @@ Volcanos("misc", {
for (var i in arg) { arg[i] != undefined && args.push(arg[i]) } return args
},
_signal: function(args) { this._list.push(args) }, _list: [], _skip: navigator && navigator.userAgent.indexOf("Chrome") > -1? 3: 3,
})
})

View File

@ -103,16 +103,17 @@ Volcanos("page", {
name && (data.name = name); var node = can.page.Create(can, type, data)
value[type] = value[name] = value[can.core.Split(data.className)[0]] = node, value._target = value._target||node, value.first = value.first||node, value.last = node
item.list && can.page.Append(can, node, item.list, value), target && target.appendChild && target.appendChild(node), can.base.isFunc(item._init) && item._init(node, value)
}); return value
},
}); return value },
Appends: function(can, target, key, value) { return target.innerHTML = "", can.page.Append(can, target, key, value) },
AppendData: function(can, target, prefix, key, value, cb) { var open = can.page.unicode.opens, close = can.page.unicode.closes
function short(value, length) {
if (length == undefined) {
value.indexOf(lex.NL) > -1 && (value = value.trim().split(lex.NL)[0]+can.page.unicode.inner)
return can.page.trans(can, value)
} else { if (length > 5) {
return can.page.unicode.inner }
} else {
if (length > 5) {
return can.page.unicode.inner
}
} return value
}
function show(value, deep) { deep = deep == undefined? 2: 0; switch (typeof value) {
@ -188,7 +189,8 @@ Volcanos("page", {
{type: "colgroup", list: can.core.List(list, function(key) { if (key[0] != "_") {
try { var value = can.Option(key) } catch (e) {}
if (value == undefined) { return {view: [key, "col"]} } return {view: [[key, "option"], "col"]}
} }) }, {type: html.THEAD}, {type: html.TBODY}]}])
} }) }, {type: html.THEAD}, {type: html.TBODY},
]}])
can.page.Append(can, ui.thead, [{type: html.TR, data: {dataset: {index: -1}}, list: can.core.List(list, function(key) {
if (key[0] != "_") { return {type: html.TH, list: [{text: can.user.trans(can, key, null, html.INPUT)}, {icon: "bi bi-sort-down-alt"}, {icon: "bi bi-sort-up"}]} }
}) }])
@ -239,6 +241,36 @@ Volcanos("page", {
var list = ["<"+type]; for (var i = 2; i < arg.length; i += 2) { list.push(lex.SP+arg[i]+mdb.EQ+arg[i+1]) }
return list.concat(">", arg[1], "</", type, ">").join("")
} },
ColorList: [
"#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",
],
Color: function(text) { if (typeof text != code.STRING) { return "" } text = text.replace(/\\n/g, "<br>")
if (text.indexOf(ice.HTTP) == 0 && text.length > 10) { var ls = text.split(lex.SP); text = "<a href='"+ls[0]+"' target='_blank'>"+decodeURI(ls[0])+"</a>"+ls.slice(1).join(lex.SP) }
if (text.indexOf("export ctx_dev=") == 0 && text.length > 10) { return "<div class='story' data-type='spark' data-name='shell'><div>"+"<span>"+text+"</span>"+"</div></div>" }
@ -363,8 +395,8 @@ Volcanos("page", {
} })()
_list.push(item), type = item.type
})()
} } return _list },
input: function(can, item, value) { var input = {type: html.INPUT, name: item.name, data: item, style: item.style||{}, dataset: {}, _init: item._init}
} } return _list },
input: function(can, item, value) { var input = {type: html.INPUT, name: item.name, data: item, style: item.style||{}, dataset: {}, _init: item._init}
item.value == ice.AUTO && (item.value = "", item.action = ice.AUTO), item.action == ice.AUTO && (input.dataset.action = ice.AUTO)
switch (item.type = item.type||html.TEXT) {
case html.SELECT: input.type = html.SELECT, item.className||can.page.ClassList.add(can, item, ctx.ARGS)
@ -385,41 +417,41 @@ Volcanos("page", {
case html.UPLOAD: item.type = html.FILE, input.name = html.UPLOAD; break
case html.BUTTON: item.value = item.value||item.name||mdb.LIST; break
} return input
},
icons: function(can, name, space) { if (!name) { return }
},
icons: function(can, name, space) { if (!name) { return }
if (can.base.contains(name, ".ico", ".png", ".jpg")) { return {img: can.misc.Resource(can, (name.indexOf(nfs.PS) == -1? nfs.USR_ICONS: "")+name, space)} }
// if (can.page.unicode[name]) { return {text: [can.page.unicode[name], "", "icon"]} }
if (name == mdb.DELETE) { return {icon: "bi bi-trash"} }
if (can.base.beginWith(name, "bi ")) { return {icon: name} }
var _icon = can.base.getValid(can.Conf("_icons."+name), can.Conf("_trans.icons."+name), can.core.Value(can.onaction, ["_trans.icons."+name]), icon[name])
if (_icon) { return {icon: _icon} }
},
requireChina: function(can, title, list, name, path) {
},
requireChina: function(can, title, list, name, path) {
can.onappend.plugin(can, {title: title, display: "/plugin/story/china.js", style: html.FLOAT, height: can.ConfHeight(), width: can.ConfHeight()}, function(sub) {
sub.run = function(event, cmds, cb) { var msg = can.request(event, {title: title, name: name, path: path})
can.core.List(list, function(item) { msg.Push(mdb.NAME, item.name), msg.Push(mdb.VALUE, item.value) }), cb(msg)
can.onmotion.resize(can, sub._target, function(height, width) { sub.onimport.size(sub, height, width, true) })
}
})
},
requireModules: function(can, libs, cb, cbs) { if (!libs || libs.length == 0) { return cb && cb() }
},
requireModules: function(can, libs, cb, cbs) { if (!libs || libs.length == 0) { return cb && cb() }
for (var i = 0; i < libs.length; i++) { if (libs[i].indexOf(nfs.PS) == 0 || libs[i].indexOf(ice.HTTP) == 0) { continue }
if (libs[i].indexOf(nfs._CSS) == -1 && libs[i].indexOf(nfs._JS) == -1) { libs[i] = libs[i]+"/lib/"+libs[i]+nfs._JS }
libs[i] = nfs.M+libs[i]
} can.require(libs, cb, cbs)
},
requireDraw: function(can, cb) { can.require([chat.PLUGIN_LOCAL+"wiki/draw.js", chat.PLUGIN_LOCAL+"wiki/draw/path.js"], function() {
},
requireDraw: function(can, cb) { can.require([chat.PLUGIN_LOCAL+"wiki/draw.js", chat.PLUGIN_LOCAL+"wiki/draw/path.js"], function() {
can.onimport._last_init(can, can.request()), can.onappend.style(can, wiki.DRAW, can._fields), cb()
}, function(can, mod, sub) { mod == chat.ONIMPORT && (can[mod]._last_init = sub._init) }) },
drawText: function(can, text, size, margin, fonts) { text = text.slice(0, 1), size = size||80, margin = margin == undefined? 10: margin
}, function(can, mod, sub) { mod == chat.ONIMPORT && (can[mod]._last_init = sub._init) }) },
drawText: function(can, text, size, margin, fonts) { text = text.slice(0, 1), size = size||80, margin = margin == undefined? 10: margin
var colors = ["rgb(239,150,26)", 'rgb(255,58,201)', "rgb(111,75,255)", "rgb(36,174,34)", "rgb(80,80,80)"]
var canvas = can.page.Create(can, html.CANVAS, {width: size, height: size}), ctx = canvas.getContext("2d")
ctx.fillStyle = colors[Math.floor(Math.random()*(colors.length))], ctx.fillRect(margin, margin, size-2*margin, size-2*margin)
ctx.fillStyle = cli.WHITE, ctx.font = (fonts||can.base.Min(size/text.length-30, 16))+"px Arial", ctx.textAlign = "center", ctx.textBaseline = "middle", ctx.fillText(text, size/2, size/2)
return canvas.toDataURL(html.IMAGE_PNG, 1)
},
position: function(event, target) { var p = target.getBoundingClientRect(); return {x: event.clientX - p.x, y: event.clientY - p.y} },
getquery: function(can, target) {
},
position: function(event, target) { var p = target.getBoundingClientRect(); return {x: event.clientX - p.x, y: event.clientY - p.y} },
getquery: function(can, target) {
var list = []; for (var p = target; p; p = p.parentNode) {
if (can.page.tagis(p, "body")) { list.pop(); break }
list.push(can.core.Keys(p.tagName.toLowerCase(), can.core.List(p.classList).join(".")), ">")
@ -429,29 +461,29 @@ Volcanos("page", {
}
}
return list.reverse().join("")
},
theme: function(cb) { var themeMedia = window.matchMedia("(prefers-color-scheme: dark)")
},
theme: function(cb) { var themeMedia = window.matchMedia("(prefers-color-scheme: dark)")
cb && themeMedia.addListener(function(event) { cb(event.matches? html.DARK: html.LIGHT) })
cb && cb(themeMedia.matches? html.DARK: html.LIGHT)
return themeMedia.matches? html.DARK: html.LIGHT
},
parseAction: function(can, value) { var action = []
},
parseAction: function(can, value) { var action = []
can.page.Select(can, can.page.Create(can, html.DIV, value.action), html.INPUT, function(target) {
action.push(target.name), target.name != target.value && can.user.trans(can, kit.Dict(target.name, target.value))
})
return action
},
buttonStyle: function(can, name) {
},
buttonStyle: function(can, name) {
return can.core.Value(can.onaction, ["_trans", "style", name])||(can.base.isIn(name, mdb.CREATE, mdb.INSERT, mdb.IMPORT, nfs.CLONE, cli.START, ctx.RUN, web.UPLOAD, web.CONFIRM, aaa.LOGIN, code.AUTOGEN, "sso", "add", "pull", "push", "commit", "preview", "auto-preview", ice.APP)? html.NOTICE:
can.base.isIn(name, mdb.REMOVE, mdb.DELETE, mdb.PRUNES, mdb.PRUNE, nfs.TRASH, cli.RESTART, cli.STOP, cli.CLOSE, cli.REBOOT, web.CANCEL, code.UPGRADE, "del", "drop", "access", "kill", "prockill")? html.DANGER: "")
},
exportValue: function(can, msg, target) { target = target||can._output
},
exportValue: function(can, msg, target) { target = target||can._output
msg.OptionDefault(ice.MSG_THEME, can.getHeaderTheme())
msg.OptionDefault(ice.MSG_BG, can.page.styleValue(can, "--plugin-bg-color", target))
msg.OptionDefault(ice.MSG_FG, can.page.styleValue(can, "--plugin-fg-color", target))
can.user.info.language && msg.OptionDefault(ice.MSG_LANGUAGE, can.user.info.language)
return msg
},
styleValue: function(can, key, target) { const styles = getComputedStyle(target||document.body); return styles.getPropertyValue(key) },
styleValueInt: function(can, key, target) { return parseInt(can.base.trimSuffix(can.page.styleValue(can, key, target), "px")) }
},
styleValue: function(can, key, target) { const styles = getComputedStyle(target||document.body); return styles.getPropertyValue(key) },
styleValueInt: function(can, key, target) { return parseInt(can.base.trimSuffix(can.page.styleValue(can, key, target), "px")) }
})

View File

@ -155,14 +155,13 @@ Volcanos("user", {
var _events = event._events||event
function click(event, button, index) { can.misc.Event(event, can, function() { can.request(event, {action: button}), can.onkeymap.prevent(event), event._events = _events;
can.onengine.signal(can, "onevent", can.request(event, {_type: html.ACTION}));
(can.base.isFunc(cb)? cb(event, button, meta, carte, index):
meta[button]? can.core.CallFunc([meta, button], {event: event, can: can, msg: msg, button: button}):
can.Update(event, [ctx.ACTION, button])) || can.onmotion.clearCarte(can)
(can.base.isFunc(cb)? cb(event, button, meta, carte, index): meta[button]? can.core.CallFunc([meta, button], {event: event, can: can, msg: msg, button: button}): can.Update(event, [ctx.ACTION, button])) || can.onmotion.clearCarte(can)
}) }
var isinput = can.page.tagis(event.target, html.INPUT)
var ui = can.page.Append(can, document.body, [{view: [[chat.CARTE,
can.Conf(ctx.INDEX)||can.ConfIndex(), msg.Option(ctx.ACTION), meta._style||msg.Option("_style"),
chat.FLOAT]], list: can.core.List(list, function(item, index) {
chat.FLOAT,
]], list: can.core.List(list, function(item, index) {
if (typeof item == code.FUNCTION) { item = item(can); if (!item) { return } }
if (item === "") { return {type: html.HR} }
if (item == web.FILTER) { return {

View File

@ -1,5 +1,6 @@
(function() { const ALL = "all", TABS = "tabs", TABVIEW = "tabview", VERTICAL = "vertical", HORIZON = "horizon", GRID = "grid", FREE = "free", FLOW = "flow", PAGE = "page", CAN_LAYOUT = "can.layout"
Volcanos(chat.ONIMPORT, {_init: function(can, msg) { var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM), list = can.db.list
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM), list = can.db.list
var _select; can.onmotion.clear(can), can.onaction.layout(can, list[3])
can.core.Next(msg.Table(), function(item, next, index) { item.type = chat.PLUGIN, item.mode = can.Mode(); if (item.deleted == ice.TRUE) { return next() }
if (msg.Length() == 1) { item.height = can.ConfHeight()-can.Conf(html.MARGIN_Y), can.base.isIn(item.index, web.CHAT_MACOS_DESKTOP, web.CHAT_MESSAGE, web.WIKI_PORTAL) && (item.style = html.OUTPUT) }
@ -37,7 +38,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { var river = can.Conf(chat.R
can.onmotion.hidden(can, can._header_tabs = can.page.Append(can, target, ["_tabs"])._target)
},
})
Volcanos(chat.ONACTION, {_init: function(can, target) { can.db.list = can.misc.SearchHash(can)
Volcanos(chat.ONACTION, {
_init: function(can, target) { can.db.list = can.misc.SearchHash(can)
can.db.list.length == 0 && can.misc.Search(can, chat.RIVER) && can.misc.Search(can, chat.STORM) && (can.db.list = [can.misc.Search(can, chat.RIVER), can.misc.Search(can, chat.STORM)])
can.Conf(html.MARGIN_X, 2*html.PLUGIN_PADDING+2*html.PLUGIN_MARGIN), can.Conf(html.MARGIN_Y, 2*html.PLUGIN_PADDING+2*html.PLUGIN_MARGIN+html.ACTION_HEIGHT)
can.core.List(["ontouchstart", "ontouchmove", "ontouchend"], function(item) {
@ -157,7 +159,8 @@ Volcanos(chat.ONEXPORT, {
msg.Push(kit.Dict(ice.CTX, ice.CAN, ice.CMD, ctx.COMMAND, mdb.TYPE, ice.CAN, mdb.NAME, name||command.name, mdb.TEXT, command.help, ctx.CONTEXT, ice.CAN, ctx.COMMAND, name, ctx.INDEX, can.core.Keys(ice.CAN, name)), fields)
}) }
})
Volcanos(chat.ONENGINE, {_engine: function(event, sup, msg, can, cmds, cb) {
Volcanos(chat.ONENGINE, {
_engine: function(event, sup, msg, can, cmds, cb) {
var storm = can.core.Value(can._root, can.core.Keys(chat.RIVER, cmds[0], chat.STORM, cmds[1])); if (!storm || cmds.length != 2) { return false }
if (storm.index) {
can.runAction(event, ctx.COMMAND, [].concat(can.core.List(storm.index, function(item) {
@ -176,7 +179,8 @@ Volcanos(chat.ONENGINE, {_engine: function(event, sup, msg, can, cmds, cb) {
msg.Push(ctx.ARGS, item.args||"[]").Push(ctx.STYLE, item.style||"").Push(ctx.DISPLAY, item.display||"")
msg.Push(web.SPACE, item.space||"").Push("_ismain", ice.TRUE)
}), can.base.isFunc(cb) && cb(msg) } return true
}})
},
})
Volcanos(chat.ONKEYMAP, {
_mode: {
plugin: {

View File

@ -1,5 +1,6 @@
(function() { var NTIP = "ntip", NLOG = "nlog", NCMD = "ncmd", NKEY = "nkey"
Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can._wss = can.ondaemon._init(can)
Volcanos(chat.ONIMPORT, {
_init: function(can, msg, target) { can._wss = can.ondaemon._init(can)
can.Conf(cli.BEGIN, can.base.Time(null, "%H:%M:%S"))
if (!can.user.isMobile && !can.misc.isDebug(can)) { can.onmotion.hidden(can); return }
can.Conf(nfs.VERSION, can.base.trimPrefix(window._version, "?_v=").split("&")[0])
@ -31,7 +32,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can._wss = can.onda
switch (event.target.value) {
case web.CLEAR:
case cli.CLOSE: break
default: var list = can.core.Split(event.target.value, lex.SP)
default:
var list = can.core.Split(event.target.value, lex.SP)
can.onexport._float(can, "cli", {index: "can.console", display: "/plugin/local/code/xterm.js"}, list, function(sub) { can.getActionSize(function(left) { can.page.style(can, sub._target, html.LEFT, left+html.PLUGIN_MARGIN, html.RIGHT, "") }) })
}
}}, "", target, [chat.TITLE]) },
@ -193,4 +195,5 @@ Volcanos(chat.ONPLUGIN, {
daemon: can.misc.sessionStorage(can, "can.daemon"),
})).Display("/plugin/story/json.js")
}),
}) })()
})
})()

View File

@ -1,11 +1,13 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) {
Volcanos(chat.ONIMPORT, {
_init: function(can, msg, target) {
can.onimport._title(can, msg, target), can.onimport._state(can, msg, target), can.onimport._search(can, msg, target)
can.onimport._avatar(can, msg, target), can.onimport._background(can, msg, target)
},
_title: function(can, msg, target) { can.core.List(can.base.getValid(can.Conf(chat.TITLE)||msg.result, [
decodeURIComponent(can.misc.Search(can, ice.POD)||location.host)]), function(item) {
_title: function(can, msg, target) {
can.core.List(can.base.getValid(can.Conf(chat.TITLE)||msg.result, [decodeURIComponent(can.misc.Search(can, ice.POD)||location.host),]), function(item) {
can.page.Append(can, target, [{view: [[html.ITEM, chat.TITLE, html.FLEX]], list: [{img: can.misc.ResourceFavicon(can)}, {text: item}], title: "返回主页", onclick: function(event) { can.onaction.title(event, can) }}])
}) },
})
},
_state: function(can, msg, target) { can.core.List(can.base.Obj(can.Conf(chat.STATE)||msg.Option(chat.STATE), [cli.QRCODE, chat.THEME, aaa.LANGUAGE, aaa.USERNICK, aaa.AVATAR, mdb.TIME]).reverse(), function(item) {
if (can.user.isMobile && can.base.isIn(item, cli.QRCODE, chat.THEME, aaa.LANGUAGE, mdb.TIME)) { return }
can.page.Append(can, target, [{view: [[html.ITEM, chat.STATE, item], "", can.Conf(item)||msg.Option(item)||""], onclick: function(event) {

View File

@ -1,5 +1,6 @@
(function() { const CAN_RIVER = "can.river", CAN_STORM = "can.storm"
Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onimport._main(can, msg), can.onappend.style(can, html.FLEX, can._action)
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { can.onimport._main(can, msg), can.onappend.style(can, html.FLEX, can._action)
var select; can.page.Appends(can, can._output, msg.Table(function(item, index) {
return can.onimport._river(can, item, function(target) { (index == 0 || item.hash == can._main_river) && (select = target) })
})), select && select.click(), can.onimport._menu(can, msg)
@ -17,7 +18,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onimport._main(can, msg
} },
_menu: function(can, msg) { can.user.isMobile || can.user.mod.isPod? can.onmotion.hidden(can, can._action): can.onappend._action(can, can.onaction.list, can._action) },
})
Volcanos(chat.ONACTION, {list: [mdb.CREATE, web.SHARE, web.REFRESH], _init: function(can) {
Volcanos(chat.ONACTION, {list: [mdb.CREATE, web.SHARE, web.REFRESH],
_init: function(can) {
can.db.storm_list = {}, can.onmotion.hidden(can)
var next = can.page.unicode.next, prev = can.page.unicode.prev
can._prev = can.page.Append(can, can._target, [{view: [[html.TOGGLE, mdb.PREV], "", prev], onclick: function(event) {
@ -123,7 +125,8 @@ Volcanos(chat.ONDETAIL, {
{name: mdb.TEXT, value: "hello", _trans: "简介"},
], function(args) { can.run({}, [river, chat.STORM, ctx.ACTION, mdb.CREATE].concat(args), function(msg) { can.misc.Search(can, {river: river, storm: msg.Result()}) }) }) },
})
Volcanos(chat.ONEXPORT, {width: function(can) { return can._target.offsetWidth },
Volcanos(chat.ONEXPORT, {
width: function(can) { return can._target.offsetWidth },
storm: function(can, msg, arg) { can.core.Item(can._root.river, function(river, value) { can.core.Item(value.storm, function(storm, item) { if (arg[1] != "" && storm.indexOf(arg[1]) == -1 && item.name.indexOf(arg[1]) == -1) { return }
msg.Push({ctx: ice.CAN, cmd: can._name, type: river, name: storm, text: shy("跳转", function(event) { can.onaction.action(event, can, river, storm) })})
}) }) },

View File

@ -1,4 +1,5 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onmotion.clear(can, can.ui.content)
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { can.onmotion.clear(can, can.ui.content)
var table = can.onappend.table(can, msg, function(value, key, index, data) { return {text: [can.base.isFunc(value) && value.help || value, html.TD], onclick: function(event) {
can.page.tagis(event.target, html.A) || can.onaction[can.db.type == mdb.FOREACH || event.ctrlKey? mdb.PLUGIN: mdb.SELECT](event, can, data)
}} }, can.ui.content, msg.append); can.onmotion.story.auto(can), can.onimport._size(can)
@ -6,7 +7,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onmotion.clear(can, can
can.onmotion.focus(can, can.ui.filter), msg.Length() == 1 && can.ui.profile.innerHTML == "" && can.page.Select(can, table, html.TD)[0].click()
},
_size: function(can) { can.ui && can.ui.content && can.getActionSize(function(left, top, width, height) {
can.page.style(can, can._target, {left: left||0, top: top||0, width: width}),
can.page.style(can, can._target, {left: left||0, top: top||0, width: width})
can.page.style(can, can._output, html.MAX_HEIGHT, height -= 2*10+(can.user.isMobile? 2: 1)*html.ACTION_HEIGHT+can.onexport.statusHeight(can))
can.core.List([can.ui.content, can.ui.display], function(target) { can.page.style(can, target, html.MAX_WIDTH, can.ConfWidth(width-2*10)) })
can.ConfHeight(can.base.Min(height-can.ui.content.offsetHeight-can.ui.display.offsetHeight, height/2))

View File

@ -543,7 +543,37 @@ Volcanos(chat.ONEXPORT, {
text: function(can, line) { return can.core.Value(can.page.SelectOne(can, line, "td.text"), "innerText") },
size: function(can, size, full) { if (size > 1) { return size } if (size > 0) { return size*full } },
keys: function(can, path, file) { return [path||can.Option(nfs.PATH), file||can.Option(nfs.FILE)].join(nfs.DF) },
content: function(can) { return can.page.Select(can, can.current&&can.current.content||can.ui.content, "td.text", function(item) { return item.innerText.trimEnd() }).join(lex.NL) },
content: function(can) {
var parse = can.onexport.parse(can)
var deep = 0
return can.page.Select(can, can.current&&can.current.content||can.ui.content, "td.text", function(item) { var text = item.innerText.trimEnd()
if (parse == "js" && !can.base.beginWith(text, "(")) { var list = []
for (var i = 0; i < text.length; i++) {
if (text[i] == "{") {
list.push(text[i])
} else if (text[i] == "}") {
if (list[list.length-1] == "{") { list.pop() } else { list.push(text[i]) }
}
if (text[i] == "(") {
list.push(text[i])
} else if (text[i] == ")") {
if (list[list.length-1] == "(") { list.pop() } else { list.push(text[i]) }
}
if (text[i] == "[") {
list.push(text[i])
} else if (text[i] == "]") {
if (list[list.length-1] == "[") { list.pop() } else { list.push(text[i]) }
}
}
if (list.indexOf("}") > -1) { deep-- } else if (list.indexOf("]") > -1) { deep-- } else if (list.indexOf(")") > -1) { deep-- }
if (deep < 0) { deep = 0 }
text = "\t".repeat(deep < 0? 0: deep)+text.trimStart()
can.base.beginWith(text, "+") && (text = "\t"+text)
if (list.indexOf("{") > -1) { deep++ } else if (list.indexOf("[") > -1) { deep++ } else if (list.indexOf("(") > -1) { deep++ }
}
return text
}).join(lex.NL)
},
position: function(can, index, total) { total = total||can.ui.content._max; return (parseInt(index))+nfs.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%" },
selection: function(can, str) { var s = document.getSelection().toString(), begin = str.indexOf(s), end = begin+s.length
for (var i = begin; i >= 0; i--) { if (str[i].match(/[a-zA-Z0-9_.]/)) { s = str.slice(i, end) } else { break } } return s

View File

@ -72,10 +72,16 @@ Volcanos(chat.ONACTION, {_trans: {input: {main: "程序", top: "顶域"}},
if (can.base.beginWith(text, "import ")) { count++; return }
if (block == "import") { count++ }
}); return count }
if (can.onexport.parse(can) == nfs.GO) { var line = can.onaction.selectLine(can); can.onmotion.clear(can, can.ui.content), can.ui.content._max = 0
if (can.onexport.parse(can) == nfs.GO) {
var line = can.onaction.selectLine(can); can.onmotion.clear(can, can.ui.content), can.ui.content._max = 0
can.core.List(msg.Result().split(lex.NL), function(text) { can.onaction.appendLine(can, text) })
can.onaction.selectLine(can, line+imports(msg.Result())-imports(msg.Option(nfs.CONTENT)))
}
if (can.onexport.parse(can) == nfs.JS) {
var line = can.onaction.selectLine(can); can.onmotion.clear(can, can.ui.content), can.ui.content._max = 0
can.core.List(msg.Option("content").split(lex.NL), function(text) { can.onaction.appendLine(can, text) })
can.onaction.selectLine(can, line)
}
},
trash: function(event, can, button) { var msg = can.request(event), p = msg.Option(nfs.PATH)+msg.Option(nfs.FILE)
can.onaction._run(event, can, button, [p], function(msg) { can.ui.zone.source.refresh() })

View File

@ -1,4 +1,5 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg) {
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.isCmdMode() || can.onmotion.hidden(can, can._action)
can.OptionPath = function(value) { return can.Option(nfs.PATH, value) }
can.OptionPid = function(value) { return can.Option(svg.PID, value) }
@ -74,9 +75,9 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) {
return meta._init && meta._init(target), target
},
layout: function(can) {
can.ui.svg && can.page.style(can, can.ui.svg, html.MIN_HEIGHT, can.ConfHeight(), html.MIN_WIDTH, can.ConfWidth())
can.ui.svg && can.page.style(can, can.ui.svg, html.MIN_HEIGHT, can.ConfHeight()-4, html.MIN_WIDTH, can.ConfWidth())
can.ui.layout && can.ui.layout(can.ConfHeight(), can.ConfWidth(), 0, function(height, width) {
can.page.style(can, can.ui.svg, html.MIN_HEIGHT, height, html.MIN_WIDTH, width)
can.page.style(can, can.ui.svg, html.MIN_HEIGHT, height-4, html.MIN_WIDTH, width)
})
},
})

View File

@ -1,5 +1,6 @@
Volcanos(chat.ONIMPORT, {
_process: function(can, msg) { if (msg.IsErr()) { can.onappend.style(can, "warn", can.user.toastFailure(can, msg.Result())._target) }
_process: function(can, msg) {
if (msg.IsErr()) { can.onappend.style(can, "warn", can.user.toastFailure(can, msg.Result())._target) }
if (can.onimport[msg.OptionProcess()]) { return can.core.CallFunc([can.onimport, msg.OptionProcess()], {can: can, sub: can.sub, msg: msg, arg: msg.Option("_arg")}), true } },
_location: function(can, msg, arg) { can.user.jumps(arg) },
_replace: function(can, msg, arg) { location.replace(arg) },
@ -130,7 +131,8 @@ Volcanos(chat.ONIMPORT, {
can.page.SelectArgs(can, can._action, "", function(target) { target.value = his[i++]||"" }); break
} can.Update(event) },
})
Volcanos(chat.ONACTION, {list: ["刷新数据",
Volcanos(chat.ONACTION, {
list: ["刷新数据",
function(can) { if (!can.user.isMobile) { return "刷新界面" } },
function(can) { if (!can.user.isMobile && !can.isCmdMode()) { return "切换浮动" } },
function(can) { if (!can.user.isMobile && !can.isCmdMode()) { return "切换全屏" } },
@ -161,14 +163,15 @@ Volcanos(chat.ONACTION, {list: ["刷新数据",
],
_engine: function(event, can, button) { can.Update(event, [ctx.ACTION, button].concat(can.Input())) },
_switch: function(can, sub, mode, save, load) {
if (can.page.ClassList.neg(can, can._target, mode)) {
(can._mode_list = can._mode_list||[]).push(kit.Dict(
if (can.page.ClassList.neg(can, can._target, mode)) { can._mode_list = can._mode_list||[]
can._mode_list.push(kit.Dict(
html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth(), ice.MODE, can.Mode()||"",
html.ACTION, can.page.isDisplay(can._action), html.STATUS, can.page.isDisplay(can._status),
html.OUTPUT, can.base.Copy({}, can._output.style, html.HEIGHT, html.WIDTH, html.MAX_HEIGHT, html.MAX_WIDTH),
ctx.STYLE, can.base.Copy({}, can._target.style, html.LEFT, html.TOP, html.RIGHT, html.BOTTOM), save()
)), can.onimport.size(can, can.ConfHeight(), can.ConfWidth(), false, mode)
} else { var back = (can._mode_list = can._mode_list||[]).pop(); if (!back) { return }
} else {
var back = (can._mode_list = can._mode_list||[]).pop(); if (!back) { return }
can.onmotion.toggle(can, can._action, back.action), can.onmotion.toggle(can, can._status, back.status)
can.onimport.size(can, back.height, back.width, false, back.mode), can.page.style(can, can._target, back.style), load && load(back)
}
@ -176,9 +179,8 @@ Volcanos(chat.ONACTION, {list: ["刷新数据",
"刷新数据": function(event, can) { can.Update(event, can.Input()), can.user.toastSuccess(can) },
"刷新界面": function(event, can) { var sub = can.sub; sub.onlayout._init(sub, sub.ConfHeight(), sub.ConfWidth()), can.user.toastSuccess(can) },
"切换浮动": function(event, can, button, sub) {
can.onaction._switch(can, sub, chat.FLOAT, function() {
can.onmotion.float(can)
}) },
can.onaction._switch(can, sub, chat.FLOAT, function() { can.onmotion.float(can) })
},
"切换全屏": function(event, can, button, sub) { can.onaction._switch(can, sub, chat.FULL, function() {
can.page.style(can, can._target, html.LEFT, "", html.TOP, can.onexport.marginTop(), html.BOTTOM, "")
can.ConfHeight(can.page.height()-can.onexport.marginTop()-can.onexport.marginBottom(can)), can.ConfWidth(can.page.width())

View File

@ -1,4 +1,5 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg, target, cb) {
Volcanos(chat.ONIMPORT, {
_init: function(can, msg, target, cb) {
if (msg.index && msg.meta && msg.list) { return cb && cb(msg), can.sup.onimport._field(can.sup, msg) }
if (can.isCmdMode() && can.Conf(ctx.STYLE) == html.FORM) { can.onappend.style(can, html.OUTPUT) }
if (can.Mode() == html.ZONE) { return can.onimport._vimer_zone(can, msg, target), cb && cb(msg) }

View File

@ -2,7 +2,7 @@ function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(t
if (type == code.OBJECT) { if (typeof arg[i] == code.OBJECT && arg[i].length == undefined) { return arg[i++] }
} else if (type == code.ARRAY) { if (typeof arg[i] == code.OBJECT && arg[i].length != undefined) { return arg[i++] }
} else if (i < arg.length && (!type || type == typeof arg[i])) { return arg[i++] }
} return cb = typeof arg[arg.length-1] == code.FUNCTION? arg[arg.length-1]: function() {}, cb.help = next(code.STRING)||"", cb.meta = next(code.OBJECT)||{}, cb.list = next(code.ARRAY)||[], cb
} return cb = typeof arg[arg.length-1] == code.FUNCTION? arg[arg.length-1]: function() {}, cb.help = next(code.STRING)||"", cb.meta = next(code.OBJECT)||{}, cb.list = next(code.ARRAY)||[], cb
}; var _can_name = "", _can_path = ""
var Volcanos = shy({iceberg: "", volcano: "", frame: chat.FRAME_JS, _cache: {}, cache: {}, pack: {}, args: {}}, function(name, can, libs, cb) {
var meta = arguments.callee.meta, list = arguments.callee.list; if (typeof name == code.OBJECT) {
@ -13,7 +13,8 @@ var Volcanos = shy({iceberg: "", volcano: "", frame: chat.FRAME_JS, _cache: {},
cb = can||function(can) { can.require([can.frame], function() { can.onengine._init(can, can.Conf(Config), panels, Config._init||meta._init, can._target) }, function(can, key, sub) { can[key] = sub }) }
can = Config, can._follow = name, can._target = Config.target||meta.target, can._height = Config.height||meta._height, can._width = Config.width||meta._width, _can_name = ""
}
can = kit.proto(can||{}, kit.proto({_name: name, _path: _can_name, _load: function(name, cbs) { var cache = meta.cache[name]||[]
can = kit.proto(can||{}, kit.proto({_name: name, _path: _can_name,
_load: function(name, cbs) { var cache = meta.cache[name]||[]
for (list.reverse(); list.length > 0; list) { var sub = list.pop(); sub != can && cache.push(sub), sub._path = sub._path||name } meta.cache[name] = cache
cache.forEach(function(sub) { var name = sub._name
if (typeof cbs == code.FUNCTION && cbs(can, name, sub)) { return }