mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt can.debug
This commit is contained in:
parent
a6726463e0
commit
05461aeba5
@ -329,6 +329,7 @@ div.project::-webkit-scrollbar { width:0 !important; height:0 !important; }
|
||||
div.content::-webkit-scrollbar { width:0 !important; height:0 !important; }
|
||||
|
||||
.picker { box-shadow:4px 4px 20px 4px #626bd0; }
|
||||
span.item:not(.string):not(.number):not(.boolean)>span.value { color:silver; }
|
||||
div.item:not(.string):not(.number):not(.boolean)>span.value { color:silver; }
|
||||
div.item.function>span.value { font-style:italic; }
|
||||
div.item.target>span.value { font-style:italic; }
|
||||
|
@ -88,7 +88,7 @@ Volcanos("core", {
|
||||
return next(0), list
|
||||
},
|
||||
Item: function(obj, cb) { var list = []
|
||||
for (var k in obj) { var res = typeof cb == lang.FUNCTION? cb(k, obj[k]): k; res != undefined && list.push(res) }
|
||||
for (var k in obj) { var res = typeof cb == lang.FUNCTION? cb(k, obj[k], list): k; res != undefined && list.push(res) }
|
||||
return list
|
||||
},
|
||||
ItemKeys: function(obj, cb) { var list = []
|
||||
|
30
lib/page.js
30
lib/page.js
@ -251,23 +251,33 @@ Volcanos("page", {ClassList: {
|
||||
open: "\u25BE", close: "\u25B8", inner: "..",
|
||||
},
|
||||
AppendData: function(can, target, prefix, key, value, cb) { var open = can.page.unicode.open, close = can.page.unicode.close
|
||||
function short(value, length) {
|
||||
if (length == undefined) { value.indexOf(ice.NL) > -1 && (value = value.split(ice.NL)[0]+"..")
|
||||
return value
|
||||
// if (value.length > 50) { return value.slice(0, 50)+can.page.unicode.inner }
|
||||
} else {
|
||||
if (length > 4) { return can.page.unicode.inner }
|
||||
}
|
||||
return value
|
||||
}
|
||||
function show(value, deep) { deep = deep == undefined? 2: 0; switch (typeof value) {
|
||||
case lang.OBJECT: if (!value) { return {} }
|
||||
if (value._path) { return {value: "@\""+value._path+"\""} }
|
||||
if (value.tagName) { return {type: nfs.TARGET, value: "$ "+value.tagName.toLowerCase()+(value.className? ice.PT+value.className.replaceAll(ice.SP, ice.PT):"")} }
|
||||
if (deep < 0) { return {value: value.length == undefined? "{"+can.page.unicode.inner+"}": "["+can.page.unicode.inner+"]"} }
|
||||
if (value.tagName) { return {type: "target", value: "# "+value.tagName.toLowerCase()+(value.className? ice.PT+value.className.replaceAll(ice.SP, ice.PT):"")} }
|
||||
if (value._path) { return {value: "@ \""+value._path+"\""} }
|
||||
if (value.length != undefined) { return {value: (value.length > 3? value.length+ice.SP: "")+"["+can.core.List(value, function(value, index) { if (index < 5) { return show(value, deep-1).value } else if (index == 5) { return can.page.unicode.inner } }).join(ice.FS)+"]"} }
|
||||
return {value: "{"+can.core.Item(value, function(key, val) { if (value.hasOwnProperty(key)) { return key+ice.DF+show(val, deep-1).value } }).join(ice.FS)+"}"}
|
||||
case lang.STRING: return {open: "s", close: "s", value: "\""+(value.indexOf(ice.NL) > -1? value.split(ice.NL)[0]+can.page.unicode.inner: value)+"\""}
|
||||
if (value.length != undefined) { return {value: (value.length > 3? value.length+ice.SP: "")+"["+can.core.List(value, function(value, index) { if (index < 5) { return short(show(value, deep-1).value, index+1) } }).join(ice.FS)+"]"} }
|
||||
return {value: "{"+can.core.Item(value, function(key, val, list) { if (value.hasOwnProperty(key) && list.length < 6) { return short(key+ice.DF+show(val, deep-1).value, list.length) } }).join(ice.FS)+"}"}
|
||||
case lang.STRING: return {open: "s", close: "s", value: "\""+short(value)+"\""}
|
||||
case lang.NUMBER: return {open: "n", close: "n", value: value}
|
||||
case lang.BOOLEAN: return {open: "b", close: "b", value: value}
|
||||
case lang.FUNCTION: return {open: "f", close: "f", value: ("$ "+value).split(ice.NL)[0]}
|
||||
case lang.FUNCTION: return {open: "f", close: "f", value: deep == 2? (""+value).split(ice.NL)[0]: "function(..) {..}"}
|
||||
default: return {value: value}
|
||||
} } var loaded = false, _show = show(value); _show.open = _show.open||open, _show.close = _show.close||close
|
||||
var ui = can.page.Append(can, target, [!key && value.tagName? can.page.AppendView(can, value): {view: [[html.ITEM, _show.type||typeof(value)]], list: [
|
||||
var ui = can.page.Append(can, target, [!key && value.tagName? can.page.AppendView(can, value): {view: [[html.ITEM, _show.type||typeof(value)], key == ""? html.SPAN: html.DIV], list: [
|
||||
{view: [mdb.ICON, html.SPAN, _show.close+ice.SP]}, {view: [mdb.NAME, html.SPAN, key || key === 0? key+ice.SP: ""]}, {view: [mdb.VALUE, html.SPAN, _show.value]},
|
||||
], onclick: function() { cb && cb(prefix, value); if (typeof value != lang.OBJECT) { return }
|
||||
if (loaded) { return ui.icon.innerText = (can.onmotion.toggle(can, ui.list)? _show.open: _show.close)+ice.SP } loaded = true, ui.icon.innerText = _show.open+ice.SP
|
||||
ui.icon.innerText = (can.onmotion.toggle(can, ui.list)? _show.open: _show.close)+ice.SP
|
||||
if (loaded) { return } loaded = true, ui.icon.innerText = _show.open+ice.SP
|
||||
if (value.tagName) { can.page.Append(can, ui.list, [can.page.AppendView(can, value)]), can.onappend.style(can, mdb.VIEW, ui.list)
|
||||
can.core.List(can.core.Item(target, function(key, value) { if (["textContent", "innerHTML", "outerHTML"].indexOf(key) > -1 || typeof value == lang.FUNCTION || key.toUpperCase() == key) { return } return key }).sort(), function(key) {
|
||||
target[key] && can.page.AppendData(can, ui.list, can.core.Keys(prefix, key), key, target[key], cb)
|
||||
@ -275,10 +285,10 @@ Volcanos("page", {ClassList: {
|
||||
} else if (value.length != undefined) {
|
||||
can.core.List(value, function(value, index) { can.page.AppendData(can, ui.list, can.core.Keys(prefix, index), index, value, cb) })
|
||||
} else {
|
||||
can.core.List(can.core.Item(value, function(key) { if (value.hasOwnProperty(key)) { return key } }).sort(), function(key) { can.page.AppendData(can, ui.list, can.core.Keys(prefix, key), key, value[key], cb) })
|
||||
can.core.List(can.core.Item(value, function(key, val) { if (value.hasOwnProperty(key) && val) { return key } }).sort(), function(key) { can.page.AppendData(can, ui.list, can.core.Keys(prefix, key), key, value[key], cb) })
|
||||
var key = "__proto__"; value[key] && can.core.Item(value[key]).length > 0 && can.page.AppendData(can, ui.list, can.core.Keys(prefix, key), key, value[key], cb)
|
||||
}
|
||||
}}, {view: html.LIST, style: {"margin-left": "20px"}}])
|
||||
}}, {view: [[html.LIST, html.HIDE]], style: {"margin-left": "20px"}}])
|
||||
return ui
|
||||
},
|
||||
AppendView: function(can, target, tag, list, loaded, cb) {
|
||||
|
@ -65,28 +65,26 @@ Volcanos(chat.ONEXPORT, {height: function(can) { return can._target.offsetHeight
|
||||
})
|
||||
Volcanos(chat.ONPLUGIN, {
|
||||
alert: shy("提示", [wiki.CONTENT], function(can, msg, arg) { arg && arg.length > 0 && can.user.alert(arg[0]) }),
|
||||
toast: shy("提示", [wiki.CONTENT, wiki.TITLE], function(can, msg, arg) {
|
||||
arg && arg.length > 0 && can.user.toast(can, arg[0], arg[1]), msg.Copy(can[NTIP]), msg.StatusTimeCount()
|
||||
}),
|
||||
toast: shy("提示", [wiki.CONTENT, wiki.TITLE], function(can, msg, arg) { arg && arg.length > 0 && can.user.toast(can, arg[0], arg[1]), msg.Copy(can[NTIP]), msg.StatusTimeCount() }),
|
||||
debug: shy("日志", ["type:select=log,info,warn,error,debug,wss,onremote", "_text"], function(can, msg, arg) { can.onmotion.delay(can, function() { var _can = can, can = msg._can
|
||||
var ui = can.page.Appends(can, can._output, [{type: html.TABLE, className: html.CONTENT, list: [{type: html.TR, list: [
|
||||
{type: html.TH, inner: mdb.TIME}, {type: html.TH, inner: mdb.TEXT},
|
||||
{type: html.TH, inner: mdb.TEXT},
|
||||
]}].concat(can.core.List(can.misc._list, function(list) { return (!arg || !arg[0] || arg[0] == "log" || arg[0] == list[2]) && {type: html.TR, list: [
|
||||
{type: html.TD, inner: list[0]},
|
||||
{type: html.TD, list: can.core.List(list.slice(1), function(item, index) { var vimer
|
||||
if (index == 0) { return {type: html.SPAN, list: [{text: can.page.unicode.close+ice.SP}, {text: [item.split("?")[0]+ice.SP, html.SPAN, nfs.PATH], onclick: function(event) {
|
||||
var _ls = /(https*:\/\/[^/]+)\/*([^:]+):([0-9]+):([0-9]+)/.exec(list[1])
|
||||
if (can.onexport.record(can, list[1], mdb.LINK, {time: list[0], link: list[1], type: list[2], path: ice.USR_VOLCANOS, file: _ls[2].split("?")[0], line: _ls[3]})) { return }
|
||||
if (vimer) { return can.page.Remove(can, vimer._target), vimer = null }
|
||||
vimer = can.onappend.plugin(_can, {index: "web.code.inner", args: [ice.USR_VOLCANOS, _ls[2], _ls[3]]}, function(sub) {}, event.target.parentNode)
|
||||
}}]} } if (!can.base.isObject(item)) { return {text: item+ice.SP} }
|
||||
return {view: mdb.DATA, _init: function(target) { can.page.AppendData(can, target, "", "", item)}}
|
||||
})},
|
||||
{type: html.TD, list: can.core.List(list.slice(0), function(item, index) { var vimer
|
||||
if (index == 1) { var _ls = /(https*:\/\/[^/]+)\/*([^:]+):([0-9]+):([0-9]+)/.exec(list[1])
|
||||
return {type: html.SPAN, list: [{text: can.page.unicode.close+ice.SP}, {text: [(_ls[1] == location.origin? _ls[2]: item).split("?")[0]+ice.SP, html.SPAN, nfs.PATH], onclick: function(event) {
|
||||
if (can.onexport.record(can, list[1], mdb.LINK, {time: list[0], link: list[1], type: list[2], path: ice.USR_VOLCANOS, file: _ls[2].split("?")[0], line: _ls[3]})) { return }
|
||||
if (vimer) { return can.page.Remove(can, vimer._target), vimer = null }
|
||||
vimer = can.onappend.plugin(_can, {index: "web.code.inner", args: [ice.USR_VOLCANOS, _ls[2], _ls[3]]}, function(sub) {}, event.target.parentNode)
|
||||
}}]}
|
||||
} if (!can.base.isObject(item)) { return {text: item+ice.SP} }
|
||||
return {view: [mdb.DATA, html.SPAN], _init: function(target) { can.page.AppendData(can, target, "", "", item)}}
|
||||
}
|
||||
)},
|
||||
]} })) }]); arg && arg[1] && can.page.Select(can, can._output, html.TR, function(tr) { can.page.ClassList.set(can, tr, html.HIDE, tr.innerText.indexOf(arg[1]) == -1) })
|
||||
can.onappend._status(can, [{name: mdb.TIME, value: can.base.Time()}, {name: mdb.COUNT, value: can.page.Select(can, can._output, html.TR+":not(.hide)").length+"x2"}])
|
||||
}) }),
|
||||
data: shy("网页标签", [mdb.KEY], function(can, msg, arg) { can.onmotion.delay(can, function() { var can = msg._can
|
||||
can.page.Append(can, can._output, [{text: "hello world"}])
|
||||
if (can.Option(mdb.KEY)) {
|
||||
can.page.AppendData(can, can._output, can.Option(mdb.KEY), can.Option(mdb.KEY).split(ice.PT).pop(), can.core.Value(can._root, can.Option(mdb.KEY)), function(prefix, value) {
|
||||
can.Option(mdb.KEY, prefix)
|
||||
@ -102,8 +100,7 @@ Volcanos(chat.ONPLUGIN, {
|
||||
can.page.AppendView(can, document.head, "head"), can.page.AppendView(can, document.body, "body", null, false, function(target) {
|
||||
var list = []; for (var p = target; p && p.tagName; p = p.parentNode) {
|
||||
list.push(p.tagName.toLowerCase()+(p.className? ice.PT+p.className.replaceAll(ice.SP, ice.PT): ""))
|
||||
}
|
||||
can.page.Appends(can, can._action, [{view: [html.ITEM, html.DIV, list.reverse().join(ice.SP+ice.GT+ice.SP)]}])
|
||||
} can.page.Appends(can, can._action, [{view: [html.ITEM, html.DIV, list.reverse().join(ice.SP+ice.GT+ice.SP)]}])
|
||||
}),
|
||||
], true)])
|
||||
}) }),
|
||||
|
@ -69,13 +69,13 @@ Volcanos(chat.ONFIGURE, {
|
||||
}, target), zone._total(msg.Length())
|
||||
})
|
||||
} },
|
||||
plugin: function(can, target, zone) { zone._delay_show = function() { var total = 0
|
||||
plugin: function(can, target, zone) { var total = 0
|
||||
can.onimport.tree(can, can.core.ItemKeys(can.onengine.plugin.meta, function(key) { return total++, {index: key} }), ctx.INDEX, ice.PT, function(event, item) {
|
||||
can.onimport.tabview(can, can.Option(nfs.PATH), can.core.Keys(ice.CAN, item.index), ctx.INDEX)
|
||||
}, target), zone._total(total)
|
||||
} },
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONACTION, {list: ["首页", "官网", "文档"],
|
||||
Volcanos(chat.ONACTION, {list: ["调试", "首页", "官网", "文档"],
|
||||
_daemon: function(event, can, arg) { switch (arg[0]) {
|
||||
case web.DREAM: can.runAction({}, arg[0], arg.slice(1), function(msg) { can.onimport.tabview(can, can.Option(nfs.PATH), can.core.Keys(can.misc.Search(can, ice.POD), msg.Option(mdb.NAME)), web.DREAM) }); break
|
||||
case code.XTERM: can.runAction({}, arg[0], arg.slice(1), function(msg) { can.onimport.tabview(can, ctx.COMMAND, code.XTERM, msg.Result()) }); break
|
||||
@ -140,7 +140,6 @@ Volcanos(chat.ONACTION, {list: ["首页", "官网", "文档"],
|
||||
"首页": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host) },
|
||||
"官网": function(event, can) { can.onaction._open(can, "https://shylinux.com/") },
|
||||
"文档": function(event, can) { can.onaction._open(can, "https://developer.mozilla.org/") },
|
||||
"百度": function(event, can) { can.onaction._open(can, "https://baidu.com") },
|
||||
"命令": function(event, can) { can.user.input(event, can, [ctx.INDEX], function(list) { can.onimport.tabview(can, can.Option(nfs.PATH), list[0], ctx.INDEX) }) },
|
||||
"插件": function(event, can) { can.user.input(event, can, [ctx.INDEX], function(list) { var sub = can.db.toolkit[list[0]]; if (sub) { sub.select(); return }
|
||||
can.onimport.toolkit(can, {index: list[0]}, function(sub) { can.db.toolkit[list[0]] = sub.select() })
|
||||
@ -152,6 +151,7 @@ Volcanos(chat.ONACTION, {list: ["首页", "官网", "文档"],
|
||||
"日志": function(event, can) { window.opencmd("cd ~/contexts; tail -f var/log/bench.log") },
|
||||
"编辑器": function(event, can) { window.opencmd("cd ~/contexts; vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)) },
|
||||
"浏览器": function(event, can) { window.openurl(location.href) },
|
||||
"调试": function(event, can) { window.openurl(location.href) },
|
||||
_open: function(can, url) { can.user.isWebview? window.openurl(url): window.open(url) },
|
||||
_complete: function(event, can, target) { if (event == undefined || event.type == "click") { return } target = target||can.ui.complete
|
||||
var pre = can.ui.current.value.slice(0, can.ui.current.selectionStart), key = can.core.Split(pre, "\t .[]", " ").pop()||"", end = can.ui.current.value.slice(can.ui.current.selectionStart)
|
||||
|
Loading…
x
Reference in New Issue
Block a user