mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
set.js
This commit is contained in:
parent
5bafb5d9d0
commit
53afdd1f28
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-09-23 20:04:21", "centos", 596,
|
"2019-09-24 11:15:57", "centos", 602,
|
||||||
}
|
}
|
||||||
|
@ -1188,11 +1188,10 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
|
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
if p, ok := m.Confv("wss", []string{v, "channel"}).(chan *ctx.Message); ok {
|
if p, ok := m.Confv("wss", []string{v, "channel"}).(chan *ctx.Message); ok {
|
||||||
if arg[1] == "sync" {
|
if msg := m.Spawn(); arg[1] == "sync" {
|
||||||
m.Meta["detail"] = arg[2:]
|
p <- msg.Add("detail", arg[2], arg[3:])
|
||||||
p <- m
|
msg.CallBack(true, func(msg *ctx.Message) *ctx.Message {
|
||||||
m.CallBack(true, func(msg *ctx.Message) *ctx.Message {
|
if data, ok := msg.Optionv("data").(map[string]interface{}); ok {
|
||||||
if data, ok := m.Optionv("data").(map[string]interface{}); ok {
|
|
||||||
if len(list) == 1 && data["append"] != nil {
|
if len(list) == 1 && data["append"] != nil {
|
||||||
for _, k := range kit.Trans(data["append"]) {
|
for _, k := range kit.Trans(data["append"]) {
|
||||||
m.Push(k, kit.Trans(data[k]))
|
m.Push(k, kit.Trans(data[k]))
|
||||||
@ -1216,8 +1215,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}, "skip")
|
}, "skip")
|
||||||
m.Table()
|
m.Table()
|
||||||
} else {
|
} else {
|
||||||
m.Meta["detail"] = arg[1:]
|
p <- msg.Add("detail", arg[1], arg[2:])
|
||||||
p <- m
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ kit project "项目" private \
|
|||||||
select "" values plugin values review values submit values trend values stats values stat values init action auto \
|
select "" values plugin values review values submit values trend values stats values stat values init action auto \
|
||||||
text "" name see imports plugin_see action auto \
|
text "" name see imports plugin_see action auto \
|
||||||
button "执行" \
|
button "执行" \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
exports see name see
|
exports see name see
|
||||||
|
|
||||||
kit compile "编译" private \
|
kit compile "编译" private \
|
||||||
@ -43,14 +43,14 @@ kit cmd "命令" private "ssh._route" _ context _ command __ \
|
|||||||
text "cli" name ctx imports plugin_ctx \
|
text "cli" name ctx imports plugin_ctx \
|
||||||
text "date" name cmd imports plugin_cmd \
|
text "date" name cmd imports plugin_cmd \
|
||||||
button "执行" \
|
button "执行" \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
exports cmd cmd
|
exports cmd cmd
|
||||||
|
|
||||||
kit dir "目录" private "ssh._route" _ "nfs.dir" _ time size line path \
|
kit dir "目录" private "ssh._route" _ "nfs.dir" _ time size line path \
|
||||||
text "" name pod imports plugin_pod action auto \
|
text "" name pod imports plugin_pod action auto \
|
||||||
text "usr/script" name dir imports plugin_dir action auto view long \
|
text "usr/script" name dir imports plugin_dir action auto view long \
|
||||||
button "浏览" action auto \
|
button "浏览" action auto \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
feature display "editor" \
|
feature display "editor" \
|
||||||
exports dir "" dir
|
exports dir "" dir
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ end
|
|||||||
kit macro "脚本宏" "macro.js" public \
|
kit macro "脚本宏" "macro.js" public \
|
||||||
text "" name mac imports plugin_mac action auto \
|
text "" name mac imports plugin_mac action auto \
|
||||||
button "查看" \
|
button "查看" \
|
||||||
button "全部" click "all" \
|
button "全部" cb "all" \
|
||||||
button "录制" click "Record" \
|
button "录制" cb "Record" \
|
||||||
button "运行" click "Replay" \
|
button "运行" cb "Replay" \
|
||||||
exports mac name
|
exports mac name
|
||||||
|
|
||||||
kit sys "命令行" public "ssh._route" _ "nfs.source" \
|
kit sys "命令行" public "ssh._route" _ "nfs.source" \
|
||||||
|
@ -20,7 +20,7 @@ kit date "日历" "index.js" "index.css" protected "cli.date" _ nature _ \
|
|||||||
text "when" name "when" \
|
text "when" name "when" \
|
||||||
text "where" name "where" \
|
text "where" name "where" \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
button "显示" click show
|
button "显示" cb show
|
||||||
|
|
||||||
fun delay "以后告诉你" protected \
|
fun delay "以后告诉你" protected \
|
||||||
text "delay" name table imports plugin_table \
|
text "delay" name table imports plugin_table \
|
||||||
@ -52,7 +52,7 @@ fun wss "推送" private \
|
|||||||
text "" name wss imports plugin_wss \
|
text "" name wss imports plugin_wss \
|
||||||
text "" name cmd view long \
|
text "" name cmd view long \
|
||||||
button "推送" \
|
button "推送" \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
exports wss key
|
exports wss key
|
||||||
|
|
||||||
if $2 == ""
|
if $2 == ""
|
||||||
@ -63,8 +63,8 @@ fun wss "推送" private \
|
|||||||
end
|
end
|
||||||
|
|
||||||
kit pos "位置" private \
|
kit pos "位置" private \
|
||||||
button "查看" click getLocation \
|
button "查看" cb getLocation \
|
||||||
button "显示" click openLocation \
|
button "显示" cb openLocation \
|
||||||
text "0.0062" name x \
|
text "0.0062" name x \
|
||||||
text "0.0014" name y \
|
text "0.0014" name y \
|
||||||
text "当前位置" name pos \
|
text "当前位置" name pos \
|
||||||
|
@ -2,6 +2,6 @@ kit xls "表格" "index.js" "index.css" private \
|
|||||||
text "" name title imports plugin_xls_id action auto \
|
text "" name title imports plugin_xls_id action auto \
|
||||||
text "" name content \
|
text "" name content \
|
||||||
button "执行" \
|
button "执行" \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
feature style "mind" \
|
feature style "mind" \
|
||||||
exports xls_id id
|
exports xls_id id
|
||||||
|
@ -15,7 +15,7 @@ fun note "记事本" public \
|
|||||||
text "" name you imports plugin_you action auto \
|
text "" name you imports plugin_you action auto \
|
||||||
text "" name tip imports plugin_tip view long action auto \
|
text "" name tip imports plugin_tip view long action auto \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
exports tip file tip \
|
exports tip file tip \
|
||||||
feature display inner
|
feature display inner
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ kit data "数据库" public "ssh.data" show \
|
|||||||
text "" name table imports plugin_table action auto view long \
|
text "" name table imports plugin_table action auto view long \
|
||||||
text "" name index action auto \
|
text "" name index action auto \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
exports table table
|
exports table table
|
||||||
|
|
||||||
kit save "导出" private "ssh.data" export \
|
kit save "导出" private "ssh.data" export \
|
||||||
@ -44,6 +44,6 @@ kit load "导入" private "ssh.data" import \
|
|||||||
|
|
||||||
kit push "上传" private "web./download/" \
|
kit push "上传" private "web./download/" \
|
||||||
upfile "" name upload \
|
upfile "" name upload \
|
||||||
button "上传" click upload \
|
button "上传" cb upload \
|
||||||
button "查看"
|
button "查看"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ kit buffer "粘贴板" public buf \
|
|||||||
text "0" name index imports plugin_tmux_bindex action auto \
|
text "0" name index imports plugin_tmux_bindex action auto \
|
||||||
text "" name txt action auto \
|
text "" name txt action auto \
|
||||||
button "查看" action auto \
|
button "查看" action auto \
|
||||||
button "返回" click Last \
|
button "返回" cb Last \
|
||||||
exports tmux_bindex cur
|
exports tmux_bindex cur
|
||||||
|
|
||||||
kit session "会话" private mux \
|
kit session "会话" private mux \
|
||||||
|
@ -288,7 +288,12 @@ var page = Page({check: true,
|
|||||||
], 0)
|
], 0)
|
||||||
},
|
},
|
||||||
Core: function(event, line, args, cbs) {
|
Core: function(event, line, args, cbs) {
|
||||||
var msg = (event.msg = line || {})
|
var msg = event.msg || {}, res
|
||||||
|
function result(res) {
|
||||||
|
res != null && res != undefined && !msg.result && (msg.result = kit.Trans(res))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
var plugin = event.Plugin || page.plugin && page.plugin.Plugin || {}, engine = {
|
var plugin = event.Plugin || page.plugin && page.plugin.Plugin || {}, engine = {
|
||||||
share: function(args) {
|
share: function(args) {
|
||||||
typeof cbs == "function" && cbs(ctx.Share({"group": option.dataset.group, "name": option.dataset.name, "cmds": [
|
typeof cbs == "function" && cbs(ctx.Share({"group": option.dataset.group, "name": option.dataset.name, "cmds": [
|
||||||
@ -297,11 +302,38 @@ var page = Page({check: true,
|
|||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
wss: function(id) {
|
wss: function(id) {
|
||||||
return page.wssid = id
|
return id && (page.wssid = id)
|
||||||
},
|
},
|
||||||
pwd: function(args) {
|
pwd: function(name, value) {
|
||||||
|
name && kit.Selector(page.action, "fieldset.item."+name, function(item) {
|
||||||
|
item.Plugin.Select()
|
||||||
|
})
|
||||||
|
if (value) {return engine.set(value)}
|
||||||
return [river, storm, page.plugin && page.plugin.Meta.name, page.input && page.input.name, page.input && page.input.value]
|
return [river, storm, page.plugin && page.plugin.Meta.name, page.input && page.input.name, page.input && page.input.value]
|
||||||
},
|
},
|
||||||
|
set: function(value, name) {
|
||||||
|
try {
|
||||||
|
if (value == undefined) {
|
||||||
|
msg.append = ["name", "value"]
|
||||||
|
msg.name = [], msg.value = []
|
||||||
|
return kit.Selector(page.plugin, ".args", function(item) {
|
||||||
|
msg.name.push(item.name)
|
||||||
|
msg.value.push(item.value)
|
||||||
|
return item.name+":"+item.value
|
||||||
|
})
|
||||||
|
|
||||||
|
} else if (name == undefined) {
|
||||||
|
kit.Selector(page.plugin, "input[type=button]", function(item) {
|
||||||
|
if (item.value == value) {item.click(); return value}
|
||||||
|
}).length > 0 || (page.action.Pane.Action[value]?
|
||||||
|
page.action.Pane.Action[value](event, value): (page.input.value = value))
|
||||||
|
} else {
|
||||||
|
page.plugin.Plugin.Inputs[name].value = value
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
engine._cmd("_cmd", [value, name])
|
||||||
|
}
|
||||||
|
},
|
||||||
dir: function(rid, sid, pid, uid) {
|
dir: function(rid, sid, pid, uid) {
|
||||||
if (!rid) {
|
if (!rid) {
|
||||||
return kit.Selector(page.river, "div.output>div.item>div.text>span", function(item) {
|
return kit.Selector(page.river, "div.output>div.item>div.text>span", function(item) {
|
||||||
@ -315,6 +347,8 @@ var page = Page({check: true,
|
|||||||
}
|
}
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
return kit.Selector(page.action, "fieldset.item>legend", function(item) {
|
return kit.Selector(page.action, "fieldset.item>legend", function(item) {
|
||||||
|
msg.push("name", item.parentNode.Meta.name)
|
||||||
|
msg.push("help", item.parentNode.Meta.help)
|
||||||
return item.innerText
|
return item.innerText
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -362,12 +396,8 @@ var page = Page({check: true,
|
|||||||
_split: function(str) {return str.trim().split(" ")},
|
_split: function(str) {return str.trim().split(" ")},
|
||||||
_cmd: function(arg) {
|
_cmd: function(arg) {
|
||||||
var args = typeof arg[1] == "string"? engine._split(arg[1]): arg[1];
|
var args = typeof arg[1] == "string"? engine._split(arg[1]): arg[1];
|
||||||
var res = null
|
|
||||||
page.script("record", args)
|
page.script("record", args)
|
||||||
function result(res) {
|
kit.Log(["cmd"].concat(args))
|
||||||
res != null && res != undefined && !msg.result && (msg.result = [res])
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof engine[args[0]] == "function") {
|
if (typeof engine[args[0]] == "function") {
|
||||||
return result(kit._call(engine[args[0]], args.slice(1)))
|
return result(kit._call(engine[args[0]], args.slice(1)))
|
||||||
@ -402,7 +432,7 @@ var page = Page({check: true,
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if (args.length > 0 && engine[args[0]] && engine[args[0]](args)) {typeof cbs == "function" && cbs(line); return}
|
if (args.length > 0 && engine[args[0]] && engine[args[0]](args)) {typeof cbs == "function" && cbs(); return}
|
||||||
event.shiftKey? engine._msg(): engine._run()
|
event.shiftKey? engine._msg(): engine._run()
|
||||||
},
|
},
|
||||||
Show: function() {var pane = field.Pane
|
Show: function() {var pane = field.Pane
|
||||||
@ -430,23 +460,29 @@ var page = Page({check: true,
|
|||||||
},
|
},
|
||||||
Action: {
|
Action: {
|
||||||
"聊天": function(event, value) {
|
"聊天": function(event, value) {
|
||||||
|
page.which.set(value)
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
},
|
},
|
||||||
"办公": function(event, value) {
|
"办公": function(event, value) {
|
||||||
|
page.which.set(value)
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
page.onlayout(event, {river: 0, action:300})
|
page.onlayout(event, {river: 0, action:300})
|
||||||
},
|
},
|
||||||
"工作": function(event, value) {
|
"工作": function(event, value) {
|
||||||
|
page.which.set(value)
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
page.onlayout(event, {river:0, action:-1})
|
page.onlayout(event, {river:0, action:-1})
|
||||||
},
|
},
|
||||||
"最高": function(event, value) {
|
"最高": function(event, value) {
|
||||||
|
page.which.set(value)
|
||||||
page.onlayout(event, {action: -1})
|
page.onlayout(event, {action: -1})
|
||||||
},
|
},
|
||||||
"最宽": function(event, value) {
|
"最宽": function(event, value) {
|
||||||
|
page.which.set(value)
|
||||||
page.onlayout(event, {river:0, storm:0})
|
page.onlayout(event, {river:0, storm:0})
|
||||||
},
|
},
|
||||||
"最大": function(event, value) {
|
"最大": function(event, value) {
|
||||||
|
page.which.set(value)
|
||||||
page.onlayout(event, {header:0, footer:0, river:0, storm:0, action: -1})
|
page.onlayout(event, {header:0, footer:0, river:0, storm:0, action: -1})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -492,7 +528,7 @@ var page = Page({check: true,
|
|||||||
page.plugin && page.plugin.Plugin.Delete()
|
page.plugin && page.plugin.Plugin.Delete()
|
||||||
},
|
},
|
||||||
"加参": function(event, value) {
|
"加参": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Append({className: "args temp"})
|
page.plugin && page.plugin.Plugin.Appends()
|
||||||
},
|
},
|
||||||
"减参": function(event, value) {
|
"减参": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Remove()
|
page.plugin && page.plugin.Plugin.Remove()
|
||||||
|
@ -5,6 +5,8 @@ ctx = context = {__proto__: kit,
|
|||||||
option[k] = dataset[k].split(",")
|
option[k] = dataset[k].split(",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kit.Log(["run"].concat(option.group).concat(option.name).concat(option.cmds))
|
||||||
|
|
||||||
var event = window.event
|
var event = window.event
|
||||||
this.POST("", option, function(msg) {
|
this.POST("", option, function(msg) {
|
||||||
msg[0] && (msg = msg[0])
|
msg[0] && (msg = msg[0])
|
||||||
@ -237,23 +239,30 @@ ctx = context = {__proto__: kit,
|
|||||||
page.ontoast("wss open")
|
page.ontoast("wss open")
|
||||||
}
|
}
|
||||||
s.onmessage = function(event) {
|
s.onmessage = function(event) {
|
||||||
var msg = JSON.parse(event.data)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var msg = JSON.parse(event.data||'{}')
|
var msg = JSON.parse(event.data||'{}')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var msg = {"result": [event.data]}
|
var msg = {"result": [event.data]}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.event = event, msg.reply = function(res) {
|
event.msg = msg, msg.event = event, msg.reply = function(res) {
|
||||||
res = res || msg, res.event = undefined
|
msg.result = (msg.result||[]).concat(kit.Trans(res))
|
||||||
kit.Log(["wss", "detail"].concat(msg.detail))
|
kit.Log(["wss", "detail"].concat(msg.detail))
|
||||||
kit.Log(["wss", "result"].concat(res.result))
|
kit.Log(["wss", "result"].concat(msg.result))
|
||||||
s.send(JSON.stringify(res))
|
delete(msg.event), s.send(JSON.stringify(msg))
|
||||||
|
}
|
||||||
|
msg.push = function(key, value) {
|
||||||
|
msg.append || (msg.append = [])
|
||||||
|
msg[key]? msg[key].push(value): (msg[key] = [value], msg.append.push(key))
|
||||||
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
kit.Log(msg)
|
try {
|
||||||
typeof cb == "function" && cb(msg)
|
kit.Log("wss", "msg", msg)
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
} catch (e) {
|
||||||
|
msg.reply(kit.Log("err", e))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s.onerror = function(event) {
|
s.onerror = function(event) {
|
||||||
kit.Log(event)
|
kit.Log(event)
|
||||||
|
@ -36,7 +36,7 @@ function Meta(target, obj) {
|
|||||||
if (value == data && !force) {return value}
|
if (value == data && !force) {return value}
|
||||||
|
|
||||||
old_value = data, data = value
|
old_value = data, data = value
|
||||||
meta && kit.Log(meta, value, old_value)
|
meta && kit.Log("key", meta, value, old_value)
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
list[i](value, old_value)
|
list[i](value, old_value)
|
||||||
}
|
}
|
||||||
@ -130,86 +130,52 @@ function Page(page) {
|
|||||||
var script = {}, record = ""
|
var script = {}, record = ""
|
||||||
page = Meta(document.body, page, {__proto__: ctx,
|
page = Meta(document.body, page, {__proto__: ctx,
|
||||||
onload: function() {
|
onload: function() {
|
||||||
var sessid = ctx.Cookie("sessid")
|
if (page.check && !ctx.Cookie("sessid")) {
|
||||||
if (page.check && !sessid) {
|
// 用户登录
|
||||||
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
||||||
page.Pane(page, field)
|
page.Pane(page, field)
|
||||||
})
|
}), page.login.Pane.Dialog(1, 1)
|
||||||
} else {
|
} else {
|
||||||
|
// 登录成功
|
||||||
document.querySelectorAll("body>fieldset").forEach(function(field) {
|
document.querySelectorAll("body>fieldset").forEach(function(field) {
|
||||||
page.Pane(page, field)
|
page.Pane(page, field)
|
||||||
}), page.init(page)
|
}), page.init(page), page.check && page.login.Pane.Run([], function(msg) {
|
||||||
}
|
|
||||||
|
|
||||||
if (page.check) {
|
|
||||||
kit.device.isWeiXin? page.login.Pane.Run(["weixin"], function(msg) {
|
|
||||||
page.Include([
|
|
||||||
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
|
|
||||||
// "/static/librarys/weixin.js",
|
|
||||||
], function(event) {
|
|
||||||
wx.error(function(res){})
|
|
||||||
wx.ready(function(){
|
|
||||||
page.getLocation = function(cb) {
|
|
||||||
wx.getLocation({success: function (res) {
|
|
||||||
cb(res)
|
|
||||||
}})
|
|
||||||
}
|
|
||||||
page.openLocation = function(latitude, longitude, name) {
|
|
||||||
wx.openLocation({latitude: parseFloat(latitude), longitude: parseFloat(longitude), name:name||"here"})
|
|
||||||
}
|
|
||||||
wx.getLocation({success: function (res) {
|
|
||||||
page.footer.Pane.State("site", parseInt(res.latitude*10000)+","+parseInt(res.longitude*10000))
|
|
||||||
}})
|
|
||||||
})
|
|
||||||
wx.config({
|
|
||||||
appId: msg.appid[0],
|
|
||||||
nonceStr: msg.nonce[0],
|
|
||||||
timestamp: msg.timestamp[0],
|
|
||||||
signature: msg.signature[0],
|
|
||||||
jsApiList: [
|
|
||||||
"scanQRCode",
|
|
||||||
"chooseImage",
|
|
||||||
"closeWindow",
|
|
||||||
"openAddress",
|
|
||||||
"getNetworkType",
|
|
||||||
"getLocation",
|
|
||||||
"openLocation",
|
|
||||||
]
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}): sessid? page.login.Pane.Run([], function(msg) {
|
|
||||||
msg.result && msg.result[0]? page.header.Pane.State("user", msg.nickname[0])
|
msg.result && msg.result[0]? page.header.Pane.State("user", msg.nickname[0])
|
||||||
:page.login.Pane.Dialog(1, 1)
|
:page.login.Pane.Dialog(1, 1)
|
||||||
}): page.login.Pane.Dialog(1, 1)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 微信接口
|
||||||
|
kit.device.isWeiXin && page.login.Pane.Run(["weixin"], function(msg) {
|
||||||
|
msg.appid[0] && page.Include(["https://res.wx.qq.com/open/js/jweixin-1.4.0.js"], function(event) {
|
||||||
|
wx.error(function(res){})
|
||||||
|
wx.ready(function(){
|
||||||
|
page.scanQRCode = function(cb) {
|
||||||
|
|
||||||
|
}
|
||||||
|
page.getLocation = function(cb) {
|
||||||
|
wx.getLocation({success: cb})
|
||||||
|
}
|
||||||
|
page.openLocation = function(latitude, longitude, name) {
|
||||||
|
wx.openLocation({latitude: parseFloat(latitude), longitude: parseFloat(longitude), name:name||"here"})
|
||||||
|
}
|
||||||
|
}), wx.config({jsApiList: ["closeWindow", "scanQRCode", "getLocation", "openLocation"],
|
||||||
|
appId: msg.appid[0], nonceStr: msg.nonce[0], timestamp: msg.timestamp[0], signature: msg.signature[0]})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 事件回调
|
||||||
window.onresize = function(event) {
|
window.onresize = function(event) {
|
||||||
page.onlayout && page.onlayout(event)
|
page.onlayout && page.onlayout(event)
|
||||||
|
|
||||||
}, document.body.onkeydown = function(event) {
|
}, document.body.onkeydown = function(event) {
|
||||||
if (page.localMap && page.localMap(event)) {return}
|
if (page.localMap && page.localMap(event)) {return}
|
||||||
page.oncontrol && page.oncontrol(event, document.body, "control")
|
page.oncontrol && page.oncontrol(event, document.body, "control")
|
||||||
|
|
||||||
if (kit.isWindows && event.ctrlKey) {
|
|
||||||
// event.stopPropagation()
|
|
||||||
// event.preventDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
}, document.body.onkeyup = function(event) {
|
}, document.body.onkeyup = function(event) {
|
||||||
if (kit.isWindows && event.ctrlKey) {
|
|
||||||
// event.stopPropagation()
|
|
||||||
// event.preventDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
}, document.body.oncontextmenu = function(event) {
|
}, document.body.oncontextmenu = function(event) {
|
||||||
event.stopPropagation()
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
}, document.body.onmousewheel = function(event) {
|
}, document.body.onmousewheel = function(event) {
|
||||||
|
|
||||||
}, document.body.onmousedown = function(event) {
|
}, document.body.onmousedown = function(event) {
|
||||||
|
|
||||||
}, document.body.onmouseup = function(event) {
|
}, document.body.onmouseup = function(event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ontoast: function(text, title, duration) {
|
ontoast: function(text, title, duration) {
|
||||||
@ -261,8 +227,7 @@ function Page(page) {
|
|||||||
}
|
}
|
||||||
ticker()
|
ticker()
|
||||||
}, 10): setTimeout(function(){toast.style.display = "none"}, args.duration||3000)
|
}, 10): setTimeout(function(){toast.style.display = "none"}, args.duration||3000)
|
||||||
page.toast = toast
|
return page.toast = toast
|
||||||
return true
|
|
||||||
},
|
},
|
||||||
oninput: function(event, local) {
|
oninput: function(event, local) {
|
||||||
var target = event.target
|
var target = event.target
|
||||||
@ -440,11 +405,8 @@ function Page(page) {
|
|||||||
},
|
},
|
||||||
WSS: function(cb, onerror, onclose) {
|
WSS: function(cb, onerror, onclose) {
|
||||||
return page.socket || (page.socket = ctx.WSS(cb || (function(m) {
|
return page.socket || (page.socket = ctx.WSS(cb || (function(m) {
|
||||||
|
|
||||||
if (m.detail) {
|
if (m.detail) {
|
||||||
page.action.Pane.Core(event, m, ["_cmd", m.detail], function(msg) {
|
page.action.Pane.Core(event, m, ["_cmd", m.detail], m.reply)
|
||||||
m.reply(msg)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
page.ontoast(m.result.join(""))
|
page.ontoast(m.result.join(""))
|
||||||
}
|
}
|
||||||
@ -566,6 +528,7 @@ function Page(page) {
|
|||||||
},
|
},
|
||||||
Pane: Pane,
|
Pane: Pane,
|
||||||
})
|
})
|
||||||
|
page.which = page.Sync("layout")
|
||||||
return window.onload = page.onload, page
|
return window.onload = page.onload, page
|
||||||
}
|
}
|
||||||
function Pane(page, field) {
|
function Pane(page, field) {
|
||||||
@ -756,6 +719,11 @@ function Plugin(page, pane, field, runs) {
|
|||||||
}
|
}
|
||||||
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
||||||
})(run, field, option, output)||{}, {
|
})(run, field, option, output)||{}, {
|
||||||
|
Inputs: {},
|
||||||
|
Appends: function() {
|
||||||
|
var name = "args"+kit.Selector(option, "input.args.temp").length
|
||||||
|
plugin.Append({type: "text", name: name, className: "args temp"}).focus()
|
||||||
|
},
|
||||||
Append: function(item, name, value) {
|
Append: function(item, name, value) {
|
||||||
kit.Item(plugin.onaction, function(k, cb) {
|
kit.Item(plugin.onaction, function(k, cb) {
|
||||||
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
|
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
|
||||||
@ -768,8 +736,8 @@ function Plugin(page, pane, field, runs) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
(item.title || item.name) && (item.title = item.title || item.name)
|
!item.title && item.name && (item.title = item.name)
|
||||||
item.title && (item.placeholder = item.title)
|
!item.placeholder && item.title && (item.placeholder = item.title)
|
||||||
|
|
||||||
name = item.name || "input"
|
name = item.name || "input"
|
||||||
var input = {type: "input", name: name, data: item}
|
var input = {type: "input", name: name, data: item}
|
||||||
@ -810,6 +778,8 @@ function Plugin(page, pane, field, runs) {
|
|||||||
var td = output.querySelector("td")
|
var td = output.querySelector("td")
|
||||||
td && td.click()
|
td && td.click()
|
||||||
})
|
})
|
||||||
|
item.which = plugin.Sync(item.name)
|
||||||
|
plugin.Inputs[item.name] = ui[name]
|
||||||
return action.target
|
return action.target
|
||||||
},
|
},
|
||||||
Remove: function() {
|
Remove: function() {
|
||||||
@ -824,6 +794,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
page.plugin && (kit.classList.del(page.plugin, "select"))
|
page.plugin && (kit.classList.del(page.plugin, "select"))
|
||||||
page.plugin = field, kit.classList.add(field, "select")
|
page.plugin = field, kit.classList.add(field, "select")
|
||||||
!silent && (option.querySelectorAll("input")[1].focus())
|
!silent && (option.querySelectorAll("input")[1].focus())
|
||||||
|
name && pane.which.set(name)
|
||||||
},
|
},
|
||||||
Reveal: function(msg) {
|
Reveal: function(msg) {
|
||||||
return msg.append && msg.append[0]? ["table", JSON.stringify(ctx.Tables(msg))]: ["code", msg.result? msg.result.join(""): ""]
|
return msg.append && msg.append[0]? ["table", JSON.stringify(ctx.Tables(msg))]: ["code", msg.result? msg.result.join(""): ""]
|
||||||
@ -839,7 +810,6 @@ function Plugin(page, pane, field, runs) {
|
|||||||
}).field.Plugin
|
}).field.Plugin
|
||||||
},
|
},
|
||||||
Last: function() {
|
Last: function() {
|
||||||
console.log(meta)
|
|
||||||
var list = history.pop()
|
var list = history.pop()
|
||||||
list? (list.target.value = list.value): inputs.map(function(item) {
|
list? (list.target.value = list.value): inputs.map(function(item) {
|
||||||
option[item.name].value = item.value
|
option[item.name].value = item.value
|
||||||
@ -951,7 +921,10 @@ function Plugin(page, pane, field, runs) {
|
|||||||
}).join("\n"), type = ".csv"
|
}).join("\n"), type = ".csv"
|
||||||
|
|
||||||
!text && (text = plugin.msg.result.join(""), type = ".txt")
|
!text && (text = plugin.msg.result.join(""), type = ".txt")
|
||||||
page.ontoast({text:'<a href="'+URL.createObjectURL(new Blob([text]))+'" target="_blank" download="'+name+type+'">'+name+type+'</a>', width: 200})
|
page.ontoast({text:'<a href="'+URL.createObjectURL(new Blob([text]))+'" target="_blank" download="'+name+type+'">'+name+type+'</a>', title: "下载中...", width: 200})
|
||||||
|
kit.Selector(page.toast, "a", function(item) {
|
||||||
|
item.click()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
show_after: function(msg) {},
|
show_after: function(msg) {},
|
||||||
upload: function(event) {
|
upload: function(event) {
|
||||||
@ -1017,15 +990,17 @@ function Plugin(page, pane, field, runs) {
|
|||||||
onaction: {
|
onaction: {
|
||||||
onfocus: function(event, action, type, name, item) {
|
onfocus: function(event, action, type, name, item) {
|
||||||
page.input = event.target, plugin.Select(true)
|
page.input = event.target, plugin.Select(true)
|
||||||
|
plugin.which.set(name)
|
||||||
},
|
},
|
||||||
onblur: function(event, action, type, name, item) {
|
onblur: function(event, action, type, name, item) {
|
||||||
|
item.which.set(action.target.value)
|
||||||
// page.input = undefined
|
// page.input = undefined
|
||||||
},
|
},
|
||||||
onclick: function(event, action, type, name, item) {
|
onclick: function(event, action, type, name, item) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "button":
|
case "button":
|
||||||
action[item.click]? action[item.click](event, item, option, field):
|
action[item.cb]? action[item.cb](event, item, option, field):
|
||||||
plugin[item.click]? plugin[item.click](event, item, option, field): plugin.Check()
|
plugin[item.cb]? plugin[item.cb](event, item, option, field): plugin.Check()
|
||||||
break
|
break
|
||||||
case "text":
|
case "text":
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
@ -1093,7 +1068,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
page.action.scrollTo(0, field.offsetTop)
|
page.action.scrollTo(0, field.offsetTop)
|
||||||
break
|
break
|
||||||
case "b":
|
case "b":
|
||||||
plugin.Append({className: "args temp", type: "text"}).focus()
|
plugin.Appends()
|
||||||
break
|
break
|
||||||
case "m":
|
case "m":
|
||||||
plugin.Clone().Select()
|
plugin.Clone().Select()
|
||||||
@ -1104,6 +1079,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
if (item.type != "textarea" && event.key == "Enter") {
|
if (item.type != "textarea" && event.key == "Enter") {
|
||||||
|
item.which.set(action.target.value)
|
||||||
history.push({target: action.target, value: action.target.value});
|
history.push({target: action.target, value: action.target.value});
|
||||||
plugin.Check(action.target)
|
plugin.Check(action.target)
|
||||||
}
|
}
|
||||||
@ -1111,6 +1087,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
},
|
},
|
||||||
exports: JSON.parse(meta.exports||'["",""]'),
|
exports: JSON.parse(meta.exports||'["",""]'),
|
||||||
})
|
})
|
||||||
|
plugin.which = plugin.Sync("input")
|
||||||
|
|
||||||
inputs.map(function(item) {plugin.Append(item)})
|
inputs.map(function(item) {plugin.Append(item)})
|
||||||
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||||
|
@ -19,18 +19,7 @@ kit = toolkit = {__proto__: document,
|
|||||||
reload: function() {
|
reload: function() {
|
||||||
location.reload()
|
location.reload()
|
||||||
},
|
},
|
||||||
// 操作日志
|
// 日志调试
|
||||||
Log: function() {
|
|
||||||
var args = []
|
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
|
||||||
args.push(arguments[i])
|
|
||||||
}
|
|
||||||
console.log(arguments.length == 1? args[0]: args)
|
|
||||||
return args
|
|
||||||
},
|
|
||||||
Delay: function(time, cb) {
|
|
||||||
return setTimeout(cb, time)
|
|
||||||
},
|
|
||||||
History: {dir: [], pod: [], ctx: [], cmd: [], txt: [], key: [], lay: [],
|
History: {dir: [], pod: [], ctx: [], cmd: [], txt: [], key: [], lay: [],
|
||||||
add: function(type, data) {
|
add: function(type, data) {
|
||||||
var list = this[type] || []
|
var list = this[type] || []
|
||||||
@ -44,6 +33,26 @@ kit = toolkit = {__proto__: document,
|
|||||||
return index == undefined? this[type]: this[type][(index+len)%len]
|
return index == undefined? this[type]: this[type][(index+len)%len]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Debug: function(key) {
|
||||||
|
if (kit.debug[key]) {debugger}
|
||||||
|
}, debug: {"why": true},
|
||||||
|
Log: function(type, arg) {
|
||||||
|
var args = [kit.time()]
|
||||||
|
if (arg == undefined) {
|
||||||
|
args = args.concat(kit.Trans(type))
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
args.push(arguments[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
!kit.hide[args[1]] && console.log(args)
|
||||||
|
kit.Debug(args[1])
|
||||||
|
return args.slice(1)
|
||||||
|
}, hide: {"wss": false},
|
||||||
|
Delay: function(time, cb) {
|
||||||
|
return setTimeout(cb, time)
|
||||||
|
},
|
||||||
|
|
||||||
// HTML节点操作
|
// HTML节点操作
|
||||||
classList: {
|
classList: {
|
||||||
@ -676,6 +685,38 @@ kit = toolkit = {__proto__: document,
|
|||||||
Format: function(objs) {
|
Format: function(objs) {
|
||||||
return JSON.stringify(objs)
|
return JSON.stringify(objs)
|
||||||
},
|
},
|
||||||
|
Trans: function(arg) {
|
||||||
|
var res = []
|
||||||
|
if (arg != undefined && arg != null) {
|
||||||
|
switch (typeof arg) {
|
||||||
|
case "string":
|
||||||
|
res.push(arg)
|
||||||
|
break
|
||||||
|
case "object":
|
||||||
|
if (arg.length > 0) {
|
||||||
|
for (var i = 0; i < arg.length; i++) {
|
||||||
|
res.push(arg[i])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var k in arg) {
|
||||||
|
res.push(k)
|
||||||
|
res.push(arg[k])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
res.push(arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i = res.length - 1; i > -1; i--) {
|
||||||
|
if (res[i] == undefined) {
|
||||||
|
res.pop()
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
time: function(t, fmt) {
|
time: function(t, fmt) {
|
||||||
var now = t? new Date(t): new Date()
|
var now = t? new Date(t): new Date()
|
||||||
fmt = fmt || "%y-%m-%d %H:%M:%S"
|
fmt = fmt || "%y-%m-%d %H:%M:%S"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user