1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shaoying 2021-02-03 19:52:09 +08:00
parent d224fcca43
commit 6b930ef204
16 changed files with 331 additions and 512 deletions

View File

@ -31,7 +31,6 @@ Volcanos("onengine", {help: "解析引擎", list: [], _init: function(can, meta,
can.misc.Runs(event, can, {names: pane._name}, cmds, cb)
pane.run(event, ["search", "Footer.onimport.ncmd"])
}, engine: function(event, can, msg, pane, cmds, cb) { return false },
listen: shy("事件回调", {}, [], function(can, name, cb) {
arguments.callee.meta[name] = (arguments.callee.meta[name]||[]).concat(cb)
}),
@ -40,7 +39,6 @@ Volcanos("onengine", {help: "解析引擎", list: [], _init: function(can, meta,
can.core.CallFunc(cb, {msg: msg})
})
}),
river: {
"serivce": {name: "运营群", storm: {
"wx": {name: "公众号 wx", action: [
@ -215,7 +213,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
if (!cmds[i]) { cmds.pop() } else { break }
}
var last = sub._history[sub._history.length-1]; !sub.core.Eq(last, cmds) && cmds[0] != "action" && !slient && sub._history.push(cmds)
var last = sub._history[sub._history.length-1]; !sub.base.Eq(last, cmds) && cmds[0] != "action" && !slient && sub._history.push(cmds)
return cmds
},
}, list.concat(Volcanos.meta.volcano, Volcanos.meta.libs), function(sub) { sub.Conf(meta)
@ -569,12 +567,10 @@ Volcanos("onlayout", {help: "页面布局", list: [], _init: function(can) {
},
})
Volcanos("onkeypop", {help: "键盘交互", list: [], _init: function(can, target) {
can.onkeypop._build(can)
var focus = []; can.onengine.listen(can, "keymap.focus", function(cb) {
cb? focus.push(cb): focus.pop()
can.base.Log("---", cb)
})
can.onkeypop._build(can)
target.onkeydown = function(event) {
if (focus.length > 0) { return focus[focus.length-1](event) }
if (event.target != target) { return }
@ -592,7 +588,7 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _init: function(can, targe
}), can.onkeypop._engine[item] = engine
})
},
_parse: function(event, can, mode, list, target) { list.push(event.key)
_parse: function(event, can, mode, list, target) { list = list||[], list.push(event.key)
can.Status("按键", list.join(""))
for (var pre = 0; pre < list.length; pre++) {
if ("0" <= list[pre] && list[pre] <= "9") { continue } break
@ -605,6 +601,9 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _init: function(can, targe
}
var map = can.onkeypop._mode[mode]
var cb = map && map[event.key]; if (typeof cb == "function" && event.key.length > 1) {
repeat(cb, count); return list
}
var cb = map && map[event.key.toLowerCase()]; if (typeof cb == "function" && event.key.length > 1) {
repeat(cb, count); return list
}

View File

@ -7,7 +7,6 @@
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="/page/cache.css">
<link rel="stylesheet" type="text/css" href="/page/index.css">
<link rel="stylesheet" type="text/css" href="/page/print.css" media="print"/>
</head>
<body>
<script src="/proto.js"></script>

View File

@ -1,5 +1,5 @@
Volcanos("base", {help: "基础模块",
Int: function(value) { return parseInt(value)||0 },
Volcanos("base", {help: "数据类型",
Int: function(value, def) { return parseInt(value)||def||0 },
Obj: function(value, def) {
try {
return (typeof value == "string" && value != ""? JSON.parse(value): value) || def || {}
@ -7,7 +7,53 @@ Volcanos("base", {help: "基础模块",
return [value]
}
},
Copy: function(to, from, fields) {
var list = []
for (var i = 2; i < arguments.length; i++) {
list.push(arguments[i])
}
for (var i = 0; i < list.length; i++) {
to[list[i]] = from[list[i]]
}
},
Eq: function(obj, other) { var self = arguments.callee
// undefined null
// string number boolen
// object function
if (typeof obj != typeof other) {
return false
}
if (typeof obj == "object") {
if (obj.length != other.length) { return false }
for (var i = 0; i < obj.length; i++) {
if (!self(obj[i], other[i])) {
return false
}
}
for (var k in obj) {
if (!self(obj[k], other[k])) {
return false
}
}
return true
}
return obj === other
},
Ext: function(file) { return (file.split("/").pop().split(".").pop()).toLowerCase() },
Path: function() { var res = ""
for (var i = 0; i < arguments.length; i++) {
res += (arguments[i].indexOf("/") == 0 || res.indexOf("/")==res.length-1? "": "/") + arguments[i].trim()
}
return res
},
Args: function(obj) {var res = [];
for (var k in obj) {
res.push(encodeURIComponent(k)+"="+encodeURIComponent(obj[k]))
}
return res.join("&")
},
URLMerge: function(url) { var args = {}
var arg = url.split("?")[1]||""
arg && arg.split("&").forEach(function(item) {
@ -39,57 +85,13 @@ Volcanos("base", {help: "基础模块",
return url.split("?")[0]+(list.length>0? "?"+list.join("&"): "")
},
Ext: function(file) { return (file.split("/").pop().split(".").pop()||"txt").toLowerCase() },
Path: function() { var res = ""
for (var i = 0; i < arguments.length; i++) {
res += (arguments[i].indexOf("/") == 0 || res.indexOf("/")==res.length-1? "": "/") + arguments[i].trim()
}
return res
},
Args: function(obj) {var res = [];
for (var k in obj) {
res.push(encodeURIComponent(k)+"="+encodeURIComponent(obj[k]))
}
return res.join("&")
},
Size: function(size) {size = parseInt(size)
if (size > 1000000000) {
return parseInt(size / 1000000000) + "." + parseInt(size / 10000000 % 100) + "G"
}
if (size > 1000000) {
return parseInt(size / 1000000) + "." + parseInt(size / 10000 % 100) + "M"
}
if (size > 1000) {
return parseInt(size / 1000) + "." + parseInt(size / 10 % 100) + "K"
}
return size + "B"
},
Date: function(t) { var now = new Date()
if (t == "") { return now }
if (typeof t == "string") { var ls = t.split(" ")
Date: function(time) { var now = new Date()
if (typeof time == "string" && time != "") { var ls = time.split(" ")
var vs = ls[0].split("-")
now.setFullYear(parseInt(vs[0]))
now.setMonth(parseInt(vs[1])-1)
now.setDate(parseInt(vs[2]))
var vs = ls[1].split(":")
now.setHours(parseInt(vs[0]))
now.setMinutes(parseInt(vs[1]))
now.setSeconds(parseInt(vs[2]))
} else if (t) {
now = t
}
return now
},
Time: shy("时间格式化", function(time, fmt) {
var now = new Date()
if (time && typeof time == "string") { var ls = time.split(" ")
var vs = ls[0].split("-")
now.setFullYear(parseInt(vs[0]))
now.setMonth(parseInt(vs[1]))
now.setDate(parseInt(vs[2]))
var vs = ls[1].split(":")
now.setHours(parseInt(vs[0]))
now.setMinutes(parseInt(vs[1]))
@ -97,8 +99,9 @@ Volcanos("base", {help: "基础模块",
} else if (time) {
now = time
}
// var now = time? new Date(time): new Date()
return now
},
Time: shy("时间格式化", function(time, fmt) { var now = this.Date(time)
var list = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
fmt = fmt || "%y-%m-%d %H:%M:%S"
fmt = fmt.replace("%y", now.getFullYear())
@ -117,19 +120,25 @@ Volcanos("base", {help: "基础模块",
h = parseInt(n/1000), h > 0 && (res += h), n = n % 1000
return res + (n > 0? "."+parseInt(n/10): "") + "s"
},
Format: shy("数据格式化", function(obj) { return JSON.stringify(obj) }),
Number: shy("数字格式化", function(d, n) { var result = []
while (d > 0) { result.push(d % 10); d = parseInt(d / 10); n-- }
while (n > 0) { result.push("0"); n-- }
return result.reverse(), result.join("")
}),
Format: shy("数据格式化", function(obj) { return JSON.stringify(obj) }),
TimeAdd: shy("时间格式化", function(t, d) {
return new Date(t - t%(24*3600*1000) - 8*3600*1000 + d*24*3600*1000)
}),
isNight: function() { var now = new Date()
return now.getHours() < 7 || now.getHours() > 17
Size: function(size) {size = parseInt(size)
if (size > 1000000000) {
return parseInt(size / 1000000000) + "." + parseInt(size / 10000000 % 100) + "G"
}
if (size > 1000000) {
return parseInt(size / 1000000) + "." + parseInt(size / 10000 % 100) + "M"
}
if (size > 1000) {
return parseInt(size / 1000) + "." + parseInt(size / 10 % 100) + "K"
}
return size + "B"
},
parseSize: function(size) { size = size.toLowerCase()
if (size.endsWith("tb") || size.endsWith("t")) {
return parseInt(size) * 1024 * 1024 * 1024 * 1024
@ -145,20 +154,17 @@ Volcanos("base", {help: "基础模块",
}
return parseInt(size)
},
isNight: function() { var now = new Date()
return now.getHours() < 7 || now.getHours() > 17
},
TimeAdd: shy("时间格式化", function(t, d) {
return new Date(t - t%(24*3600*1000) - 8*3600*1000 + d*24*3600*1000)
}),
_fileLine: function() { var obj = {}
Error.captureStackTrace && Error.captureStackTrace(obj, arguments.callee)
return obj.stack || ""
},
fileLine: function(depth) {
return (this._fileLine().split("\n")[1+depth]||"").trim()
},
FileLine: function(depth, length) {
return this.fileLine(depth+1).split("/").slice(3).slice(-length).join("/").split(")")[0]
},
Log: function() {
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3)]
Debug: function() {
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3), "debug"]
for (var i in arguments) { args.push(arguments[i]) }
args.push(this.fileLine(2, 3))
console.log.apply(console, args)
},
Warn: function() {
@ -167,11 +173,20 @@ Volcanos("base", {help: "基础模块",
args.push("\n", this._fileLine().split("\n").slice(2).join("\n"))
console.log.apply(console, args)
},
Debug: function() {
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3), "debug"]
Log: function() {
var args = [this.Time(null, "%H:%M:%S"), this.FileLine(2, 3)]
for (var i in arguments) { args.push(arguments[i]) }
args.push(this.fileLine(2, 3))
console.log.apply(console, args)
},
FileLine: function(depth, length) {
return this.fileLine(depth+1).split("/").slice(3).slice(-length).join("/").split(")")[0]
},
fileLine: function(depth) {
return (this._fileLine().split("\n")[1+depth]||"").trim()
},
_fileLine: function() { var obj = {}
Error.captureStackTrace && Error.captureStackTrace(obj, arguments.callee)
return obj.stack || ""
},
})

View File

@ -1,106 +1,4 @@
Volcanos("core", {help: "核心模块",
Items: shy("迭代器", function(obj, cb) { var list = []
for (var key in obj) {
list = list.concat(this.List(obj[key], function(value, index, array) {
return typeof cb == "function" && cb(value, index, key, obj)
}))
}
return list
}),
Item: shy("迭代器", function(obj, cb) { var list = []
for (var k in obj) {
var res = typeof cb == "function"? cb(k, obj[k]): k
res && list.push(res)
}
return list
}),
List: shy("迭代器", function(obj, cb, interval, cbs) {
if (typeof obj == "number") {
var begin = 0, end = obj, step = 1
if (typeof interval == "number") {
step = interval
}
if (typeof cb == "number") {
begin = obj, end = cb
}
var list = []
for (var i = begin; i < end; i += step) {
list.push(i)
}
return list
}
obj = typeof obj == "string"? [obj]: (obj || [])
if (interval > 0) {
function loop(i) { if (i >= obj.length) { return typeof cbs == "function" && cbs(obj) }
typeof cb == "function" && cb(obj[i], i, obj), setTimeout(function() { loop(i+1) }, interval)
}
obj.length > 0 && setTimeout(function() { loop(0) }, interval/4)
return obj
}
var list = [], res
for (var i = 0; i < obj.length; i++) {
typeof cb == "function"? (res = cb(obj[i], i, obj)) != undefined && list.push(res): list.push(obj[i])
}
return list
}),
Next: shy("迭代器", function(obj, cb, cbs) { obj = typeof obj == "string"? [obj]: (obj || [])
function next(list, cb, index) {
list && list.length > 0? typeof cb == "function" && cb(list[0], function() {
list.length > 0 && next(list.slice(1), cb, index+1)
}, index, obj): typeof cbs == "function" && cbs()
}
next(obj, cb, 0)
}),
Keys: function() { var list = []
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
switch (typeof v) {
case "number": list.push(v+""); break
case "string": list.push(v); break
case "object": list.push(arguments.callee.apply(this, v)); break
case "function": list.push(v()); break
default: list.push(v+"")
}
}
return list.join(".")
},
Value: function(data, key, value) {
if (data == undefined) { return }
if (key == undefined) { return data }
if (typeof key == "object") { for (var k in key) {
arguments.callee.call(this, data, k, key[k])
}; return data }
if (value != undefined) { data[key] = value }
if (data[key] != undefined) { return data[key] }
var p = data, ls = key.split("."); while (p && ls.length > 0) {
if (ls[0] == "-1") { ls[0] = p.length-1 }
p = p[ls[0]], ls = ls.slice(1)
}; return p
},
CallFunc: shy("调用器", function(func, args, mod) { args = args||{}
var can = args["can"]||args[0], msg = args["msg"]||args[1]
func = typeof func == "function"? func: typeof func == "string"? this.Value(mod||can, func):
typeof func == "object" && func.slice? this.Value(func[0], this.Keys(func.slice(1))): null
if (typeof func != "function") { return }
var cb = args["cb"]
var ls = func.toString().split(")")[0].split("(")[1].split(",")
var list = [], echo = false; this.List(ls, function(item, index) { item = item.trim()
list.push(args[item] || args[index] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || null)
if (item == "cb") { echo = true }
})
var res = func.apply(mod||can, list)
if (!echo && typeof cb == "function") { res && msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) }
return res
}),
Volcanos("core", {help: "数据结构",
Split: shy("分词器", function(str) { if (!str || !str.length) { return [] }
var opt = {detail: false}, arg = []; for (var i = 1; i < arguments.length; i++) {
typeof arguments[i] == "object"? opt = arguments[i]: arg.push(arguments[i])
@ -170,51 +68,119 @@ Volcanos("core", {help: "核心模块",
if (timer.stop || i >= interval.length && interval.length >= 0) {
return typeof cbs == "function" && cbs(timer, interval)
}
return typeof cb == "function" && cb(timer, interval.value||interval[i], i, interval)?
typeof cbs == "function" && cbs(timer, interval): setTimeout(function() { loop(timer, i+1) }, interval.value||interval[i+1])
return typeof cb == "function" && cb(timer, interval.interval||interval[i], i, interval)?
typeof cbs == "function" && cbs(timer, interval): setTimeout(function() { loop(timer, i+1) }, interval.interval||interval[i+1])
}
setTimeout(function() { loop(timer, 0) }, interval.value||interval[0])
setTimeout(function() { loop(timer, 0) }, interval.interval||interval[0])
return timer
}),
Delay: function(list, interval, cb, cbs) {
Delay: shy("延时器", function(list, interval, cb, cbs) {
list.push(cb); this.Timer(interval, function() {
var cb = list.pop(); list.length = 0
typeof cb == "function" && cb()
}, cbs)
},
}),
Copy: function(to, from, fields) {
var list = []
for (var i = 2; i < arguments.length; i++) {
list.push(arguments[i])
Items: shy("迭代器", function(obj, cb) { var list = []
for (var key in obj) {
list = list.concat(this.List(obj[key], function(value, index, array) {
return typeof cb == "function" && cb(value, index, key, obj)
}))
}
return list
}),
Item: shy("迭代器", function(obj, cb) { var list = []
for (var k in obj) {
var res = typeof cb == "function"? cb(k, obj[k]): k
res && list.push(res)
}
return list
}),
List: shy("迭代器", function(obj, cb, interval, cbs) {
if (typeof obj == "number") {
var begin = 0, end = obj, step = 1
if (typeof interval == "number") {
step = interval
}
if (typeof cb == "number") {
begin = obj, end = cb
}
var list = []
for (var i = begin; i < end; i += step) {
list.push(i)
}
return list
}
for (var i = 0; i < list.length; i++) {
to[list[i]] = from[list[i]]
}
},
Eq: function(obj, other) { var self = arguments.callee
// undefined null
// string number boolen
// object function
if (typeof obj != typeof other) {
return false
}
if (typeof obj == "object") {
if (obj.length != other.length) { return false }
for (var i = 0; i < obj.length; i++) {
if (!self(obj[i], other[i])) {
return false
}
obj = typeof obj == "string"? [obj]: (obj || [])
if (interval > 0) {
function loop(i) { if (i >= obj.length) { return typeof cbs == "function" && cbs(obj) }
typeof cb == "function" && cb(obj[i], i, obj), setTimeout(function() { loop(i+1) }, interval)
}
for (var k in obj) {
if (!self(obj[k], other[k])) {
return false
}
}
return true
obj.length > 0 && setTimeout(function() { loop(0) }, interval/4)
return obj
}
return obj === other
},
var list = [], res
for (var i = 0; i < obj.length; i++) {
typeof cb == "function"? (res = cb(obj[i], i, obj)) != undefined && list.push(res): list.push(obj[i])
}
return list
}),
Next: shy("迭代器", function(obj, cb, cbs) { obj = typeof obj == "string"? [obj]: (obj || [])
function next(list, cb, index) {
list && list.length > 0? typeof cb == "function" && cb(list[0], function() {
list.length > 0 && next(list.slice(1), cb, index+1)
}, index, obj): typeof cbs == "function" && cbs()
}
next(obj, cb, 0)
}),
Keys: shy("生成器", function() { var list = []
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
switch (typeof v) {
case "number": list.push(v+""); break
case "string": list.push(v); break
case "object": list.push(arguments.callee.apply(this, v)); break
case "function": list.push(v()); break
default: list.push(v+"")
}
}
return list.join(".")
}),
Value: shy("存储器", function(data, key, value) {
if (data == undefined) { return }
if (key == undefined) { return data }
if (typeof key == "object") { for (var k in key) {
arguments.callee.call(this, data, k, key[k])
}; return data }
if (value != undefined) { data[key] = value }
if (data[key] != undefined) { return data[key] }
var p = data, ls = key.split("."); while (p && ls.length > 0) {
if (ls[0] == "-1") { ls[0] = p.length-1 }
p = p[ls[0]], ls = ls.slice(1)
}; return p
}),
CallFunc: shy("调用器", function(func, args, mod) { args = args||{}
var can = args["can"]||args[0], msg = args["msg"]||args[1]
func = typeof func == "function"? func: typeof func == "string"? this.Value(mod||can, func):
typeof func == "object" && func.slice? this.Value(func[0], this.Keys(func.slice(1))): null
if (typeof func != "function") { return }
var cb = args["cb"]
var ls = func.toString().split(")")[0].split("(")[1].split(",")
var list = [], echo = false; this.List(ls, function(item, index) { item = item.trim()
list.push(args[item] || args[index] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || null)
if (item == "cb") { echo = true }
})
var res = func.apply(mod||can, list)
if (!echo && typeof cb == "function") { res && msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) }
return res
}),
})

View File

@ -81,7 +81,7 @@ Volcanos("user", {help: "用户模块", agent: {
]},
], ondblclick: function(event) { ui.Close() }}])
var timer = can.core.Timer({value: 100, length: (meta.duration||1000)/100}, function(event, interval, index) {
var timer = can.core.Timer({interval: 100, length: (meta.duration||1000)/100}, function(event, interval, index) {
if (index > 20) { ui.duration.innerHTML = parseInt(index/10)+"."+(index%10)+"s..." }
}, function() {
can.page.Remove(can, ui.first), timer.stop = true

View File

@ -112,7 +112,7 @@ table.layout th {
}
table.content {
width:-webkit-fill-available;
/* width:-webkit-fill-available; */
border:0; white-space:pre;
font-size:14px; font-family:monospace;
cursor:pointer; overflow: auto;

View File

@ -8,6 +8,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg)
can.onappend.plugin(can, item, function(sub, meta) {
can.onimport._plugin(can, river, storm, sub, meta), next()
sub._option.dataset = sub._option.dataset || {}
sub._option.dataset.id = item.id
})
})
@ -16,8 +17,6 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg)
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
var toast = msg.Option("_toast") && can.user.toast(can, msg.Option("_toast"), "", 1000000)
return can.run(event, (can.onengine[cmds[0]]? []: [river, storm, item.id||item.index||item.key+"."+item.name]).concat(cmds), function(msg) {
console.log(sub)
console.log(item)
toast && toast.Close(), typeof cb == "function" && cb(msg)
})
}, can._plugins = (can._plugins||[]).concat([sub])

View File

@ -100,7 +100,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}) })
},
_time: function(can, target) {
can.core.Timer({interval: 1000, length: -1}, function() {
can.core.Timer({interval: 1000}, function() {
can.onimport.time(can, target)
})
can.onappend.figure(can, {style: {left: "", right: "0", top: can._target.offsetHeight}}, "@date", target)
@ -188,7 +188,7 @@ Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg,
var msg = can.request(event, {name: meta.name, content: JSON.stringify(Volcanos.meta.pack)})
var toast = can.user.toast(can, "打包中...", "webpack", 1000000)
can.run(event, ["pack"], function(msg) {
can.run(event, ["webpack"], function(msg) {
toast.Close(), can.user.toast(can, "打包成功", "webpack")
})
return true

View File

@ -37,7 +37,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
]},
{view: "tags", style: {"max-height": 160}},
]},
]); can.core.Copy(can.ui, ui, "search", "word", "tags")
]); can.base.Copy(can.ui, ui, "search", "word", "tags")
},
_favor: function(can, target) {
can.onappend.plugin(can, {index: "web.code.favor"}, function(sub) {
@ -207,7 +207,11 @@ Volcanos("onaction", {help: "控件交互", list: ["项目", "运行", "搜索"]
typeof line == "object" && can.page.Select(can, line, "td.text", function(item) {
can.current = {
scroll: function(x, y) { return can.ui.content.scrollBy(x, y) },
scroll: function(x, y) {
can.ui.content.scrollLeft += x
can.ui.content.scrollTop += y
// return can.ui.content.scrollBy(x, y)
},
window: function() { return can.ui.content.offsetHeight },
offset: function() { return can.ui.content.scrollTop },
@ -219,7 +223,7 @@ Volcanos("onaction", {help: "控件交互", list: ["项目", "运行", "搜索"]
}
var push = {path: can.Option("path"), file: can.Option("file"), line: can.Option("line")}
can.core.Eq({path: push.path, file: push.file}, can.history[can.history.length-1]) || can.history.push(push)
can.base.Eq({path: push.path, file: push.file}, can.history[can.history.length-1]) || can.history.push(push)
can.Status("跳转数", can.history.length)
})

View File

@ -15,7 +15,8 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
}, onblur: function(event) {
can.current.text(can.ui.current.value)
}, onfocus: function(event) {
can._output.scrollBy(-1000, 0)
can._output.scrollLeft += -1000
can.current.scroll(-1000, 0)
}, onclick: function(event) {
can.onkeymap._insert(can)
@ -23,10 +24,10 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
{view: ["command", "input"], onkeydown: function(event) {
can.onkeymap.parse(event, can, "command")
}, onfocus: function(event) {
can._output.scrollBy(-1000, 0)
can._output.scrollLeft += -1000
can.current.scroll(-1000, 0)
}},
]); can.core.Copy(can.ui, ui, "current", "command")
]); can.base.Copy(can.ui, ui, "current", "command")
var ui = can.page.Appends(can, can.ui.display, [
{view: "action", list: [
@ -43,7 +44,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _merge: function(can, sub)
can.onmotion.hidden(can, can.ui.display)
} ]},
]}, {view: "output"},
]); can.core.Copy(can.ui, ui, "output", "cmd")
]); can.base.Copy(can.ui, ui, "output", "cmd")
}, target)
})
},

View File

@ -1,3 +1,3 @@
fieldset.drawer div.output div.content svg {
fieldset.draw div.output div.content svg {
background-color:#1b5b738c;
}

View File

@ -7,7 +7,6 @@ fieldset.word h2.story {
fieldset.word h3.story {
clear:both;
}
fieldset.word h1:hover {
background:green;
cursor:pointer;
@ -61,11 +60,6 @@ fieldset.word div.story[data-type=spark] span:hover {
fieldset.word svg.story {
display:block; float:left;
}
fieldset.word fieldset.story {
margin:10px; border:0;
clear:both; float:left;
box-shadow: 4px 4px 10px 1px #626bd0;
}
fieldset.word code.story {
display:block; border:solid 3px green;
color:white; background-color:#272822;
@ -74,25 +68,41 @@ fieldset.word code.story {
padding:10px; white-space:pre;
clear:both;
}
fieldset.word fieldset.story {
margin:10px; border:0;
clear:both; float:left;
box-shadow: 4px 4px 10px 1px #626bd0;
}
fieldset.word.float {
width:-webkit-fill-available;
height:-webkit-fill-available;
position:absolute; left:0; top:0;
background-color:aliceblue;
color:black;
}
fieldset.word.float div.project {
fieldset.word.float>div.output {
background-color:aliceblue;
overflow:auto;
padding:20px;
}
fieldset.word.float div.project {
background-color:#bad1e6a6;
padding:10px;
}
fieldset.word.float div.content div.page {
background-color:aliceblue;
margin-top:30px;
display:none;
}
fieldset.word.float div.content div.page.select {
display:block;
}
fieldset.word.float div.content.grid div.page {
float:left; display:block;
width:200px; height:200px;
overflow:auto; margin:10px;
background-color:#a4cbecb5;
}
fieldset.word.float h1 {
text-align:center;
@ -104,73 +114,3 @@ fieldset.word.float h3 {
text-align:center;
}
div.show>div.control {
background-color:aliceblue;
}
div.show>div.project div.item {
cursor:pointer;
}
div.show>div.project div.item:hover {
background-color:white;
}
div.show>div.content {
background-color:aliceblue;
text-align:center;
padding:20px;
}
div.show>div.content h1 {
margin-top:100px;
font-size:60px;
}
div.show>div.content h2 {
clear:both;
}
div.show>div.content h3 {
clear:both;
}
div.show>div.content ul {
text-align:left;
}
div.show>div.content div.page.first {
}
div.show>div.content div.page.first ul {
text-align:center;
}
div.show>div.content div.page {
margin-top:30px;
display:none;
}
div.show>div.content div.page.show {
background-color:aliceblue;
display:block;
}
div.show>div.content div.page ul li.H2 {
font-size:24px;
}
div.show>div.content div.page ul li.H3 {
font-size:16px;
}
div.show>div.content div.page code.story {
display:block; border:solid 3px green;
color:white; background-color:#272822;
font-size:14px; font-family:monospace;
max-height:640px; overflow:auto;
padding:10px; white-space:pre;
clear:both;
}
body.white fieldset.word p.story[data-name=inner] {
/* background-color:#bad8f7; */
border-left:solid 4px blue;
}
body.white fieldset.word div.story[data-type=spark] {
/* background-color:#c2daef; */
clear:both;
}
body.white fieldset.word div.story[data-type=spark] span:hover {
background-color:blue;
/* background-color:white; */
}

View File

@ -7,20 +7,20 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.page.Select(can, target, ".story", function(item) { var data = item.dataset||{}
can.core.CallFunc([can.onimport, data.type], [can, data, item])
can.page.Modify(can, item, {style: can.base.Obj(data.style)})
// delete(data.meta)
})
},
premenu: function(can, list, target) { var meta = can.base.Obj(list.meta)
premenu: function(can, data, target) {
can.page.Select(can, can._output, "h2.story, h3.story", function(item) {
can.page.Append(can, target, [{text: [item.innerHTML, "li", item.tagName], onclick: function() {
item.scrollIntoView()
}}]), item.onclick = function(event) {
target.scrollIntoView()
}
}}])
item.onclick = function(event) { target.scrollIntoView() }
})
},
spark: function(can, item, target) {
if (item["name"] == "inner") {
spark: function(can, data, target) {
if (data["name"] == "inner") {
target.title = "点击复制", target.onclick = function(event) {
can.user.copy(event, can, target.innerText)
}
@ -32,61 +32,44 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}
})
},
field: function(can, item, target) { var meta = can.base.Obj(item.meta)
meta.width = can.Conf("width"), meta.height = can.Conf("height")
can.onappend._init(can, meta, ["/plugin/state.js"], function(sub) {
sub.run = function(event, cmds, cb, silent) {
can.run(event, (cmds[0] == "search"? []: ["action", "story", item.type, item.name, item.text]).concat(cmds), cb, true)
}
delete(target.dataset.meta)
}, can._output, target)
},
table: function(can, list, target) {
table: function(can, data, target) {
can.page.ClassList.add(can, target, "content")
can.page.Select(can, target, "td", function(item) {
item.title = "点击复制", item.onclick = function(event) {
can.user.copy(event, can, item.innerText)
}
})
},
iframe: function(can, list, target) { var meta = can.base.Obj(list.meta)
field: function(can, data, target) { var meta = can.base.Obj(data.meta)
meta.width = can.Conf("width"), meta.height = can.Conf("height")
can.onappend._init(can, meta, ["/plugin/state.js"], function(sub) {
sub.run = function(event, cmds, cb, silent) {
can.run(event, (cmds[0] == "search"? []: ["action", "story", data.type, data.name, data.text]).concat(cmds), cb, true)
}
}, can._output, target)
},
iframe: function(can, data, target) { var meta = can.base.Obj(data.meta)
can.page.Modify(can, target, {width: can.Conf("width")-200})
},
keydown: function(event, can, key) {
switch (key) {
case "g":
can.ui["布局"].value = "网格"
can.onaction.grid(can)
break
case "f":
can.ui["布局"].value = "快闪"
can.onaction.flash(can)
break
case "s":
can.ui["布局"].value = "层叠"
can.onaction.spring(can)
break
case "n":
case "j":
case "ArrowRight":
can.onaction.next(can)
break
case "k":
case "p":
case "ArrowLeft":
can.onaction.prev(can)
break
case "t":
can.page.Toggle(can, can.ui.content)
break
case "q":
can.ui && can.page.Remove(can, can.ui.show)
}
},
}, ["/plugin/local/wiki/word.css"])
Volcanos("onkeypop", {help: "键盘交互", list: [],
_mode: {
normal: {
"n": function(event, can) { can.onaction.next(can.sub) },
"j": function(event, can) { can.onaction.next(can.sub) },
"ArrowRight": function(event, can) { can.onaction.next(can.sub) },
"ArrowLeft": function(event, can) { can.onaction.prev(can.sub) },
"k": function(event, can) { can.onaction.prev(can.sub) },
"p": function(event, can) { can.onaction.prev(can.sub) },
"q": function(event, can) { can.onaction["结束"](event, can.sub) },
"h": function(event, can) { can.onaction["隐藏"](event, can.sub) },
},
}, _engine: {},
})
Volcanos("onaction", {help: "控件交互", list: [],
"演示": function(event, can) {
var current = [], list = []
"演示": function(event, can) { var list = [], current = []
can.page.Select(can, can._output, ".story", function(item) {
switch (item.tagName) {
case "H1":
@ -98,174 +81,90 @@ Volcanos("onaction", {help: "控件交互", list: [],
current.push(item)
})
can.onappend._init(can, {type: "story word float"}, [], function(sub) {
sub.ui = sub.page.Append(sub, sub._output, [{view: "project"}, {view: "content"}])
sub.run = function(event, cmds, cb) { can.run(event, cmds, cb, true) }
sub.onappend._action(sub, [
["布局", "开讲", "快闪", "网格", "层叠"],
can.onappend._init(can, {type: "story word float"}, [], function(sub) { sub.sup = can
can.onappend._action(sub, [
["布局", "开讲", "快闪", "网格"],
"大纲", "首页", "上一页",
["菜单"].concat(can.page.Select(can, can._output, "h1,h2,h3", function(item) { return item.innerHTML })),
["菜单"].concat(can.core.List(list, function(page) { return page[0].innerHTML })),
"下一页", "隐藏", "结束",
], sub._action, {
"开讲": function(event) { sub.onaction.show(sub, 0) },
"网格": function(event) { sub.onaction.grid(sub) },
"快闪": function(event) { sub.onaction.flash(sub) },
"层叠": function(event) { sub.onaction.spring(sub) },
], sub._action, can.onaction)
"大纲": function(event) { sub.page.Toggle(sub, sub.ui.project) },
"首页": function(event) { can.onaction.show(sub, 0) },
"上一页": function(event) { can.onaction.prev(sub, sub.ui.content) },
"菜单": function(event) { can.onaction.show(sub, event.target.selectedIndex) },
"下一页": function(event) { can.onaction.next(sub, sub.ui.content) },
"隐藏": function(event) { sub.page.Toggle(sub, sub._output) },
"结束": function(event) { sub.page.Remove(sub, sub._target) },
})
can.onmotion.hidden(can, sub.ui.project)
can.page.Select(can, can._output, "h1.story,h2.story,h3.story", function(item, index) {
can.onappend.item(can, "item", {name: item.innerHTML}, function(event) {
can.onaction.show(sub, index)
}, function(event) {
}, sub.ui.project)
})
can.sub = sub, can.onkeypop._build(can)
can.onengine.signal(can, "keymap.focus", can.request(event, {cb: function(event) {
can.keylist = can.onkeypop._parse(event, can, "normal", can.keylist)
}}))
sub.list = list
sub.page.Modify(sub, sub._output, {style: {"width": window.innerWidth-40}})
sub.page.Modify(sub, sub._output, {style: {"height": window.innerHeight-93}})
sub.ui = sub.page.Append(sub, sub._output, [{view: "project"}, {view: "content"}])
can.core.List(list, function(page, index) {
var items = can.core.List(page, function(item) {
switch (item.tagName) {
case "FIELDSET":
return can.onappend._init(can, can.base.Obj(item.dataset.meta), ["/plugin/state.js"], function(sub) {
sub.run = function(event, cmds, cb) {
can.run(event, (cmds[0] == "search"? []: ["action", "story", item.dataset.type, item.dataset.name, item.dataset.text]).concat(cmds), cb, true)
}
}, sub.ui.content)._target
default: return item.cloneNode(true)
}
})
can.onappend.item(can, "item", {name: page[0].innerHTML}, function(event) {
can.onaction.show(sub, index)
}, function(event) {}, sub.ui.project)
sub.page.Append(sub, sub.ui.content, [{view: "page "+(index==0?"select": "")+(index==0? " first": ""), list: items}])
sub.page.Append(sub, sub.ui.content, [{view: "page"+(index==0? " first": ""), list: can.core.List(page, function(item) { var data = item.dataset||{}
switch (data.type) {
case "premenu": item = item.cloneNode(false); break
case "field": item = can.onappend.field(can, "story", can.base.Obj(data.meta), sub.ui.content).first; break
default: item = item.cloneNode(true)
}
return can.core.CallFunc([can.onimport, data.type], [can, data, item]), item
}), }])
}), can.onmotion.hidden(can, sub.ui.project)
can.onaction.show(sub, 0)
sub.Status("from", can.base.Time(null, "%H:%M:%S"))
var from = new Date(); can.core.Timer({interval: 100}, function() { var now = new Date()
sub.Status("cost", can.base.Duration(now-from))
})
}, document.body)
},
show: function(can, which) {
can.page.Select(can, can.ui.content, "div.page", function(page, index) {
if (index == which) {
can.page.ClassList.add(can, page, "select")
can.page.Select(can, page, "h1,h2,h3", function(item) {
can.Action("菜单", item.innerHTML)
})
} else {
can.page.ClassList.del(can, page, "select")
}
})
},
next: function(can, target) {
can.page.Select(can, target, "div.page.select", function(page) {
if (page.nextSibling) {
can.page.ClassList.del(can, page, "select")
can.page.ClassList.add(can, page.nextSibling, "select")
"开讲": function(event, sub) { sub.sup.onaction.show(sub, 0) },
"快闪": function(event, sub) { sub.sup.onaction.flash(sub) },
"网格": function(event, sub) { sub.sup.onaction.grid(sub) },
can.page.Select(can, page.nextSibling, "h1,h2,h3", function(item) {
can.Action("菜单", item.innerHTML)
})
} else {
can.user.toast(can, "end")
}
})
"大纲": function(event, sub) { sub.page.Toggle(sub, sub.ui.project) },
"首页": function(event, sub) { sub.sup.onaction.show(sub, 0) },
"上一页": function(event, sub) { sub.sup.onaction.prev(sub, sub.ui.content) },
"菜单": function(event, sub) { sub.sup.onaction.show(sub, event.target.selectedIndex) },
"下一页": function(event, sub) { sub.sup.onaction.next(sub, sub.ui.content) },
"隐藏": function(event, sub) { sub.page.Toggle(sub, sub._output) },
"结束": function(event, sub) { sub.page.Remove(sub, sub._target)
sub.onengine.signal(sub, "keymap.focus", sub.request(event, {cb: null}))
},
prev: function(can, target) {
can.page.Select(can, target, "div.page.select", function(page) {
if (page.previousSibling) {
can.page.ClassList.del(can, page, "select")
can.page.ClassList.add(can, page.previousSibling, "select")
can.page.Select(can, page.previousSibling, "h1,h2,h3", function(item) {
can.Action("菜单", item.innerHTML)
})
show: function(sub, which) { sub.page.Modify(sub, sub.ui.content, {className: "content"})
sub.page.Select(sub, sub.ui.content, "div.page", function(page, index) {
if (index == which || page == which) {
sub.page.Select(sub, page, "h1,h2,h3", function(item) { sub.Action("菜单", item.innerHTML) })
sub.onmotion.select(sub, sub.ui.project, "div.item", index)
sub.page.ClassList.add(sub, page, "select")
sub.Status("page", index+1+"/"+sub.list.length)
} else {
can.user.toast(can, "end")
sub.page.ClassList.del(sub, page, "select")
}
})
},
grid: function(can) {
can.page.Select(can, can.ui.content, "div.page.show", function(page) {
can.page.ClassList.del(can, page, "show")
})
can.core.Next(can.page.Select(can, can.ui.content, "div.page"), function(page, next, index) {
can.page.ClassList.add(can, page, "show"), can.page.Modify(can, page, {style: {
"position": "relative", "float": "left",
"margin-left": 0, "margin-top": 0,
"width": 200, "height": 200,
"border": "solid 2px red",
"overflow": "auto",
}, onclick: function(event) {
page.style.position == "absolute"? can.page.Modify(can, page, {style: {
"position": "relative", "float": "left",
"margin-left": 0, "margin-top": 0,
"width": 200, "height": 200,
"border": "solid 2px red",
"overflow": "auto",
"z-index": 0,
}}): can.page.Modify(can, page, {style: {
"position": "absolute", "float": "none",
"margin-left": 20, "margin-top": 40,
"width": document.body.offsetWidth, "height": document.body.offsetHeight,
"overflow": "auto",
"border": "",
"z-index": 10,
}})
}, })
can.onmotion.show(can, {value: 10, length: 20}, next, page)
next: function(sub) {
sub.page.Select(sub, sub.ui.content, "div.page.select", function(page) {
page.nextSibling? sub.sup.onaction.show(sub, page.nextSibling):
sub.user.toast(sub, "end")
})
},
flash: function(can) {
can.page.Select(can, can.ui.content, "div.page.show", function(page) {
can.page.ClassList.del(can, page, "show")
})
can.core.Next(can.page.Select(can, can.ui.content, "div.page"), function(page, next, index) {
can.page.ClassList.add(can, page, "show"), can.page.Modify(can, page, {style: {
"position": "absolute", "float": "none",
"margin-left": 20, "margin-top": 40,
"width": document.body.offsetWidth, "height": document.body.offsetHeight,
"border": "none",
"overflow": "auto",
}, ondblclick: function(event) {
can.onaction.show(can, index)
can.ui["布局"].value = "开讲"
}, onclick: function(event) {
can.onaction.show(can, index)
can.ui["布局"].value = "开讲"
}, })
can.onmotion.show(can, {value: 10, length: 20}, next, page)
prev: function(sub) {
sub.page.Select(sub, sub.ui.content, "div.page.select", function(page) {
page.previousSibling? sub.sup.onaction.show(sub, page.previousSibling):
sub.user.toast(sub, "end")
})
},
spring: function(can) {
can.page.Select(can, can.ui.content, "div.page.show", function(page) {
can.page.ClassList.del(can, page, "show")
})
can.core.Next(can.page.Select(can, can.ui.content, "div.page"), function(page, next, index) {
can.page.ClassList.add(can, page, "show"), can.page.Modify(can, page, {style: {
"position": "absolute", "float": "none",
"margin-left": 10*(index+1), "margin-top": 60*(index+1),
"height": document.body.offsetHeight,
"width": document.body.offsetWidth,
"border": "solid 2px red",
"overflow": "auto",
}, onclick: function(event) {
page.style["margin-left"] == "0px"? can.page.Modify(can, page, {style: {
"margin-left": 10*(index+1), "margin-top": 60*(index+1),
"z-index": 0,
}}): can.page.Modify(can, page, {style: {
"margin-left": 0, "margin-top": 60*(index+1),
"z-index": 10,
}})
}, })
can.onmotion.show(can, {value: 10, length: 20}, next, page)
flash: function(sub) {
sub.core.Next(sub.page.Select(sub, sub.ui.content, "div.page"), function(page, next) {
sub.core.Timer(500, function() { next() })
sub.sup.onaction.show(sub, page)
})
},
grid: function(sub) { sub.page.Modify(sub, sub.ui.content, {className: "content grid"}) },
})

View File

@ -6,7 +6,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can._tree = can.onimport._tree(can, msg.Table(), "path", "/")
can.onmotion.clear(can)
can.onappend.plugins(can, {index: "web.wiki.draw"}, function(sub) {
can.onappend.plugins(can, {type: "inner draw drawer", index: "web.wiki.draw"}, function(sub) {
sub.run = function(event, cmds, cb) {
typeof cb == "function" && cb(sub.request())
can.core.Timer(100, function() { can.sub = sub._outputs[0]
@ -16,9 +16,6 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
sub.Action("go", "run")
can.onaction[can.Action("view")](event, can)
can.onlayout.resize(can, "action.resize", function(event) {
can.onaction[can.Action("view")](event, can)
})
})
})
}

View File

@ -5,7 +5,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.Action("height", parseInt(msg.Option("height")||"400"))
can.onmotion.clear(can)
can.onappend.plugins(can, {index: "web.wiki.draw"}, function(sub) {
can.onappend.plugins(can, {type: "inner draw drawer", index: "web.wiki.draw"}, function(sub) {
sub.run = function(event, cmds, cb) { typeof cb == "function" && cb(sub.request())
can.core.Timer(100, function() { can.sub = sub._outputs[0]
can.sub.onmotion.hidden(can.sub, can.sub.ui.project)

View File

@ -24,7 +24,7 @@ var Volcanos = shy("火山架", {pack: {}, libs: [], cache: {}}, [], function(na
// 根模块
name = Config.name, can = {_follow: Config.name, _target: document.body}
libs = Preload.concat(Config.main.list, Config.libs), cb = function(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(can.user.title(), "run", can)
document.body.onresize = function() { can.onlayout._init(can, can._target) }
}, can._target)
}