1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-26 01:04:06 +08:00
This commit is contained in:
shaoying 2021-01-25 00:56:51 +08:00
parent e195374528
commit 6c251ac241
8 changed files with 73 additions and 74 deletions

View File

@ -15,7 +15,6 @@ Volcanos("onengine", {help: "解析引擎", list: [], _init: function(can, meta,
pane.onaction._init(pane, msg, [], cb, pane._target) pane.onaction._init(pane, msg, [], cb, pane._target)
}) })
}, },
search: function(event, can, msg, pane, cmds, cb) { search: function(event, can, msg, pane, cmds, cb) {
var sub, mod = can, fun = can, key = ""; can.core.List(cmds[1].split("."), function(value) { var sub, mod = can, fun = can, key = ""; can.core.List(cmds[1].split("."), function(value) {
fun && (sub = mod, mod = fun, fun = mod[value], key = value) fun && (sub = mod, mod = fun, fun = mod[value], key = value)
@ -213,12 +212,12 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
meta.feature = sub.base.Obj(meta.feature, {}) meta.feature = sub.base.Obj(meta.feature, {})
sub.page.ClassList.add(sub, field, meta.style||meta.feature.style||"") sub.page.ClassList.add(sub, field, meta.style||meta.feature.style||"")
meta.inputs && sub.onappend._option(sub, meta, sub._option)
typeof cb == "function" && cb(sub) typeof cb == "function" && cb(sub)
meta.option = can.base.Obj(meta.option||"{}", {})
meta.inputs && sub.onappend._option(sub, meta, sub._option)
}); return sub }); return sub
}, },
_option: function(can, meta, option) { var index = -1, args = can.base.Obj(meta.args||meta.arg, []) _option: function(can, meta, option) { var index = -1, args = can.base.Obj(meta.args||meta.arg, [])
meta.option = can.base.Obj(meta.option||"{}", {})
function add(item, next) { item._input != "button" && item.type != "button" && index++ function add(item, next) { item._input != "button" && item.type != "button" && index++
Volcanos(item.name, {_follow: can._follow+"."+item.name, Volcanos(item.name, {_follow: can._follow+"."+item.name,
_option: can._option, _action: can._action, _output: can._output, _status: can._status, _option: can._option, _action: can._action, _output: can._output, _status: can._status,
@ -277,7 +276,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
} }
var feature = can.Conf("feature") var feature = can.Conf("feature")
var input = cmds && cmds[0] == "action" && feature && feature[cmds[1]]; if (input) { var input = cmds && cmds[0] == "action" && cmds.length == 2 && feature && feature[cmds[1]]; if (input) {
can.user.input(event, can, input, function(ev, button, data, list) { can.user.input(event, can, input, function(ev, button, data, list) {
cmds = cmds.slice(0, 2), can.core.Item(data, function(key, value) { cmds = cmds.slice(0, 2), can.core.Item(data, function(key, value) {
key && value && cmds.push(key, value) key && value && cmds.push(key, value)
@ -320,7 +319,6 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
table.onaction && table.onappend._action(table, msg._action||meta._action||table.onaction.list) table.onaction && table.onappend._action(table, msg._action||meta._action||table.onaction.list)
table.ondetail && table.onappend._detail(table, msg._detail||meta._detail||table.ondetail.list) table.ondetail && table.onappend._detail(table, msg._detail||meta._detail||table.ondetail.list)
table.onexport && table.onappend._status(table, msg._export||meta._export||table.onexport.list) table.onexport && table.onappend._status(table, msg._export||meta._export||table.onexport.list)
}, can._output) }, can._output)
}) })
}) })

View File

@ -66,7 +66,8 @@ Volcanos("base", {help: "基础模块",
return size + "B" return size + "B"
}, },
Date: function(t) { var now = new Date() Date: function(t) { var now = new Date()
if (t && typeof t == "string") { var ls = t.split(" ") if (t == "") { return now }
if (typeof t == "string") { var ls = t.split(" ")
var vs = ls[0].split("-") var vs = ls[0].split("-")
now.setFullYear(parseInt(vs[0])) now.setFullYear(parseInt(vs[0]))
now.setMonth(parseInt(vs[1])-1) now.setMonth(parseInt(vs[1])-1)

View File

@ -300,7 +300,7 @@ Volcanos("page", {help: "网页模块",
text = text.replace(/\\n/g, "<br>") text = text.replace(/\\n/g, "<br>")
return text return text
}, },
Format: function(type) { Format: function(type, src, name) {
switch (type) { switch (type) {
case "a": case "a":
return "<a href='"+arguments[1]+"' target='_blank'>"+(arguments[2]||arguments[1])+"</a>" return "<a href='"+arguments[1]+"' target='_blank'>"+(arguments[2]||arguments[1])+"</a>"

View File

@ -21,9 +21,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}) })
}, },
toast: function(can, msg, text) { toast: function(can, msg, text) { can.page.Modify(can, can.toast, text) },
can.page.Modify(can, can.toast, text)
},
ncmd: function(can, target) { ncmd: function(can, target) {
can.page.Select(can, target, "span.ncmd", function(item) { can.page.Select(can, target, "span.ncmd", function(item) {
item.innerHTML = can.Conf("ncmd", parseInt(can.Conf("ncmd")||"0")+1+"")+"" item.innerHTML = can.Conf("ncmd", parseInt(can.Conf("ncmd")||"0")+1+"")+""
@ -31,9 +29,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}, },
}) })
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg, list, cb, target) { Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg, list, cb, target) {
can.run({}, [], function(msg) { can.run({}, [], function(msg) { can.onimport._init(can, msg, list, cb, can._output) })
can.onimport._init(can, msg, list, cb, can._output)
})
}, },
}) })
Volcanos("onexport", {help: "导出数据", list: [], Volcanos("onexport", {help: "导出数据", list: [],

View File

@ -6,14 +6,14 @@ fieldset.plan>div.output div.process {
background-color:green; background-color:green;
color:white; color:white;
} }
fieldset.plan>div.output div.finish {
background-color:red;
color:white;
}
fieldset.plan>div.output div.cancel { fieldset.plan>div.output div.cancel {
background-color:yellow; background-color:yellow;
color:white; color:white;
} }
fieldset.plan>div.output div.finish {
background-color:red;
color:white;
}
fieldset.plan>div.output td { fieldset.plan>div.output td {
vertical-align:top; vertical-align:top;

View File

@ -6,44 +6,41 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.onimport[can.Option("scale")||"week"](can, msg) can.onimport[can.Option("scale")||"week"](can, msg)
}, },
_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.base.Time(can.Option("begin_time")))
var hash = {}; msg.Table(function(value, index) { var hash = {}; msg.Table(function(value, index) {
var k = key(can.base.Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value]) var k = key(can.base.Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
can.Status("count", index+1) }), can.Status("count", msg.Length())
})
var begin_time = can.base.Date(can.Option("begin_time"))
can.page.Append(can, can.ui.content, [{view: ["content", "table"], list: can.core.List(list, function(hour, row) { can.page.Append(can, can.ui.content, [{view: ["content", "table"], list: can.core.List(list, function(hour, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(week) { return {text: [week, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(week, col) { return {type: "tr", list: can.core.List(head, function(week, col) {
if (row == 0) { return {text: [week, "th"]} }
if (col == 0) { return {text: [hour, "td"]} } if (col == 0) { return {text: [hour, "td"]} }
return can.onimport._task(can, msg, set(begin_time, col, row), get(begin_time, col, row, hash)) return can.onimport._task(can, msg, get(begin_time, col, row, hash), set(begin_time, col, row))
})} })}
}) }]) }) }])
}, },
_task: function(can, msg, time, list, view) { return {text: ["", "td"], _task: function(can, msg, list, time, view) { return {text: ["", "td"],
ondrop: function(event) { ondblclick: function(event) {
can.onaction.insertTask(event, can, time+can.base.Time().slice(time.length))
},
ondrop: function(event) { event.preventDefault()
can.drop(event, event.target, time) can.drop(event, event.target, time)
event.preventDefault()
}, },
ondragover: function(event) { ondragover: function(event) { event.preventDefault()
can.page.Select(can, can.ui.content, "td", function(item) { can.page.ClassList.del(can, item, "over") }) can.page.Select(can, can.ui.content, "td", function(item) {
can.page.ClassList.add(can, event.target, "over") can.page.ClassList[event.target == item? "add": "del"](can, item, "over")
event.preventDefault() })
}, },
ondblclick: function(event) { var now = can.base.Time() list: can.core.List(list, function(task) { return typeof task == "string"? {text: [task, "div", "date"]}:
can.onaction.insertTask(event, can, can.base.Time(can.base.Date(time+now.slice(time.length)))) {text: [can.onexport[view||can.Action("view")||"text"](can, task), "div", can.onexport.style(can, task)],
}, ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { td.append(target)
list: can.core.List(list, function(task) { return typeof task == "string"? {view: ["date", "div", task]}:
{view: [can.onexport.style(can, task), "div", can.onexport[view||can.Action("view")||"text"](can, task)],
draggable: time != undefined, ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) {
can.onaction.modifyTask(event, can, task, "begin_time", time+task.begin_time.slice(time.length), task.begin_time) can.onaction.modifyTask(event, can, task, "begin_time", time+task.begin_time.slice(time.length), task.begin_time)
can.run() } }, draggable: time != undefined,
} }, title: can.onexport.title(can, task),
_init: function(target) { title: can.onexport.title(can, task), _init: function(target) {
var item = can.onappend.item(can, "item", {nick: task.name+":"+task.text}, function() { var item = can.onappend.item(can, "item", {nick: task.name+":"+task.text}, function() {
can.onimport._profile(can, msg, task)
can.core.Timer(10, function() { can.onmotion.select(can, can.ui.content, "td", target.parentNode) }) can.core.Timer(10, function() { can.onmotion.select(can, can.ui.content, "td", target.parentNode) })
can.onimport._profile(can, task)
}, function() { }, function() {
}, can.ui.project); can.task || item.click() }, can.ui.project); can.task || item.click()
@ -52,37 +49,46 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
} }
}), }),
} }, } },
_profile: function(can, msg, task) { _profile: function(can, task) {
task.extra && can.core.Item(can.base.Obj(task.extra), function(key, value) { task["extra."+key] = value }), delete(task.extra) task.extra && can.core.Item(can.base.Obj(task.extra), function(key, value) { task["extra."+key] = value }), delete(task.extra)
var info = {}; can.core.List(can.onexport.list, function(key) { info[key] = task[key] }), can.Status(info)
if (can.task) {
can.page.Cache(can.task.id+".profile", can.ui.profile, can.task.id)
can.page.Cache(can.task.id+".display", can.ui.display, can.task.id)
}
can.task && can.page.Cache(can.task.id, can.ui.display, can.task.id)
can.task = task can.task = task
var info = {}; can.core.List(can.onexport.list, function(key) { info[key] = task[key] }) var profile = can.page.Cache(task.id+".profile", can.ui.profile)
can.Status(info); can.page.Cache(task.id, can.ui.display) || task["extra.cmd"] && can.onappend.plugin(can, { var display = can.page.Cache(task.id+".display", can.ui.display)
height: can.Conf("height"), width: can.Conf("width"), index: task["extra.ctx"]+"."+task["extra.cmd"], args: task["extra.arg"], if (profile || display) { return }
}, function(sub) {
sub.run = function(event, cmds, cb, silent) {
var msg = can.request(event); can.core.Item(can.task, function(key, value) {
msg.Option("task."+key, value)
})
can.run(event, ["action", "command", "run", task["extra.ctx"]+"."+task["extra.cmd"]].concat(cmds), function(msg) {
typeof cb == "function" && cb(msg)
}, true)
}
}, can.ui.display)
var table = can.page.Appends(can, can.ui.profile, [{view: ["content", "table"], list: [{th: ["key", "value"]}]}]).first var table = can.page.Appends(can, can.ui.profile, [{view: ["content", "table"], list: [{th: ["key", "value"]}]}]).first
can.core.Item(task, function(key, value) { can.page.Append(can, table, [{td: [key, key == "pod"? ('<a href="'+can.user.MergeURL(can, {pod: value})+'" target="_blank">'+value+'</a>'): value], can.core.Item(task, function(key, value) { can.page.Append(can, table, [{
onclick: function(event) { if (event.target.type == "button") { td: [key, key == "pod"? can.page.Format("a", can.user.MergeURL(can, {pod: value}), value): value],
var msg = can.request(event, can.task)
can.run(event, ["action", event.target.name])
} },
ondblclick: function(event) { ondblclick: function(event) {
can.onmotion.modify(can, event.target, function(ev, value, old) { can.onmotion.modify(can, event.target, function(ev, value, old) {
can.onaction.modifyTask(event, can, task, key, value) can.onaction.modifyTask(event, can, task, key, value)
}) })
}, },
onclick: function(event) { if (event.target.type == "button") {
var msg = can.request(event, can.task)
can.run(event, ["action", event.target.name])
} },
}]) }) }]) })
task["extra.cmd"] && can.onappend.plugin(can, {
index: task["extra.ctx"]+"."+task["extra.cmd"], args: task["extra.arg"],
}, function(sub, meta) {
sub.run = function(event, cmds, cb) {
var msg = can.request(event); can.core.Item(can.task, function(key, value) {
msg.Option("task."+key, value)
})
can.run(event, ["action", "command", "run", meta.index].concat(cmds), function(msg) {
typeof cb == "function" && cb(msg)
}, true)
}
}, can.ui.display)
}, },
day: function(can, msg) { day: function(can, msg) {
@ -156,20 +162,19 @@ Volcanos("onaction", {help: "组件交互", list: [
["view", "", "name", "text", "level", "score"], ["view", "", "name", "text", "level", "score"],
], ],
insertTask: function(event, can, time) { insertTask: function(event, can, time) {
can.user.input(event, can, can.Conf("feature")["insert"], function(event, button, data, list) { can.user.input(event, can, can.Conf("feature.insert"), function(event, button, data, list) {
var args = ["action", "insert"]; can.core.Item(data, function(key, value) { var args = ["action", "insert"]; can.core.Item(data, function(key, value) {
if (key == "begin_time") { value = value || time } if (key == "begin_time") { value = value || time }
if (key == "close_time") { value = value || time } if (key == "close_time") { value = value || time }
key && value && args.push(key, value) key && value && args.push(key, value)
}) }), can.run(event, args)
can.run(event, args, function(msg) { })
return true return true
}) })
}, },
modifyTask: function(event, can, task, key, value) { modifyTask: function(event, can, task, key, value) {
var msg = can.request(event); msg.Option(task) var msg = can.request(event, task)
can.run(event, ["action", "modify", key, value, task[key]], function(msg) { can.run(event, ["action", "modify", key, value, task[key]], function(msg) {
task[key] = value, can.onimport._profile(can, can._msg, task) task[key] = value, can.onimport._profile(can, task)
can.user.toast(can, "修改成功") can.user.toast(can, "修改成功")
}, true) }, true)
}, },
@ -195,7 +200,12 @@ Volcanos("onaction", {help: "组件交互", list: [
level: 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) },
status: 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) },
score: 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.onimport[can.Option("scale")](can, can._msg) }, view: function(event, can, key, value) {
can.Action(key, value)
can.onmotion.clear(can, can.ui.project)
can.onmotion.clear(can, can.ui.content)
can.onimport[can.Option("scale")](can, can._msg)
},
}) })
Volcanos("onexport", {help: "导出数据", list: ["count", "begin_time", "zone", "id", "type", "name"], Volcanos("onexport", {help: "导出数据", list: ["count", "begin_time", "zone", "id", "type", "name"],
name: function(can, task) { return task.name }, name: function(can, task) { return task.name },

View File

@ -165,4 +165,3 @@ Volcanos("onaction", {help: "操作数据", list: ["编辑", ["view", "横向",
}, },
}) })

View File

@ -17,16 +17,13 @@ var Volcanos = shy("火山架", {libs: [], cache: {}}, [], function(name, can, l
meta.libs = Config.libs, meta.volcano = Config.volcano meta.libs = Config.libs, meta.volcano = Config.volcano
// 预加载 // 预加载
var Preload = [Config.volcano] var Preload = [Config.volcano]; for (var i = 0; i < Config.panes.length; i++) { var pane = Config.panes[i]
for (var i = 0; i < Config.panes.length; i++) { var pane = Config.panes[i]
pane && (Preload = Preload.concat(pane.list = pane.list || ["/pane/"+pane.name+".css", "/pane/"+pane.name+".js"])) pane && (Preload = Preload.concat(pane.list = pane.list || ["/pane/"+pane.name+".css", "/pane/"+pane.name+".js"]))
} }; Preload = Preload.concat(Config.plugin)
Preload = Preload.concat(Config.plugin)
// 根模块 // 根模块
name = Config.name, can = {_follow: Config.name, _target: document.body} name = Config.name, can = {_follow: Config.name, _target: document.body}
libs = Preload.concat(Config.main.list, Config.libs), cb = function(can) { libs = Preload.concat(Config.main.list, Config.libs), cb = function(can) {
window.can = can
can.onengine._init(can, can.Conf(Config), Config.panes, function(msg) { can.base.Log(name, "run", can) can.onengine._init(can, can.Conf(Config), Config.panes, function(msg) { can.base.Log(name, "run", can)
document.body.onresize = function() { can.onlayout._init(can, can._target) } document.body.onresize = function() { can.onlayout._init(can, can._target) }
}, can._target) }, can._target)
@ -65,9 +62,7 @@ var Volcanos = shy("火山架", {libs: [], cache: {}}, [], function(name, can, l
}); return event._msg }); return event._msg
}, },
Conf: function(key, value) { return can.core.Value(can._conf, key, value) }, _conf: {}, Conf: function(key, value) { return can.core.Value(can._conf, key, value) }, _conf: {},
} }; can = can || {}; for (var k in proto) { can.hasOwnProperty(k) || (can[k] = proto[k]) }
can = can || {}; for (var k in proto) { can[k] = proto[k] }
if (_can_name) { if (_can_name) {
meta.cache[_can_name] = meta.cache[_can_name] || [] meta.cache[_can_name] = meta.cache[_can_name] || []