1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
harveyshao 2022-10-16 22:39:44 +08:00
parent 68348b0176
commit dfce6de0f4
8 changed files with 63 additions and 85 deletions

View File

@ -309,11 +309,10 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list,
action === false || table.onappend._action(table, msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), action)
action === false || table.onappend._status(table, msg.Option(ice.MSG_STATUS))
// action === false || table.onimport.tool(table, can.base.Obj(msg.Option(ice.MSG_TOOLKIT)))
var mode= ["float", "full", "cmd"]; for (var i in mode) {
if (can.page.ClassList.has(can, can._target, mode[i])) { table.onlayout[mode[i]](table); break }
}
can.base.isFunc(cb) && cb(msg)
can.onaction._output(can, msg), can.base.isFunc(cb) && cb(msg)
}, target: output||can._output})
})
},

View File

@ -165,11 +165,11 @@ Volcanos(chat.ONACTION, {help: "控件交互",
]}]); return ui.tr
},
selectLine: function(can, line) {
if (!line) { return parseInt(can.core.Value(can.page.Select(can, can.ui._content, [[[html.TR, html.SELECT], [html.TD, nfs.LINE]]])[0], "innerText")||"1") }
can.page.Select(can, can.ui._content, html.TR, function(item, index, array) {
if (!can.page.ClassList.set(can, item, html.SELECT, item == line || index+1 == line)) { return }
line = item, can.Status("当前行", can.onexport.position(can, can.Option(nfs.LINE, index+1)))
}); if (!can.base.isObject(line)) { return 1 }
if (!line) { return can.onexport.line(can, can.page.Select(can, can.ui._content, "tr.select")[0]) }
can.page.Select(can, can.ui._content, "tr>td.line", function(td, index) { var tr = td.parentNode, n = parseInt(td.innerText)
if (!can.page.ClassList.set(can, tr, html.SELECT, tr == line || n == line)) { return }
line = tr, can.Status("当前行", can.onexport.position(can, can.Option(nfs.LINE, n)))
}); if (!can.base.isObject(line)) { return 0 }
can.page.Select(can, line, "td.text", function(item) {
can.current = {
@ -184,7 +184,7 @@ Volcanos(chat.ONACTION, {help: "控件交互",
}
can.onimport.history(can, {path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE)})
can.onexport.hash(can), can.onengine.signal(can, "tabview.line.select")
}); return parseInt(can.page.Select(can, line, "td.line")[0].innerText)
}); return can.onexport.line(can, line)
},
searchLine: function(event, can, value) {
can.runAction(can.request(event, {name: value, text: can.current.text()}, can.Option()), code.NAVIGATE, [], function(msg) {
@ -211,6 +211,8 @@ Volcanos(chat.ONEXPORT, {help: "导出数据", list: ["文件数", "解析器",
keys: function(can, path, file) { return [path||can.Option(nfs.PATH), file||can.Option(nfs.FILE)].join(ice.FS) },
content: function(can) { return can.page.Select(can, can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL) },
position: function(can, index, total) { total = total||can.max; return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%" },
text: function(can, line) { return can.core.Value(can.page.Select(can, line, "td.text")[0], "innerText") },
line: function(can, line) { return parseInt(can.core.Value(can.page.Select(can, line, "td.line")[0], "innerText")) },
})
Volcanos(chat.ONIMPORT, {help: "导入数据",
@ -258,14 +260,17 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
},
display: function(can, msg) {
var height = can.display_size[can.onexport.keys(can)]||can.ConfHeight()/2
can.onimport.process(can, msg, can.ui.display_output, height, can.ui.display.offsetWidth)
can.onimport.process(can, msg, can.ui.display_output, height, can.ui.display.offsetWidth, function(sub) {
can.display_size[can.onexport.keys(can)] = can.base.Max(sub._output.offsetHeight, can.ConfHeight()/2)+2*html.ACTION_HEIGHT+sub.onexport.statusHeight(sub)
can.onimport.layout(can)
})
can.onappend._status(can, msg.Option(ice.MSG_STATUS), can.ui.display_status)
can.onmotion.toggle(can, can.ui.display, true), can.onimport.layout(can)
},
process: function(can, msg, target, height, width) { can.onmotion.clear(can, target), can.user.toastSuccess(can)
process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target), can.user.toastSuccess(can)
if (msg.Option(ice.MSG_PROCESS) == "_field") {
msg.Table(function(item) { item.display = msg.Option(ice.MSG_DISPLAY)
can.onimport.plug(can, item, target, function(sub) {
can.onimport.plug(can, item, target, function(sub) { sub.onaction._output = function(_sub, _msg) { can.base.isFunc(cb) && cb(_sub, _msg) }
sub.onaction.close = function() { can.onmotion.hidden(can, target.parentNode), can.onimport.layout(can) }
height && sub.ConfHeight(height-3*html.ACTION_HEIGHT), width && sub.ConfWidth(width), sub.Focus()
})

View File

@ -272,6 +272,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮",
},
keyword: {
"var": code.KEYWORD,
"typeof": code.KEYWORD,
"if": code.KEYWORD,
"else": code.KEYWORD,

View File

@ -155,7 +155,7 @@ Volcanos(chat.ONKEYMAP, {help: "键盘交互",
yy: shy("复制当前行", function(event, can, target, count) {
var list = [], line = can.current.line; for (var i = 0; i < count; i++) {
list.push(can.core.Value(can.page.Select(can, line, "td.text")[0], "innerText")), line = line.nextSibling
list.push(can.onexport.text(can, line)), line = line.nextSibling
} can._last_text = list
return true
}),
@ -184,7 +184,7 @@ Volcanos(chat.ONKEYMAP, {help: "键盘交互",
}),
J: shy("合并两行", function(can) {
var next = can.current.next(); if (!next) { return }
var rest = can.page.Select(can, next, "td.text")[0].innerText
var rest = can.onexport.text(can, next)
var line = can.onaction.selectLine(can), text = can.current.text()
can.ui.current.value = can.current.text(text.trimRight()+ice.SP+rest.trimLeft()), can.onaction.deleteLine(can, next)
can.undo.push(function() { can.onaction.modifyLine(can, line, text), can.onaction.insertLine(can, rest, line+1) })
@ -265,7 +265,7 @@ Volcanos(chat.ONACTION, {help: "控件交互",
},
save: function(event, can, button) { can.request(event, {file: can.Option(nfs.FILE), content: can.onexport.content(can)})
can.onaction._run(event, can, button, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)])
can.onaction._run(event, can, button, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function() { can.user.toastSuccess(can, button) })
},
compile: function(event, can, button) {
can.runAction(can.request(event, {_toast: "编译中..."}), button, [], function(msg) {
@ -409,13 +409,13 @@ Volcanos(chat.ONACTION, {help: "控件交互",
},
_getLine: function(can, line) {
return can.page.Select(can, can.ui.content, html.TR, function(item, index, array) { if (item == line || index+1 == line) { return item } })[0]
return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return td.parentNode } })[0]
},
_getLineno: function(can, line) {
return can.page.Select(can, can.ui.content, html.TR, function(item, index, array) { if (item == line || index+1 == line) { return index+1 } })[0]
return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return index+1 } })[0]
},
rerankLine: function(can, value) {
can.max = can.page.Select(can, can.ui.content, "tr>td.line", function(target, index) { return target.innerText = index+1 }).length
can.max = can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { return td.innerText = index+1 }).length
},
insertLine: function(can, value, before) { var line = can.onaction.appendLine(can, value)
before && can.ui.content.insertBefore(line, can.onaction._getLine(can, before))
@ -426,8 +426,8 @@ Volcanos(chat.ONACTION, {help: "控件交互",
return can.page.Remove(can, line), can.onaction.rerankLine(can), next
},
modifyLine: function(can, line, value) {
can.page.Select(can, can.onaction._getLine(can, line), "td.text", function(target) {
target.innerHTML = can.onsyntax._parse(can, value)
can.page.Select(can, can.onaction._getLine(can, line), "td.text", function(td) {
td.innerHTML = can.onsyntax._parse(can, value)
})
},

View File

@ -1,42 +1,29 @@
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
can.onmotion.clear(can, target), can.base.isFunc(cb) && cb(msg)
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) { can.onmotion.clear(can, target)
can.ui = can.onlayout.profile(can), can.onimport[can.Option("scale")||"week"](can, msg)
can.page.style(can, can.ui.project, html.MAX_HEIGHT, can.ui.content.offsetHeight)
can.page.style(can, can.ui.profile, html.MAX_HEIGHT, can.ui.content.offsetHeight)
can.user.isMobile && !can.user.isLandscape() && can.onmotion.hidden(can, can.ui.project)
!can.user.isMobile && can.onmotion.toggle(can, can.ui.profile, true)
!can.user.isMobile && can.onmotion.toggle(can, can.ui.display, true)
can.onappend.tools(can, msg)
can.onappend.tools(can, msg), can.base.isFunc(cb) && cb(msg)
can.Status(mdb.COUNT, msg.Length())
},
_content: function(can, msg, head, list, key, get, set) {
_content: function(can, msg, head, list, key, get, set) { var begin_time = can.base.Date(can.Option("begin_time"))
var hash = {}; msg.Table(function(value, index) { var k = key(can.base.Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value]) })
can.sup.task && (can.sup.task._target = null)
var begin_time = can.base.Date(can.Option("begin_time"))
can.page.Append(can, can.ui.content, [{view: [chat.CONTENT, html.TABLE], list: can.core.List(list, function(hour, row) {
return {type: html.TR, list: can.core.List(head, function(week, col) {
if (row == 0) { return {text: [can.user.trans(can, week), html.TH]} }
if (col == 0) { return {text: [hour, html.TD]} }
return can.onimport._task(can, msg, get(begin_time, col, row, hash), set(begin_time, col, row))
})}
}) }]), can.Status(mdb.COUNT, msg.Length())
msg.Length() > 0 && can.sup.task && can.onmotion.delay(can, function() {
var target = can.sup.task._target||can.task._target; can.sup.task = null, target && target.click()
})
}) }]); if (!can.sup.task) { return }
can.onmotion.delay(can, function() { var target = can.sup.task._target||can.task._target; can.sup.task = null, target && target.click() })
},
_task: function(can, msg, list, time) { return {text: ["", html.TD],
ondblclick: function(event) {
can.onaction.insertTask(event, can, time+can.base.Time(null, "%y-%m-%d %H:%M:%S").slice(time.length))
},
ondrop: function(event) { can.onkeymap.prevent(event)
can.drop(event, event.target, time)
},
ondragover: function(event) { can.onkeymap.prevent(event)
can.page.Select(can, can.ui.content, html.TD, function(item) {
can.page.ClassList.set(can, item, "over", event.target == item)
})
},
ondblclick: function(event) { can.onaction.insertTask(event, can, time+can.base.Time(null, "%y-%m-%d %H:%M:%S").slice(time.length)) },
ondrop: function(event) { can.onkeymap.prevent(event), can.drop(event, event.target, time) },
ondragover: function(event) { can.onkeymap.prevent(event), can.page.Select(can, can.ui.content, html.TD, function(td) { can.page.ClassList.set(can, td, "over", td == event.target) }) },
list: can.core.List(list, function(task) {
return can.base.isString(task)? {text: [task, html.DIV, "date"]}: {text: [can.onexport[can.Action("view")||"text"](can, task), html.DIV, can.onexport.style(can, task)],
ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { td.append(target)
@ -65,6 +52,12 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
case "zone":
case "id":
return
case "status":
msg.Push(key, "prepare")
msg.Push(key, "process")
msg.Push(key, "finish")
msg.Push(key, "cancel")
break
case "level":
case "score":
msg.Push(key, "1")
@ -73,52 +66,38 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
msg.Push(key, "4")
msg.Push(key, "5")
break
case "status":
msg.Push(key, "prepare")
msg.Push(key, "process")
msg.Push(key, "finish")
msg.Push(key, "cancel")
break
}
can.onmotion.modify(can, event.target, function(sub, value) {
can.onaction.modifyTask(event, can, task, key, value)
event.target.innerText = value
can.onaction.modifyTask(event, can, task, key, value), event.target.innerText = value
}, {name: key, action: key.indexOf(mdb.TIME) > 0? "date": "key", msg: msg, mode: "simple"})
},
}]) }), can.onimport._display(can, task)
},
_display: function(can, task) { if (!task["extra.index"]) { return }
can.onappend.plugin(can, {type: "plug", index: task["extra.index"], args: task["extra.args"]}, function(sub, meta) {
sub.run = function(event, cmds, cb) { var msg = can.request(event, kit.Dict("task.pod", task["pod"], "task.zone", task.zone, "task.id", task.id))
can.runAction(event, ice.RUN, [task[mdb.ZONE], task[mdb.ID]].concat(cmds), cb)
can.onappend.plugin(can, {type: chat.STORY, index: task["extra.index"], args: task["extra.args"]}, function(sub, meta) {
sub.run = function(event, cmds, cb) {
can.runAction(can.request(event, kit.Dict("task.pod", task.pod, "task.zone", task.zone, "task.id", task.id)), ice.RUN, [task[mdb.ZONE], task[mdb.ID]].concat(cmds), cb)
}
sub.ConfHeight(can.ConfHeight()-can.ui.content.offsetHeight-3*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth()-can.ui.project.offsetWidth)
}, can.ui.display)
},
day: function(can, msg) {
var head = ["hour", "task"]
day: function(can, msg) { var head = ["hour", "task"]
var list = [0]; for (var i = 7; i < 24; i++) { list.push(can.base.Number(i, 2)) }
function key(time) { return can.base.Number(time.getHours(), 2) }
function get(begin_time, col, row, hash) { return hash[list[row]] }
function set(begin_time, col, row) { return can.base.Time(begin_time, "%y-%m-%d ")+list[row] }
can.onimport._content(can, msg, head, list, key, get, set)
},
week: function(can, msg) {
var head = can.onexport.head(can, "hour")
week: function(can, msg) { var head = can.onexport.head(can, "hour")
var list = [0]; for (var i = 7; i < 24; i++) { list.push(can.base.Number(i, 2)) }
function key(time) { return time.getDay()+" "+can.base.Number(time.getHours(), 2) }
function get(begin_time, col, row, hash) { return hash[col-1+" "+list[row]] }
function set(begin_time, col, row) { return can.base.Time(can.base.TimeAdd(begin_time, -begin_time.getDay()+col-1), "%y-%m-%d ")+list[row] }
can.onimport._content(can, msg, head, list, key, get, set)
},
month: function(can, msg) {
var head = can.onexport.head(can, "order")
month: function(can, msg) { var head = can.onexport.head(can, "order")
var list = [0]; for (var i = 1; i < 6; i++) { list.push(i) }
function key(time) { return can.base.Time(time, "%y-%m-%d") }
function get(begin_time, col, row, hash) {
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
@ -132,17 +111,13 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
var day = can.base.TimeAdd(last, (row-1)*7+col)
return key(day)
}
can.onimport._content(can, msg, head, list, key, get, set)
},
year: function(can, msg) {
var head = can.onexport.head(can, "month")
year: function(can, msg) { var head = can.onexport.head(can, "month")
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
function key(time) { return can.base.Time(time, "%y-%m ")+time.getDay() }
function get(begin_time, col, row, hash) { return hash[begin_time.getFullYear()+"-"+can.base.Number(row, 2)+" "+(col-1)] }
function set(begin_time, col, row) { return begin_time.getFullYear()+"-"+can.base.Number(list[row], 2) }
can.onimport._content(can, msg, head, list, key, get, set)
},
long: function(can, msg) {
@ -151,28 +126,24 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
var head = ["month"]; for (var i = 0; i < 10; i++) { head.push(begin+i) }
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
function key(time) { return can.base.Time(time, "%y-%m") }
function get(begin_time, col, row, hash) { return hash[begin+col-1+"-"+can.base.Number(row, 2)] }
function set(begin_time, col, row) { return begin+col-1+"-"+can.base.Number(row, 2) }
can.onimport._content(can, msg, head, list, key, get, set)
},
}, [""])
Volcanos(chat.ONACTION, {help: "组件交互", list: [
"insert", "export", "import",
["level", "all", "l1", "l2", "l3", "l4", "l5"],
Volcanos(chat.ONACTION, {help: "组件交互", list: [mdb.INSERT, mdb.EXPORT, mdb.IMPORT,
["status", "all", "prepare", "process", "cancel", "finish"],
["level", "all", "l1", "l2", "l3", "l4", "l5"],
["score", "all", "s1", "s2", "s3", "s4", "s5"],
["view", "", "name", "text", "level", "score"],
],
_trans: {"task": "任务", "hour": "时间", "month": "月份"},
], _trans: {"task": "任务", "hour": "时间", "month": "月份"},
insertTask: function(event, can, time) { var msg = can.sup.request(event, {begin_time: time})
can.user.input(event, can, can.Conf([ctx.FEATURE, mdb.INSERT]), function(args) {
can.runAction(event, mdb.INSERT, ["zone", args[1], "begin_time", time].concat(args))
})
},
modifyTask: function(event, can, task, key, value) {
modifyTask: function(event, can, task, key, value) { task[key] = value
can.runAction(can.request(event, task, can.Option()), mdb.MODIFY, [key, value])
},
@ -191,8 +162,8 @@ Volcanos(chat.ONACTION, {help: "组件交互", list: [
}
can.Action(key, value), can.Status(mdb.COUNT, count)
},
level: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
status: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
level: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
score: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
view: function(event, can, key, value) { can.Action(key, value)
can.onmotion.clear(can, can.ui.project), can.onmotion.clear(can, can.ui.content)

View File

@ -152,7 +152,9 @@ Volcanos(chat.ONDETAIL, {help: "组件菜单", list: ["关闭", "下载", "删
"下一个": function(event, can) { can.order < can.list.length-1? can.show(++can.order): can.user.toast(can, "已经是最后一张啦!") },
"设置头像": function(event, can) { can.setHeader("avatar", can.onimport._file(can, can.list[can.order].path)) },
"设置背景": function(event, can) { can.setHeader("background", can.onimport._file(can, can.list[can.order].path)) },
"复制链接": function(event, can) { can.user.copy(event, can, can.misc.MergeURL(can, {_path: can.onimport._file(can, can.list[can.order].path)}, true)) },
"复制链接": function(event, can) {
can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.misc.MergeURL(can, {_path: can.onimport._file(can, can.list[can.order].path)}, true)) ])
},
})
Volcanos(chat.ONEXPORT, {help: "导出数据", list: [cli.BEGIN, mdb.LIMIT, mdb.TOTAL, nfs.FILE, "position"],
height: function(can) { var height = can.Action(html.HEIGHT)

View File

@ -118,6 +118,7 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [
}
},
_resize: function(can, auto, height, width) { can.onimport.size(can, height, width, auto) },
_output: function(can, msg) { },
"刷新页面": function(event, can, button, sub) { can.core.CallFunc([sub.onlayout, "_init"], {can: sub}), can.user.toastSuccess(can, button) },
"刷新数据": function(event, can) { can.Update({}, can.Input([], true)) },

View File

@ -3,7 +3,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
var cbs = can.onimport[msg.Option(ctx.STYLE)||can.Conf(ctx.STYLE)]; if (can.base.isFunc(cbs)) {
can.core.CallFunc(cbs, {can: can, msg: msg, target: target, list: msg.Table()})
can.page.ClassList.add(can, target, can._args[ctx.STYLE])
return cbs(can, msg, target)
return cbs(can, msg, cb, target)
}
can.page.style(can, can._output, html.HEIGHT, "")
@ -147,7 +147,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
}}
})).first
},
card: function(can, msg, target) {
card: function(can, msg, cb, target) {
can.page.Appends(can, target, msg.Table(function(value) {
return {view: html.ITEM+" "+(value.status||""), list: [
{view: [wiki.TITLE, html.DIV, value.name]},
@ -158,10 +158,9 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
]}
}))
can.page.Select(can, target, "input[type=button]", function(target) {
if (target.value == target.name) {
target.value = can.user.trans(can, target.name)
}
if (target.value == target.name) { target.value = can.user.trans(can, target.name) }
})
can.base.isFunc(cb) && cb(msg)
},
plug: function(can, meta, target, cb) { if (!meta || !meta.index) { return }
meta.type = "plug", can.onappend.plugin(can, meta, function(sub) { sub.sup = can
@ -172,7 +171,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
}, target)
},
tool: function(can, list, cb, target) { target = target||can._output
can.core.List(list, function(meta) { typeof meta == "string" && (meta = {index: meta})
can.core.List(list.reverse(), function(meta) { typeof meta == "string" && (meta = {index: meta})
can.onimport.plug(can, meta, target, function(sub) { sub._delay_init = true
sub.ConfHeight(can.ConfHeight()-4*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth())
sub.page.style(sub, sub._output, html.MAX_HEIGHT, sub.ConfHeight())
@ -186,7 +185,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
}
can.onmotion.select(can, target, html.FIELDSET, sub._target), sub.Focus()
can.onmotion.select(can, can._status, html.LEGEND, event.target)
if (meta.msg == true) { meta.msg = false, sub.Update() }
if (sub._delay_init || meta.msg == true) { sub._delay_init = false, meta.msg = false, sub.Update() }
}, sub.select = function() { return sub._legend.click(), sub }
sub.onaction.close = function() { sub.select() }
sub._legend.onmouseenter = null