mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add debug.js
This commit is contained in:
parent
c0a949ccd0
commit
985413fcd4
@ -7,5 +7,5 @@ var version = struct {
|
|||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
[]string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"},
|
||||||
`2019-10-05 11:17:52`, `mac`, 638,
|
`2019-10-05 14:55:37`, `mac`, 639,
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,9 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
|||||||
map[string]interface{}{"name": "carte",
|
map[string]interface{}{"name": "carte",
|
||||||
"tmpl": "fieldset", "view": "Carte dialog", "init": "initCarte",
|
"tmpl": "fieldset", "view": "Carte dialog", "init": "initCarte",
|
||||||
},
|
},
|
||||||
|
map[string]interface{}{"name": "debug",
|
||||||
|
"tmpl": "fieldset", "view": "Debug dialog", "init": "initDebug",
|
||||||
|
},
|
||||||
map[string]interface{}{"name": "login",
|
map[string]interface{}{"name": "login",
|
||||||
"tmpl": "fieldset", "view": "Login dialog", "init": "initLogin",
|
"tmpl": "fieldset", "view": "Login dialog", "init": "initLogin",
|
||||||
"ctx": "web.chat", "cmd": "login",
|
"ctx": "web.chat", "cmd": "login",
|
||||||
|
@ -537,6 +537,9 @@ var page = Page({check: true,
|
|||||||
"返回": function(event, value) {
|
"返回": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Last()
|
page.plugin && page.plugin.Plugin.Last()
|
||||||
},
|
},
|
||||||
|
"调试": function(event, value) {
|
||||||
|
page.debug.Pane.Show()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
|
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
|
||||||
"", "刷新", "清屏", "并行", "串行",
|
"", "刷新", "清屏", "并行", "串行",
|
||||||
@ -546,7 +549,7 @@ var page = Page({check: true,
|
|||||||
],
|
],
|
||||||
Choice: [
|
Choice: [
|
||||||
["layout", "聊天", "办公", "工作"],
|
["layout", "聊天", "办公", "工作"],
|
||||||
"刷新", "清屏", "并行", "串行",
|
"刷新", "清屏", "并行", "串行", "调试",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -216,6 +216,28 @@ fieldset.dialog.Carte>div.output div.space {
|
|||||||
border:solid 1px gray;
|
border:solid 1px gray;
|
||||||
margin-top:8px;
|
margin-top:8px;
|
||||||
}
|
}
|
||||||
|
fieldset.dialog.Debug {
|
||||||
|
height:300px;
|
||||||
|
opacity:0.8;
|
||||||
|
}
|
||||||
|
fieldset.dialog.Debug tr.hide {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
fieldset.dialog.Debug tr.event {
|
||||||
|
display:red;
|
||||||
|
}
|
||||||
|
fieldset.dialog.Debug tr.run {
|
||||||
|
background-color:lightgreen;
|
||||||
|
}
|
||||||
|
fieldset.dialog.Debug tr.key {
|
||||||
|
background-color:lightyellow;
|
||||||
|
}
|
||||||
|
fieldset.dialog.Debug>div.output table th {
|
||||||
|
min-width:30px;
|
||||||
|
}
|
||||||
|
fieldset.dialog.Debug>div.output table td {
|
||||||
|
min-width:10px;
|
||||||
|
}
|
||||||
|
|
||||||
fieldset.Login {
|
fieldset.Login {
|
||||||
font-size:28px;
|
font-size:28px;
|
||||||
|
@ -5,6 +5,8 @@ function Meta(zone, target, obj) {
|
|||||||
a.__proto__ = arguments[i], a = arguments[i]
|
a.__proto__ = arguments[i], a = arguments[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var names = obj && obj.Event && obj.Event.meta && obj.Event.meta.name && obj.Event.meta.name.concat([zone]) || [zone]
|
||||||
|
|
||||||
// 构造对象
|
// 构造对象
|
||||||
var id = 1
|
var id = 1
|
||||||
var conf = {}, conf_cb = {}, old
|
var conf = {}, conf_cb = {}, old
|
||||||
@ -12,6 +14,9 @@ function Meta(zone, target, obj) {
|
|||||||
var cache = {}
|
var cache = {}
|
||||||
var history = []
|
var history = []
|
||||||
var meta = {__proto__: obj, target: target,
|
var meta = {__proto__: obj, target: target,
|
||||||
|
Event: shy("事件入口", {name: names}, function(event, msg) {
|
||||||
|
return ctx.Event(event, msg||{}, arguments.callee.meta)
|
||||||
|
}),
|
||||||
ID: shy("单一序列", function() {return id++}),
|
ID: shy("单一序列", function() {return id++}),
|
||||||
Conf: shy("配置变量", function(key, value, cb) {
|
Conf: shy("配置变量", function(key, value, cb) {
|
||||||
if (kit.isNone(key)) {return conf}
|
if (kit.isNone(key)) {return conf}
|
||||||
@ -433,6 +438,60 @@ function Page(page) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
initDebug: function(page, field, option, output) {
|
||||||
|
var list = kit.AppendChilds(output, "table")
|
||||||
|
var caption = kit.AppendChilds(list, [{type: "caption"}]).last
|
||||||
|
var head = kit.AppendChild(list, [{row: ["time", "type", "main", "arg", "args"], sub: "th"}]).last
|
||||||
|
kit.OrderTable(list)
|
||||||
|
var data, types = {all: 0, event: 0, run: 0, key: 0}
|
||||||
|
|
||||||
|
|
||||||
|
kit.Log.meta.call.push(function(time, type, main, arg) {var Choice = field.Pane && field.Pane.Choice || []
|
||||||
|
if (kit.isNone(types[type])) {types[type] = 0, Choice.push(type)}
|
||||||
|
types[type]++
|
||||||
|
types.all++
|
||||||
|
|
||||||
|
data = kit.AppendChild(list, [{className: type, row: [time, type, main, arg||"", kit.List(arguments, function(item) {
|
||||||
|
return typeof item == "object"? "{...}": item
|
||||||
|
}).slice(4).join(" ")]}]).last
|
||||||
|
data.scrollIntoView()
|
||||||
|
caption.innerHTML = kit.List(Choice.slice(1), function(item) {return item+": "+types[item]}).join(" ")
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
Show: function() {
|
||||||
|
kit.ModifyView(field, {display: field.style.display != "block"? "block": "none"})
|
||||||
|
},
|
||||||
|
clear: function() {
|
||||||
|
var th = kit.AppendChilds(list, [{row: ["time", "type", "main", "arg", "args"], sub: "th"}]).last
|
||||||
|
},
|
||||||
|
Action: shy({
|
||||||
|
"关闭": function() {
|
||||||
|
field.Pane.Show()
|
||||||
|
},
|
||||||
|
"最大": function() {
|
||||||
|
kit.size(field, document.body.clientWidth, document.body.clientHeight)
|
||||||
|
},
|
||||||
|
"最小": function() {
|
||||||
|
kit.size(field, document.body.clientWidth/2, document.body.clientHeight/2)
|
||||||
|
},
|
||||||
|
"左边": function() {
|
||||||
|
field.style.left = "0px"
|
||||||
|
kit.size(field, document.body.clientWidth/2, document.body.clientHeight)
|
||||||
|
},
|
||||||
|
"右边": function() {
|
||||||
|
field.style.left = document.body.clientWidth/2+"px"
|
||||||
|
kit.size(field, document.body.clientWidth/2, document.body.clientHeight)
|
||||||
|
},
|
||||||
|
}, function(event, type) {
|
||||||
|
kit.Selector(list, "tr", function(item, index) {
|
||||||
|
index == 0 || type == "all" || kit.classList.has(item, type)?
|
||||||
|
kit.classList.del(item, "hide"): kit.classList.add(item, "hide")
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
Choice: ["关闭", "all", "event", "run", "key"],
|
||||||
|
Button: ["关闭", "最大", "最小", "左边", "右边"],
|
||||||
|
}
|
||||||
|
},
|
||||||
initLogin: function(page, field, option, output) {
|
initLogin: function(page, field, option, output) {
|
||||||
var ui = kit.AppendChilds(option, [
|
var ui = kit.AppendChilds(option, [
|
||||||
{label: "username"}, {input: ["username"]}, {type: "br"},
|
{label: "username"}, {input: ["username"]}, {type: "br"},
|
||||||
@ -648,6 +707,9 @@ function Pane(page, field) {
|
|||||||
},
|
},
|
||||||
Run: function(cmds, cb) {ctx.Run(option.dataset, cmds, cb||pane.ondaemon)},
|
Run: function(cmds, cb) {ctx.Run(option.dataset, cmds, cb||pane.ondaemon)},
|
||||||
|
|
||||||
|
Show: function() {
|
||||||
|
kit.ModifyView(field, {display: "block"})
|
||||||
|
},
|
||||||
Hide: function() {
|
Hide: function() {
|
||||||
kit.ModifyView(field, {display: "none"})
|
kit.ModifyView(field, {display: "none"})
|
||||||
},
|
},
|
||||||
@ -690,7 +752,7 @@ function Pane(page, field) {
|
|||||||
onaction: shy("事件列表", {
|
onaction: shy("事件列表", {
|
||||||
oncontextmenu: function(event) {
|
oncontextmenu: function(event) {
|
||||||
pane.Choice && page.carte.Pane.Show(event, shy({}, pane.Choice, function(value, meta, event) {
|
pane.Choice && page.carte.Pane.Show(event, shy({}, pane.Choice, function(value, meta, event) {
|
||||||
kit._call(pane.Action[value], [event])
|
call(value, event)
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
}, function(event, key, cb) {cb(event)}),
|
}, function(event, key, cb) {cb(event)}),
|
||||||
@ -700,7 +762,16 @@ function Pane(page, field) {
|
|||||||
// Event入口 1.1
|
// Event入口 1.1
|
||||||
ctx.Event(event, {}, {name: name+"."+value})
|
ctx.Event(event, {}, {name: name+"."+value})
|
||||||
page.script("record", [name, value])
|
page.script("record", [name, value])
|
||||||
typeof pane.Action == "function"? pane.Action(value, event): pane.Action[value](event, value)
|
|
||||||
|
if (pane.Action && pane.Action.meta && typeof pane.Action.meta[value] == "function") {
|
||||||
|
kit._call(pane.Action.meta[value], [event, value])
|
||||||
|
} else if (pane.Action && typeof pane.Action[value] == "function") {
|
||||||
|
kit._call(pane.Action[value], [event, value])
|
||||||
|
} else if (typeof pane.Action == "function") {
|
||||||
|
kit._call(pane.Action, [event, value])
|
||||||
|
} else if (typeof pane[value] == "function") {
|
||||||
|
kit._call(pane[value], [event, value])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
kit.AppendAction(action, pane.Button, call)
|
kit.AppendAction(action, pane.Button, call)
|
||||||
|
|
||||||
|
@ -38,11 +38,12 @@ kit = toolkit = (function() {var kit = {__proto__: document,
|
|||||||
Debug: shy("调试断点", {why: true, msg: true}, function(key) {
|
Debug: shy("调试断点", {why: true, msg: true}, function(key) {
|
||||||
if (arguments.callee.meta[key]) {debugger}
|
if (arguments.callee.meta[key]) {debugger}
|
||||||
}),
|
}),
|
||||||
Log: shy("输出日志", {hide: {"init": true, "wss": false},
|
Log: shy("输出日志", {hide: {"init": true, "wss": false}, call: [],
|
||||||
func: {debug: "debug", info: "info", parn: "warn", err: "error"},
|
func: {debug: "debug", info: "info", parn: "warn", err: "error"},
|
||||||
}, function(type, arg) {var meta = arguments.callee.meta
|
}, function(type, arg) {var meta = arguments.callee.meta
|
||||||
var args = [kit.time().split(" ")[1]].concat(kit.List(kit.isNone(arg)? type: arguments))
|
var args = [kit.time().split(" ")[1]].concat(kit.List(kit.isNone(arg)? type: arguments))
|
||||||
!meta.hide[args[1]] && console[meta.func[args[1]]||"log"](args)
|
!meta.hide[args[1]] && console[meta.func[args[1]]||"log"](args)
|
||||||
|
kit.List(meta.call, function(cb) {kit._call(cb, args)})
|
||||||
kit.Debug(args[1])
|
kit.Debug(args[1])
|
||||||
return args.slice(1)
|
return args.slice(1)
|
||||||
}),
|
}),
|
||||||
@ -50,6 +51,15 @@ kit = toolkit = (function() {var kit = {__proto__: document,
|
|||||||
|
|
||||||
// HTML节点操作
|
// HTML节点操作
|
||||||
classList: {
|
classList: {
|
||||||
|
has: function(obj, key) {
|
||||||
|
var list = obj.className? obj.className.split(" "): []
|
||||||
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
|
if (list.indexOf(arguments[i]) == -1) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
add: function(obj, key) {var list = obj.className? obj.className.split(" "): []
|
add: function(obj, key) {var list = obj.className? obj.className.split(" "): []
|
||||||
return obj.className = list.concat(kit.List(arguments, function(value, index) {
|
return obj.className = list.concat(kit.List(arguments, function(value, index) {
|
||||||
return index > 0 && list.indexOf(value) == -1? value: undefined
|
return index > 0 && list.indexOf(value) == -1? value: undefined
|
||||||
|
Loading…
x
Reference in New Issue
Block a user