1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00

opt module

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-03-06 18:59:11 +08:00
parent 48bfa27388
commit f57aba1296
8 changed files with 51 additions and 35 deletions

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -1,6 +1,21 @@
Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { can.require([can.volcano], null, function(can, key, sub) { can[key] = sub })
if (!can.user.isMailMaster) { if (can.misc.Search(can, ice.MSG_SESSID)) { can.misc.CookieSessid(can, can.misc.Search(can, ice.MSG_SESSID)); return can.misc.Search(can, ice.MSG_SESSID, "") } }
can.user.title(can.misc.SearchOrConf(can, chat.TITLE)||can.misc.Search(can, ice.POD)||location.host)
can.page.Append(can, document.head, ctx.STYLE, {"innerText": `
body, fieldset { border:0; margin:0; overflow:hidden; }
fieldset>legend { float:left; }
fieldset>form.option { float:left; }
fieldset>div.action { float:left; }
fieldset>div.output { clear:both; }
fieldset>form.option>div.item { float:left; }
fieldset>div.action>div.item { float:left; }
fieldset>div.status>div.item { float:left; }
fieldset.Action>legend { display:none; }
div.float, fieldset.float { position:fixed; }
div.input.float div.action>div.item { float:right; }
div.item, fieldset>legend { cursor:pointer; }
.hide { display:none; }
`})
can.onappend.theme(can, html.DARK), can.onappend.theme(can, html.LIGHT, {panel: cli.WHITE, plugin: cli.ALICEBLUE, legend: "lightsteelblue", input: cli.WHITE, output: cli.WHITE, table: cli.ALICEBLUE,
hover: cli.ALICEBLUE, border: cli.TRANSPARENT, label: cli.BLACK, text: cli.BLACK, info: cli.BLUE, warn: cli.RED})
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) }
@ -31,7 +46,9 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { can.requ
if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) }
} can.onengine.signal(panel, chat.ONREMOTE, can.request({}, {_follow: panel._follow, _msg: msg, _cmds: cmds}))
var names = msg.Option(chat._NAMES)||panel._names||((can.Conf("iceberg")||Volcanos.meta.iceberg)+panel._name)
if (msg.Option("log.trace") == ice.TRUE) { debugger }
can.misc.Run(event, can, {names: names, daemon: msg[ice.MSG_DAEMON]}, cmds, function(msg) { toast && toast.close(), toast = true
if (msg.Option("log.trace") == ice.TRUE) { debugger }
can.base.isFunc(cb) && cb(msg), Volcanos.meta.pack[can.core.Keys(panel._name, cmds.join(ice.FS))] = msg
})
},
@ -200,9 +217,10 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
}): can.core.CallFunc(action, {can: can, msg: can.request(event), arg: cmds.slice(2), cb: cb})
} return can.user.input(event, can, meta.feature[cmds[1]], function(args) { can.Update(can.request(event, {_handle: ice.TRUE}, can.Option()), cmds.slice(0, 2).concat(args), cb) })
}
return can.onengine._plugin(event, can, msg, can, cmds, cb) || can.run(event, cmds, cb||function(msg) { if (silent) { return } var _can = can._fields? can.sup: can
if (_can == (msg._can._fields? msg._can.sup: msg._can) && can.core.CallFunc([_can, chat.ONIMPORT, ice.MSG_PROCESS], {can: _can, msg: msg})) { return }
if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.CREATE, mdb.INSERT, mdb.IMPORT, nfs.TRASH) || msg.Length() == 0 && !msg.Result()) { return can.user.toastSuccess(can, cmds[1]), can.Update() } }
return can.onengine._plugin(event, can, msg, can, cmds, cb) || can.run(event, cmds, function(msg) {
var _can = can._fields? can.sup: can; if (_can == (msg._can._fields? msg._can.sup: msg._can)) { if (can.core.CallFunc([_can, chat.ONIMPORT, ice.MSG_PROCESS], {can: _can, msg: msg})) { return } }
if (can.base.isFunc(cb)) { return cb(msg) } if (silent) { return }
if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.CREATE, mdb.INSERT, mdb.IMPORT, mdb.EXPORT, "exports", "imports", nfs.TRASH) || msg.Length() == 0 && !msg.Result()) { return can.user.toastSuccess(can, cmds[1]), can.Update() } }
can.onappend._output(can, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display)
})
},
@ -311,6 +329,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
}).join(ice.NL) } can.page.Append(can, document.head, ctx.STYLE, {"innerText": render(html.BODY+ice.PT+theme, list)})
},
style: function(can, style, target) { target = target||can._fields||can._target
if (can.base.endWith(style, ".css")) { return can.require([style]) }
can.base.isObject(style) && !can.base.isArray(style)? can.page.style(can, target, style): can.page.ClassList.add(can, target, style)
},
field: function(can, type, item, target) { type = type||html.STORY, item = item||{}

View File

@ -13,13 +13,15 @@ input[name=ID] { width:48px; }
input[name=url] { width:320px; }
input[name=cmd] { background-color:black; color:white; width:100%; }
input[type=button] { background-color:black; color:cyan; }
input[type=button][name=restart] { background-color:blue; color:white; }
input[type=button][name=start] { background-color:blue; color:white; }
input[type=button][name=open] { background-color:blue; color:white; }
input[type=button][name=stop] { background-color:red; color:white; }
input[type=button][name=trash] { background-color:red; color:white; }
input[type=button][name=delete] { background-color:red; color:white; }
input[type=button][name=remove] { background-color:red; color:white; }
input:hover[type=button][name=create] { background-color:blue; color:white; }
input:hover[type=button][name=insert] { background-color:blue; color:white; }
input:hover[type=button][name=restart] { background-color:blue; color:white; }
input:hover[type=button][name=start] { background-color:blue; color:white; }
input:hover[type=button][name=open] { background-color:blue; color:white; }
input:hover[type=button][name=stop] { background-color:red; color:white; }
input:hover[type=button][name=trash] { background-color:red; color:white; }
input:hover[type=button][name=delete] { background-color:red; color:white; }
input:hover[type=button][name=remove] { background-color:red; color:white; }
textarea { background-color:cyan; padding:5px; width:100%; }
/* output */
div.project div.list { margin-left:10px; }
@ -40,7 +42,7 @@ table.content td { padding:2px 5px; }
table.content.action th:last-child { position:sticky; right:2px; }
table.content.action td:last-child { background-color:steelblue; position:sticky; right:2px; }
table.content.full { width:100%; }
div.code { background-color:#5066b945; font-size:14px; padding:10px; }
div.code { background-color:#5066b945; font-size:14px; }
div.story[data-type=spark] { background-color:#2169a9a6; color:white; padding:5px 10px; border-left:blue solid 5px; }
// div.story[data-type=spark] { background-color:#2169a9a6; color:white; padding:5px 10px; border-left:blue solid 5px; margin:10px; }
table.content div.story[data-type=spark] { margin:0; }
@ -117,7 +119,6 @@ body>div.upload input[type=file] { width:320px; }
/* font */
legend { font-size:1.2rem; line-height:32px; height:32px; }
legend>span.delete { font-size:1rem; margin-left:5px; margin-right:-15px; visibility:hidden; }
// legend:hover>span.delete { visibility:visible; }
select, input { font-size:1rem; height:32px; } textarea { tab-size:2; height:93px; } input::placeholder { font-style:italic; }
table.content, div.item, div.code, div.story[data-type=spark] { white-space:pre; text-align:left; }
table.content, div.item, div.code, div.story[data-type=spark] { font-family:monospace; }
@ -176,10 +177,10 @@ select, input[type=text], textarea { box-shadow:4px 4px 20px 4px #626bd0; }
body.black input[type=text], body.black textarea { background-color:#243783bd; color:white; outline:none; }
legend, select, input[type=button], div.tabs, div.item, span.item, th, td, h1, h2, h3 { cursor:pointer; }
div.title, div.story[data-type=spark] { cursor:copy; }
table.content tr:not(:hover) input[type=button][name=remove] { visibility:hidden; }
table.content tr:not(:hover) input[type=button][name=delete] { visibility:hidden; }
table.content tr:not(:hover) input[type=button][name=trash] { visibility:hidden; }
table.content tr:not(:hover) input[type=button][name=stop] { visibility:hidden; }
table.content tr:not(:hover) input[type=button][name=trash] { visibility:hidden; }
table.content tr:not(:hover) input[type=button][name=delete] { visibility:hidden; }
table.content tr:not(:hover) input[type=button][name=remove] { visibility:hidden; }
/* theme */
body.black a { color:yellow; }
body.black div.project div.zone>div.list>div.zone>div.item { background-color:#09466fc2; }
@ -189,13 +190,6 @@ body.white div.item.select div { background-color:yellowgreen; color:white; floa
body.white input { background-color:white; }
body.white input[name=cmd] { background-color:black; color:white; }
body.white input[type=button] { background-color:cornflowerblue; color:white; }
body.white input[type=button][name=restart] { background-color:blue; }
body.white input[type=button][name=start] { background-color:blue; }
body.white input[type=button][name=open] { background-color:blue; }
body.white input[type=button][name=stop] { background-color:red; }
body.white input[type=button][name=trash] { background-color:red; }
body.white input[type=button][name=delete] { background-color:red; }
body.white input[type=button][name=remove] { background-color:red; }
body.white textarea { background-color:white; }
body.white table.content th { background-color:skyblue; }
body.white table.content.action td:last-child { background-color:skyblue; }
@ -210,7 +204,6 @@ body.white fieldset.full { background-color:white; color:black; }
body.white legend:hover { background-color:skyblue; }
body.white select:hover { background-color:#99cc667d; }
body.white input[name=cmd]:hover { background-color:white; color:black; }
body.white input[type=button]:hover { background-color:#1b7acc8c; }
body.white div.project div.zone>div.list>div.zone>div.item:hover { background-color:#4682b46b; }
body.white div.item:hover, body.white span.item:hover { background-color:#4682b46b; }
body.white div.item.select { background-color:#4682b46b; }

View File

@ -116,7 +116,7 @@ Volcanos("base", {
} return str },
contains: function(str) { var arg = arguments; for (var i = 1; i < arg.length; i++) { if (!arg[i] || str.indexOf(arg[i]) > -1) { return true } } },
beginWith: function(str) { for (var i = 1; i < arguments.length; i++) { if (typeof str == code.STRING && str.trim().indexOf(arguments[i]) == 0) { return true } } },
endWith: function(str) { var arg = arguments; for (var i = 1; i < arg.length; i++) { if (typeof str == code.STRING && str.lastIndexOf(arg[i]) + arg[i].length == str.length) { return true } } },
endWith: function(str) { var arg = arguments; for (var i = 1; i < arg.length; i++) { if (typeof str == code.STRING && str.lastIndexOf(arg[i]) > 0 && str.lastIndexOf(arg[i]) + arg[i].length == str.length) { return true } } },
trimPrefix: function(str, pre) { if (typeof str != code.STRING) { return str } var arg = arguments, callee = arg.callee
if (arg.length > 2) { for (var i = 1; i < arg.length; i++) { str = callee(str, arg[i]) } return str }
if (str.indexOf(pre) == -1) { return str } return str.slice(pre.length)

View File

@ -7,8 +7,8 @@ Volcanos(chat.ONFIGURE, {key: {
if (can.base.isIn(msg.append[msg.append.length-1], ctx.ACTION, "cb")) { msg.append = msg.append.slice(0, -1) }
can.onmotion.clear(can), can.onappend.table(can, msg, function(value, key, index, item) { value = item[key]
return {text: [value, html.TD, value == ""? html.HR: ""], style: msg.append && msg.append.length == 1? kit.Dict(html.MIN_WIDTH, target.offsetWidth-16): {}, onclick: function(event) {
can.close(); var cb = can.Conf("select"); if (cb) { return cb(target.value = value) }
if (msg.cb && msg.cb[index]) { return msg.cb[index](value) } cb(can, value, target.value)
can.close(); if (msg.cb && msg.cb[index]) { return msg.cb[index](value) }
var _cb = can.Conf("select"); if (_cb) { return _cb(target.value = value) } can.base.isFunc(cb) && cb(can, value, target.value)
msg.Option(ice.MSG_PROCESS) == ice.PROCESS_AGAIN && can.onmotion.delay(can, function() { can._load(event, can, cb, target, name, value) })
}}
}), can.onappend._status(can, [mdb.TOTAL, mdb.INDEX]), can.Status(mdb.TOTAL, msg.Length())

View File

@ -166,11 +166,10 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl
var height = can.ui.profile.offsetHeight||can.ui.content.offsetHeight
var per = 0.5; if (msg.Append(ctx.INDEX) == web.WIKI_WORD) { per = 0.6 }
var width = can.onexport.size(can, can.db.profile_size[can.onexport.keys(can)]||per, can.ConfWidth()-can.ui.project.offsetWidth)
can.onimport.process(can, msg, can.ui.profile, height, width, function(sub) {
can.onimport.process(can, msg, can.ui.profile, height, width, function(sub) { can.ui.profile._plugin = can._msg._profile = sub
var _width = can.base.Max(sub._target.offsetWidth, width-2); if (_width == sub.ConfWidth()) { return }
can.page.style(can, sub._output, html.MAX_WIDTH, "")
var _width = can.base.Max(sub._target.offsetWidth, width-2)
can.db.profile_size[can.onexport.keys(can)] = _width, can.onimport.layout(can), sub.onimport.size(sub, height, _width, true)
can.ui.profile._plugin = can._msg._profile = sub
})
can.page.Select(can, can.ui.profile, html.TABLE, function(target) { can.onmotion.delay(can, function() {
if (target.offsetWidth < can.ui._profile.offsetWidth) { can.db.profile_size[can.onexport.keys(can)] = target.offsetWidth, can.onimport.layout(can) }
@ -181,27 +180,30 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl
var height = can.onexport.size(can, can.db.display_size[can.onexport.keys(can)]||0.5, can.ui.content.offsetHeight||can.ConfHeight())
can.page.style(can, can.ui.display, html.MAX_HEIGHT, can.ConfHeight()/2)
can.onimport.process(can, msg, can.ui.display, height, width, function(sub) {
var _height = can.base.Max(sub._target.offsetHeight, height); if (_height == sub.ConfHeight()) { return }
if (sub.ConfHeight() < can.ui.content.offsetHeight-100) { can.page.style(can, sub._output, html.MAX_HEIGHT, "") }
var _height = can.base.Max(sub._target.offsetHeight, height)
can.db.display_size[can.onexport.keys(can)] = _height, can.onimport.layout(can), sub.onimport.size(sub, _height, width, true)
})
},
process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target)
if (msg.Option(ice.MSG_PROCESS) == ice.PROCESS_FIELD) {
msg.Table(function(item) { item.type = chat.STORY, item.display = msg.Option(ice.MSG_DISPLAY), item.height = height-2*html.ACTION_HEIGHT, item.width = width
if (item.index == web.CODE_XTERM) { item.style = html.OUTPUT }
if (item.index == web.WIKI_WORD) { item.style = html.OUTPUT }
if (item.index == web.CODE_XTERM) { item.style = html.OUTPUT } if (item.index == web.WIKI_WORD) { item.style = html.OUTPUT }
can.onimport.plug(can, item, function(sub) { height && sub.ConfHeight(item.height), width && sub.ConfWidth(item.width)
sub.onaction.close = function() { can.onmotion.hidden(can, target), can.onimport.layout(can) }
sub.onexport.output = function(_sub, _msg) { can.onmotion.delay(can, function() { can.base.isFunc(cb) && cb(_sub, _msg) }) }
sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, can.Option()), item.index, cmds, function(msg) {
height && sub.ConfHeight(item.height), width && sub.ConfWidth(item.width)
can.base.isFunc(cb) && cb(msg)
if (sub == (msg._can._fields? msg._can.sup: msg._can)) {
if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.IMPORT, mdb.EXPORT, "imports", "exports")) { return can.user.toastSuccess(can, cmds[1]), sub.Update() } }
} can.base.isFunc(cb) && cb(msg)
}) }
}, target)
})
} else if (msg.Option(ice.MSG_DISPLAY) != "") {
can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY), target, false, function(msg) { can.onimport.layout(can) })
} else if (msg.Result().indexOf("<iframe src=") > -1) {
var src = can.page.Select(can, can.page.Create(can, html.DIV, msg.Result()), html.IFRAME, function(target) { return target.src })[0]
can.page.Append(can, target, [{type: html.IFRAME, src: src, style: {height: height, width: width}}])
} else if (msg.Length() > 0 || msg.Result() != "") {
can.onappend.table(can, msg, function(value, key, index, line, array) {
return {text: [value, html.TD], onclick: function(event) { if (line.line || line.file) {

View File

@ -561,6 +561,7 @@ Volcanos(chat.ONSYNTAX, {
"meta": code.KEYWORD,
"link": code.KEYWORD,
"title": code.KEYWORD,
"script": code.KEYWORD,
"h1": code.KEYWORD,
"h2": code.KEYWORD,

View File

@ -281,8 +281,9 @@ var Volcanos = shy({iceberg: "/chat/", volcano: "/frame.js", cache: {}, pack: {}
}
if (libs[0] == undefined) { return can.require(libs.slice(1), cb, cbs) }
if (libs[0] == "") { libs[0] = can._path.replace(nfs._JS, nfs._CSS) }
if (libs[0].indexOf("src/") == 0) { libs[0] = "/require/"+libs[0] }
if (libs[0][0] != ice.PS && libs[0].indexOf(ice.HTTP) != 0) { libs[0] = can._path.slice(0, can._path.lastIndexOf(ice.PS)+1)+libs[0] }
var name = (libs[0].indexOf(ice.HTTP) == 0? libs[0]: libs[0].split("?")[0]).toLowerCase()
var name = (libs[0].indexOf(ice.HTTP) == 0? libs[0]: libs[0].split(ice.QS)[0]).toLowerCase()
function next() { can._load(name, cbs), can.require(libs.slice(1), cb, cbs) }
meta.cache[name]? next(): (_can_path = libs[0], meta._load(name, next))
},