forked from x/volcanos
opt css
This commit is contained in:
parent
3865cbb3b9
commit
73d4c76f1c
508
lib/base.js
508
lib/base.js
@ -1,264 +1,264 @@
|
|||||||
Volcanos("base", {help: "数据类型",
|
Volcanos("base", {help: "数据类型",
|
||||||
Int: function(val, def) {
|
Int: function(val, def) {
|
||||||
return parseInt(val)||def||0
|
return parseInt(val)||def||0
|
||||||
},
|
},
|
||||||
Obj: function(val, def) {
|
Obj: function(val, def) {
|
||||||
try {
|
try {
|
||||||
val = typeof val == lang.STRING && val != ""? JSON.parse(val): val
|
val = typeof val == lang.STRING && val != ""? JSON.parse(val): val
|
||||||
if (val && val.length == 0 && def && def.length > 0) { return def }
|
if (val && val.length == 0 && def && def.length > 0) { return def }
|
||||||
return val||def
|
return val||def
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [val]
|
return [val]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Copy: function(to, from) {
|
Copy: function(to, from) {
|
||||||
if (arguments.length == 2) {
|
if (arguments.length == 2) {
|
||||||
for (var k in from) { to[k] = from[k] }
|
for (var k in from) { to[k] = from[k] }
|
||||||
return to
|
return to
|
||||||
}
|
}
|
||||||
for (var i = 2; i < arguments.length; i++) {
|
for (var i = 2; i < arguments.length; i++) {
|
||||||
var k = arguments[i]; to[k] = from[k]
|
var k = arguments[i]; to[k] = from[k]
|
||||||
}
|
}
|
||||||
return to
|
return to
|
||||||
},
|
},
|
||||||
Eq: function(to, from) { var call = arguments.callee
|
Eq: function(to, from) { var call = arguments.callee
|
||||||
if (typeof to != typeof from) { return false }
|
if (typeof to != typeof from) { return false }
|
||||||
|
|
||||||
if (typeof to == lang.OBJECT) {
|
if (typeof to == lang.OBJECT) {
|
||||||
if (to.length != from.length) { return false }
|
if (to.length != from.length) { return false }
|
||||||
for (var i = 0; i < to.length; i++) {
|
for (var i = 0; i < to.length; i++) {
|
||||||
if (!call(to[i], from[i])) { return false }
|
if (!call(to[i], from[i])) { return false }
|
||||||
}
|
}
|
||||||
for (var k in to) {
|
for (var k in to) {
|
||||||
if (!call(to[k], from[k])) { return false }
|
if (!call(to[k], from[k])) { return false }
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return to === from
|
return to === from
|
||||||
},
|
},
|
||||||
|
|
||||||
Ext: function(path) {
|
Ext: function(path) {
|
||||||
return (path.split(ice.PS).pop().split(ice.PT).pop()).toLowerCase()
|
return (path.split(ice.PS).pop().split(ice.PT).pop()).toLowerCase()
|
||||||
},
|
},
|
||||||
Path: function(path) { var res = ""
|
Path: function(path) { var res = ""
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
res += (arguments[i][0]==ice.PS || res=="" || res[res.length-1]==ice.PS? "": ice.PS) + arguments[i].trim()
|
res += (arguments[i][0]==ice.PS || res=="" || res[res.length-1]==ice.PS? "": ice.PS) + arguments[i].trim()
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
Args: function(obj) { var res = []
|
Args: function(obj) { var res = []
|
||||||
for (var k in obj) {
|
for (var k in obj) {
|
||||||
res.push(encodeURIComponent(k)+"="+encodeURIComponent(obj[k]))
|
res.push(encodeURIComponent(k)+"="+encodeURIComponent(obj[k]))
|
||||||
}
|
}
|
||||||
return res.join("&")
|
return res.join("&")
|
||||||
},
|
},
|
||||||
MergeURL: function(url) {
|
MergeURL: function(url) {
|
||||||
var args = {}; (url.split("?")[1]||"").split("&").forEach(function(item) { if (!item) { return }
|
var args = {}; (url.split("?")[1]||"").split("&").forEach(function(item) { if (!item) { return }
|
||||||
var ls = item.split("="); args[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
var ls = item.split("="); args[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
||||||
})
|
})
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
switch (typeof arguments[i]) {
|
switch (typeof arguments[i]) {
|
||||||
case lang.STRING:
|
case lang.STRING:
|
||||||
args[arguments[i]] = arguments[i+1], i++
|
args[arguments[i]] = arguments[i+1], i++
|
||||||
break
|
break
|
||||||
case lang.OBJECT:
|
case lang.OBJECT:
|
||||||
if (arguments[i].length > 0) {
|
if (arguments[i].length > 0) {
|
||||||
for (var j = 0; j < arguments[i].length; j += 2) {
|
for (var j = 0; j < arguments[i].length; j += 2) {
|
||||||
args[arguments[i][j]] = arguments[i][j]
|
args[arguments[i][j]] = arguments[i][j]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var k in arguments[i]) {
|
for (var k in arguments[i]) {
|
||||||
args[k] = arguments[i][k]
|
args[k] = arguments[i][k]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var list = []; for (var k in args) {
|
var list = []; for (var k in args) {
|
||||||
list.push(encodeURIComponent(k)+"="+encodeURIComponent(args[k]))
|
list.push(encodeURIComponent(k)+"="+encodeURIComponent(args[k]))
|
||||||
}
|
}
|
||||||
return url.split("?")[0]+(list.length>0? "?"+list.join("&"): "")
|
return url.split("?")[0]+(list.length>0? "?"+list.join("&"): "")
|
||||||
},
|
},
|
||||||
ParseURL: function(url) { var res = {link: url}
|
ParseURL: function(url) { var res = {link: url}
|
||||||
var list = url.split("?"); res["origin"] = list[0]
|
var list = url.split("?"); res["origin"] = list[0]
|
||||||
list[1] && list[1].split("&").forEach(function(item) {
|
list[1] && list[1].split("&").forEach(function(item) {
|
||||||
var ls = item.split("="); res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
var ls = item.split("="); res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
ParseJSON: function(str) { var res
|
ParseJSON: function(str) { var res
|
||||||
if (typeof str == lang.OBJECT) { return str }
|
if (typeof str == lang.OBJECT) { return str }
|
||||||
if (str.indexOf("http") == 0) { var ls = str.split("?")
|
if (str.indexOf("http") == 0) { var ls = str.split("?")
|
||||||
res = {type: mdb.LINK, name: "", text: str}
|
res = {type: mdb.LINK, name: "", text: str}
|
||||||
res.name = ls[0].split("://").pop().split(ice.PS)[0]
|
res.name = ls[0].split("://").pop().split(ice.PS)[0]
|
||||||
ls[1] && ls[1].split("&").forEach(function(item) { var ls = item.split("=")
|
ls[1] && ls[1].split("&").forEach(function(item) { var ls = item.split("=")
|
||||||
res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
try { res = JSON.parse(str)
|
try { res = JSON.parse(str)
|
||||||
res.text = res.text||str
|
res.text = res.text||str
|
||||||
res.type = res.type||nfs.JSON
|
res.type = res.type||nfs.JSON
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res = {type: mdb.TEXT, text: str}
|
res = {type: mdb.TEXT, text: str}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
ParseSize: function(size) { size = size.toLowerCase()
|
ParseSize: function(size) { size = size.toLowerCase()
|
||||||
if (size.endsWith("tb") || size.endsWith("t")) {
|
if (size.endsWith("tb") || size.endsWith("t")) {
|
||||||
return parseInt(size) * 1024 * 1024 * 1024 * 1024
|
return parseInt(size) * 1024 * 1024 * 1024 * 1024
|
||||||
}
|
}
|
||||||
if (size.endsWith("gb") || size.endsWith("g")) {
|
if (size.endsWith("gb") || size.endsWith("g")) {
|
||||||
return parseInt(size) * 1024 * 1024 * 1024
|
return parseInt(size) * 1024 * 1024 * 1024
|
||||||
}
|
}
|
||||||
if (size.endsWith("mb") || size.endsWith("m")) {
|
if (size.endsWith("mb") || size.endsWith("m")) {
|
||||||
return parseInt(size) * 1024 * 1024
|
return parseInt(size) * 1024 * 1024
|
||||||
}
|
}
|
||||||
if (size.endsWith("kb") || size.endsWith("k")) {
|
if (size.endsWith("kb") || size.endsWith("k")) {
|
||||||
return parseInt(size) * 1024
|
return parseInt(size) * 1024
|
||||||
}
|
}
|
||||||
return parseInt(size)
|
return parseInt(size)
|
||||||
},
|
},
|
||||||
|
|
||||||
Size: function(size) { size = parseInt(size)
|
Size: function(size) { size = parseInt(size)
|
||||||
if (size > 1000000000) {
|
if (size > 1000000000) {
|
||||||
return parseInt(size/1000000000) + ice.PT + parseInt(size/10000000%100) + "G"
|
return parseInt(size/1000000000) + ice.PT + parseInt(size/10000000%100) + "G"
|
||||||
}
|
}
|
||||||
if (size > 1000000) {
|
if (size > 1000000) {
|
||||||
return parseInt(size/1000000) + ice.PT + parseInt(size/10000%100) + "M"
|
return parseInt(size/1000000) + ice.PT + parseInt(size/10000%100) + "M"
|
||||||
}
|
}
|
||||||
if (size > 1000) {
|
if (size > 1000) {
|
||||||
return parseInt(size/1000) + ice.PT + parseInt(size/10%100) + "K"
|
return parseInt(size/1000) + ice.PT + parseInt(size/10%100) + "K"
|
||||||
}
|
}
|
||||||
return size + "B"
|
return size + "B"
|
||||||
},
|
},
|
||||||
Number: function(d, n) { var result = []
|
Number: function(d, n) { var result = []
|
||||||
while (d > 0) { result.push(d%10); d = parseInt(d/10); n-- }
|
while (d > 0) { result.push(d%10); d = parseInt(d/10); n-- }
|
||||||
while (n > 0) { result.push("0"); n-- }
|
while (n > 0) { result.push("0"); n-- }
|
||||||
return result.reverse(), result.join("")
|
return result.reverse(), result.join("")
|
||||||
},
|
},
|
||||||
Format: function(obj) {
|
Format: function(obj) {
|
||||||
return JSON.stringify(obj)
|
return JSON.stringify(obj)
|
||||||
},
|
},
|
||||||
Simple: function() { var res = []
|
Simple: function() { var res = []
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
var arg = arguments[i]; switch (typeof arguments[i]) {
|
var arg = arguments[i]; switch (typeof arguments[i]) {
|
||||||
case lang.NUMBER: res.push(arg); break
|
case lang.NUMBER: res.push(arg); break
|
||||||
case lang.STRING: res.push(arg); break
|
case lang.STRING: res.push(arg); break
|
||||||
case lang.OBJECT:
|
case lang.OBJECT:
|
||||||
if (arg.length > 0) { res = res.concat(arg); break }
|
if (arg.length > 0) { res = res.concat(arg); break }
|
||||||
for (var k in arg) { k && arg[k] && res.push(k, arg[k]) }
|
for (var k in arg) { k && arg[k] && res.push(k, arg[k]) }
|
||||||
break
|
break
|
||||||
default: res.push(arg);
|
default: res.push(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
AddUniq: function(list, value) { list = list||[]
|
AddUniq: function(list, value) { list = list||[]
|
||||||
return list.indexOf(value) == -1 && list.push(value), list
|
return list.indexOf(value) == -1 && list.push(value), list
|
||||||
},
|
},
|
||||||
|
|
||||||
Date: function(time) { var now = new Date()
|
Date: function(time) { var now = new Date()
|
||||||
if (typeof time == lang.STRING && time != "") { var ls = time.split(ice.SP)
|
if (typeof time == lang.STRING && time != "") { var ls = time.split(ice.SP)
|
||||||
var vs = ls[0].split("-")
|
var vs = ls[0].split("-")
|
||||||
now.setFullYear(parseInt(vs[0]))
|
now.setFullYear(parseInt(vs[0]))
|
||||||
now.setMonth(parseInt(vs[1])-1)
|
now.setMonth(parseInt(vs[1])-1)
|
||||||
now.setDate(parseInt(vs[2]))
|
now.setDate(parseInt(vs[2]))
|
||||||
|
|
||||||
var vs = ls[1].split(":")
|
var vs = ls[1].split(":")
|
||||||
now.setHours(parseInt(vs[0]))
|
now.setHours(parseInt(vs[0]))
|
||||||
now.setMinutes(parseInt(vs[1]))
|
now.setMinutes(parseInt(vs[1]))
|
||||||
now.setSeconds(parseInt(vs[2]))
|
now.setSeconds(parseInt(vs[2]))
|
||||||
} else if (time) {
|
} else if (time) {
|
||||||
now = time
|
now = time
|
||||||
}
|
}
|
||||||
return now
|
return now
|
||||||
},
|
},
|
||||||
Time: function(time, fmt) { var now = this.Date(time)
|
Time: function(time, fmt) { var now = this.Date(time)
|
||||||
var list = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
var list = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
||||||
fmt = fmt||"%H:%M:%S"
|
fmt = fmt||"%H:%M:%S"
|
||||||
fmt = fmt.replace("%y", now.getFullYear())
|
fmt = fmt.replace("%y", now.getFullYear())
|
||||||
fmt = fmt.replace("%m", this.Number(now.getMonth()+1, 2))
|
fmt = fmt.replace("%m", this.Number(now.getMonth()+1, 2))
|
||||||
fmt = fmt.replace("%d", this.Number(now.getDate(), 2))
|
fmt = fmt.replace("%d", this.Number(now.getDate(), 2))
|
||||||
fmt = fmt.replace("%w", list[now.getDay()])
|
fmt = fmt.replace("%w", list[now.getDay()])
|
||||||
fmt = fmt.replace("%H", this.Number(now.getHours(), 2))
|
fmt = fmt.replace("%H", this.Number(now.getHours(), 2))
|
||||||
fmt = fmt.replace("%M", this.Number(now.getMinutes(), 2))
|
fmt = fmt.replace("%M", this.Number(now.getMinutes(), 2))
|
||||||
fmt = fmt.replace("%S", this.Number(now.getSeconds(), 2))
|
fmt = fmt.replace("%S", this.Number(now.getSeconds(), 2))
|
||||||
return fmt
|
return fmt
|
||||||
},
|
},
|
||||||
TimeAdd: function(t, d) {
|
TimeAdd: function(t, d) {
|
||||||
return new Date(t - t%(24*3600*1000) - 8*3600*1000 + d*24*3600*1000)
|
return new Date(t - t%(24*3600*1000) - 8*3600*1000 + d*24*3600*1000)
|
||||||
},
|
},
|
||||||
Duration: function(n) { var res = "", h = 0
|
Duration: function(n) { var res = "", h = 0
|
||||||
h = parseInt(n/3600000/24), h > 0 && (res += h+"d"), n = n % (3600000*24)
|
h = parseInt(n/3600000/24), h > 0 && (res += h+"d"), n = n % (3600000*24)
|
||||||
h = parseInt(n/3600000), h > 0 && (res += h+"h"), n = n % 3600000
|
h = parseInt(n/3600000), h > 0 && (res += h+"h"), n = n % 3600000
|
||||||
h = parseInt(n/60000), h > 0 && (res += h+"m"), n = n % 60000
|
h = parseInt(n/60000), h > 0 && (res += h+"m"), n = n % 60000
|
||||||
h = parseInt(n/1000), h > 0 && (res += h), n = n % 1000
|
h = parseInt(n/1000), h > 0 && (res += h), n = n % 1000
|
||||||
return res + (n > 0? ice.PT+parseInt(n/10): "") + "s"
|
return res + (n > 0? ice.PT+parseInt(n/10): "") + "s"
|
||||||
},
|
},
|
||||||
|
|
||||||
getValid: function() {
|
getValid: function() {
|
||||||
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
||||||
if (typeof v == lang.OBJECT) {
|
if (typeof v == lang.OBJECT) {
|
||||||
if (v == null) { continue }
|
if (v == null) { continue }
|
||||||
for (var k in v) { return v }
|
for (var k in v) { return v }
|
||||||
if (v.length > 0) { return v }
|
if (v.length > 0) { return v }
|
||||||
} else if (typeof v == lang.STRING && v) {
|
} else if (typeof v == lang.STRING && v) {
|
||||||
return v
|
return v
|
||||||
} else if (v == undefined) {
|
} else if (v == undefined) {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isNumber: function(val) { return typeof val == lang.NUMBER },
|
isNumber: function(val) { return typeof val == lang.NUMBER },
|
||||||
isString: function(val) { return typeof val == lang.STRING },
|
isString: function(val) { return typeof val == lang.STRING },
|
||||||
isObject: function(val) { return typeof val == lang.OBJECT },
|
isObject: function(val) { return typeof val == lang.OBJECT },
|
||||||
isArray: function(val) { return typeof val == lang.OBJECT && val.length != undefined },
|
isArray: function(val) { return typeof val == lang.OBJECT && val.length != undefined },
|
||||||
isFunc: function(val) { return typeof val == lang.FUNCTION },
|
isFunc: function(val) { return typeof val == lang.FUNCTION },
|
||||||
isFunction: function(val) { return typeof val == lang.FUNCTION },
|
isFunction: function(val) { return typeof val == lang.FUNCTION },
|
||||||
isCallback: function(key, value) { return key.indexOf("on") == 0 && typeof value == lang.FUNCTION },
|
isCallback: function(key, value) { return key.indexOf("on") == 0 && typeof value == lang.FUNCTION },
|
||||||
isUndefined: function(val) { return val == undefined },
|
isUndefined: function(val) { return val == undefined },
|
||||||
isNull: function(val) { return val == null },
|
isNull: function(val) { return val == null },
|
||||||
replaceAll: function(str) {
|
replaceAll: function(str) {
|
||||||
for (var i = 1; i < arguments.length; i += 2) {
|
for (var i = 1; i < arguments.length; i += 2) {
|
||||||
str = str.replaceAll(arguments[i], arguments[i+1])
|
str = str.replaceAll(arguments[i], arguments[i+1])
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
},
|
},
|
||||||
|
|
||||||
isNight: function() { var now = new Date()
|
isNight: function() { var now = new Date()
|
||||||
return now.getHours() < 7 || now.getHours() > 17
|
return now.getHours() < 7 || now.getHours() > 17
|
||||||
},
|
},
|
||||||
beginWith: function(str, begin) {
|
beginWith: function(str, begin) {
|
||||||
return str.trim().indexOf(begin) == 0
|
return str.trim().indexOf(begin) == 0
|
||||||
},
|
},
|
||||||
endWith: function(str, end) {
|
endWith: function(str, end) {
|
||||||
return str.lastIndexOf(end) + end.length == str.length
|
return str.lastIndexOf(end) + end.length == str.length
|
||||||
},
|
},
|
||||||
trim: function(args) { if (this.isString(args)) { return args.trim() }
|
trim: function(args) { if (this.isString(args)) { return args.trim() }
|
||||||
if (this.isArray(args)) { for (var i = args.length-1; i >= 0; i--) { if (!args[i]) { args.pop() } else { break } } }
|
if (this.isArray(args)) { for (var i = args.length-1; i >= 0; i--) { if (!args[i]) { args.pop() } else { break } } }
|
||||||
return args
|
return args
|
||||||
},
|
},
|
||||||
trimPrefix: function(str, pre) {
|
trimPrefix: function(str, pre) {
|
||||||
if (str.indexOf(pre) == -1) {
|
if (str.indexOf(pre) == -1) {
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
return str.slice(pre.length)
|
return str.slice(pre.length)
|
||||||
},
|
},
|
||||||
trimSuffix: function(str, end) {
|
trimSuffix: function(str, end) {
|
||||||
if (str.indexOf(end) == -1) {
|
if (str.indexOf(end) == -1) {
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
return str.slice(0, str.indexOf(end))
|
return str.slice(0, str.indexOf(end))
|
||||||
},
|
},
|
||||||
join: function(list, sp) { return (list||[]).join(sp||ice.SP) },
|
join: function(list, sp) { return (list||[]).join(sp||ice.SP) },
|
||||||
joins: function(list, inner, outer) {
|
joins: function(list, inner, outer) {
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
list[i] = typeof list[i] == lang.STRING? list[i]: list[i].join(inner||ice.FS)
|
list[i] = typeof list[i] == lang.STRING? list[i]: list[i].join(inner||ice.FS)
|
||||||
}
|
}
|
||||||
return list.join(outer||ice.SP)
|
return list.join(outer||ice.SP)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
334
lib/core.js
334
lib/core.js
@ -1,191 +1,191 @@
|
|||||||
Volcanos("core", {help: "数据结构",
|
Volcanos("core", {help: "数据结构",
|
||||||
Keys: shy("连接器", function() { var list = []
|
Keys: shy("连接器", function() { var list = []
|
||||||
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
||||||
switch (typeof v) {
|
switch (typeof v) {
|
||||||
case lang.OBJECT:
|
case lang.OBJECT:
|
||||||
for (var j = 0; j < v.length; j++) {
|
for (var j = 0; j < v.length; j++) {
|
||||||
list.push(v[j])
|
list.push(v[j])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case lang.FUNCTION: v = v()
|
case lang.FUNCTION: v = v()
|
||||||
default: v && list.push(v+"")
|
default: v && list.push(v+"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list.join(ice.PT)
|
return list.join(ice.PT)
|
||||||
}),
|
}),
|
||||||
Value: shy("存储器", function(data, key, value) {
|
Value: shy("存储器", function(data, key, value) {
|
||||||
if (data == undefined) { return }
|
if (data == undefined) { return }
|
||||||
if (key == undefined) { return data }
|
if (key == undefined) { return data }
|
||||||
|
|
||||||
if (typeof key == lang.OBJECT) { for (var k in key) {
|
if (typeof key == lang.OBJECT) { for (var k in key) {
|
||||||
arguments.callee.call(this, data, k, key[k])
|
arguments.callee.call(this, data, k, key[k])
|
||||||
}; return data }
|
}; return data }
|
||||||
|
|
||||||
if (value != undefined) { data[key] = value }
|
if (value != undefined) { data[key] = value }
|
||||||
if (data[key] != undefined) { return data[key] }
|
if (data[key] != undefined) { return data[key] }
|
||||||
|
|
||||||
var p = data, ls = key.split(ice.PT); while (p && ls.length > 0) {
|
var p = data, ls = key.split(ice.PT); while (p && ls.length > 0) {
|
||||||
if (ls[0] == "-1") { ls[0] = p.length-1 }
|
if (ls[0] == "-1") { ls[0] = p.length-1 }
|
||||||
p = p[ls[0]], ls = ls.slice(1)
|
p = p[ls[0]], ls = ls.slice(1)
|
||||||
}; return p
|
}; return p
|
||||||
}),
|
}),
|
||||||
Split: shy("分词器", function(str) { if (!str || !str.length) { return [] }
|
Split: shy("分词器", function(str) { if (!str || !str.length) { return [] }
|
||||||
var opt = {detail: false}, arg = []; for (var i = 1; i < arguments.length; i++) {
|
var opt = {detail: false}, arg = []; for (var i = 1; i < arguments.length; i++) {
|
||||||
typeof arguments[i] == lang.OBJECT? opt = arguments[i]: arg.push(arguments[i])
|
typeof arguments[i] == lang.OBJECT? opt = arguments[i]: arg.push(arguments[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字符定义
|
// 字符定义
|
||||||
function _list(str) { var res = {}; for (var i = 0; i < str.length; i++) { res[str[i]] = true }; return res }
|
function _list(str) { var res = {}; for (var i = 0; i < str.length; i++) { res[str[i]] = true }; return res }
|
||||||
var space = _list(arg[0]||"\t ,;\n") // 空白符
|
var space = _list(arg[0]||"\t ,;\n") // 空白符
|
||||||
var block = _list(arg[1]||"{[()]}") // 分隔符
|
var block = _list(arg[1]||"{[()]}") // 分隔符
|
||||||
var quote = _list(arg[2]||"'\"`") // 引用符
|
var quote = _list(arg[2]||"'\"`") // 引用符
|
||||||
var trans = _list(arg[3]||"\\") // 转义符
|
var trans = _list(arg[3]||"\\") // 转义符
|
||||||
|
|
||||||
var res = [], begin = 0; function push(obj) {
|
var res = [], begin = 0; function push(obj) {
|
||||||
obj && res.push(typeof obj == lang.STRING || opt.detail? obj: obj.text), begin = -1
|
obj && res.push(typeof obj == lang.STRING || opt.detail? obj: obj.text), begin = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开始分词
|
// 开始分词
|
||||||
for (var s = "", i = 0; i < str.length; i++) {
|
for (var s = "", i = 0; i < str.length; i++) {
|
||||||
if (space[str[i]]) { // 空白符
|
if (space[str[i]]) { // 空白符
|
||||||
if (s) { continue }
|
if (s) { continue }
|
||||||
begin > -1 && push(str.slice(begin, i))
|
begin > -1 && push(str.slice(begin, i))
|
||||||
opt.detail && push({type: "space", text: str.slice(i, i+1)})
|
opt.detail && push({type: "space", text: str.slice(i, i+1)})
|
||||||
|
|
||||||
} else if (block[str[i]]) { // 分隔符
|
} else if (block[str[i]]) { // 分隔符
|
||||||
if (s) { continue }
|
if (s) { continue }
|
||||||
begin > -1 && push(str.slice(begin, i))
|
begin > -1 && push(str.slice(begin, i))
|
||||||
push(str.slice(i, i+1))
|
push(str.slice(i, i+1))
|
||||||
|
|
||||||
} else if (quote[str[i]]) { // 引用符
|
} else if (quote[str[i]]) { // 引用符
|
||||||
if (s == "") {
|
if (s == "") {
|
||||||
s = str[i], begin = i+1
|
s = str[i], begin = i+1
|
||||||
} else if (s == str[i]) {
|
} else if (s == str[i]) {
|
||||||
push({type: lang.STRING, text: str.slice(begin, i), left: s, right: str[i]})
|
push({type: lang.STRING, text: str.slice(begin, i), left: s, right: str[i]})
|
||||||
s = "", begin = -1
|
s = "", begin = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (trans[str[i]]) { // 转义符
|
} else if (trans[str[i]]) { // 转义符
|
||||||
begin == -1 && (begin = i++)
|
begin == -1 && (begin = i++)
|
||||||
|
|
||||||
} else { // 普通符
|
} else { // 普通符
|
||||||
begin == -1 && (begin = i)
|
begin == -1 && (begin = i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 剩余字符
|
// 剩余字符
|
||||||
begin >= 0 && (s? push({type: lang.STRING, text: str.slice(begin), left: s, right: ""}): push(str.slice(begin)))
|
begin >= 0 && (s? push({type: lang.STRING, text: str.slice(begin), left: s, right: ""}): push(str.slice(begin)))
|
||||||
return res
|
return res
|
||||||
}),
|
}),
|
||||||
CallFunc: shy("调用器", function(func, args, mod) { args = args||{}
|
CallFunc: shy("调用器", function(func, args, mod) { args = args||{}
|
||||||
var can = args["can"]||args[0], msg = args["msg"]||args[1], cmds = args["cmds"]||[], event = args["event"]||{}
|
var can = args["can"]||args[0], msg = args["msg"]||args[1], cmds = args["cmds"]||[], event = args["event"]||{}
|
||||||
|
|
||||||
// 查找调用
|
// 查找调用
|
||||||
func = typeof func == lang.FUNCTION? func: typeof func == lang.STRING? this.Value(mod||can, func):
|
func = typeof func == lang.FUNCTION? func: typeof func == lang.STRING? this.Value(mod||can, func):
|
||||||
typeof func == lang.OBJECT && func.length > 0? this.Value(func[0], this.Keys(func.slice(1))): null
|
typeof func == lang.OBJECT && func.length > 0? this.Value(func[0], this.Keys(func.slice(1))): null
|
||||||
if (typeof func != lang.FUNCTION) { return }
|
if (typeof func != lang.FUNCTION) { return }
|
||||||
|
|
||||||
// 解析参数
|
// 解析参数
|
||||||
var list = [], echo = false, cb = args["cb"]
|
var list = [], echo = false, cb = args["cb"]
|
||||||
this.List(func.toString().split(")")[0].split("(")[1].split(ice.FS), function(item, index) { item = item.trim(); if (item == "") { return }
|
this.List(func.toString().split(")")[0].split("(")[1].split(ice.FS), function(item, index) { item = item.trim(); if (item == "") { return }
|
||||||
var arg = args[item] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) ||
|
var arg = args[item] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) ||
|
||||||
event&&!(event instanceof Event)&&event[item] || args[index] || cmds[index] || null
|
event&&!(event instanceof Event)&&event[item] || args[index] || cmds[index] || null
|
||||||
if (item == "cb") { echo = true }
|
if (item == "cb") { echo = true }
|
||||||
list.push(arg)
|
list.push(arg)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 执行调用
|
// 执行调用
|
||||||
var res = func.apply(mod||can, list)
|
var res = func.apply(mod||can, list)
|
||||||
if (!echo && typeof cb == lang.FUNCTION) { res && msg && msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) }
|
if (!echo && typeof cb == lang.FUNCTION) { res && msg && msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) }
|
||||||
return res
|
return res
|
||||||
}),
|
}),
|
||||||
|
|
||||||
List: shy("迭代器", function(list, cb, interval, cbs) {
|
List: shy("迭代器", function(list, cb, interval, cbs) {
|
||||||
if (typeof list == lang.STRING) { // 默认序列
|
if (typeof list == lang.STRING) { // 默认序列
|
||||||
list = [list]
|
list = [list]
|
||||||
} else if (typeof list == lang.NUMBER) { // 等差序列 [end cb interval]|[begin end interval]
|
} else if (typeof list == lang.NUMBER) { // 等差序列 [end cb interval]|[begin end interval]
|
||||||
var begin = 0, end = list, step = typeof interval == lang.NUMBER? interval: 1
|
var begin = 0, end = list, step = typeof interval == lang.NUMBER? interval: 1
|
||||||
if (typeof cb == lang.NUMBER) { begin = list, end = cb, cb = null }
|
if (typeof cb == lang.NUMBER) { begin = list, end = cb, cb = null }
|
||||||
list = []; for (var i = begin; i < end; i += step) { list.push(i) }
|
list = []; for (var i = begin; i < end; i += step) { list.push(i) }
|
||||||
}
|
}
|
||||||
|
|
||||||
list = list||[]
|
list = list||[]
|
||||||
|
|
||||||
if (interval > 0) { // 时间序列
|
if (interval > 0) { // 时间序列
|
||||||
function loop(i) { if (i >= list.length) { return typeof cbs == lang.FUNCTION && cbs(list) }
|
function loop(i) { if (i >= list.length) { return typeof cbs == lang.FUNCTION && cbs(list) }
|
||||||
cb(list[i], i, list), setTimeout(function() { loop(i+1) }, interval)
|
cb(list[i], i, list), setTimeout(function() { loop(i+1) }, interval)
|
||||||
}
|
}
|
||||||
typeof cb == lang.FUNCTION && list.length > 0 && setTimeout(function() { loop(0) }, interval/4)
|
typeof cb == lang.FUNCTION && list.length > 0 && setTimeout(function() { loop(0) }, interval/4)
|
||||||
} else { // 选择序列
|
} else { // 选择序列
|
||||||
var slice = [], res
|
var slice = [], res
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (var i = 0; i < list.length; i++) {
|
||||||
typeof cb == lang.FUNCTION? (res = cb(list[i], i, list)) != undefined && slice.push(res): slice.push(list[i])
|
typeof cb == lang.FUNCTION? (res = cb(list[i], i, list)) != undefined && slice.push(res): slice.push(list[i])
|
||||||
}; list = slice
|
}; list = slice
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}),
|
}),
|
||||||
Next: shy("迭代器", function(list, cb, cbs) {
|
Next: shy("迭代器", function(list, cb, cbs) {
|
||||||
switch (typeof list) {
|
switch (typeof list) {
|
||||||
case lang.OBJECT: if (list == null) { list = []; break }
|
case lang.OBJECT: if (list == null) { list = []; break }
|
||||||
if (list.length == undefined) { var ls = []; for (var k in list) { ls.push(k) } list = ls } break
|
if (list.length == undefined) { var ls = []; for (var k in list) { ls.push(k) } list = ls } break
|
||||||
default: if (list == undefined) { list = []; break }
|
default: if (list == undefined) { list = []; break }
|
||||||
list = [list]
|
list = [list]
|
||||||
}
|
}
|
||||||
|
|
||||||
function next(i) { i < list.length? typeof cb == lang.FUNCTION && cb(list[i], function() { next(i+1) }, i, list):
|
function next(i) { i < list.length? typeof cb == lang.FUNCTION && cb(list[i], function() { next(i+1) }, i, list):
|
||||||
typeof cbs == lang.FUNCTION && cbs(list) }
|
typeof cbs == lang.FUNCTION && cbs(list) }
|
||||||
return next(0), list
|
return next(0), list
|
||||||
}),
|
}),
|
||||||
Items: shy("迭代器", function(obj, cb) { var list = []
|
Items: shy("迭代器", function(obj, cb) { var list = []
|
||||||
for (var k in obj) {
|
for (var k in obj) {
|
||||||
list = list.concat(this.List(obj[k], function(v, i) {
|
list = list.concat(this.List(obj[k], function(v, i) {
|
||||||
return typeof cb == lang.FUNCTION && cb(v, i, k, obj)
|
return typeof cb == lang.FUNCTION && cb(v, i, k, obj)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}),
|
}),
|
||||||
Item: shy("迭代器", function(obj, cb) { var list = []
|
Item: shy("迭代器", function(obj, cb) { var list = []
|
||||||
for (var k in obj) {
|
for (var k in obj) {
|
||||||
var res = typeof cb == lang.FUNCTION? cb(k, obj[k]): k
|
var res = typeof cb == lang.FUNCTION? cb(k, obj[k]): k
|
||||||
res != undefined && list.push(res)
|
res != undefined && list.push(res)
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}),
|
}),
|
||||||
ItemCB: shy("迭代器", function(meta, cb, can, item) { var list = []
|
ItemCB: shy("迭代器", function(meta, cb, can, item) { var list = []
|
||||||
for (var k in meta) { (function(k) {
|
for (var k in meta) { (function(k) {
|
||||||
if (k.indexOf("on") == 0 && typeof meta[k] == lang.FUNCTION) {
|
if (k.indexOf("on") == 0 && typeof meta[k] == lang.FUNCTION) {
|
||||||
if (typeof cb == lang.FUNCTION) {
|
if (typeof cb == lang.FUNCTION) {
|
||||||
cb(k, meta[k])
|
cb(k, meta[k])
|
||||||
} else {
|
} else {
|
||||||
cb[k] = function(event) { meta[k](event, can, item) }
|
cb[k] = function(event) { meta[k](event, can, item) }
|
||||||
}
|
}
|
||||||
list.push(k)
|
list.push(k)
|
||||||
}
|
}
|
||||||
})(k) }
|
})(k) }
|
||||||
return list
|
return list
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Timer300ms: function(cb) { this.Timer(300, cb) },
|
Timer300ms: function(cb) { this.Timer(300, cb) },
|
||||||
Timer300: function(cb) { this.Timer(300, cb) },
|
Timer300: function(cb) { this.Timer(300, cb) },
|
||||||
Timer3s: function(cb) { this.Timer(3000, cb) },
|
Timer3s: function(cb) { this.Timer(3000, cb) },
|
||||||
Timer: shy("定时器, value, [1,2,3,4], {interval, length}", function(interval, cb, cbs) {
|
Timer: shy("定时器, value, [1,2,3,4], {interval, length}", function(interval, cb, cbs) {
|
||||||
var timer = {stop: false}; function loop(i) {
|
var timer = {stop: false}; function loop(i) {
|
||||||
timer.stop || i >= interval.length && interval.length >= 0 || cb(timer, interval.interval||interval[i], i, interval)?
|
timer.stop || i >= interval.length && interval.length >= 0 || cb(timer, interval.interval||interval[i], i, interval)?
|
||||||
typeof cbs == lang.FUNCTION && cbs(timer, interval): setTimeout(function() { loop(i+1) }, interval.interval||interval[i+1])
|
typeof cbs == lang.FUNCTION && cbs(timer, interval): setTimeout(function() { loop(i+1) }, interval.interval||interval[i+1])
|
||||||
}
|
}
|
||||||
|
|
||||||
interval = typeof interval == lang.OBJECT? interval: [interval]
|
interval = typeof interval == lang.OBJECT? interval: [interval]
|
||||||
if (interval.interval == 0) { cb(); return timer }
|
if (interval.interval == 0) { cb(); return timer }
|
||||||
|
|
||||||
typeof cb == lang.FUNCTION && setTimeout(function() { loop(0) }, interval.interval||interval[0])
|
typeof cb == lang.FUNCTION && setTimeout(function() { loop(0) }, interval.interval||interval[0])
|
||||||
return timer
|
return timer
|
||||||
}),
|
}),
|
||||||
Delay: shy("延时器", function(list, interval, cb, cbs) { list = list || []
|
Delay: shy("延时器", function(list, interval, cb, cbs) { list = list || []
|
||||||
list.push(cb); this.Timer(interval, function() {
|
list.push(cb); this.Timer(interval, function() {
|
||||||
var cb = list.pop(); list.length = 0
|
var cb = list.pop(); list.length = 0
|
||||||
typeof cb == lang.FUNCTION && cb()
|
typeof cb == lang.FUNCTION && cb()
|
||||||
}, cbs)
|
}, cbs)
|
||||||
return list
|
return list
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
540
lib/misc.js
540
lib/misc.js
@ -1,296 +1,296 @@
|
|||||||
Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg = {}
|
Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg = {}
|
||||||
var proto = {_event: event, _can: can,
|
var proto = {_event: event, _can: can,
|
||||||
RunAction: function(event, sub, cmds) { var msg = can.request(event)
|
RunAction: function(event, sub, cmds) { var msg = can.request(event)
|
||||||
if (msg.Option(ice.MSG_HANDLE) == ice.TRUE) { return }
|
if (msg.Option(ice.MSG_HANDLE) == ice.TRUE) { return }
|
||||||
if (cmds && cmds[0] == ctx.ACTION && sub && can.base.isFunc(sub.onaction[cmds[1]])) {
|
if (cmds && cmds[0] == ctx.ACTION && sub && can.base.isFunc(sub.onaction[cmds[1]])) {
|
||||||
return msg.Option(ice.MSG_HANDLE, ice.TRUE), can.core.CallFunc(sub.onaction[cmds[1]], {event: event, can: sub, msg: msg, button: cmds[1], cmd: cmds[1]}), true
|
return msg.Option(ice.MSG_HANDLE, ice.TRUE), can.core.CallFunc(sub.onaction[cmds[1]], {event: event, can: sub, msg: msg, button: cmds[1], cmd: cmds[1]}), true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
OptionStatus: function() { return msg.Option(ice.MSG_STATUS) },
|
OptionStatus: function() { return msg.Option(ice.MSG_STATUS) },
|
||||||
OptionProcess: function() { return msg.Option(ice.MSG_PROCESS) },
|
OptionProcess: function() { return msg.Option(ice.MSG_PROCESS) },
|
||||||
OptionOrSearch: function(key) { return can.misc.Search(can, key)||msg.Option(key) },
|
OptionOrSearch: function(key) { return can.misc.Search(can, key)||msg.Option(key) },
|
||||||
Option: function(key, val) {
|
Option: function(key, val) {
|
||||||
if (key == undefined) { return msg && msg.option || [] }
|
if (key == undefined) { return msg && msg.option || [] }
|
||||||
if (can.base.isObject(key)) { can.core.Item(key, msg.Option) }
|
if (can.base.isObject(key)) { can.core.Item(key, msg.Option) }
|
||||||
if (val == undefined) { return msg && msg[key] && msg[key][0] || "" }
|
if (val == undefined) { return msg && msg[key] && msg[key][0] || "" }
|
||||||
return msg.option = can.base.AddUniq(msg.option, key), msg[key] = can.core.List(arguments).slice(1), val
|
return msg.option = can.base.AddUniq(msg.option, key), msg[key] = can.core.List(arguments).slice(1), val
|
||||||
},
|
},
|
||||||
Append: function(key, val) {
|
Append: function(key, val) {
|
||||||
if (key == undefined) { return msg && msg.append || [] }
|
if (key == undefined) { return msg && msg.append || [] }
|
||||||
if (can.base.isObject(key)) { can.core.Item(key, msg.Append) }
|
if (can.base.isObject(key)) { can.core.Item(key, msg.Append) }
|
||||||
if (val == undefined) { return msg && msg[key] && msg[key][0] || "" }
|
if (val == undefined) { return msg && msg[key] && msg[key][0] || "" }
|
||||||
return msg.append = can.base.AddUniq(msg.append, key), msg[key] = can.core.List(arguments).slice(1), val
|
return msg.append = can.base.AddUniq(msg.append, key), msg[key] = can.core.List(arguments).slice(1), val
|
||||||
},
|
},
|
||||||
Result: function() { return msg.result && msg.result.join("") || "" },
|
Result: function() { return msg.result && msg.result.join("") || "" },
|
||||||
|
|
||||||
Length: function() {
|
Length: function() {
|
||||||
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
||||||
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
||||||
})
|
})
|
||||||
return len
|
return len
|
||||||
},
|
},
|
||||||
Table: function(cb) { if (!msg.append || msg.append.length == 0) { return }
|
Table: function(cb) { if (!msg.append || msg.append.length == 0) { return }
|
||||||
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
||||||
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
||||||
})
|
})
|
||||||
|
|
||||||
return can.core.List(msg[max], function(value, index, array) { var one = {}, res
|
return can.core.List(msg[max], function(value, index, array) { var one = {}, res
|
||||||
can.core.List(msg.append, function(key) { one[key] = (msg[key]&&msg[key][index]||"") })
|
can.core.List(msg.append, function(key) { one[key] = (msg[key]&&msg[key][index]||"") })
|
||||||
return can.base.isFunc(cb) && (res = cb(one, index, array)) && res != undefined && res || one
|
return can.base.isFunc(cb) && (res = cb(one, index, array)) && res != undefined && res || one
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Clear: function(key) { switch (key||ice.MSG_APPEND) {
|
Clear: function(key) { switch (key||ice.MSG_APPEND) {
|
||||||
case ice.MSG_APPEND:
|
case ice.MSG_APPEND:
|
||||||
case ice.MSG_OPTION:
|
case ice.MSG_OPTION:
|
||||||
can.core.List(msg[key], function(item) { delete(msg[item]) })
|
can.core.List(msg[key], function(item) { delete(msg[item]) })
|
||||||
default: msg[key] = []
|
default: msg[key] = []
|
||||||
} },
|
} },
|
||||||
Copy: function(res) { if (!res) { return msg }
|
Copy: function(res) { if (!res) { return msg }
|
||||||
res.result && (msg.result = (msg.result||[]).concat(res.result))
|
res.result && (msg.result = (msg.result||[]).concat(res.result))
|
||||||
res.append && (msg.append = res.append) && res.append.forEach(function(item) {
|
res.append && (msg.append = res.append) && res.append.forEach(function(item) {
|
||||||
var i = msg.option && msg.option.indexOf(item); if (i > -1) {
|
var i = msg.option && msg.option.indexOf(item); if (i > -1) {
|
||||||
msg.option[i] = "", delete(msg[item])
|
msg.option[i] = "", delete(msg[item])
|
||||||
}
|
}
|
||||||
res[item] && (msg[item] = (msg[item]||[]).concat(res[item]))
|
res[item] && (msg[item] = (msg[item]||[]).concat(res[item]))
|
||||||
})
|
})
|
||||||
res.option && (msg.option = res.option) && res.option.forEach(function(item) {
|
res.option && (msg.option = res.option) && res.option.forEach(function(item) {
|
||||||
res[item] && (msg[item] = res[item])
|
res[item] && (msg[item] = res[item])
|
||||||
})
|
})
|
||||||
res._option && (msg._option = res._option) && res._option.forEach(function(item) {
|
res._option && (msg._option = res._option) && res._option.forEach(function(item) {
|
||||||
res[item] && (msg[item] = res[item])
|
res[item] && (msg[item] = res[item])
|
||||||
})
|
})
|
||||||
return msg
|
return msg
|
||||||
},
|
},
|
||||||
Push: function(key, value, detail) {
|
Push: function(key, value, detail) {
|
||||||
if (can.base.isObject(key)) {
|
if (can.base.isObject(key)) {
|
||||||
value = value||can.core.Item(key), can.core.List(value, function(item) {
|
value = value||can.core.Item(key), can.core.List(value, function(item) {
|
||||||
detail? msg.Push(mdb.KEY, item).Push(mdb.VALUE, key[item]||""):
|
detail? msg.Push(mdb.KEY, item).Push(mdb.VALUE, key[item]||""):
|
||||||
msg.Push(item, key[item]||"")
|
msg.Push(item, key[item]||"")
|
||||||
})
|
})
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.append = can.base.AddUniq(msg.append, key), msg[key] = msg[key] || []
|
msg.append = can.base.AddUniq(msg.append, key), msg[key] = msg[key] || []
|
||||||
msg[key].push(can.base.isString(value)||can.base.isFunction(value)? value: JSON.stringify(value))
|
msg[key].push(can.base.isString(value)||can.base.isFunction(value)? value: JSON.stringify(value))
|
||||||
return msg
|
return msg
|
||||||
},
|
},
|
||||||
Echo: function(res) { msg.result = msg.result || []
|
Echo: function(res) { msg.result = msg.result || []
|
||||||
for (var i = 0; i < arguments.length; i++) { msg.result.push(arguments[i]) }
|
for (var i = 0; i < arguments.length; i++) { msg.result.push(arguments[i]) }
|
||||||
return msg._hand = true, msg
|
return msg._hand = true, msg
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return can.misc.proto(msg, proto)
|
return can.misc.proto(msg, proto)
|
||||||
},
|
},
|
||||||
POST: function(can, msg, url, form, cb) { // _method _accept _upload _progress
|
POST: function(can, msg, url, form, cb) { // _method _accept _upload _progress
|
||||||
var xhr = new XMLHttpRequest(); msg._xhr = xhr
|
var xhr = new XMLHttpRequest(); msg._xhr = xhr
|
||||||
xhr.open(msg._method||"POST", url), xhr.onreadystatechange = function() {
|
xhr.open(msg._method||"POST", url), xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState != 4) { return }
|
if (xhr.readyState != 4) { return }
|
||||||
|
|
||||||
try { // 解析响应
|
try { // 解析响应
|
||||||
var res = JSON.parse(xhr.responseText)
|
var res = JSON.parse(xhr.responseText)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var res = {result: [xhr.responseText]}
|
var res = {result: [xhr.responseText]}
|
||||||
}
|
}
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
return can.base.isFunc(cb) && cb(msg.Copy(res))
|
return can.base.isFunc(cb) && cb(msg.Copy(res))
|
||||||
}
|
}
|
||||||
can.user.toast(can, res, xhr.status)
|
can.user.toast(can, res, xhr.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg._upload) { // 上传文件
|
if (msg._upload) { // 上传文件
|
||||||
var data = new FormData(); can.core.Items(form, function(value, index, key) {
|
var data = new FormData(); can.core.Items(form, function(value, index, key) {
|
||||||
data.append(key, value)
|
data.append(key, value)
|
||||||
}), data.append(html.UPLOAD, msg._upload), data.append(ice.MSG_UPLOAD, "upload")
|
}), data.append(html.UPLOAD, msg._upload), data.append(ice.MSG_UPLOAD, "upload")
|
||||||
|
|
||||||
xhr.upload.onprogress = function(event) {
|
xhr.upload.onprogress = function(event) {
|
||||||
can.base.isFunc(msg._progress) && msg._progress(event, parseInt(event.loaded*100/event.total), event.total, event.loaded)
|
can.base.isFunc(msg._progress) && msg._progress(event, parseInt(event.loaded*100/event.total), event.total, event.loaded)
|
||||||
}
|
}
|
||||||
} else { // 请求数据
|
} else { // 请求数据
|
||||||
var data = can.core.Items(form, function(value, index, key) { return key+"="+encodeURIComponent(value) }).join("&")
|
var data = can.core.Items(form, function(value, index, key) { return key+"="+encodeURIComponent(value) }).join("&")
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
xhr.setRequestHeader("Accept", msg._accept||"application/json")
|
xhr.setRequestHeader("Accept", msg._accept||"application/json")
|
||||||
try { xhr.send(data) } catch(e) { can.misc.Log(e) }
|
try { xhr.send(data) } catch(e) { can.misc.Log(e) }
|
||||||
},
|
},
|
||||||
Run: function(event, can, dataset, cmds, cb) {
|
Run: function(event, can, dataset, cmds, cb) {
|
||||||
var msg = can.request(event||{}), skip = {_handle: true}
|
var msg = can.request(event||{}), skip = {_handle: true}
|
||||||
var form = {cmds: cmds||msg.cmd}; msg.option && msg.option.forEach(function(item) {
|
var form = {cmds: cmds||msg.cmd}; msg.option && msg.option.forEach(function(item) {
|
||||||
!skip[item] && msg[item] && (form[item] = msg[item])
|
!skip[item] && msg[item] && (form[item] = msg[item])
|
||||||
})
|
})
|
||||||
|
|
||||||
can.misc.POST(can, msg, can.base.MergeURL(dataset.names.toLowerCase(),
|
can.misc.POST(can, msg, can.base.MergeURL(dataset.names.toLowerCase(),
|
||||||
"_", (msg._can.sup||msg._can)._name, ice.MSG_DAEMON, msg.__daemon||dataset.daemon||""
|
"_", (msg._can.sup||msg._can)._name, ice.MSG_DAEMON, msg.__daemon||dataset.daemon||""
|
||||||
), form, cb)
|
), form, cb)
|
||||||
},
|
},
|
||||||
WSS: function(can, args, cb, onopen, onclose, onerror) { if (can.user.isIE) { return }
|
WSS: function(can, args, cb, onopen, onclose, onerror) { if (can.user.isIE) { return }
|
||||||
var url = location.protocol.replace("http", "ws")+"//"+location.host+"/space/"
|
var url = location.protocol.replace("http", "ws")+"//"+location.host+"/space/"
|
||||||
if (url.indexOf("chrome") == 0) { url = "ws://localhost:9020/space/" }
|
if (url.indexOf("chrome") == 0) { url = "ws://localhost:9020/space/" }
|
||||||
|
|
||||||
var socket = new WebSocket(can.base.MergeURL(url, args))
|
var socket = new WebSocket(can.base.MergeURL(url, args))
|
||||||
socket.onclose = function() { can.misc.Log(html.WSS, cli.CLOSE, args)
|
socket.onclose = function() { can.misc.Log(html.WSS, cli.CLOSE, args)
|
||||||
can.base.isFunc(onclose)? onclose(socket): can.core.Timer(1000, function() {
|
can.base.isFunc(onclose)? onclose(socket): can.core.Timer(1000, function() {
|
||||||
can.misc.WSS(can, args, cb, onopen, onerror, onclose)
|
can.misc.WSS(can, args, cb, onopen, onerror, onclose)
|
||||||
})
|
})
|
||||||
}, socket.onerror = function() { can.misc.Log(html.WSS, cli.ERROR, args)
|
}, socket.onerror = function() { can.misc.Log(html.WSS, cli.ERROR, args)
|
||||||
can.base.isFunc(onerror)? onerror(socket): socket.close()
|
can.base.isFunc(onerror)? onerror(socket): socket.close()
|
||||||
|
|
||||||
}, socket.onopen = function() { can.misc.Log(html.WSS, cli.OPEN, args)
|
}, socket.onopen = function() { can.misc.Log(html.WSS, cli.OPEN, args)
|
||||||
can.base.isFunc(onopen) && onopen(socket)
|
can.base.isFunc(onopen) && onopen(socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.onmessage = function(event) {
|
socket.onmessage = function(event) {
|
||||||
try { // 解析命令
|
try { // 解析命令
|
||||||
var data = JSON.parse(event.data)
|
var data = JSON.parse(event.data)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var data = {detail: [event.data]}
|
var data = {detail: [event.data]}
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = can.request(event); msg.Reply = function() { // 回复命令
|
var msg = can.request(event); msg.Reply = function() { // 回复命令
|
||||||
msg.result = (msg.result||[]).concat(can.core.List(arguments))
|
msg.result = (msg.result||[]).concat(can.core.List(arguments))
|
||||||
|
|
||||||
msg.Option({_handle: true, _source: (msg[ice.MSG_TARGET]||[]).reverse().slice(1).join(ice.PT)||"",_target: (msg[ice.MSG_SOURCE]||[]).reverse().join(".")})
|
msg.Option({_handle: true, _source: (msg[ice.MSG_TARGET]||[]).reverse().slice(1).join(ice.PT)||"",_target: (msg[ice.MSG_SOURCE]||[]).reverse().join(".")})
|
||||||
can.misc.Log(html.WSS, ice.MSG_RESULT, msg.result, msg)
|
can.misc.Log(html.WSS, ice.MSG_RESULT, msg.result, msg)
|
||||||
|
|
||||||
delete(msg._event), delete(msg._can)
|
delete(msg._event), delete(msg._can)
|
||||||
socket.send(JSON.stringify(msg))
|
socket.send(JSON.stringify(msg))
|
||||||
}, msg.detail = data.detail, msg.Copy(data)
|
}, msg.detail = data.detail, msg.Copy(data)
|
||||||
|
|
||||||
// 执行命令
|
// 执行命令
|
||||||
try {
|
try {
|
||||||
can.misc.Log(html.WSS, ice.MSG_DETAIL, msg.detail, msg)
|
can.misc.Log(html.WSS, ice.MSG_DETAIL, msg.detail, msg)
|
||||||
can.base.isFunc(cb) && cb(event, msg, msg.detail[0], msg.detail.slice(1))
|
can.base.isFunc(cb) && cb(event, msg, msg.detail[0], msg.detail.slice(1))
|
||||||
} catch (e) { // 执行失败
|
} catch (e) { // 执行失败
|
||||||
can.misc.Log(e), msg.Reply()
|
can.misc.Log(e), msg.Reply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CookieSessid: shy("会话变量", function(can, value, path) {
|
CookieSessid: shy("会话变量", function(can, value, path) {
|
||||||
var name = ice.MSG_SESSID+"_"+location.host.replaceAll(".", "_").replaceAll(":", "_")
|
var name = ice.MSG_SESSID+"_"+location.host.replaceAll(".", "_").replaceAll(":", "_")
|
||||||
return can.misc.Cookie(can, name, value, path)
|
return can.misc.Cookie(can, name, value, path)
|
||||||
}),
|
}),
|
||||||
Cookie: shy("会话变量", function(can, key, value, path) {
|
Cookie: shy("会话变量", function(can, key, value, path) {
|
||||||
function set(k, v) { document.cookie = k+"="+v+";path="+(path||ice.PS) }
|
function set(k, v) { document.cookie = k+"="+v+";path="+(path||ice.PS) }
|
||||||
|
|
||||||
if (can.base.isObject(key)) {
|
if (can.base.isObject(key)) {
|
||||||
for (var k in key) { set(k, key[k]) }
|
for (var k in key) { set(k, key[k]) }
|
||||||
key = undefined
|
key = undefined
|
||||||
}
|
}
|
||||||
if (key == undefined) { var cs = {}
|
if (key == undefined) { var cs = {}
|
||||||
document.cookie.split("; ").forEach(function(item) {
|
document.cookie.split("; ").forEach(function(item) {
|
||||||
var ls = item.split("="); cs[ls[0]] = ls[1]
|
var ls = item.split("="); cs[ls[0]] = ls[1]
|
||||||
})
|
})
|
||||||
return cs
|
return cs
|
||||||
}
|
}
|
||||||
|
|
||||||
value != undefined && set(key, value)
|
value != undefined && set(key, value)
|
||||||
var val = (new RegExp(key+"=([^;]*);?")).exec(document.cookie)
|
var val = (new RegExp(key+"=([^;]*);?")).exec(document.cookie)
|
||||||
return val && val.length > 0? val[1]: ""
|
return val && val.length > 0? val[1]: ""
|
||||||
}),
|
}),
|
||||||
SearchOrConf: function(can, key, def) {
|
SearchOrConf: function(can, key, def) {
|
||||||
can.base.getValid(can.misc.Search(can, key), can.Conf(key), def)
|
can.base.getValid(can.misc.Search(can, key), can.Conf(key), def)
|
||||||
},
|
},
|
||||||
Search: shy("请求参数", function(can, key, value) { var args = {}
|
Search: shy("请求参数", function(can, key, value) { var args = {}
|
||||||
if (value == undefined && can.base.isString(key)) {
|
if (value == undefined && can.base.isString(key)) {
|
||||||
var ls = location.pathname.split(ice.PS)
|
var ls = location.pathname.split(ice.PS)
|
||||||
if (ls[1] == chat.SHARE) { args[chat.SHARE] = ls[2] }
|
if (ls[1] == chat.SHARE) { args[chat.SHARE] = ls[2] }
|
||||||
if (ls[1] == "chat" && ls[2] == ice.POD) { args[ice.POD] = ls[3] }
|
if (ls[1] == "chat" && ls[2] == ice.POD) { args[ice.POD] = ls[3] }
|
||||||
}
|
}
|
||||||
|
|
||||||
location.search && location.search.slice(1).split("&").forEach(function(item) { var x = item.split("=")
|
location.search && location.search.slice(1).split("&").forEach(function(item) { var x = item.split("=")
|
||||||
x[1] != "" && (args[x[0]] = decodeURIComponent(x[1]))
|
x[1] != "" && (args[x[0]] = decodeURIComponent(x[1]))
|
||||||
})
|
})
|
||||||
|
|
||||||
if (can.base.isObject(key)) {
|
if (can.base.isObject(key)) {
|
||||||
can.core.Item(key, function(key, value) {
|
can.core.Item(key, function(key, value) {
|
||||||
if (value != undefined) {args[key] = value}
|
if (value != undefined) {args[key] = value}
|
||||||
args[key] == "" && delete(args[key])
|
args[key] == "" && delete(args[key])
|
||||||
})
|
})
|
||||||
} else if (key == undefined) {
|
} else if (key == undefined) {
|
||||||
return args
|
return args
|
||||||
} else if (value == undefined) {
|
} else if (value == undefined) {
|
||||||
return args[key]
|
return args[key]
|
||||||
} else {
|
} else {
|
||||||
args[key] = value, args[key] == "" && delete(args[key])
|
args[key] = value, args[key] == "" && delete(args[key])
|
||||||
}
|
}
|
||||||
|
|
||||||
return location.search = can.core.Item(args, function(key, value) {
|
return location.search = can.core.Item(args, function(key, value) {
|
||||||
return key+"="+encodeURIComponent(value)
|
return key+"="+encodeURIComponent(value)
|
||||||
}).join("&")
|
}).join("&")
|
||||||
}),
|
}),
|
||||||
MergeURL: shy("地址链接", function(can, objs, clear) {
|
MergeURL: shy("地址链接", function(can, objs, clear) {
|
||||||
var path = location.pathname; objs._path && (path = objs._path, delete(objs._path))
|
var path = location.pathname; objs._path && (path = objs._path, delete(objs._path))
|
||||||
objs && objs.pod && (path = "/chat/pod/"+objs.pod, delete(objs.pod))
|
objs && objs.pod && (path = "/chat/pod/"+objs.pod, delete(objs.pod))
|
||||||
return can.base.MergeURL(location.origin+path+(clear?"":location.search), objs)
|
return can.base.MergeURL(location.origin+path+(clear?"":location.search), objs)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
runAction: function(can, msg, cmds, cb, list) {
|
runAction: function(can, msg, cmds, cb, list) {
|
||||||
if (cmds[0] == ctx.ACTION && list[cmds[1]]) { return list[cmds[1]](cmds.slice(2)), true }
|
if (cmds[0] == ctx.ACTION && list[cmds[1]]) { return list[cmds[1]](cmds.slice(2)), true }
|
||||||
if (list[cmds[0]]) { return list[cmds[0]](cmds.slice(1)), true }
|
if (list[cmds[0]]) { return list[cmds[0]](cmds.slice(1)), true }
|
||||||
},
|
},
|
||||||
concat: function(can, to, from) { to = to||[], from = from||[]
|
concat: function(can, to, from) { to = to||[], from = from||[]
|
||||||
if (from[0] == ctx.ACTION && from[1] == ice.RUN && can.onengine.plugin.meta[from[2]]) {
|
if (from[0] == ctx.ACTION && from[1] == ice.RUN && can.onengine.plugin.meta[from[2]]) {
|
||||||
return from
|
return from
|
||||||
}
|
}
|
||||||
if (can.onengine.plugin.meta[from[0]]) {
|
if (can.onengine.plugin.meta[from[0]]) {
|
||||||
return from
|
return from
|
||||||
}
|
}
|
||||||
if (from[0] == "_search") { return from }
|
if (from[0] == "_search") { return from }
|
||||||
return to.concat(from)
|
return to.concat(from)
|
||||||
},
|
},
|
||||||
proto: function(sub, sup) {
|
proto: function(sub, sup) {
|
||||||
if (navigator.userAgent.indexOf("MSIE") > -1) {
|
if (navigator.userAgent.indexOf("MSIE") > -1) {
|
||||||
for (var k in sup) { sub[k] = sub[k]||sup[k] }
|
for (var k in sup) { sub[k] = sub[k]||sup[k] }
|
||||||
} else {
|
} else {
|
||||||
sub.__proto__ = sup
|
sub.__proto__ = sup
|
||||||
}
|
}
|
||||||
return sub
|
return sub
|
||||||
},
|
},
|
||||||
|
|
||||||
Log: function() {
|
Log: function() {
|
||||||
var args = [this._time(), this.FileLine(2, 3)]
|
var args = [this._time(), this.FileLine(2, 3)]
|
||||||
for (var i in arguments) { args.push(arguments[i]) }
|
for (var i in arguments) { args.push(arguments[i]) }
|
||||||
console.log.apply(console, args)
|
console.log.apply(console, args)
|
||||||
},
|
},
|
||||||
Info: function() {
|
Info: function() {
|
||||||
var args = [this._time(), this.FileLine(2, 3)]
|
var args = [this._time(), this.FileLine(2, 3)]
|
||||||
for (var i in arguments) { args.push(arguments[i]) }
|
for (var i in arguments) { args.push(arguments[i]) }
|
||||||
console.log.apply(console, args)
|
console.log.apply(console, args)
|
||||||
},
|
},
|
||||||
Warn: function() {
|
Warn: function() {
|
||||||
var args = [this._time(), this.FileLine(2, 3), "warn"]
|
var args = [this._time(), this.FileLine(2, 3), "warn"]
|
||||||
for (var i in arguments) { args.push(arguments[i]) }
|
for (var i in arguments) { args.push(arguments[i]) }
|
||||||
args.push(ice.NL, this._fileLine().split(ice.NL).slice(2).join(ice.NL))
|
args.push(ice.NL, this._fileLine().split(ice.NL).slice(2).join(ice.NL))
|
||||||
console.log.apply(console, args)
|
console.log.apply(console, args)
|
||||||
},
|
},
|
||||||
Debug: function() {
|
Debug: function() {
|
||||||
var args = [this._time(), this.FileLine(2, 3), "debug"]
|
var args = [this._time(), this.FileLine(2, 3), "debug"]
|
||||||
for (var i in arguments) { args.push(arguments[i]) }
|
for (var i in arguments) { args.push(arguments[i]) }
|
||||||
args.push(this.fileLine(2, 3))
|
args.push(this.fileLine(2, 3))
|
||||||
console.log.apply(console, args)
|
console.log.apply(console, args)
|
||||||
navigator.userAgent.indexOf("Mobile") > -1 && alert(JSON.stringify(args.join(ice.SP)))
|
navigator.userAgent.indexOf("Mobile") > -1 && alert(JSON.stringify(args.join(ice.SP)))
|
||||||
},
|
},
|
||||||
FileLine: function(depth, length) {
|
FileLine: function(depth, length) {
|
||||||
return this.fileLine(depth+1).split(ice.PS).slice(3).slice(-length).join(ice.PS).split(")")[0]
|
return this.fileLine(depth+1).split(ice.PS).slice(3).slice(-length).join(ice.PS).split(")")[0]
|
||||||
},
|
},
|
||||||
fileLine: function(depth) {
|
fileLine: function(depth) {
|
||||||
return (this._fileLine().split(ice.NL)[1+depth]||"").trim()
|
return (this._fileLine().split(ice.NL)[1+depth]||"").trim()
|
||||||
},
|
},
|
||||||
_fileLine: function() { var obj = {}
|
_fileLine: function() { var obj = {}
|
||||||
Error.captureStackTrace && Error.captureStackTrace(obj, arguments.callee)
|
Error.captureStackTrace && Error.captureStackTrace(obj, arguments.callee)
|
||||||
return obj.stack || ""
|
return obj.stack || ""
|
||||||
},
|
},
|
||||||
_time: function() { var now = new Date()
|
_time: function() { var now = new Date()
|
||||||
var hour = now.getHours()
|
var hour = now.getHours()
|
||||||
if (hour < 10) { hour = "0"+hour }
|
if (hour < 10) { hour = "0"+hour }
|
||||||
var minute = now.getMinutes()
|
var minute = now.getMinutes()
|
||||||
if (minute < 10) { minute = "0"+minute }
|
if (minute < 10) { minute = "0"+minute }
|
||||||
var second = now.getSeconds()
|
var second = now.getSeconds()
|
||||||
if (second < 10) { second = "0"+second }
|
if (second < 10) { second = "0"+second }
|
||||||
return hour+":"+minute+":"+second
|
return hour+":"+minute+":"+second
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
762
lib/page.js
762
lib/page.js
@ -1,417 +1,417 @@
|
|||||||
Volcanos("page", {help: "用户界面", ClassList: {
|
Volcanos("page", {help: "用户界面", ClassList: {
|
||||||
has: function(can, obj, key) { var list = obj.className? obj.className.split(ice.SP): []
|
has: function(can, obj, key) { var list = obj.className? obj.className.split(ice.SP): []
|
||||||
return list.indexOf(key) > -1
|
return list.indexOf(key) > -1
|
||||||
},
|
},
|
||||||
add: function(can, obj, key) { var list = obj.className? obj.className.split(ice.SP): []
|
add: function(can, obj, key) { var list = obj.className? obj.className.split(ice.SP): []
|
||||||
var value = can.base.AddUniq(list, key).join(ice.SP).trim()
|
var value = can.base.AddUniq(list, key).join(ice.SP).trim()
|
||||||
return value != obj.className && (obj.className = value), value
|
return value != obj.className && (obj.className = value), value
|
||||||
},
|
},
|
||||||
del: function(can, obj, key) { var list = obj.className? obj.className.split(ice.SP): []
|
del: function(can, obj, key) { var list = obj.className? obj.className.split(ice.SP): []
|
||||||
return obj.className = can.core.List(list, function(value) {
|
return obj.className = can.core.List(list, function(value) {
|
||||||
return value == key? undefined: value
|
return value == key? undefined: value
|
||||||
}).join(ice.SP).trim()
|
}).join(ice.SP).trim()
|
||||||
},
|
},
|
||||||
set: function(can, obj, key, condition) {
|
set: function(can, obj, key, condition) {
|
||||||
return (condition? this.add(can, obj, key): this.del(can, obj, key)).indexOf(key) > -1
|
return (condition? this.add(can, obj, key): this.del(can, obj, key)).indexOf(key) > -1
|
||||||
},
|
},
|
||||||
neg: function(can, obj, key) {
|
neg: function(can, obj, key) {
|
||||||
return (this.has(can, obj, key)? this.del(can, obj, key): this.add(can, obj, key)).indexOf(key) > -1
|
return (this.has(can, obj, key)? this.del(can, obj, key): this.add(can, obj, key)).indexOf(key) > -1
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
SelectArgs: function(can, option, key, cb) {
|
SelectArgs: function(can, option, key, cb) {
|
||||||
if (can.base.isUndefined(key)) { var value = {}
|
if (can.base.isUndefined(key)) { var value = {}
|
||||||
can.page.SelectArgs(can, option, "", function(item) {
|
can.page.SelectArgs(can, option, "", function(item) {
|
||||||
item.name && item.value && (value[item.name] = item.value)
|
item.name && item.value && (value[item.name] = item.value)
|
||||||
}); return [value]
|
}); return [value]
|
||||||
}
|
}
|
||||||
if (can.base.isObject(key)) {
|
if (can.base.isObject(key)) {
|
||||||
return can.core.Item(key, function(key, value) { can.page.SelectArgs(can, option, key, value) }), [key]
|
return can.core.Item(key, function(key, value) { can.page.SelectArgs(can, option, key, value) }), [key]
|
||||||
}
|
}
|
||||||
if (!can.base.isFunc(cb)) { var value = cb; cb = function(item) { if (item.type == html.BUTTON) { return }
|
if (!can.base.isFunc(cb)) { var value = cb; cb = function(item) { if (item.type == html.BUTTON) { return }
|
||||||
return item.name && (can.base.isUndefined(value)? item.value: (item.value = value))||""
|
return item.name && (can.base.isUndefined(value)? item.value: (item.value = value))||""
|
||||||
} }
|
} }
|
||||||
if (key.indexOf(ice.PT) > -1) { return [""]}
|
if (key.indexOf(ice.PT) > -1) { return [""]}
|
||||||
return can.page.Select(can, option, key? "textarea[name="+key+"],"+"input[name="+key+"],"+"select[name="+key+"]": ".args", cb)
|
return can.page.Select(can, option, key? "textarea[name="+key+"],"+"input[name="+key+"],"+"select[name="+key+"]": ".args", cb)
|
||||||
},
|
},
|
||||||
SelectAll: shy("选择节点", function(can, target, key, cb, interval, cbs) {
|
SelectAll: shy("选择节点", function(can, target, key, cb, interval, cbs) {
|
||||||
can.page.Select(can, target, html.IFRAME, function(item) {
|
can.page.Select(can, target, html.IFRAME, function(item) {
|
||||||
can.page.SelectAll(can, item.contentWindow.document.body, key, cb, interval, cbs)
|
can.page.SelectAll(can, item.contentWindow.document.body, key, cb, interval, cbs)
|
||||||
})
|
})
|
||||||
return can.core.List(target && target.querySelectorAll(key), cb, interval, cbs)
|
return can.core.List(target && target.querySelectorAll(key), cb, interval, cbs)
|
||||||
}),
|
}),
|
||||||
Select: shy("选择节点", function(can, target, key, cb, interval, cbs) { if (key == ice.PT) { cb(target); return [] }
|
Select: shy("选择节点", function(can, target, key, cb, interval, cbs) { if (key == ice.PT) { cb(target); return [] }
|
||||||
return can.core.List(target && target.querySelectorAll(can.page.Keys(key)), cb, interval, cbs)
|
return can.core.List(target && target.querySelectorAll(can.page.Keys(key)), cb, interval, cbs)
|
||||||
}),
|
}),
|
||||||
Modify: shy("修改节点", function(can, target, value) { target = target||{}
|
Modify: shy("修改节点", function(can, target, value) { target = target||{}
|
||||||
target = can.base.isObject(target)? target: document.querySelector(target)
|
target = can.base.isObject(target)? target: document.querySelector(target)
|
||||||
can.base.isString(value)? (target.innerHTML = value): can.core.Item(value, function(key, val) {
|
can.base.isString(value)? (target.innerHTML = value): can.core.Item(value, function(key, val) {
|
||||||
!can.base.isObject(val)? (target[key] = val): can.core.Item(val, function(k, v) {
|
!can.base.isObject(val)? (target[key] = val): can.core.Item(val, function(k, v) {
|
||||||
var size = {
|
var size = {
|
||||||
"height": true, "max-height": true, "min-height": true,
|
"height": true, "max-height": true, "min-height": true,
|
||||||
"width": true, "max-width": true, "min-width": true,
|
"width": true, "max-width": true, "min-width": true,
|
||||||
}
|
}
|
||||||
if (size[k] && parseInt(v) < 0) { return target[key] && (target[key][k] = "") }
|
if (size[k] && parseInt(v) < 0) { return target[key] && (target[key][k] = "") }
|
||||||
|
|
||||||
var size = {
|
var size = {
|
||||||
"margin-top": true, "margin-left": true, "font-size": true,
|
"margin-top": true, "margin-left": true, "font-size": true,
|
||||||
"left": true, "right": true, "top": true, "bottom": true,
|
"left": true, "right": true, "top": true, "bottom": true,
|
||||||
"height": true, "max-height": true, "min-height": true,
|
"height": true, "max-height": true, "min-height": true,
|
||||||
"width": true, "max-width": true, "min-width": true,
|
"width": true, "max-width": true, "min-width": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size[k] && v && (can.base.isNumber(v) || v.indexOf && v.indexOf("px") == -1)) {
|
if (size[k] && v && (can.base.isNumber(v) || v.indexOf && v.indexOf("px") == -1)) {
|
||||||
v += "px"
|
v += "px"
|
||||||
}
|
}
|
||||||
target[key] && (target[key][k] = v)
|
target[key] && (target[key][k] = v)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return target
|
return target
|
||||||
}),
|
}),
|
||||||
Remove: shy("删除节点", function(can, target) {
|
Remove: shy("删除节点", function(can, target) {
|
||||||
return target && target.parentNode && target.parentNode.removeChild(target), target
|
return target && target.parentNode && target.parentNode.removeChild(target), target
|
||||||
}),
|
}),
|
||||||
Create: shy("创建节点", function(can, key, value) {
|
Create: shy("创建节点", function(can, key, value) {
|
||||||
return can.page.Modify(can, document.createElement(key), value)
|
return can.page.Modify(can, document.createElement(key), value)
|
||||||
}),
|
}),
|
||||||
Append: shy("添加节点", function(can, target, key, value) { value = value||{}
|
Append: shy("添加节点", function(can, target, key, value) { value = value||{}
|
||||||
if (can.base.isString(key)) { var res = can.page.Create(can, key, value); return target.appendChild(res), res }
|
if (can.base.isString(key)) { var res = can.page.Create(can, key, value); return target.appendChild(res), res }
|
||||||
|
|
||||||
can.core.List(key, function(item, index) { if (!item) { return }
|
can.core.List(key, function(item, index) { if (!item) { return }
|
||||||
if (can.base.isString(item)) { target.innerHTML = item; return }
|
if (can.base.isString(item)) { target.innerHTML = item; return }
|
||||||
if (item.nodeName) { target.appendChild(item); return }
|
if (item.nodeName) { target.appendChild(item); return }
|
||||||
|
|
||||||
// 基本结构: type name data list
|
// 基本结构: type name data list
|
||||||
var type = item.type||html.DIV, data = item.data||{}
|
var type = item.type||html.DIV, data = item.data||{}
|
||||||
var name = item.name||data.name||""
|
var name = item.name||data.name||""
|
||||||
|
|
||||||
// 数据调整
|
// 数据调整
|
||||||
can.core.Item(item, function(key, value) {
|
can.core.Item(item, function(key, value) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case mdb.TYPE: break
|
case mdb.TYPE: break
|
||||||
case mdb.NAME: break
|
case mdb.NAME: break
|
||||||
case mdb.DATA: break
|
case mdb.DATA: break
|
||||||
case mdb.LIST: break
|
case mdb.LIST: break
|
||||||
case html.INNER: data.innerHTML = item.inner; break
|
case html.INNER: data.innerHTML = item.inner; break
|
||||||
case html.CLICK: data.onclick = item.click; break
|
case html.CLICK: data.onclick = item.click; break
|
||||||
default: data[key] = item[key]
|
default: data[key] = item[key]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 基本类型: view text button select input username password
|
// 基本类型: view text button select input username password
|
||||||
// 基本类型: img row th td
|
// 基本类型: img row th td
|
||||||
if (item.view) { var list = can.core.List(item.view)
|
if (item.view) { var list = can.core.List(item.view)
|
||||||
list.length > 0 && list[0] && can.page.ClassList.add(can, data, list[0])
|
list.length > 0 && list[0] && can.page.ClassList.add(can, data, list[0])
|
||||||
type = list[1]||html.DIV
|
type = list[1]||html.DIV
|
||||||
data.innerHTML = list[2]||data.innerHTML||""
|
data.innerHTML = list[2]||data.innerHTML||""
|
||||||
name = name||list[3]||""
|
name = name||list[3]||""
|
||||||
|
|
||||||
} else if (item.text) { var list = can.core.List(item.text)
|
} else if (item.text) { var list = can.core.List(item.text)
|
||||||
data.innerHTML = list[0]||data.innerHTML||""
|
data.innerHTML = list[0]||data.innerHTML||""
|
||||||
type = list[1]||html.SPAN
|
type = list[1]||html.SPAN
|
||||||
list[2] && can.page.ClassList.add(can, data, list[2])
|
list[2] && can.page.ClassList.add(can, data, list[2])
|
||||||
|
|
||||||
} else if (item.button) { var list = can.core.List(item.button)
|
} else if (item.button) { var list = can.core.List(item.button)
|
||||||
type = html.BUTTON, name = name||list[0]
|
type = html.BUTTON, name = name||list[0]
|
||||||
data.innerText = can.user.trans(can, list[0]), data.onclick = function(event) {
|
data.innerText = can.user.trans(can, list[0]), data.onclick = function(event) {
|
||||||
can.base.isFunction(list[1]) && list[1](event, name)
|
can.base.isFunction(list[1]) && list[1](event, name)
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (item.select) { var list = item.select
|
} else if (item.select) { var list = item.select
|
||||||
type = html.SELECT, data.name = name = name||list[0][0]
|
type = html.SELECT, data.name = name = name||list[0][0]
|
||||||
data.title = can.user.trans(can, data.title||name)
|
data.title = can.user.trans(can, data.title||name)
|
||||||
data.className = data.className||list[0][0]||""
|
data.className = data.className||list[0][0]||""
|
||||||
|
|
||||||
item.list = list[0].slice(1).map(function(value) {
|
item.list = list[0].slice(1).map(function(value) {
|
||||||
return {type: html.OPTION, value: value, inner: can.user.trans(can, value)}
|
return {type: html.OPTION, value: value, inner: can.user.trans(can, value)}
|
||||||
})
|
})
|
||||||
data.onchange = function(event) {
|
data.onchange = function(event) {
|
||||||
can.base.isFunction(list[1]) && list[1](event, event.target.value, name)
|
can.base.isFunction(list[1]) && list[1](event, event.target.value, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (item.input) { var list = can.core.List(item.input)
|
} else if (item.input) { var list = can.core.List(item.input)
|
||||||
type = html.INPUT, name = name||list[0]||"", data.name = data.name||name
|
type = html.INPUT, name = name||list[0]||"", data.name = data.name||name
|
||||||
data.className = data.className||data.name
|
data.className = data.className||data.name
|
||||||
data.autocomplete = "off"
|
data.autocomplete = "off"
|
||||||
|
|
||||||
data.onfocus = data.onfocus||function(event) {
|
data.onfocus = data.onfocus||function(event) {
|
||||||
event.target.setSelectionRange(0, -1)
|
event.target.setSelectionRange(0, -1)
|
||||||
}
|
}
|
||||||
data.onkeydown = function(event) {
|
data.onkeydown = function(event) {
|
||||||
can.base.isFunction(list[1]) && list[1](event)
|
can.base.isFunction(list[1]) && list[1](event)
|
||||||
}
|
}
|
||||||
data.onkeyup = function(event) {
|
data.onkeyup = function(event) {
|
||||||
can.base.isFunction(list[2]) && list[2](event)
|
can.base.isFunction(list[2]) && list[2](event)
|
||||||
}
|
}
|
||||||
} else if (item.username) { var list = can.core.List(item.username)
|
} else if (item.username) { var list = can.core.List(item.username)
|
||||||
type = html.INPUT, name = name||list[0]||html.USERNAME, data.name = data.name||name
|
type = html.INPUT, name = name||list[0]||html.USERNAME, data.name = data.name||name
|
||||||
data.className = list[1]||data.className||data.name
|
data.className = list[1]||data.className||data.name
|
||||||
data.autocomplete = data.autocomplete||html.USERNAME
|
data.autocomplete = data.autocomplete||html.USERNAME
|
||||||
|
|
||||||
} else if (item.password) { var list = can.core.List(item.password)
|
} else if (item.password) { var list = can.core.List(item.password)
|
||||||
type = html.INPUT, name = name||list[0]||html.PASSWORD, data.name = data.name||name
|
type = html.INPUT, name = name||list[0]||html.PASSWORD, data.name = data.name||name
|
||||||
data.className = list[1]||data.className||data.name
|
data.className = list[1]||data.className||data.name
|
||||||
data.autocomplete = data.autocomplete||"current-password"
|
data.autocomplete = data.autocomplete||"current-password"
|
||||||
data.type = html.PASSWORD
|
data.type = html.PASSWORD
|
||||||
|
|
||||||
} else if (item.img) { var list = can.core.List(item.img)
|
} else if (item.img) { var list = can.core.List(item.img)
|
||||||
type = html.IMG, data.src = list[0]
|
type = html.IMG, data.src = list[0]
|
||||||
|
|
||||||
} else if (item.row) { type = html.TR
|
} else if (item.row) { type = html.TR
|
||||||
item.list = item.row.map(function(text) { return {text: [text, item.sub||html.TD]} })
|
item.list = item.row.map(function(text) { return {text: [text, item.sub||html.TD]} })
|
||||||
} else if (item.th) { type = html.TR
|
} else if (item.th) { type = html.TR
|
||||||
item.list = item.th.map(function(text) { return {text: [text, html.TH]} })
|
item.list = item.th.map(function(text) { return {text: [text, html.TH]} })
|
||||||
} else if (item.td) { type = html.TR
|
} else if (item.td) { type = html.TR
|
||||||
item.list = item.td.map(function(text) { return {text: [text, html.TD]} })
|
item.list = item.td.map(function(text) { return {text: [text, html.TD]} })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 语言转换
|
// 语言转换
|
||||||
if (type == html.INPUT) { data.type == html.BUTTON && (data.value = can.user.trans(can, data.value))
|
if (type == html.INPUT) { data.type == html.BUTTON && (data.value = can.user.trans(can, data.value))
|
||||||
if (data.type == html.TEXT||data.type == html.PASSWORD||!data.type) { data.autocomplete = data.autocomplete||"off"
|
if (data.type == html.TEXT||data.type == html.PASSWORD||!data.type) { data.autocomplete = data.autocomplete||"off"
|
||||||
data.placeholder = can.user.trans(can, (data.placeholder||data.name||"").split(ice.PT).pop())
|
data.placeholder = can.user.trans(can, (data.placeholder||data.name||"").split(ice.PT).pop())
|
||||||
data.title = can.user.trans(can, data.title||data.placeholder)
|
data.title = can.user.trans(can, data.title||data.placeholder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == html.TEXTAREA) {
|
if (type == html.TEXTAREA) {
|
||||||
data.placeholder = can.user.trans(can, (data.placeholder||data.name||"").split(ice.PT).pop())
|
data.placeholder = can.user.trans(can, (data.placeholder||data.name||"").split(ice.PT).pop())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建节点
|
// 创建节点
|
||||||
!data.name && item.name && (data.name = item.name)
|
!data.name && item.name && (data.name = item.name)
|
||||||
var node = can.page.Create(can, type, data)
|
var node = can.page.Create(can, type, data)
|
||||||
|
|
||||||
// 创建索引
|
// 创建索引
|
||||||
name = name||data.className||type||""
|
name = name||data.className||type||""
|
||||||
value[name||""] = value[data.className||""] = value[type] = node
|
value[name||""] = value[data.className||""] = value[type] = node
|
||||||
value.first = value.first||node, value.last = node
|
value.first = value.first||node, value.last = node
|
||||||
value._target = value._target||node
|
value._target = value._target||node
|
||||||
|
|
||||||
// 递归节点
|
// 递归节点
|
||||||
item.list && can.page.Append(can, node, item.list, value)
|
item.list && can.page.Append(can, node, item.list, value)
|
||||||
target && target.appendChild && target.appendChild(node)
|
target && target.appendChild && target.appendChild(node)
|
||||||
can.base.isFunc(item._init) && item._init(node)
|
can.base.isFunc(item._init) && item._init(node)
|
||||||
})
|
})
|
||||||
return value
|
return value
|
||||||
}),
|
}),
|
||||||
Appends: shy("添加节点", function(can, target, key, value) {
|
Appends: shy("添加节点", function(can, target, key, value) {
|
||||||
return target.innerHTML = "", can.page.Append(can, target, key, value)
|
return target.innerHTML = "", can.page.Append(can, target, key, value)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
AppendTable: shy("添加表格", function(can, msg, target, list, cb) {
|
AppendTable: shy("添加表格", function(can, msg, target, list, cb) {
|
||||||
if (!msg.append||msg.append.length == 0) {return}
|
if (!msg.append||msg.append.length == 0) {return}
|
||||||
|
|
||||||
var table = can.page.Append(can, target, html.TABLE)
|
var table = can.page.Append(can, target, html.TABLE)
|
||||||
can.page.Append(can, table, [{type: html.TR, data: {dataset: {index: -1}}, list:
|
can.page.Append(can, table, [{type: html.TR, data: {dataset: {index: -1}}, list:
|
||||||
can.core.List(list, function(key) {
|
can.core.List(list, function(key) {
|
||||||
return key[0] == "_"? undefined: {text: [key.trim(), html.TH]}
|
return key[0] == "_"? undefined: {text: [key.trim(), html.TH]}
|
||||||
})
|
})
|
||||||
}])
|
}])
|
||||||
can.page.Append(can, table, can.core.List(msg.Table(), function(line, index, array) {
|
can.page.Append(can, table, can.core.List(msg.Table(), function(line, index, array) {
|
||||||
var _list = can.core.List(list, function(key) { if (key.indexOf("_") == 0) { return }
|
var _list = can.core.List(list, function(key) { if (key.indexOf("_") == 0) { return }
|
||||||
return cb(can.page.Color(line[key]).trim(), key, index, line, array)
|
return cb(can.page.Color(line[key]).trim(), key, index, line, array)
|
||||||
})
|
})
|
||||||
return _list.length > 0? {type: html.TR, dataset: {index: index}, list: _list}: undefined
|
return _list.length > 0? {type: html.TR, dataset: {index: index}, list: _list}: undefined
|
||||||
}))
|
}))
|
||||||
return can.page.OrderTable(can, table)
|
return can.page.OrderTable(can, table)
|
||||||
}),
|
}),
|
||||||
OrderTable: function(can, table) {
|
OrderTable: function(can, table) {
|
||||||
can.page.Select(can, table, html.TH, function(th, index) {
|
can.page.Select(can, table, html.TH, function(th, index) {
|
||||||
th.onclick = function(event) { var dataset = event.target.dataset
|
th.onclick = function(event) { var dataset = event.target.dataset
|
||||||
dataset["sort_asc"] = (dataset["sort_asc"] == "1") ? 0: 1
|
dataset["sort_asc"] = (dataset["sort_asc"] == "1") ? 0: 1
|
||||||
can.page.RangeTable(can, table, index, dataset["sort_asc"] == "1")
|
can.page.RangeTable(can, table, index, dataset["sort_asc"] == "1")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return table
|
return table
|
||||||
},
|
},
|
||||||
RangeTable: function(can, table, index, sort_asc) {
|
RangeTable: function(can, table, index, sort_asc) {
|
||||||
var list = can.page.Select(can, table, html.TR, function(tr) {
|
var list = can.page.Select(can, table, html.TR, function(tr) {
|
||||||
return tr.style.display == html.NONE||can.page.ClassList.has(can, tr, "hide")? null: tr
|
return tr.style.display == html.NONE||can.page.ClassList.has(can, tr, "hide")? null: tr
|
||||||
}).slice(1)
|
}).slice(1)
|
||||||
|
|
||||||
index = can.base.isObject(index)? index: [index]
|
index = can.base.isObject(index)? index: [index]
|
||||||
index = can.core.List(index, function(item) { if (item > -1) { return item} })
|
index = can.core.List(index, function(item) { if (item > -1) { return item} })
|
||||||
if (index.length == 0) { return }
|
if (index.length == 0) { return }
|
||||||
|
|
||||||
var is_time = true, is_number = true
|
var is_time = true, is_number = true
|
||||||
can.core.List(list, function(tr) {
|
can.core.List(list, function(tr) {
|
||||||
var text = tr.childNodes[index[0]].innerText
|
var text = tr.childNodes[index[0]].innerText
|
||||||
is_time = is_time && Date.parse(text) > 0
|
is_time = is_time && Date.parse(text) > 0
|
||||||
is_number = is_number && !isNaN(parseInt(text))
|
is_number = is_number && !isNaN(parseInt(text))
|
||||||
})
|
})
|
||||||
|
|
||||||
var num_list = can.core.List(list, function(tr) {
|
var num_list = can.core.List(list, function(tr) {
|
||||||
var text = tr.childNodes[index[0]].innerText
|
var text = tr.childNodes[index[0]].innerText
|
||||||
return is_time? Date.parse(text):
|
return is_time? Date.parse(text):
|
||||||
is_number? can.base.ParseSize(text): text
|
is_number? can.base.ParseSize(text): text
|
||||||
})
|
})
|
||||||
function isless(a, b, index) {
|
function isless(a, b, index) {
|
||||||
if (a.childNodes[index[0]] && b.childNodes[index[0]]) {
|
if (a.childNodes[index[0]] && b.childNodes[index[0]]) {
|
||||||
if (a.childNodes[index[0]].innerText < b.childNodes[index[0]].innerText) { return true }
|
if (a.childNodes[index[0]].innerText < b.childNodes[index[0]].innerText) { return true }
|
||||||
if (a.childNodes[index[0]].innerText > b.childNodes[index[0]].innerText) { return false }
|
if (a.childNodes[index[0]].innerText > b.childNodes[index[0]].innerText) { return false }
|
||||||
}
|
}
|
||||||
return index.length > 1 && isless(a, b, index.slice(1))
|
return index.length > 1 && isless(a, b, index.slice(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择排序
|
// 选择排序
|
||||||
for (var i = 0; i < num_list.length; i++) { var min = i
|
for (var i = 0; i < num_list.length; i++) { var min = i
|
||||||
for (var j = i+1; j < num_list.length; j++) {
|
for (var j = i+1; j < num_list.length; j++) {
|
||||||
if (num_list[min] == num_list[j] && index.length > 1 && list[index[1]]) {
|
if (num_list[min] == num_list[j] && index.length > 1 && list[index[1]]) {
|
||||||
if (sort_asc? isless(list[min], list[j], index.slice(1)): isless(list[j], list[min], index.slice(1))) {
|
if (sort_asc? isless(list[min], list[j], index.slice(1)): isless(list[j], list[min], index.slice(1))) {
|
||||||
min = j
|
min = j
|
||||||
}
|
}
|
||||||
} else if (sort_asc? num_list[min] < num_list[j]: num_list[j] < num_list[min]) {
|
} else if (sort_asc? num_list[min] < num_list[j]: num_list[j] < num_list[min]) {
|
||||||
min = j
|
min = j
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min != i) {
|
if (min != i) {
|
||||||
var temp = num_list[i]; num_list[i] = num_list[min]; num_list[min] = temp
|
var temp = num_list[i]; num_list[i] = num_list[min]; num_list[min] = temp
|
||||||
var temp = list[i]; list[i] = list[min]; list[min] = temp
|
var temp = list[i]; list[i] = list[min]; list[min] = temp
|
||||||
}
|
}
|
||||||
|
|
||||||
var tbody = list[i].parentElement
|
var tbody = list[i].parentElement
|
||||||
list[i].parentElement && tbody.removeChild(list[i])
|
list[i].parentElement && tbody.removeChild(list[i])
|
||||||
tbody.appendChild(list[i])
|
tbody.appendChild(list[i])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Cache: function(name, output, data) { if (!name) { return }
|
Cache: function(name, output, data) { if (!name) { return }
|
||||||
var cache = output._cache||{}; output._cache = cache
|
var cache = output._cache||{}; output._cache = cache
|
||||||
if (data) { if (output.children.length == 0) { return }
|
if (data) { if (output.children.length == 0) { return }
|
||||||
var temp = document.createDocumentFragment()
|
var temp = document.createDocumentFragment()
|
||||||
while (output.childNodes.length > 0) { // 写缓存
|
while (output.childNodes.length > 0) { // 写缓存
|
||||||
var item = output.childNodes[0]
|
var item = output.childNodes[0]
|
||||||
item.parentNode.removeChild(item),
|
item.parentNode.removeChild(item),
|
||||||
temp.appendChild(item)
|
temp.appendChild(item)
|
||||||
}
|
}
|
||||||
return cache[name] = {node: temp, data: data}, name
|
return cache[name] = {node: temp, data: data}, name
|
||||||
}
|
}
|
||||||
output.innerHTML = ""
|
output.innerHTML = ""
|
||||||
|
|
||||||
var list = cache[name]; if (!list) { return }
|
var list = cache[name]; if (!list) { return }
|
||||||
while (list.node.childNodes.length > 0) { // 读缓存
|
while (list.node.childNodes.length > 0) { // 读缓存
|
||||||
var item = list.node.childNodes[0]
|
var item = list.node.childNodes[0]
|
||||||
item.parentNode.removeChild(item)
|
item.parentNode.removeChild(item)
|
||||||
output.appendChild(item)
|
output.appendChild(item)
|
||||||
}
|
}
|
||||||
return delete(cache[name]), list.data
|
return delete(cache[name]), list.data
|
||||||
},
|
},
|
||||||
Format: function(type) {
|
Format: function(type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case html.A: return "<a href='"+arguments[1]+"' target='_blank'>"+(arguments[2]||arguments[1])+"</a>"
|
case html.A: return "<a href='"+arguments[1]+"' target='_blank'>"+(arguments[2]||arguments[1])+"</a>"
|
||||||
case html.IMG: return arguments[2]? "<img src='"+arguments[1]+"' height="+arguments[2]+">": "<img src='"+arguments[1]+"'>"
|
case html.IMG: return arguments[2]? "<img src='"+arguments[1]+"' height="+arguments[2]+">": "<img src='"+arguments[1]+"'>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
replace: function(can, text, key, value) {
|
replace: function(can, text, key, value) {
|
||||||
text = can.base.replaceAll(text, "<", "<", ">", ">", key, value)
|
text = can.base.replaceAll(text, "<", "<", ">", ">", key, value)
|
||||||
return text
|
return text
|
||||||
},
|
},
|
||||||
Color: function(text) { if (typeof text != lang.STRING) { return "" }
|
Color: function(text) { if (typeof text != lang.STRING) { return "" }
|
||||||
if (text.indexOf("http://") == 0 || text.indexOf("https://") == 0 || text.indexOf("ftp://") == 0) {
|
if (text.indexOf("http://") == 0 || text.indexOf("https://") == 0 || text.indexOf("ftp://") == 0) {
|
||||||
var ls = text.split(ice.SP);
|
var ls = text.split(ice.SP);
|
||||||
text = "<a href='"+ls[0]+"' target='_blank'>"+ls[0]+"</a>"+ls.slice(1).join(ice.SP)
|
text = "<a href='"+ls[0]+"' target='_blank'>"+ls[0]+"</a>"+ls.slice(1).join(ice.SP)
|
||||||
}; text = text.replace(/\\n/g, "<br>")
|
}; text = text.replace(/\\n/g, "<br>")
|
||||||
|
|
||||||
if (text.indexOf("\033\[") == -1) { return text }
|
if (text.indexOf("\033\[") == -1) { return text }
|
||||||
text = text.replace(/\033\[31m/g, "<span style='color:#f00'>")
|
text = text.replace(/\033\[31m/g, "<span style='color:#f00'>")
|
||||||
text = text.replace(/\033\[32m/g, "<span style='color:#0f0'>")
|
text = text.replace(/\033\[32m/g, "<span style='color:#0f0'>")
|
||||||
text = text.replace(/\033\[33m/g, "<span style='color:#ff0'>")
|
text = text.replace(/\033\[33m/g, "<span style='color:#ff0'>")
|
||||||
text = text.replace(/\033\[34m/g, "<span style='color:#00f'>")
|
text = text.replace(/\033\[34m/g, "<span style='color:#00f'>")
|
||||||
text = text.replace(/\033\[36m/g, "<span style='color:#0ff'>")
|
text = text.replace(/\033\[36m/g, "<span style='color:#0ff'>")
|
||||||
text = text.replace(/\033\[34;1m/g, "<span style='color:#00f'>")
|
text = text.replace(/\033\[34;1m/g, "<span style='color:#00f'>")
|
||||||
text = text.replace(/\033\[37;1m/g, "<span style='color:#fff'>")
|
text = text.replace(/\033\[37;1m/g, "<span style='color:#fff'>")
|
||||||
text = text.replace(/\033\[1m/g, "<span style='font-weight:bold'>")
|
text = text.replace(/\033\[1m/g, "<span style='font-weight:bold'>")
|
||||||
text = text.replace(/\033\[0m/g, "</span>")
|
text = text.replace(/\033\[0m/g, "</span>")
|
||||||
text = text.replace(/\033\[m/g, "</span>")
|
text = text.replace(/\033\[m/g, "</span>")
|
||||||
return text
|
return text
|
||||||
},
|
},
|
||||||
input: function(can, item, value) {
|
input: function(can, item, value) {
|
||||||
var input = {type: html.INPUT, name: item.name, data: item, dataset: {}, _init: item._init, style: item.style||{}}
|
var input = {type: html.INPUT, name: item.name, data: item, dataset: {}, _init: item._init, style: item.style||{}}
|
||||||
item.value == ice.AUTO && (item.value = "", item.action = ice.AUTO), item.action == ice.AUTO && (input.dataset.action = ice.AUTO)
|
item.value == ice.AUTO && (item.value = "", item.action = ice.AUTO), item.action == ice.AUTO && (input.dataset.action = ice.AUTO)
|
||||||
|
|
||||||
switch (item.type = item.type||html.TEXT) {
|
switch (item.type = item.type||html.TEXT) {
|
||||||
case html.TEXTAREA: input.type = html.TEXTAREA
|
case html.TEXTAREA: input.type = html.TEXTAREA
|
||||||
input.style.height = input.style.height||can.Conf(["feature", html.TEXTAREA, item.name, html.HEIGHT].join(ice.PT))||can.Conf(["feature", html.TEXTAREA, html.HEIGHT].join(ice.PT))
|
input.style.height = input.style.height||can.Conf(["feature", html.TEXTAREA, item.name, html.HEIGHT].join(ice.PT))||can.Conf(["feature", html.TEXTAREA, html.HEIGHT].join(ice.PT))
|
||||||
input.style.width = input.style.width||can.Conf(["feature", html.TEXTAREA, item.name, html.WIDTH].join(ice.PT))||can.Conf(["feature", html.TEXTAREA, html.WIDTH].join(ice.PT))
|
input.style.width = input.style.width||can.Conf(["feature", html.TEXTAREA, item.name, html.WIDTH].join(ice.PT))||can.Conf(["feature", html.TEXTAREA, html.WIDTH].join(ice.PT))
|
||||||
// no break
|
// no break
|
||||||
case html.USERNAME:
|
case html.USERNAME:
|
||||||
case html.PASSWORD:
|
case html.PASSWORD:
|
||||||
// no break
|
// no break
|
||||||
case html.TEXT:
|
case html.TEXT:
|
||||||
item.autocomplete = "off"
|
item.autocomplete = "off"
|
||||||
item.name = item.name||item.type
|
item.name = item.name||item.type
|
||||||
item.value = value||item.value||""
|
item.value = value||item.value||""
|
||||||
item.placeholder = item.placeholder||item.name||item.type
|
item.placeholder = item.placeholder||item.name||item.type
|
||||||
item.title = item.title||item.placeholder||item.name||item.type
|
item.title = item.title||item.placeholder||item.name||item.type
|
||||||
item.className || can.page.ClassList.add(can, item, ctx.ARGS)
|
item.className || can.page.ClassList.add(can, item, ctx.ARGS)
|
||||||
break
|
break
|
||||||
case html.SELECT: input.type = html.SELECT
|
case html.SELECT: input.type = html.SELECT
|
||||||
item.values = can.base.isString(item.values)? can.core.Split(item.values): item.values
|
item.values = can.base.isString(item.values)? can.core.Split(item.values): item.values
|
||||||
if (!item.values && item.value) { item.values = can.core.Split(item.value), item.value = item.values[0] }
|
if (!item.values && item.value) { item.values = can.core.Split(item.value), item.value = item.values[0] }
|
||||||
|
|
||||||
item.value = value||item.value, input.list = item.values.map(function(value) {
|
item.value = value||item.value, input.list = item.values.map(function(value) {
|
||||||
return {type: html.OPTION, value: value, inner: value}
|
return {type: html.OPTION, value: value, inner: value}
|
||||||
}), item.className || can.page.ClassList.add(can, item, ctx.ARGS)
|
}), item.className || can.page.ClassList.add(can, item, ctx.ARGS)
|
||||||
break
|
break
|
||||||
case html.BUTTON: item.value = item.value||item.name||"list"; break
|
case html.BUTTON: item.value = item.value||item.name||"list"; break
|
||||||
case "upfile": item.type = html.FILE; break
|
case "upfile": item.type = html.FILE; break
|
||||||
case html.UPLOAD: item.type = html.FILE, input.name = html.UPLOAD; break
|
case html.UPLOAD: item.type = html.FILE, input.name = html.UPLOAD; break
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return input
|
return input
|
||||||
},
|
},
|
||||||
|
|
||||||
styleHeight: function(can, target, value) {
|
styleHeight: function(can, target, value) {
|
||||||
can.page.style(can, target, html.HEIGHT, value)
|
can.page.style(can, target, html.HEIGHT, value)
|
||||||
return target.offsetHeight
|
return target.offsetHeight
|
||||||
},
|
},
|
||||||
styleWidth: function(can, target, value) {
|
styleWidth: function(can, target, value) {
|
||||||
can.page.style(can, target, html.WIDTH, value)
|
can.page.style(can, target, html.WIDTH, value)
|
||||||
return target.offsetWidth
|
return target.offsetWidth
|
||||||
},
|
},
|
||||||
style: function(can, target, style) { var value = {}
|
style: function(can, target, style) { var value = {}
|
||||||
for (var i = 2; i < arguments.length; i += 2) {
|
for (var i = 2; i < arguments.length; i += 2) {
|
||||||
if (typeof arguments[i] == lang.OBJECT) {
|
if (typeof arguments[i] == lang.OBJECT) {
|
||||||
can.base.Copy(value, arguments[i--])
|
can.base.Copy(value, arguments[i--])
|
||||||
} else {
|
} else {
|
||||||
value[arguments[i]] = arguments[i+1]
|
value[arguments[i]] = arguments[i+1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
can.page.Modify(can, target, {style: value})
|
can.page.Modify(can, target, {style: value})
|
||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
Keys: function() { var list = []
|
Keys: function() { var list = []
|
||||||
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
|
||||||
if (typeof v == lang.OBJECT) {
|
if (typeof v == lang.OBJECT) {
|
||||||
for (var j = 0; j < v.length; j++) {
|
for (var j = 0; j < v.length; j++) {
|
||||||
if (typeof v[j] == lang.OBJECT) {
|
if (typeof v[j] == lang.OBJECT) {
|
||||||
for (var k = 0; k < v[j].length; k++) {
|
for (var k = 0; k < v[j].length; k++) {
|
||||||
if (typeof v[j][k] == lang.OBJECT) { v[j][k] = v[j][k].join(ice.PT) }
|
if (typeof v[j][k] == lang.OBJECT) { v[j][k] = v[j][k].join(ice.PT) }
|
||||||
}
|
}
|
||||||
v[j] = v[j].join(ice.GT)
|
v[j] = v[j].join(ice.GT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.push(v.join(ice.SP))
|
list.push(v.join(ice.SP))
|
||||||
} else {
|
} else {
|
||||||
list.push(v+"")
|
list.push(v+"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list.join(ice.FS)
|
return list.join(ice.FS)
|
||||||
},
|
},
|
||||||
css: function(text) {
|
css: function(text) {
|
||||||
var styleSheet = document.createElement("style")
|
var styleSheet = document.createElement("style")
|
||||||
styleSheet.type = "text/css", styleSheet.innerText = text
|
styleSheet.type = "text/css", styleSheet.innerText = text
|
||||||
document.head.appendChild(styleSheet)
|
document.head.appendChild(styleSheet)
|
||||||
},
|
},
|
||||||
offsetTop: function(item) { var res = 0
|
offsetTop: function(item) { var res = 0
|
||||||
while (item) { res += item.offsetTop||0, item = item.parentNode }
|
while (item) { res += item.offsetTop||0, item = item.parentNode }
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
offsetLeft: function(item) { var res = 0
|
offsetLeft: function(item) { var res = 0
|
||||||
// if (item.offsetLeft) { return item.offsetLeft }
|
// if (item.offsetLeft) { return item.offsetLeft }
|
||||||
while (item) { res += item.offsetLeft||0, item = item.parentNode }
|
while (item) { res += item.offsetLeft||0, item = item.parentNode }
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
636
lib/user.js
636
lib/user.js
@ -1,346 +1,346 @@
|
|||||||
Volcanos("user", {help: "用户操作", agent: {
|
Volcanos("user", {help: "用户操作", agent: {
|
||||||
scanQRCode: function(cb, can) {
|
scanQRCode: function(cb, can) {
|
||||||
can.user.input(event, can, [{type: html.TEXTAREA, name: "text", text: ""}], function(ev, button, data, list, args) {
|
can.user.input(event, can, [{type: html.TEXTAREA, name: "text", text: ""}], function(ev, button, data, list, args) {
|
||||||
cb(list[0], can.base.ParseJSON(list[0]))
|
cb(list[0], can.base.ParseJSON(list[0]))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getLocation: function(cb) {
|
getLocation: function(cb) {
|
||||||
navigator.geolocation.getCurrentPosition(function(res) {
|
navigator.geolocation.getCurrentPosition(function(res) {
|
||||||
cb({latitude: parseInt(res.coords.latitude*100000), longitude: parseInt(res.coords.longitude*100000)})
|
cb({latitude: parseInt(res.coords.latitude*100000), longitude: parseInt(res.coords.longitude*100000)})
|
||||||
}, function(some) {
|
}, function(some) {
|
||||||
typeof cb == lang.FUNCTION && cb({name: "some"})
|
typeof cb == lang.FUNCTION && cb({name: "some"})
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
openLocation: function(msg) {
|
openLocation: function(msg) {
|
||||||
window.open("https://map.baidu.com/search/"+encodeURIComponent(msg.Option(mdb.TEXT))
|
window.open("https://map.baidu.com/search/"+encodeURIComponent(msg.Option(mdb.TEXT))
|
||||||
+"/@12958750.085,4825785.55,16z?querytype=s&da_src=shareurl&wd="+encodeURIComponent(msg.Option(mdb.TEXT)))
|
+"/@12958750.085,4825785.55,16z?querytype=s&da_src=shareurl&wd="+encodeURIComponent(msg.Option(mdb.TEXT)))
|
||||||
},
|
},
|
||||||
chooseImage: function(cb) {
|
chooseImage: function(cb) {
|
||||||
typeof cb == lang.FUNCTION && cb([])
|
typeof cb == lang.FUNCTION && cb([])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1,
|
isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1,
|
||||||
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
|
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
|
||||||
isMobile: navigator.userAgent.indexOf("Mobile") > -1,
|
isMobile: navigator.userAgent.indexOf("Mobile") > -1,
|
||||||
isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1,
|
isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1,
|
||||||
isWindows: navigator.userAgent.indexOf("Windows") > -1,
|
isWindows: navigator.userAgent.indexOf("Windows") > -1,
|
||||||
isIE: navigator.userAgent.indexOf("MSIE") > -1,
|
isIE: navigator.userAgent.indexOf("MSIE") > -1,
|
||||||
isExtension: location && location.protocol && location.protocol == "chrome-extension:",
|
isExtension: location && location.protocol && location.protocol == "chrome-extension:",
|
||||||
isLocalFile: location && location.protocol && location.protocol == "file:",
|
isLocalFile: location && location.protocol && location.protocol == "file:",
|
||||||
isLandscape: function() { return window.innerWidth > window.innerHeight },
|
isLandscape: function() { return window.innerWidth > window.innerHeight },
|
||||||
mod: {
|
mod: {
|
||||||
isPod: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0),
|
isPod: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0),
|
||||||
isDiv: location && location.pathname && (location.pathname.indexOf("/chat/div/") == 0),
|
isDiv: location && location.pathname && (location.pathname.indexOf("/chat/div/") == 0),
|
||||||
isCmd: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0 && location.pathname.indexOf("/cmd/") > 0 ||
|
isCmd: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0 && location.pathname.indexOf("/cmd/") > 0 ||
|
||||||
location.pathname.indexOf("/chat/cmd/") == 0 || location.pathname.indexOf("/help/") == 0),
|
location.pathname.indexOf("/chat/cmd/") == 0 || location.pathname.indexOf("/help/") == 0),
|
||||||
},
|
},
|
||||||
|
|
||||||
alert: function(text) { alert(JSON.stringify(text)) },
|
alert: function(text) { alert(JSON.stringify(text)) },
|
||||||
confirm: function(text) { return confirm(JSON.stringify(text)) },
|
confirm: function(text) { return confirm(JSON.stringify(text)) },
|
||||||
prompt: function(tip, def, cb, silent) { (text = silent? def: prompt(tip, def||"")) != undefined && typeof cb == lang.FUNCTION && cb(text); return text },
|
prompt: function(tip, def, cb, silent) { (text = silent? def: prompt(tip, def||"")) != undefined && typeof cb == lang.FUNCTION && cb(text); return text },
|
||||||
reload: function(force) { (force || confirm("重新加载页面?")) && location.reload() },
|
reload: function(force) { (force || confirm("重新加载页面?")) && location.reload() },
|
||||||
jumps: function(url) { location.href = url },
|
jumps: function(url) { location.href = url },
|
||||||
open: function(url) { window.open(url) },
|
open: function(url) { window.open(url) },
|
||||||
time: function(can, time, fmt) { var now = can.base.Date(time)
|
time: function(can, time, fmt) { var now = can.base.Date(time)
|
||||||
var list = can.user.language(can) == "en"? ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
|
var list = can.user.language(can) == "en"? ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
|
||||||
return can.base.Time(time, (fmt||"%y-%m-%d %H:%M:%S").replace("%w", list[now.getDay()]))
|
return can.base.Time(time, (fmt||"%y-%m-%d %H:%M:%S").replace("%w", list[now.getDay()]))
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function(text) {
|
title: function(text) {
|
||||||
return text && (document.title = text), document.title
|
return text && (document.title = text), document.title
|
||||||
},
|
},
|
||||||
topic: function(can, name) {
|
topic: function(can, name) {
|
||||||
can.user.isMobile && (name += " mobile") && can.user.isLandscape() && (name += " landscape")
|
can.user.isMobile && (name += " mobile") && can.user.isLandscape() && (name += " landscape")
|
||||||
can.page.Modify(can, document.body, {className: name})
|
can.page.Modify(can, document.body, {className: name})
|
||||||
},
|
},
|
||||||
language: function(can) {
|
language: function(can) {
|
||||||
return can.misc.Search(can, "language")
|
return can.misc.Search(can, "language")
|
||||||
},
|
},
|
||||||
trans: function(can, text, list) { if (can.base.isObject(text)) {
|
trans: function(can, text, list) { if (can.base.isObject(text)) {
|
||||||
return can.core.Item(text, function(k, v) { can.core.Value(can._trans, k, v) })
|
return can.core.Item(text, function(k, v) { can.core.Value(can._trans, k, v) })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can.user.language(can) == "en") { return text }
|
if (can.user.language(can) == "en") { return text }
|
||||||
if (can.base.isFunction(text)) { text = text.name||"" }
|
if (can.base.isFunction(text)) { text = text.name||"" }
|
||||||
return list&&list[text] || can.Conf("trans."+text) || can.Conf("feature._trans."+text) || can._trans&&can._trans[text] || {
|
return list&&list[text] || can.Conf("trans."+text) || can.Conf("feature._trans."+text) || can._trans&&can._trans[text] || {
|
||||||
"create": "创建", "remove": "删除", "insert": "添加", "delete": "删除", "modify": "编辑",
|
"create": "创建", "remove": "删除", "insert": "添加", "delete": "删除", "modify": "编辑",
|
||||||
"inputs": "补全", "prunes": "清理", "export": "导出", "import": "导入",
|
"inputs": "补全", "prunes": "清理", "export": "导出", "import": "导入",
|
||||||
"list": "查看", "back": "返回", "run": "执行", "done": "完成", "share": "共享",
|
"list": "查看", "back": "返回", "run": "执行", "done": "完成", "share": "共享",
|
||||||
"edit": "编辑", "save": "保存", "copy": "复制", "show": "显示", "hide": "隐藏",
|
"edit": "编辑", "save": "保存", "copy": "复制", "show": "显示", "hide": "隐藏",
|
||||||
"project": "项目", "profile": "详情", "actions": "参数",
|
"project": "项目", "profile": "详情", "actions": "参数",
|
||||||
"plugin": "插件",
|
"plugin": "插件",
|
||||||
|
|
||||||
"open": "打开", "close": "关闭",
|
"open": "打开", "close": "关闭",
|
||||||
"start": "启动", "stop": "停止",
|
"start": "启动", "stop": "停止",
|
||||||
"begin": "开始", "end": "结束",
|
"begin": "开始", "end": "结束",
|
||||||
"clear": "清空", "refresh": "刷新",
|
"clear": "清空", "refresh": "刷新",
|
||||||
"submit": "提交", "cancel": "取消",
|
"submit": "提交", "cancel": "取消",
|
||||||
"label": "标签", "exec": "执行",
|
"label": "标签", "exec": "执行",
|
||||||
}[text]||text
|
}[text]||text
|
||||||
},
|
},
|
||||||
toastProcess: function(can, title) {
|
toastProcess: function(can, title) {
|
||||||
return can.user.toast(can, ice.PROCESS, title)
|
return can.user.toast(can, ice.PROCESS, title)
|
||||||
},
|
},
|
||||||
toastSuccess: function(can, title) {
|
toastSuccess: function(can, title) {
|
||||||
return can.user.toast(can, ice.SUCCESS, title)
|
return can.user.toast(can, ice.SUCCESS, title)
|
||||||
},
|
},
|
||||||
toast: function(can, content, title, duration, progress) {
|
toast: function(can, content, title, duration, progress) {
|
||||||
var meta = can.base.isObject(content)? content: {content: content, title: title||can._help, duration: duration, progress: progress}
|
var meta = can.base.isObject(content)? content: {content: content, title: title||can._help, duration: duration, progress: progress}
|
||||||
var width = meta.width||400, height = meta.height||100; if (width < 0) { width = window.innerWidth + width }
|
var width = meta.width||400, height = meta.height||100; if (width < 0) { width = window.innerWidth + width }
|
||||||
|
|
||||||
var ui = can.page.Append(can, document.body, [{view: chat.TOAST, style: {
|
var ui = can.page.Append(can, document.body, [{view: chat.TOAST, style: {
|
||||||
left: (window.innerWidth-width)/2, width: width, bottom: 100,
|
left: (window.innerWidth-width)/2, width: width, bottom: 100,
|
||||||
}, list: [
|
}, list: [
|
||||||
{text: [meta.title||"", html.DIV, html.TITLE], title: "点击复制", onclick: function(event) {
|
{text: [meta.title||"", html.DIV, html.TITLE], title: "点击复制", onclick: function(event) {
|
||||||
can.user.copy(event, can, meta.title)
|
can.user.copy(event, can, meta.title)
|
||||||
}},
|
}},
|
||||||
{view: "duration", title: "点击关闭", onclick: function() { action.close() }},
|
{view: "duration", title: "点击关闭", onclick: function() { action.close() }},
|
||||||
can.base.isObject(meta.content)? meta.content: {text: [meta.content||"执行成功", html.DIV, "content"]},
|
can.base.isObject(meta.content)? meta.content: {text: [meta.content||"执行成功", html.DIV, "content"]},
|
||||||
|
|
||||||
{view: chat.ACTION}, meta.progress != undefined && {view: "progress", style: {width: width}, list: [
|
{view: chat.ACTION}, meta.progress != undefined && {view: "progress", style: {width: width}, list: [
|
||||||
{view: "current", style: {width: (meta.progress||0)/100*width}},
|
{view: "current", style: {width: (meta.progress||0)/100*width}},
|
||||||
]},
|
]},
|
||||||
] }])
|
] }])
|
||||||
|
|
||||||
var action = can.onappend._action(can, meta.action||[""], ui.action, {
|
var action = can.onappend._action(can, meta.action||[""], ui.action, {
|
||||||
close: function(event) { can.page.Remove(can, action._target), action.timer.stop = true },
|
close: function(event) { can.page.Remove(can, action._target), action.timer.stop = true },
|
||||||
timer: can.core.Timer({interval: 100, length: (parseInt(meta.duration||1000))/100}, function(event, interval, index) {
|
timer: can.core.Timer({interval: 100, length: (parseInt(meta.duration||1000))/100}, function(event, interval, index) {
|
||||||
if (index > 30) { ui.duration.innerHTML = parseInt(index/10)+ice.PT+(index%10)+"s..." }
|
if (index > 30) { ui.duration.innerHTML = parseInt(index/10)+ice.PT+(index%10)+"s..." }
|
||||||
}, function() { action.close() }), _target: ui._target, ui: ui,
|
}, function() { action.close() }), _target: ui._target, ui: ui,
|
||||||
}); can.onmotion.story.auto(can, ui._target)
|
}); can.onmotion.story.auto(can, ui._target)
|
||||||
|
|
||||||
can.onengine.signal(can, chat.ONTOAST, can.request({}, {
|
can.onengine.signal(can, chat.ONTOAST, can.request({}, {
|
||||||
title: meta.title, content: meta.content,
|
title: meta.title, content: meta.content,
|
||||||
time: can.base.Time(), fileline: can.misc.FileLine(2, 2),
|
time: can.base.Time(), fileline: can.misc.FileLine(2, 2),
|
||||||
}))
|
}))
|
||||||
return action
|
return action
|
||||||
},
|
},
|
||||||
share: function(can, msg, cmd) {
|
share: function(can, msg, cmd) {
|
||||||
can.run(msg._event, cmd||[ctx.ACTION, chat.SHARE], function(msg) {
|
can.run(msg._event, cmd||[ctx.ACTION, chat.SHARE], function(msg) {
|
||||||
can.user.toast(can, {height: 300, width: 500,
|
can.user.toast(can, {height: 300, width: 500,
|
||||||
title: msg.Append(mdb.NAME), duration: -1,
|
title: msg.Append(mdb.NAME), duration: -1,
|
||||||
content: msg.Append(mdb.TEXT), action: [cli.CLOSE],
|
content: msg.Append(mdb.TEXT), action: [cli.CLOSE],
|
||||||
}), can.user.copy(msg._event, can, msg.Append(mdb.NAME))
|
}), can.user.copy(msg._event, can, msg.Append(mdb.NAME))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
login: function(can, cb, method) {
|
login: function(can, cb, method) {
|
||||||
var ui = can.user.input({}, can, [
|
var ui = can.user.input({}, can, [
|
||||||
{type: html.USERNAME}, {type: html.PASSWORD},
|
{type: html.USERNAME}, {type: html.PASSWORD},
|
||||||
], function(event, button, data, list) { return {
|
], function(event, button, data, list) { return {
|
||||||
"登录": function() {
|
"登录": function() {
|
||||||
can.run({}, [aaa.LOGIN, data[html.USERNAME], data[html.PASSWORD]], function(msg) {
|
can.run({}, [aaa.LOGIN, data[html.USERNAME], data[html.PASSWORD]], function(msg) {
|
||||||
if (msg.Option(ice.MSG_USERNAME)) {
|
if (msg.Option(ice.MSG_USERNAME)) {
|
||||||
can.page.Remove(can, ui._target), can.base.isFunc(cb) && cb()
|
can.page.Remove(can, ui._target), can.base.isFunc(cb) && cb()
|
||||||
} else {
|
} else {
|
||||||
can.user.toast(can, "用户名或密码错误")
|
can.user.toast(can, "用户名或密码错误")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
"扫码": function() {
|
"扫码": function() {
|
||||||
can.misc.WSS(can, {type: html.CHROME, cmd: "pwd"}, function(event, msg, cmd, arg) { if (!msg) { return }
|
can.misc.WSS(can, {type: html.CHROME, cmd: "pwd"}, function(event, msg, cmd, arg) { if (!msg) { return }
|
||||||
if (cmd == "pwd") {
|
if (cmd == "pwd") {
|
||||||
return can.user.toast(can, arg[2], arg[1], -1), msg.Reply()
|
return can.user.toast(can, arg[2], arg[1], -1), msg.Reply()
|
||||||
}
|
}
|
||||||
if (cmd == ice.MSG_SESSID) {
|
if (cmd == ice.MSG_SESSID) {
|
||||||
return can.misc.CookieSessid(can, arg[0]), msg.Reply(), can.user.reload(true)
|
return can.misc.CookieSessid(can, arg[0]), msg.Reply(), can.user.reload(true)
|
||||||
}
|
}
|
||||||
can.search(event, msg[ice.MSG_DETAIL]||[], function(msg) { msg.Reply() })
|
can.search(event, msg[ice.MSG_DETAIL]||[], function(msg) { msg.Reply() })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"授权": function() {
|
"授权": function() {
|
||||||
can.misc.WSS(can, {type: html.CHROME, cmd: "sso", "user.web": location.href}, function(event, msg, cmd, arg) { if (!msg) { return }
|
can.misc.WSS(can, {type: html.CHROME, cmd: "sso", "user.web": location.href}, function(event, msg, cmd, arg) { if (!msg) { return }
|
||||||
if (cmd == "pwd") {
|
if (cmd == "pwd") {
|
||||||
return location.href = arg[1]
|
return location.href = arg[1]
|
||||||
}
|
}
|
||||||
if (cmd == ice.MSG_SESSID) {
|
if (cmd == ice.MSG_SESSID) {
|
||||||
return can.misc.CookieSessid(can, arg[0]), msg.Reply(), can.user.reload(true)
|
return can.misc.CookieSessid(can, arg[0]), msg.Reply(), can.user.reload(true)
|
||||||
}
|
}
|
||||||
can.search(event, msg[ice.MSG_DETAIL]||[], function(msg) { msg.Reply() })
|
can.search(event, msg[ice.MSG_DETAIL]||[], function(msg) { msg.Reply() })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"飞书": function() { location.href = "/chat/lark/sso" },
|
"飞书": function() { location.href = "/chat/lark/sso" },
|
||||||
}[button]() }, can.base.Obj(method, ["登录", "扫码", "授权"]))
|
}[button]() }, can.base.Obj(method, ["登录", "扫码", "授权"]))
|
||||||
|
|
||||||
can.page.Modify(can, ui._target, {className: "input login", style: {left: (window.innerWidth-ui._target.offsetWidth)/2, top: window.innerHeight/6}})
|
can.page.Modify(can, ui._target, {className: "input login", style: {left: (window.innerWidth-ui._target.offsetWidth)/2, top: window.innerHeight/6}})
|
||||||
},
|
},
|
||||||
logout: function(can, force) { if (force||can.user.confirm("logout?")) {
|
logout: function(can, force) { if (force||can.user.confirm("logout?")) {
|
||||||
can.run({}, [ctx.ACTION, aaa.LOGOUT], function(msg) {
|
can.run({}, [ctx.ACTION, aaa.LOGOUT], function(msg) {
|
||||||
can.misc.Search(can, chat.SHARE)? can.misc.Search(can, chat.SHARE, ""): can.user.reload(true)
|
can.misc.Search(can, chat.SHARE)? can.misc.Search(can, chat.SHARE, ""): can.user.reload(true)
|
||||||
})
|
})
|
||||||
} },
|
} },
|
||||||
|
|
||||||
toPNG: function(can, name, text, height, width) {
|
toPNG: function(can, name, text, height, width) {
|
||||||
if (text.indexOf("<svg") != 0) {
|
if (text.indexOf("<svg") != 0) {
|
||||||
text = '<svg xmlns="http://www.w3.org/2000/svg">'+text+"</svg>"
|
text = '<svg xmlns="http://www.w3.org/2000/svg">'+text+"</svg>"
|
||||||
}
|
}
|
||||||
var img = document.createElement(html.IMG)
|
var img = document.createElement(html.IMG)
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
var canvas = document.createElement("canvas")
|
var canvas = document.createElement("canvas")
|
||||||
canvas.height = height, canvas.width = width
|
canvas.height = height, canvas.width = width
|
||||||
canvas.getContext("2d").drawImage(img, 0, 0)
|
canvas.getContext("2d").drawImage(img, 0, 0)
|
||||||
|
|
||||||
var a = document.createElement("a")
|
var a = document.createElement("a")
|
||||||
a.href = canvas.toDataURL("image/png")
|
a.href = canvas.toDataURL("image/png")
|
||||||
a.download = name, a.click()
|
a.download = name, a.click()
|
||||||
}, img.src = "data:image/svg+xml,"+encodeURIComponent(text)
|
}, img.src = "data:image/svg+xml,"+encodeURIComponent(text)
|
||||||
},
|
},
|
||||||
copy: function(event, can, text) {
|
copy: function(event, can, text) {
|
||||||
if (navigator.clipboard) { var ok = false
|
if (navigator.clipboard) { var ok = false
|
||||||
navigator.clipboard.writeText(text).then(function() { ok = true })
|
navigator.clipboard.writeText(text).then(function() { ok = true })
|
||||||
if (ok) { return can.user.toastSuccess(can) }
|
if (ok) { return can.user.toastSuccess(can) }
|
||||||
}
|
}
|
||||||
|
|
||||||
var input = can.page.Append(can, event.target.parentNode, [{type: html.TEXTAREA, value: text}]).first
|
var input = can.page.Append(can, event.target.parentNode, [{type: html.TEXTAREA, value: text}]).first
|
||||||
can.onmotion.focus(can, input), document.execCommand("Copy")
|
can.onmotion.focus(can, input), document.execCommand("Copy")
|
||||||
can.page.Remove(can, input), can.user.toastSuccess(can)
|
can.page.Remove(can, input), can.user.toastSuccess(can)
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
can.misc.Log("copy", text)
|
can.misc.Log("copy", text)
|
||||||
return text
|
return text
|
||||||
},
|
},
|
||||||
carte: function(event, can, meta, list, cb, parent) {
|
carte: function(event, can, meta, list, cb, parent) {
|
||||||
meta = meta||can.ondetail||can.onaction||{}, list = list&&list.length > 0? list: meta.list||[]; if (list.length == 0) { return }
|
meta = meta||can.ondetail||can.onaction||{}, list = list&&list.length > 0? list: meta.list||[]; if (list.length == 0) { return }
|
||||||
cb = cb||function(event, item, meta) { var cb = meta[item]||meta["_engine"]; can.base.isFunc(cb) && cb(event, can, item) }
|
cb = cb||function(event, item, meta) { var cb = meta[item]||meta["_engine"]; can.base.isFunc(cb) && cb(event, can, item) }
|
||||||
|
|
||||||
var ui = can.page.Append(can, document.body, [{view: chat.CARTE, style: {left: 0, top: 0}, onmouseleave: function(event) {
|
var ui = can.page.Append(can, document.body, [{view: chat.CARTE, style: {left: 0, top: 0}, onmouseleave: function(event) {
|
||||||
// can.page.Remove(can, ui._target)
|
// can.page.Remove(can, ui._target)
|
||||||
}, list: can.core.List(list, function(item, index) {
|
}, list: can.core.List(list, function(item, index) {
|
||||||
return can.base.isString(item)? {view: html.ITEM, list: [{text: can.user.trans(can, item), click: function(event) {
|
return can.base.isString(item)? {view: html.ITEM, list: [{text: can.user.trans(can, item), click: function(event) {
|
||||||
can.user.isMobile && can.page.Remove(can, ui._target)
|
can.user.isMobile && can.page.Remove(can, ui._target)
|
||||||
can.base.isFunc(cb) && cb(event, item, meta, index)
|
can.base.isFunc(cb) && cb(event, item, meta, index)
|
||||||
}, onmouseenter: function(event) {
|
}, onmouseenter: function(event) {
|
||||||
carte._float && can.page.Remove(can, carte._float._target)
|
carte._float && can.page.Remove(can, carte._float._target)
|
||||||
} }] }: {view: html.ITEM, list: [{text: can.user.trans(can, item[0])}], onmouseenter: function(event) {
|
} }] }: {view: html.ITEM, list: [{text: can.user.trans(can, item[0])}], onmouseenter: function(event) {
|
||||||
var sub = can.user.carte(event, can, meta, item.slice(1), cb, carte)
|
var sub = can.user.carte(event, can, meta, item.slice(1), cb, carte)
|
||||||
carte._float && can.page.Remove(can, carte._float._target), carte._float = sub
|
carte._float && can.page.Remove(can, carte._float._target), carte._float = sub
|
||||||
can.onlayout.figure(event, can, sub._target, true)
|
can.onlayout.figure(event, can, sub._target, true)
|
||||||
} }
|
} }
|
||||||
}) }] ); can.onlayout.figure(event, can, ui._target)
|
}) }] ); can.onlayout.figure(event, can, ui._target)
|
||||||
|
|
||||||
var carte = {_target: ui._target, _parent: parent}
|
var carte = {_target: ui._target, _parent: parent}
|
||||||
null && can.onmotion.float.add(can, chat.CARTE, carte)
|
null && can.onmotion.float.add(can, chat.CARTE, carte)
|
||||||
ui._target.onmouseover = function(event) {
|
ui._target.onmouseover = function(event) {
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
}
|
}
|
||||||
return can.onkeymap.prevent(event), carte
|
return can.onkeymap.prevent(event), carte
|
||||||
},
|
},
|
||||||
carteRight: function(event, can, meta, list, cb, parent) {
|
carteRight: function(event, can, meta, list, cb, parent) {
|
||||||
var carte = can.user.carte(event, can, meta, list, cb, parent)
|
var carte = can.user.carte(event, can, meta, list, cb, parent)
|
||||||
can.page.Modify(can, carte._target, {style: {
|
can.page.Modify(can, carte._target, {style: {
|
||||||
left: event.clientX-event.offsetX+event.target.offsetWidth-3,
|
left: event.clientX-event.offsetX+event.target.offsetWidth-3,
|
||||||
top: carte._target.offsetTop-event.target.offsetHeight+5,
|
top: carte._target.offsetTop-event.target.offsetHeight+5,
|
||||||
}})
|
}})
|
||||||
return carte
|
return carte
|
||||||
},
|
},
|
||||||
carteClient: function(event, can, meta, list, cb, parent) {
|
carteClient: function(event, can, meta, list, cb, parent) {
|
||||||
var ui = can.user.carte(event, can, meta, list, cb, parent)
|
var ui = can.user.carte(event, can, meta, list, cb, parent)
|
||||||
can.page.Modify(can, ui._target, {style: {left: event.clientX, top: event.clientY}})
|
can.page.Modify(can, ui._target, {style: {left: event.clientX, top: event.clientY}})
|
||||||
},
|
},
|
||||||
|
|
||||||
input: function(event, can, form, cb, button) { if (!form || form.length == 0) { return cb() }
|
input: function(event, can, form, cb, button) { if (!form || form.length == 0) { return cb() }
|
||||||
var msg = can.request(event)
|
var msg = can.request(event)
|
||||||
var ui = can.page.Append(can, document.body, [{view: [html.INPUT], style: {left: 0, top: 0}, list: [
|
var ui = can.page.Append(can, document.body, [{view: [html.INPUT], style: {left: 0, top: 0}, list: [
|
||||||
{view: [chat.OPTION, html.TABLE], list: can.core.List(form, function(item) {
|
{view: [chat.OPTION, html.TABLE], list: can.core.List(form, function(item) {
|
||||||
item = can.base.isString(item)? {type: html.TEXT, name: item}: item.length > 0? {type: html.SELECT, name: item[0], values: item.slice(1)}: item
|
item = can.base.isString(item)? {type: html.TEXT, name: item}: item.length > 0? {type: html.SELECT, name: item[0], values: item.slice(1)}: item
|
||||||
item.type = item.type||(item.values? html.SELECT: item.name == html.TEXT? html.TEXTAREA: html.TEXT)
|
item.type = item.type||(item.values? html.SELECT: item.name == html.TEXT? html.TEXTAREA: html.TEXT)
|
||||||
|
|
||||||
item._init = function(target) {
|
item._init = function(target) {
|
||||||
item.run = function(event, cmds, cb) {
|
item.run = function(event, cmds, cb) {
|
||||||
can.request(event, function() { var value = {_handle: ice.TRUE, action: msg.Option(chat.ACTION)}
|
can.request(event, function() { var value = {_handle: ice.TRUE, action: msg.Option(chat.ACTION)}
|
||||||
can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
||||||
item.name && item.value && (value[item.name] = item.value)
|
item.name && item.value && (value[item.name] = item.value)
|
||||||
}); return value
|
}); return value
|
||||||
}, msg, can.Option()), can.run(event, cmds, cb, true)
|
}, msg, can.Option()), can.run(event, cmds, cb, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
target.value = target.value||(item.name&&(msg.Option(item.name)||can.Option(item.name)))||""
|
target.value = target.value||(item.name&&(msg.Option(item.name)||can.Option(item.name)))||""
|
||||||
can.onappend.figure(can, item, target)
|
can.onappend.figure(can, item, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {type: html.TR, list: [{type: html.TD, list: [{text: item._trans||can.user.trans(can, item.name)||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]}
|
return {type: html.TR, list: [{type: html.TD, list: [{text: item._trans||can.user.trans(can, item.name)||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]}
|
||||||
})}, {view: chat.ACTION},
|
})}, {view: chat.ACTION},
|
||||||
]}]);
|
]}]);
|
||||||
var layout = can.onlayout.figure(event, can, ui._target)
|
var layout = can.onlayout.figure(event, can, ui._target)
|
||||||
if (layout.left == undefined) { if (!layout.top) { layout.top = 32 }
|
if (layout.left == undefined) { if (!layout.top) { layout.top = 32 }
|
||||||
layout.left = window.innerWidth/2-ui._target.offsetWidth/2
|
layout.left = window.innerWidth/2-ui._target.offsetWidth/2
|
||||||
layout.right = ""
|
layout.right = ""
|
||||||
can.page.style(can, ui._target, layout)
|
can.page.style(can, ui._target, layout)
|
||||||
}
|
}
|
||||||
can.page.ClassList.add(can, ui._target, chat.FLOAT)
|
can.page.ClassList.add(can, ui._target, chat.FLOAT)
|
||||||
|
|
||||||
var action = can.onappend._action(can, button||[html.SUBMIT, html.CANCEL], ui.action, {
|
var action = can.onappend._action(can, button||[html.SUBMIT, html.CANCEL], ui.action, {
|
||||||
cancel: function(event) { can.page.Remove(can, ui._target) },
|
cancel: function(event) { can.page.Remove(can, ui._target) },
|
||||||
_engine: function(event, can, button) { action.submit(event, can, button) },
|
_engine: function(event, can, button) { action.submit(event, can, button) },
|
||||||
submit: function(event, can, button) { var data = {}, args = [], list = []
|
submit: function(event, can, button) { var data = {}, args = [], list = []
|
||||||
list = can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
list = can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
||||||
return item.name && item.value && args.push(item.name, item.value), data[item.name] = item.value
|
return item.name && item.value && args.push(item.name, item.value), data[item.name] = item.value
|
||||||
})
|
})
|
||||||
var msg = can.request(event, {_handle: ice.TRUE})
|
var msg = can.request(event, {_handle: ice.TRUE})
|
||||||
can.base.isFunc(cb) && !cb(event, button, data, list, args) && action.cancel()
|
can.base.isFunc(cb) && !cb(event, button, data, list, args) && action.cancel()
|
||||||
}, _target: ui._target,
|
}, _target: ui._target,
|
||||||
})
|
})
|
||||||
if (button === true) {
|
if (button === true) {
|
||||||
action.submit(event, can, "submit")
|
action.submit(event, can, "submit")
|
||||||
return action
|
return action
|
||||||
}
|
}
|
||||||
|
|
||||||
can.page.Select(can, ui._target, html.INPUT_ARGS, function(item, index) {
|
can.page.Select(can, ui._target, html.INPUT_ARGS, function(item, index) {
|
||||||
index == 0 && can.core.Timer(100, function() { can.onmotion.focus(can, item) })
|
index == 0 && can.core.Timer(100, function() { can.onmotion.focus(can, item) })
|
||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
},
|
},
|
||||||
select: function(event, can, type, fields, cb, cbs) {
|
select: function(event, can, type, fields, cb, cbs) {
|
||||||
var msg = can.request(event, {fields: fields||"type,name,text"})
|
var msg = can.request(event, {fields: fields||"type,name,text"})
|
||||||
can.search(msg._event, ["Search.onimport.select", type, "", ""], function(list) {
|
can.search(msg._event, ["Search.onimport.select", type, "", ""], function(list) {
|
||||||
can.core.Next(list, cb, cbs||function() {
|
can.core.Next(list, cb, cbs||function() {
|
||||||
can.user.toastSuccess(can)
|
can.user.toastSuccess(can)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
upload: function(event, can) { var begin = new Date()
|
upload: function(event, can) { var begin = new Date()
|
||||||
var ui = can.page.Append(can, document.body, [{view: html.UPLOAD, style: {left: 0, top: 0}, list: [
|
var ui = can.page.Append(can, document.body, [{view: html.UPLOAD, style: {left: 0, top: 0}, list: [
|
||||||
{view: html.ACTION}, {view: html.OUTPUT, list: [{view: "progress"}]},
|
{view: html.ACTION}, {view: html.OUTPUT, list: [{view: "progress"}]},
|
||||||
{view: html.STATUS, list: [{view: html.SHOW}, {view: "cost"}, {view: "size"}]},
|
{view: html.STATUS, list: [{view: html.SHOW}, {view: "cost"}, {view: "size"}]},
|
||||||
]}]); can.onlayout.figure(event, can, ui._target)
|
]}]); can.onlayout.figure(event, can, ui._target)
|
||||||
|
|
||||||
var action = can.onappend._action(can, [
|
var action = can.onappend._action(can, [
|
||||||
{type: html.UPLOAD, onchange: function(event) {
|
{type: html.UPLOAD, onchange: function(event) {
|
||||||
action.show(event, 0, event.target.files[0].size, 0)
|
action.show(event, 0, event.target.files[0].size, 0)
|
||||||
}}, cli.CLOSE,
|
}}, cli.CLOSE,
|
||||||
], ui.action, {
|
], ui.action, {
|
||||||
close: function(event) { can.page.Remove(can, ui._target) },
|
close: function(event) { can.page.Remove(can, ui._target) },
|
||||||
begin: function(event) { begin = new Date()
|
begin: function(event) { begin = new Date()
|
||||||
var upload = can.page.Select(can, ui.action, "input[type=file]")
|
var upload = can.page.Select(can, ui.action, "input[type=file]")
|
||||||
if (upload[0].files.length == 0) { return upload[0].focus() }
|
if (upload[0].files.length == 0) { return upload[0].focus() }
|
||||||
|
|
||||||
var msg = can.request(event, can.Option(), {_handle: "true"})
|
var msg = can.request(event, can.Option(), {_handle: "true"})
|
||||||
msg._upload = upload[0].files[0], msg._progress = action.show
|
msg._upload = upload[0].files[0], msg._progress = action.show
|
||||||
|
|
||||||
can.run(event, [ctx.ACTION, html.UPLOAD], function(msg) {
|
can.run(event, [ctx.ACTION, html.UPLOAD], function(msg) {
|
||||||
can.user.toastSuccess(can), can.Update(), action.close()
|
can.user.toastSuccess(can), can.Update(), action.close()
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
show: function (event, value, total, loaded) { now = new Date()
|
show: function (event, value, total, loaded) { now = new Date()
|
||||||
value == 0 && action.begin(event)
|
value == 0 && action.begin(event)
|
||||||
|
|
||||||
ui.show.innerHTML = value+"%"
|
ui.show.innerHTML = value+"%"
|
||||||
ui.cost.innerHTML = can.base.Duration(now - begin)
|
ui.cost.innerHTML = can.base.Duration(now - begin)
|
||||||
ui.size.innerHTML = can.base.Size(loaded)+ice.PS+can.base.Size(total)
|
ui.size.innerHTML = can.base.Size(loaded)+ice.PS+can.base.Size(total)
|
||||||
can.page.Modify(can, ui.progress, {style: {width: value*(ui.output.offsetWidth-2)/100}})
|
can.page.Modify(can, ui.progress, {style: {width: value*(ui.output.offsetWidth-2)/100}})
|
||||||
},
|
},
|
||||||
}); can.page.Select(can, ui.action, "input[type=file]")[0].click()
|
}); can.page.Select(can, ui.action, "input[type=file]")[0].click()
|
||||||
|
|
||||||
return action
|
return action
|
||||||
},
|
},
|
||||||
download: function(can, path, name) {
|
download: function(can, path, name) {
|
||||||
var a = can.page.Append(can, document.body, [{type: html.A, href: path, download: name||path.split(ice.PS).pop()}]).first
|
var a = can.page.Append(can, document.body, [{type: html.A, href: path, download: name||path.split(ice.PS).pop()}]).first
|
||||||
a.click(), can.page.Remove(can, a)
|
a.click(), can.page.Remove(can, a)
|
||||||
},
|
},
|
||||||
downloads: function(can, text, name) { can.user.download(can, URL.createObjectURL(new Blob([text])), name) },
|
downloads: function(can, text, name) { can.user.download(can, URL.createObjectURL(new Blob([text])), name) },
|
||||||
camera: function(can, msg, cb) {
|
camera: function(can, msg, cb) {
|
||||||
navigator.getUserMedia({video: true}, cb, function(error) {
|
navigator.getUserMedia({video: true}, cb, function(error) {
|
||||||
can.misc.Log(error)
|
can.misc.Log(error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ body.white table.content tr:hover { background-color:green; }
|
|||||||
body.white fieldset.Action fieldset.plugin legend:hover { background-color:#6ee4e4; }
|
body.white fieldset.Action fieldset.plugin legend:hover { background-color:#6ee4e4; }
|
||||||
body.print fieldset.River>div.output div.item.select { background-color:white; border:solid 2px red; }
|
body.print fieldset.River>div.output div.item.select { background-color:white; border:solid 2px red; }
|
||||||
|
|
||||||
body.mobile select { font-size:1.6rem; height:1.6em; }
|
body.mobile select { font-size:1.4rem; height:1.4em; margin-top:3px; }
|
||||||
body.mobile legend { font-size:2rem; }
|
body.mobile legend { font-size:2rem; }
|
||||||
body.mobile input { font-size:1.6rem; }
|
body.mobile input { font-size:1.2rem; }
|
||||||
body.mobile input[type=text] { margin-top:5px; height:1.2em; }
|
body.mobile input[type=text] { margin-top:5px; height:1.2em; }
|
||||||
body.mobile fieldset.Header.head { width:-webkit-fill-available; }
|
body.mobile fieldset.Header.head { width:-webkit-fill-available; }
|
||||||
body.mobile fieldset.Header.head { background-color:#000000b8; font-size:2rem; height:2em; position:fixed; top:0; }
|
body.mobile fieldset.Header.head { background-color:#000000b8; font-size:2rem; height:2em; position:fixed; top:0; }
|
||||||
|
235
page/index.js
235
page/index.js
@ -1,119 +1,118 @@
|
|||||||
Volcanos({name: "chat", panels: [
|
Volcanos({name: "chat", panels: [
|
||||||
{name: "Header", help: "标题栏", pos: chat.HEAD, state: ["time", "usernick", "avatar"]},
|
{name: "Header", help: "标题栏", pos: chat.HEAD, state: ["time", "usernick", "avatar"]},
|
||||||
{name: "River", help: "群聊组", pos: chat.LEFT, action: ["create", "refresh"]},
|
{name: "River", help: "群聊组", pos: chat.LEFT, action: ["create", "refresh"]},
|
||||||
{name: "Action", help: "工作台", pos: chat.MAIN},
|
{name: "Action", help: "工作台", pos: chat.MAIN},
|
||||||
{name: "Footer", help: "状态条", pos: chat.FOOT, state: ["ncmd"]},
|
{name: "Footer", help: "状态条", pos: chat.FOOT, state: ["ncmd"]},
|
||||||
{name: "Search", help: "搜索框", pos: chat.AUTO},
|
{name: "Search", help: "搜索框", pos: chat.AUTO},
|
||||||
], main: {name: "Header", list: ["/publish/order.js"]}, river: {
|
], main: {name: "Header", list: ["/publish/order.js"]}, river: {
|
||||||
serivce: {name: "运营群", storm: {
|
serivce: {name: "运营群", storm: {
|
||||||
wx: {name: "公众号 wx", list: [
|
wx: {name: "公众号 wx", list: [
|
||||||
{name: "微信公众号", help: "wx", index: "web.wiki.word", args: ["usr/icebergs/misc/wx/wx.shy"]},
|
{name: "微信公众号", help: "wx", index: "web.wiki.word", args: ["usr/icebergs/misc/wx/wx.shy"]},
|
||||||
]},
|
]},
|
||||||
mp: {name: "小程序 mp", list: [
|
mp: {name: "小程序 mp", list: [
|
||||||
{name: "微信小程序", help: "mp", index: "web.wiki.word", args: ["usr/icebergs/misc/mp/mp.shy"]},
|
{name: "微信小程序", help: "mp", index: "web.wiki.word", args: ["usr/icebergs/misc/mp/mp.shy"]},
|
||||||
]},
|
]},
|
||||||
lark: {name: "机器人 lark", list: [
|
lark: {name: "机器人 lark", list: [
|
||||||
{name: "飞书机器人", help: "lark", index: "web.wiki.word", args: ["usr/icebergs/misc/lark/lark.shy"]},
|
{name: "飞书机器人", help: "lark", index: "web.wiki.word", args: ["usr/icebergs/misc/lark/lark.shy"]},
|
||||||
]},
|
]},
|
||||||
}},
|
}},
|
||||||
product: {name: "产品群", storm: {
|
product: {name: "产品群", storm: {
|
||||||
office: {name: "办公 office", list: [
|
office: {name: "办公 office", list: [
|
||||||
{name: "feel", help: "影音媒体", index: "web.wiki.feel"},
|
{name: "feel", help: "影音媒体", index: "web.wiki.feel"},
|
||||||
{name: "draw", help: "思维导图", index: "web.wiki.draw"},
|
{name: "draw", help: "思维导图", index: "web.wiki.draw"},
|
||||||
{name: "data", help: "数据表格", index: "web.wiki.data"},
|
{name: "data", help: "数据表格", index: "web.wiki.data"},
|
||||||
{name: "plan", help: "计划任务", index: "web.team.plan"},
|
{name: "plan", help: "计划任务", index: "web.team.plan"},
|
||||||
{name: "think", help: "智库", index: "web.wiki.word", args: ["usr/learning/"]},
|
{name: "think", help: "智库", index: "web.wiki.word", args: ["usr/learning/"]},
|
||||||
{name: "index", help: "索引", index: "web.wiki.word", args: ["usr/learning/index.shy"]},
|
{name: "index", help: "索引", index: "web.wiki.word", args: ["usr/learning/index.shy"]},
|
||||||
{name: "context", help: "编程", index: "web.wiki.word", args: ["src/main.shy"]},
|
{name: "context", help: "编程", index: "web.wiki.word", args: ["src/main.shy"]},
|
||||||
]},
|
]},
|
||||||
english: {name: "英汉 english", list: [
|
english: {name: "英汉 english", list: [
|
||||||
{name: "english", help: "英汉", index: "web.wiki.alpha.alpha", args: ["word", "hi"]},
|
{name: "english", help: "英汉", index: "web.wiki.alpha.alpha", args: ["word", "hi"]},
|
||||||
{name: "chinese", help: "汉英", index: "web.wiki.alpha.alpha", args: ["line", "你好"]},
|
{name: "chinese", help: "汉英", index: "web.wiki.alpha.alpha", args: ["line", "你好"]},
|
||||||
{name: "wubi", help: "五笔", index: "web.code.input.wubi", args: ["word", "wqvb"]},
|
{name: "wubi", help: "五笔", index: "web.code.input.wubi", args: ["word", "wqvb"]},
|
||||||
{name: "wubi", help: "五笔", index: "web.code.input.wubi", args: ["line", "你好"]},
|
{name: "wubi", help: "五笔", index: "web.code.input.wubi", args: ["line", "你好"]},
|
||||||
]},
|
]},
|
||||||
learning: {name: "学习 learning", list: [
|
learning: {name: "学习 learning", list: [
|
||||||
{name: "golang", help: "编程", index: "web.wiki.word", args: ["usr/golang-story/src/main.shy"]},
|
{name: "golang", help: "编程", index: "web.wiki.word", args: ["usr/golang-story/src/main.shy"]},
|
||||||
{name: "tmux", help: "粘贴", index: "web.code.tmux.text"},
|
{name: "tmux", help: "粘贴", index: "web.code.tmux.text"},
|
||||||
{name: "study", help: "学习", index: "web.wiki.word", args: ["usr/learning/study.shy"]},
|
{name: "study", help: "学习", index: "web.wiki.word", args: ["usr/learning/study.shy"]},
|
||||||
]},
|
]},
|
||||||
chrome: {name: "爬虫 chrome", list: [
|
chrome: {name: "爬虫 chrome", list: [
|
||||||
{name: "feel", help: "网页爬虫", index: "web.wiki.feel", args: ["spide/"], feature: {
|
{name: "feel", help: "网页爬虫", index: "web.wiki.feel", args: ["spide/"], feature: {
|
||||||
display: "/plugin/local/wiki/feel.js",
|
display: "/plugin/local/wiki/feel.js",
|
||||||
height: 200, limit: 3,
|
height: 200, limit: 3,
|
||||||
}},
|
}},
|
||||||
{name: "cached", help: "爬虫缓存", index: "web.code.chrome.cache", args: []},
|
{name: "cached", help: "爬虫缓存", index: "web.code.chrome.cache", args: []},
|
||||||
{name: "spided", help: "网页爬虫", index: "web.code.chrome.spide", args: location && location.protocol && location.protocol=="chrome-extension:"? ["1", "", "spide"]: ["1"]},
|
{name: "spided", help: "网页爬虫", index: "web.code.chrome.spide", args: location && location.protocol && location.protocol=="chrome-extension:"? ["1", "", "spide"]: ["1"]},
|
||||||
{name: "modify", help: "编辑页面", index: "web.code.chrome.modify", args: []},
|
{name: "modify", help: "编辑页面", index: "web.code.chrome.modify", args: []},
|
||||||
]},
|
]},
|
||||||
}},
|
}},
|
||||||
project: {name: "研发群", storm: {
|
project: {name: "研发群", storm: {
|
||||||
studio: {name: "研发 studio", list: [
|
studio: {name: "研发 studio", list: [
|
||||||
{name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"], _action: ["autogen", "compile", "binpack"]},
|
{name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"], _action: ["autogen", "compile", "binpack"]},
|
||||||
{name: "repos", help: "代码库", index: "web.code.git.status"},
|
{name: "repos", help: "代码库", index: "web.code.git.status"},
|
||||||
{name: "plan", help: "任务表", index: "web.team.plan"},
|
{name: "plan", help: "任务表", index: "web.team.plan"},
|
||||||
{name: "ctx", help: "上下文", index: "web.wiki.word", args: ["src/main.shy"]},
|
{name: "ctx", help: "上下文", index: "web.wiki.word", args: ["src/main.shy"]},
|
||||||
]},
|
]},
|
||||||
web: {name: "网页 web", list: [
|
web: {name: "网页 web", list: [
|
||||||
{name: "HTML5", help: "浏览器", index: "web.wiki.word", args: ["usr/icebergs/misc/chrome/chrome.shy"]},
|
{name: "HTML5", help: "浏览器", index: "web.wiki.word", args: ["usr/icebergs/misc/chrome/chrome.shy"]},
|
||||||
]},
|
]},
|
||||||
cli: {name: "命令 cli", list: [
|
cli: {name: "命令 cli", list: [
|
||||||
{name: "bash", help: "命令行", index: "web.wiki.word", args: ["usr/icebergs/misc/bash/bash.shy"]},
|
{name: "bash", help: "命令行", index: "web.wiki.word", args: ["usr/icebergs/misc/bash/bash.shy"]},
|
||||||
{name: "git", help: "代码库", index: "web.wiki.word", args: ["usr/icebergs/misc/git/git.shy"]},
|
{name: "git", help: "代码库", index: "web.wiki.word", args: ["usr/icebergs/misc/git/git.shy"]},
|
||||||
{name: "vim", help: "编辑器", index: "web.wiki.word", args: ["usr/icebergs/misc/vim/vim.shy"]},
|
{name: "vim", help: "编辑器", index: "web.wiki.word", args: ["usr/icebergs/misc/vim/vim.shy"]},
|
||||||
{name: "tmux", help: "命令行", index: "web.wiki.word", args: ["usr/icebergs/misc/tmux/tmux.shy"]},
|
{name: "tmux", help: "命令行", index: "web.wiki.word", args: ["usr/icebergs/misc/tmux/tmux.shy"]},
|
||||||
]},
|
]},
|
||||||
linux: {name: "系统 linux", list: [
|
linux: {name: "系统 linux", list: [
|
||||||
{name: "idc", help: "平台", index: "web.wiki.word", args: ["usr/linux-story/idc/idc.shy"]},
|
{name: "idc", help: "平台", index: "web.wiki.word", args: ["usr/linux-story/idc/idc.shy"]},
|
||||||
{name: "iso", help: "系统", index: "web.wiki.word", args: ["usr/linux-story/iso/iso.shy"]},
|
{name: "iso", help: "系统", index: "web.wiki.word", args: ["usr/linux-story/iso/iso.shy"]},
|
||||||
{name: "iot", help: "设备", index: "web.wiki.word", args: ["usr/linux-story/iot/iot.shy"]},
|
{name: "iot", help: "设备", index: "web.wiki.word", args: ["usr/linux-story/iot/iot.shy"]},
|
||||||
{name: "cli", help: "命令", index: "web.wiki.word", args: ["usr/linux-story/cli/cli.shy"]},
|
{name: "cli", help: "命令", index: "web.wiki.word", args: ["usr/linux-story/cli/cli.shy"]},
|
||||||
{name: "linux", help: "系统", index: "web.wiki.word", args: ["usr/linux-story/src/main.shy"]},
|
{name: "linux", help: "系统", index: "web.wiki.word", args: ["usr/linux-story/src/main.shy"]},
|
||||||
]},
|
]},
|
||||||
nginx: {name: "代理 nginx", list: [
|
nginx: {name: "代理 nginx", list: [
|
||||||
{name: "nginx", help: "代理", index: "web.wiki.word", args: ["usr/nginx-story/src/main.shy"]},
|
{name: "nginx", help: "代理", index: "web.wiki.word", args: ["usr/nginx-story/src/main.shy"]},
|
||||||
]},
|
]},
|
||||||
context: {name: "编程 context", list: [
|
context: {name: "编程 context", list: [
|
||||||
{name: "golang", help: "编程", index: "web.wiki.word", args: ["usr/golang-story/src/main.shy"]},
|
{name: "golang", help: "编程", index: "web.wiki.word", args: ["usr/golang-story/src/main.shy"]},
|
||||||
]},
|
]},
|
||||||
redis: {name: "缓存 redis", list: [
|
redis: {name: "缓存 redis", list: [
|
||||||
{name: "redis", help: "缓存", index: "web.wiki.word", args: ["usr/redis-story/src/main.shy"]},
|
{name: "redis", help: "缓存", index: "web.wiki.word", args: ["usr/redis-story/src/main.shy"]},
|
||||||
{name: "kafka", help: "队列", index: "web.wiki.word", args: ["usr/redis-story/src/kafka/kafka.shy"]},
|
{name: "kafka", help: "队列", index: "web.wiki.word", args: ["usr/redis-story/src/kafka/kafka.shy"]},
|
||||||
]},
|
]},
|
||||||
mysql: {name: "存储 mysql", list: [
|
mysql: {name: "存储 mysql", list: [
|
||||||
{name: "mysql", help: "数据存储", index: "web.wiki.word", args: ["usr/mysql-story/src/main.shy"]},
|
{name: "mysql", help: "数据存储", index: "web.wiki.word", args: ["usr/mysql-story/src/main.shy"]},
|
||||||
{name: "clickhouse", help: "数据存储", index: "web.wiki.word", args: ["usr/mysql-story/src/clickhouse/clickhouse.shy"]},
|
{name: "clickhouse", help: "数据存储", index: "web.wiki.word", args: ["usr/mysql-story/src/clickhouse/clickhouse.shy"]},
|
||||||
]},
|
]},
|
||||||
}},
|
}},
|
||||||
profile: {name: "测试群", storm: {
|
profile: {name: "测试群", storm: {
|
||||||
website: {name: "定制 website", index: [
|
website: {name: "定制 website", index: [
|
||||||
"web.chat.website",
|
"web.chat.website",
|
||||||
"web.chat.div",
|
"web.chat.div",
|
||||||
"web.code.vimer",
|
"web.code.vimer",
|
||||||
"web.dream",
|
"web.dream",
|
||||||
]},
|
]},
|
||||||
release: {name: "发布 release", index: [
|
release: {name: "发布 release", index: [
|
||||||
"web.code.publish", "web.code.compile", "web.code.autogen", "web.code.git.server",
|
"web.code.publish", "web.code.compile", "web.code.autogen", "web.code.git.server",
|
||||||
]},
|
]},
|
||||||
research: {name: "测试 research", index: [
|
research: {name: "测试 research", index: [
|
||||||
"web.code.favor", "web.code.bench", "web.code.pprof",
|
"web.code.favor", "web.code.bench", "web.code.pprof",
|
||||||
"web.code.case",
|
"web.code.case",
|
||||||
]},
|
]},
|
||||||
}},
|
}},
|
||||||
operate: {name: "运维群", storm: {
|
operate: {name: "运维群", storm: {
|
||||||
aaa: {name: "权限 aaa", index: [
|
aaa: {name: "权限 aaa", index: [
|
||||||
"user", "totp", "sess", "role",
|
"user", "totp", "sess", "role",
|
||||||
]},
|
]},
|
||||||
web: {name: "应用 web", index: [
|
web: {name: "应用 web", index: [
|
||||||
"serve", "space", "dream", "route",
|
"serve", "space", "dream", "route",
|
||||||
"share", "spide", "cache", "story",
|
"share", "spide", "cache", "story",
|
||||||
]},
|
]},
|
||||||
cli: {name: "系统 cli", index: [
|
cli: {name: "系统 cli", index: [
|
||||||
"qrcode", "daemon", "system", "runtime",
|
"qrcode", "daemon", "system", "runtime",
|
||||||
]},
|
]},
|
||||||
nfs: {name: "文件 nfs", index: [
|
nfs: {name: "文件 nfs", index: [
|
||||||
"cat", "dir", "tail", "trash",
|
"cat", "dir", "tail", "trash",
|
||||||
]},
|
]},
|
||||||
}},
|
}},
|
||||||
},
|
}})
|
||||||
})
|
|
||||||
|
443
panel/action.js
443
panel/action.js
@ -1,250 +1,249 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg) {
|
||||||
var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM)
|
var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM)
|
||||||
can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) {
|
can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) {
|
||||||
item.height = can.Conf(html.HEIGHT)-can.Conf(html.MARGIN_Y)
|
item.height = can.Conf(html.HEIGHT)-can.Conf(html.MARGIN_Y)
|
||||||
item.width = can.Conf(html.WIDTH)-can.Conf(html.MARGIN_X)
|
item.width = can.Conf(html.WIDTH)-can.Conf(html.MARGIN_X)
|
||||||
item.feature = can.base.Obj(item.feature||item.meta)
|
item.feature = can.base.Obj(item.feature||item.meta)
|
||||||
item.inputs = can.base.Obj(item.inputs||item.list)
|
item.inputs = can.base.Obj(item.inputs||item.list)
|
||||||
|
|
||||||
can.onappend.plugin(can, item, function(sub, meta, skip) {
|
can.onappend.plugin(can, item, function(sub, meta, skip) {
|
||||||
can.onimport._plugin(can, river, storm, sub, meta), skip || next()
|
can.onimport._plugin(can, river, storm, sub, meta), skip || next()
|
||||||
})
|
})
|
||||||
}, function() { can.onimport._menu(can, msg), can.onkeymap._init(can)
|
}, function() { can.onimport._menu(can, msg), can.onkeymap._init(can)
|
||||||
can.onaction.onstorm_select(can, msg, river, storm)
|
can.onaction.onstorm_select(can, msg, river, storm)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_plugin: function(can, river, storm, sub, meta) { sub._target._meta = meta
|
_plugin: function(can, river, storm, sub, meta) { sub._target._meta = meta
|
||||||
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
|
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
|
||||||
return can.run(event, can.misc.concat(can, [river, storm, meta.id||meta.index], cmds), function(msg) {
|
return can.run(event, can.misc.concat(can, [river, storm, meta.id||meta.index], cmds), function(msg) {
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
})
|
})
|
||||||
}, can._plugins = can.misc.concat(can, can._plugins, [sub])
|
}, can._plugins = can.misc.concat(can, can._plugins, [sub])
|
||||||
|
|
||||||
meta.id && (sub._option.dataset = sub._option.dataset||{}, sub._option.dataset.id = meta.id)
|
meta.id && (sub._option.dataset = sub._option.dataset||{}, sub._option.dataset.id = meta.id)
|
||||||
|
|
||||||
can.page.Modify(can, sub._output, {style: kit.Dict(html.MAX_WIDTH, meta.width)})
|
can.page.Modify(can, sub._output, {style: kit.Dict(html.MAX_WIDTH, meta.width)})
|
||||||
can.page.Append(can, can._action, [{view: [chat.TABS, html.DIV, meta.name], onclick: function(event) {
|
can.page.Append(can, can._action, [{view: [chat.TABS, html.DIV, meta.name], onclick: function(event) {
|
||||||
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, sub._target)
|
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, sub._target)
|
||||||
can.onmotion.select(can, can._action, chat.DIV_TABS, event.target)
|
can.onmotion.select(can, can._action, chat.DIV_TABS, event.target)
|
||||||
}, onmouseenter: sub._legend.onmouseenter}])
|
}, onmouseenter: sub._legend.onmouseenter}])
|
||||||
},
|
},
|
||||||
_menu: function(can, msg) { if (can.user.mod.isPod||can.user.isMobile) { return }
|
_menu: function(can, msg) { if (can.user.mod.isPod||can.user.isMobile) { return }
|
||||||
can.setHeaderMenu(can.base.Obj(msg.Option(chat.MENUS), can.Conf(chat.MENUS)||can.onaction._menus), function(event, button, list) {
|
can.setHeaderMenu(can.base.Obj(msg.Option(chat.MENUS), can.Conf(chat.MENUS)||can.onaction._menus), function(event, button, list) {
|
||||||
can.core.CallFunc([can.onaction, list[0]], [can, button])
|
can.core.CallFunc([can.onaction, list[0]], [can, button])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
_share: function(can, share) { share && can.run({}, ["_share", share], function(msg) {
|
_share: function(can, share) { share && can.run({}, ["_share", share], function(msg) {
|
||||||
can.user.title(msg.OptionOrSearch(chat.TITLE))
|
can.user.title(msg.OptionOrSearch(chat.TITLE))
|
||||||
can.setHeader(chat.TOPIC, msg.OptionOrSearch(chat.TOPIC))
|
can.setHeader(chat.TOPIC, msg.OptionOrSearch(chat.TOPIC))
|
||||||
can.page.Select(can, document.body, html.FIELDSET_PANEL, function(item) {
|
// can.page.Select(can, document.body, html.FIELDSET_PANEL, function(item) {
|
||||||
item != can._target && can.onmotion.hidden(can, item)
|
// item != can._target && can.onmotion.hidden(can, item)
|
||||||
})
|
// })
|
||||||
|
|
||||||
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
||||||
can.page.ClassList.add(can, can._target, ice.CMD)
|
// can.page.ClassList.add(can, can._target, ice.CMD)
|
||||||
can.onlayout._init(can)
|
can.onlayout._init(can)
|
||||||
|
|
||||||
can.Conf(chat.RIVER, "_share", chat.STORM, share)
|
can.Conf(chat.RIVER, "_share", chat.STORM, share)
|
||||||
can.onimport._init(can, msg)
|
can.onimport._init(can, msg)
|
||||||
}) },
|
}) },
|
||||||
_cmd: function(can, item, next) {
|
_cmd: function(can, item, next) {
|
||||||
can.base.Copy(item, {
|
can.base.Copy(item, {
|
||||||
height: can.Conf(html.HEIGHT)-can.Conf(html.MARGIN_Y),
|
height: can.Conf(html.HEIGHT)-can.Conf(html.MARGIN_Y),
|
||||||
width: can.Conf(html.WIDTH)-can.Conf(html.MARGIN_X),
|
width: can.Conf(html.WIDTH)-can.Conf(html.MARGIN_X),
|
||||||
opts: can.misc.Search(can),
|
opts: can.misc.Search(can),
|
||||||
})
|
})
|
||||||
can.onappend.plugin(can, item, function(sub, meta, skip) {
|
can.onappend.plugin(can, item, function(sub, meta, skip) {
|
||||||
can.user.title(meta.name), skip || next()
|
can.user.title(meta.name), skip || next()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onengine", {help: "解析引擎", list: [], _engine: function(event, page, msg, can, cmds, cb) {
|
Volcanos("onengine", {help: "解析引擎", list: [], _engine: function(event, page, msg, can, cmds, cb) {
|
||||||
var storm = can.core.Value(can._root, can.core.Keys(chat.RIVER, cmds[0], chat.STORM, cmds[1]))
|
var storm = can.core.Value(can._root, can.core.Keys(chat.RIVER, cmds[0], chat.STORM, cmds[1]))
|
||||||
if (!storm || cmds.length != 2) { return false }
|
if (!storm || cmds.length != 2) { return false }
|
||||||
|
|
||||||
if (storm.index) { // 命令索引
|
if (storm.index) { // 命令索引
|
||||||
can.run(event, [ctx.ACTION, ctx.COMMAND].concat(storm.index), cb)
|
can.run(event, [ctx.ACTION, ctx.COMMAND].concat(storm.index), cb)
|
||||||
} else { // 命令列表
|
} else { // 命令列表
|
||||||
can.core.List(storm.list, function(value) {
|
can.core.List(storm.list, function(value) {
|
||||||
msg.Push(mdb.NAME, value.name||"")
|
msg.Push(mdb.NAME, value.name||"")
|
||||||
msg.Push(mdb.HELP, value.help||"")
|
msg.Push(mdb.HELP, value.help||"")
|
||||||
msg.Push(ctx.INPUTS, JSON.stringify(value.inputs))
|
msg.Push(ctx.INPUTS, JSON.stringify(value.inputs))
|
||||||
msg.Push(ctx.FEATURE, JSON.stringify(value.feature))
|
msg.Push(ctx.FEATURE, JSON.stringify(value.feature))
|
||||||
msg.Push(ctx.INDEX, value.index||"")
|
msg.Push(ctx.INDEX, value.index||"")
|
||||||
msg.Push(ctx.ARGS, value.args||"[]")
|
msg.Push(ctx.ARGS, value.args||"[]")
|
||||||
msg.Push(ice.MSG_ACTION, value._action||"")
|
msg.Push(ice.MSG_ACTION, value._action||"")
|
||||||
}), can.base.isFunc(cb) && cb(msg)
|
}), can.base.isFunc(cb) && cb(msg)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
}})
|
||||||
})
|
|
||||||
Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, cb, target) {
|
Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, cb, target) {
|
||||||
can.Conf(html.MARGIN_Y, 4*html.PLUGIN_MARGIN+2*html.ACTION_HEIGHT+html.ACTION_MARGIN)
|
can.Conf(html.MARGIN_Y, 4*html.PLUGIN_MARGIN+2*html.ACTION_HEIGHT+html.ACTION_MARGIN)
|
||||||
can.Conf(html.MARGIN_X, 4*html.PLUGIN_MARGIN)
|
can.Conf(html.MARGIN_X, 4*html.PLUGIN_MARGIN)
|
||||||
target.ontouchstart = function(event) {
|
target.ontouchstart = function(event) {
|
||||||
can.onengine.signal(can, "onaction_touch", can.request(event))
|
can.onengine.signal(can, "onaction_touch", can.request(event))
|
||||||
}, can.base.isFunc(cb) && cb()
|
}, can.base.isFunc(cb) && cb()
|
||||||
},
|
},
|
||||||
_menus: [
|
_menus: [
|
||||||
[chat.LAYOUT, "auto", "flow", "grid", "tabs", "free", "page", "toimage"],
|
[chat.LAYOUT, "auto", "flow", "grid", "tabs", "free", "page", "toimage"],
|
||||||
[ice.HELP, "tutor", "manual", "service", "devops", "refer"],
|
[ice.HELP, "tutor", "manual", "service", "devops", "refer"],
|
||||||
],
|
],
|
||||||
_trans: {
|
_trans: {
|
||||||
"layout": "布局",
|
"layout": "布局",
|
||||||
"auto": "默认布局",
|
"auto": "默认布局",
|
||||||
"flow": "流动布局",
|
"flow": "流动布局",
|
||||||
"grid": "网格布局",
|
"grid": "网格布局",
|
||||||
"tabs": "标签布局",
|
"tabs": "标签布局",
|
||||||
"free": "自由布局",
|
"free": "自由布局",
|
||||||
"page": "网页布局",
|
"page": "网页布局",
|
||||||
"toimage": "生成图片",
|
"toimage": "生成图片",
|
||||||
|
|
||||||
"help": "帮助",
|
"help": "帮助",
|
||||||
"tutor": "入门简介",
|
"tutor": "入门简介",
|
||||||
"manual": "使用手册",
|
"manual": "使用手册",
|
||||||
"service": "服务手册",
|
"service": "服务手册",
|
||||||
"devops": "编程手册",
|
"devops": "编程手册",
|
||||||
"refer": "参考手册",
|
"refer": "参考手册",
|
||||||
},
|
},
|
||||||
onmain: function(can) {
|
onmain: function(can) {
|
||||||
can.onimport._share(can, can.misc.Search(can, web.SHARE))
|
can.onimport._share(can, can.misc.Search(can, web.SHARE))
|
||||||
},
|
},
|
||||||
onlogin: function(can) { if (!can.user.mod.isCmd) { return }
|
onlogin: function(can) { if (!can.user.mod.isCmd) { return }
|
||||||
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
||||||
can.page.ClassList.add(can, can._target, ice.CMD)
|
can.page.ClassList.add(can, can._target, ice.CMD)
|
||||||
can.onlayout._init(can)
|
can.onlayout._init(can)
|
||||||
|
|
||||||
can._names = location.pathname
|
can._names = location.pathname
|
||||||
can.Conf(chat.TOOL)? can.core.Next(can.Conf(chat.TOOL), function(item, next) {
|
can.Conf(chat.TOOL)? can.core.Next(can.Conf(chat.TOOL), function(item, next) {
|
||||||
can.onimport._cmd(can, item, next)
|
can.onimport._cmd(can, item, next)
|
||||||
|
|
||||||
}): can.run(can.request()._event, [ctx.ACTION, ctx.COMMAND], function(msg) {
|
}): can.run(can.request()._event, [ctx.ACTION, ctx.COMMAND], function(msg) {
|
||||||
can.core.Next(msg.Table(), function(item, next) {
|
can.core.Next(msg.Table(), function(item, next) {
|
||||||
can.onimport._cmd(can, item, next)
|
can.onimport._cmd(can, item, next)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onstorm_select: function(can, msg, river, storm) { can.onlayout._init(can)
|
onstorm_select: function(can, msg, river, storm) { can.onlayout._init(can)
|
||||||
if (can.onmotion.cache(can, function() {
|
if (can.onmotion.cache(can, function() {
|
||||||
var key = can.core.Keys(can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm))
|
var key = can.core.Keys(can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm))
|
||||||
return key
|
return key
|
||||||
}, can._action, can._output)) {
|
}, can._action, can._output)) {
|
||||||
var conf = can.core.Value(can._root, can.core.Keys(chat.RIVER, river, chat.STORM, storm))||{}
|
var conf = can.core.Value(can._root, can.core.Keys(chat.RIVER, river, chat.STORM, storm))||{}
|
||||||
can.onaction.layout(can, conf.layout||can.misc.SearchOrConf(can, chat.LAYOUT)||"auto", true)
|
can.onaction.layout(can, conf.layout||can.misc.SearchOrConf(can, chat.LAYOUT)||"auto", true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
can.run({}, [river, storm], function(msg) { if (msg.Length() > 0) { return can.onimport._init(can, msg) }
|
can.run({}, [river, storm], function(msg) { if (msg.Length() > 0) { return can.onimport._init(can, msg) }
|
||||||
can.onengine.signal(can, "onaction_notool", can.request({}, {river: river, storm: storm}))
|
can.onengine.signal(can, "onaction_notool", can.request({}, {river: river, storm: storm}))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onsearch: function(can, msg, word) {
|
onsearch: function(can, msg, word) {
|
||||||
if (word[0] == mdb.FOREACH || word[0] == mdb.PLUGIN) { can.onexport.plugin(can, msg, word) }
|
if (word[0] == mdb.FOREACH || word[0] == mdb.PLUGIN) { can.onexport.plugin(can, msg, word) }
|
||||||
},
|
},
|
||||||
onsize: function(can, msg, height, width) { can.Conf({height: height, width: width}) },
|
onsize: function(can, msg, height, width) { can.Conf({height: height, width: width}) },
|
||||||
|
|
||||||
help: function(can, button) { can.user.open("/help/"+button+".shy") },
|
help: function(can, button) { can.user.open("/help/"+button+".shy") },
|
||||||
layout: function(can, button, slient) {
|
layout: function(can, button, slient) {
|
||||||
if (button == "toimage") {
|
if (button == "toimage") {
|
||||||
can.onmotion.toimage(event, can, document.title, can._output)
|
can.onmotion.toimage(event, can, document.title, can._output)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
can.page.ClassList.del(can, can._target, can.Conf(chat.LAYOUT))
|
can.page.ClassList.del(can, can._target, can.Conf(chat.LAYOUT))
|
||||||
can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button))
|
can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button))
|
||||||
|
|
||||||
if (button == "tabs") {
|
if (button == "tabs") {
|
||||||
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, 0)
|
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, 0)
|
||||||
can.onmotion.select(can, can._action, chat.DIV_TABS, 0)
|
can.onmotion.select(can, can._action, chat.DIV_TABS, 0)
|
||||||
} else if (button == "free") {
|
} else if (button == "free") {
|
||||||
can.page.Select(can, can._target, [[html.DIV_OUTPUT, html.FIELDSET_PLUGIN]], function(item, index) {
|
can.page.Select(can, can._target, [[html.DIV_OUTPUT, html.FIELDSET_PLUGIN]], function(item, index) {
|
||||||
can.page.Modify(can, item, {style: {left: 40*index, top: 40*index}})
|
can.page.Modify(can, item, {style: {left: 40*index, top: 40*index}})
|
||||||
can.onmotion.move(can, item, {left: 40*index, top: 40*index})
|
can.onmotion.move(can, item, {left: 40*index, top: 40*index})
|
||||||
})
|
})
|
||||||
} else if (button == "grid") {
|
} else if (button == "grid") {
|
||||||
can.user.input(event, can, [{name: "m", value: 2}, {name: "n", value: 2}], function(event, button, data, list, args) {
|
can.user.input(event, can, [{name: "m", value: 2}, {name: "n", value: 2}], function(event, button, data, list, args) {
|
||||||
can.getActionSize(function(height, width) { var m = parseInt(data.m)||2, n = parseInt(data.n)||2
|
can.getActionSize(function(height, width) { var m = parseInt(data.m)||2, n = parseInt(data.n)||2
|
||||||
can.page.css(can.base.replaceAll(chat.ACTION_LAYOUT_FMT, "_width", (width-(4*m+1)*html.PLUGIN_MARGIN)/m+"px", "_height", (height-(4*n+1)*html.PLUGIN_MARGIN)/n+"px"))
|
can.page.css(can.base.replaceAll(chat.ACTION_LAYOUT_FMT, "_width", (width-(4*m+1)*html.PLUGIN_MARGIN)/m+"px", "_height", (height-(4*n+1)*html.PLUGIN_MARGIN)/n+"px"))
|
||||||
})
|
})
|
||||||
}, true)
|
}, true)
|
||||||
}
|
}
|
||||||
can.onlayout._init(can)
|
can.onlayout._init(can)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onkeymap", {help: "键盘交互", list: [], _focus: [], _init: function(can, target) {
|
Volcanos("onkeymap", {help: "键盘交互", list: [], _focus: [], _init: function(can, target) {
|
||||||
can.onkeymap._build(can), can.onengine.listen(can, "onkeydown", function(msg, model) {
|
can.onkeymap._build(can), can.onengine.listen(can, "onkeydown", function(msg, model) {
|
||||||
can._keylist = can.onkeymap._parse(msg._event, can, model, can._keylist||[], can._output)
|
can._keylist = can.onkeymap._parse(msg._event, can, model, can._keylist||[], can._output)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_mode: {
|
_mode: {
|
||||||
normal: {
|
normal: {
|
||||||
j: function(event, can, target) { target.scrollBy(0, event.ctrlKey? 300: 30) },
|
j: function(event, can, target) { target.scrollBy(0, event.ctrlKey? 300: 30) },
|
||||||
k: function(event, can, target) { target.scrollBy(0, event.ctrlKey? -300: -30) },
|
k: function(event, can, target) { target.scrollBy(0, event.ctrlKey? -300: -30) },
|
||||||
|
|
||||||
b: function(event, can, target) { can.search(event, ["Header.onaction.black"]) },
|
b: function(event, can, target) { can.search(event, ["Header.onaction.black"]) },
|
||||||
w: function(event, can, target) { can.search(event, ["Header.onaction.white"]) },
|
w: function(event, can, target) { can.search(event, ["Header.onaction.white"]) },
|
||||||
|
|
||||||
g: function(event, can, target) { can.search(event, ["River.ondetail.创建群组"]) },
|
g: function(event, can, target) { can.search(event, ["River.ondetail.创建群组"]) },
|
||||||
s: function(event, can, target) { can.search(event, ["River.ondetail.添加应用"]) },
|
s: function(event, can, target) { can.search(event, ["River.ondetail.添加应用"]) },
|
||||||
t: function(event, can, target) { can.search(event, ["River.ondetail.添加工具"]) },
|
t: function(event, can, target) { can.search(event, ["River.ondetail.添加工具"]) },
|
||||||
|
|
||||||
" ": function(event, can, target) {
|
" ": function(event, can, target) {
|
||||||
can.onengine.signal(can, "onsearchfocus")
|
can.onengine.signal(can, "onsearchfocus")
|
||||||
},
|
},
|
||||||
":": function(event, can, target) {
|
":": function(event, can, target) {
|
||||||
can.onengine.signal(can, "oncommandfocus")
|
can.onengine.signal(can, "oncommandfocus")
|
||||||
},
|
},
|
||||||
enter: function(event, can, target) { can.misc.Log("enter") },
|
enter: function(event, can, target) { can.misc.Log("enter") },
|
||||||
escape: function(event, can, target) {
|
escape: function(event, can, target) {
|
||||||
can.page.Select(can, document.body, html.FIELDSET_AUTO, function(item) {
|
can.page.Select(can, document.body, html.FIELDSET_AUTO, function(item) {
|
||||||
can.onmotion.hidden(can, item)
|
can.onmotion.hidden(can, item)
|
||||||
})
|
})
|
||||||
can.page.Select(can, document.body, can.page.Keys(html.FIELDSET_FLOAT, html.DIV_FLOAT), function(item) {
|
can.page.Select(can, document.body, can.page.Keys(html.FIELDSET_FLOAT, html.DIV_FLOAT), function(item) {
|
||||||
can.page.Remove(can, item)
|
can.page.Remove(can, item)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, _engine: {},
|
}, _engine: {},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
args: function(can, cb, target) {
|
args: function(can, cb, target) {
|
||||||
can.core.Next(can.page.Select(can, target, [[html.FIELDSET_PLUGIN, html.FORM_OPTION]]), function(item, next, index, array) {
|
can.core.Next(can.page.Select(can, target, [[html.FIELDSET_PLUGIN, html.FORM_OPTION]]), function(item, next, index, array) {
|
||||||
item.dataset.args = JSON.stringify(can.page.Select(can, item, html.OPTION_ARGS, function(item) { return item.value||"" }))
|
item.dataset.args = JSON.stringify(can.page.Select(can, item, html.OPTION_ARGS, function(item) { return item.value||"" }))
|
||||||
cb(item, next, index, array)
|
cb(item, next, index, array)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
size: function(can, msg) {
|
size: function(can, msg) {
|
||||||
msg.Option(html.TOP, can._target.offsetTop)
|
msg.Option(html.TOP, can._target.offsetTop)
|
||||||
msg.Option(html.LEFT, can._target.offsetLeft)
|
msg.Option(html.LEFT, can._target.offsetLeft)
|
||||||
msg.Option(html.WIDTH, can._target.offsetWidth)
|
msg.Option(html.WIDTH, can._target.offsetWidth)
|
||||||
msg.Option(html.HEIGHT, can._target.offsetHeight-can._action.offsetHeight)
|
msg.Option(html.HEIGHT, can._target.offsetHeight-can._action.offsetHeight)
|
||||||
msg.Option(html.SCROLL, can.user.isMobile? can._target.parentNode.parentNode.scrollTop: can._output.scrollTop)
|
msg.Option(html.SCROLL, can.user.isMobile? can._target.parentNode.parentNode.scrollTop: can._output.scrollTop)
|
||||||
msg.Option(html.MARGIN_X, can.Conf(html.MARGIN_X))
|
msg.Option(html.MARGIN_X, can.Conf(html.MARGIN_X))
|
||||||
msg.Option(html.MARGIN_Y, can.Conf(html.MARGIN_Y))
|
msg.Option(html.MARGIN_Y, can.Conf(html.MARGIN_Y))
|
||||||
},
|
},
|
||||||
layout: function(can, msg) { return can.Conf(chat.LAYOUT) },
|
layout: function(can, msg) { return can.Conf(chat.LAYOUT) },
|
||||||
plugin: function(can, msg, word) { var fields = can.core.Split(msg.Option(ice.MSG_FIELDS))
|
plugin: function(can, msg, word) { var fields = can.core.Split(msg.Option(ice.MSG_FIELDS))
|
||||||
can.page.Select(can, can._output, [[html.FIELDSET_PLUGIN, html.LEGEND]], function(item) {
|
can.page.Select(can, can._output, [[html.FIELDSET_PLUGIN, html.LEGEND]], function(item) {
|
||||||
if (item.innerHTML.indexOf(word[1]) == -1) { return }
|
if (item.innerHTML.indexOf(word[1]) == -1) { return }
|
||||||
|
|
||||||
var meta = item.parentNode._meta
|
var meta = item.parentNode._meta
|
||||||
var list = can.page.Select(can, item.nextSibling, html.OPTION_ARGS, function(item) { return item.value||"" })
|
var list = can.page.Select(can, item.nextSibling, html.OPTION_ARGS, function(item) { return item.value||"" })
|
||||||
|
|
||||||
var data = {ctx: "web.chat", cmd: ctx.ACTION,
|
var data = {ctx: "web.chat", cmd: ctx.ACTION,
|
||||||
type: mdb.PLUGIN, name: item.innerHTML, text: shy("跳转", function(event) {
|
type: mdb.PLUGIN, name: item.innerHTML, text: shy("跳转", function(event) {
|
||||||
var input = can.page.Select(can, item.parentNode, html.INPUT_ARGS)[0]
|
var input = can.page.Select(can, item.parentNode, html.INPUT_ARGS)[0]
|
||||||
input && input.focus()
|
input && input.focus()
|
||||||
}), argument: JSON.stringify(list),
|
}), argument: JSON.stringify(list),
|
||||||
}
|
}
|
||||||
if (meta.index) {
|
if (meta.index) {
|
||||||
data.context = "", data.command = meta.index
|
data.context = "", data.command = meta.index
|
||||||
} else if (meta.cmd) {
|
} else if (meta.cmd) {
|
||||||
data.context = meta.ctx, data.command = meta.cmd
|
data.context = meta.ctx, data.command = meta.cmd
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg.Push(data, fields)
|
msg.Push(data, fields)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
168
panel/footer.js
168
panel/footer.js
@ -1,96 +1,96 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can)
|
can.onmotion.clear(can)
|
||||||
can.onimport._title(can, msg, target)
|
can.onimport._title(can, msg, target)
|
||||||
can.onimport._state(can, msg, target)
|
can.onimport._state(can, msg, target)
|
||||||
can.onimport._toast(can, msg, target)
|
can.onimport._toast(can, msg, target)
|
||||||
can.onimport._cli(can, msg, target)
|
can.onimport._cli(can, msg, target)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
},
|
},
|
||||||
_title: function(can, msg, target) {
|
_title: function(can, msg, target) {
|
||||||
!can.user.isMobile && can.core.List(msg.result, function(item) {
|
!can.user.isMobile && can.core.List(msg.result, function(item) {
|
||||||
can.page.Append(can, target, [{view: [chat.TITLE, html.DIV, item], title: "联系站长"}])
|
can.page.Append(can, target, [{view: [chat.TITLE, html.DIV, item], title: "联系站长"}])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_state: function(can, msg, target) {
|
_state: function(can, msg, target) {
|
||||||
can.core.List(can.base.Obj(msg.Option(chat.STATE)||can.Conf(chat.STATE), ["ncmd"]), function(item) {
|
can.core.List(can.base.Obj(msg.Option(chat.STATE)||can.Conf(chat.STATE), ["ncmd"]), function(item) {
|
||||||
can.page.Append(can, target, [{view: [can.base.join([chat.STATE, item]), html.DIV, can.Conf(item)], list: [
|
can.page.Append(can, target, [{view: [can.base.join([chat.STATE, item]), html.DIV, can.Conf(item)], list: [
|
||||||
{text: [item, html.LABEL]}, {text: [": ", html.LABEL]}, {text: [can.Conf(item)||"", html.SPAN, item]},
|
{text: [item, html.LABEL]}, {text: [": ", html.LABEL]}, {text: [can.Conf(item)||"", html.SPAN, item]},
|
||||||
], onclick: function(event) {
|
], onclick: function(event) {
|
||||||
can.show = can.show? (can.page.Remove(can, can.show), null): can.onaction._cmd(can)
|
can.show = can.show? (can.page.Remove(can, can.show), null): can.onaction._cmd(can)
|
||||||
can.page.Modify(can, can.show, {style: {left: "", top: "", right: 0, bottom: can.onexport.height(can)}})
|
can.page.Modify(can, can.show, {style: {left: "", top: "", right: 0, bottom: can.onexport.height(can)}})
|
||||||
}}])
|
}}])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_toast: function(can, msg, target) {
|
_toast: function(can, msg, target) {
|
||||||
can.toast = can.page.Append(can, target, [{view: chat.TOAST, onclick: function(event) {
|
can.toast = can.page.Append(can, target, [{view: chat.TOAST, onclick: function(event) {
|
||||||
can.show = can.show? (can.page.Remove(can, can.show), null): can.onappend.float(can, can._toast).first
|
can.show = can.show? (can.page.Remove(can, can.show), null): can.onappend.float(can, can._toast).first
|
||||||
can.page.Modify(can, can.show, {style: {left: "", top: "", right: 0, bottom: can.onexport.height(can)}})
|
can.page.Modify(can, can.show, {style: {left: "", top: "", right: 0, bottom: can.onexport.height(can)}})
|
||||||
}}]).first
|
}}]).first
|
||||||
},
|
},
|
||||||
_cli: function(can, msg, target) {
|
_cli: function(can, msg, target) {
|
||||||
can.onappend.input(can, {type: html.TEXT, name: "cmd", onkeydown: function(event) {
|
can.onappend.input(can, {type: html.TEXT, name: "cmd", onkeydown: function(event) {
|
||||||
can.onkeymap.input(event, can); if (event.key != lang.ENTER) { return }
|
can.onkeymap.input(event, can); if (event.key != lang.ENTER) { return }
|
||||||
switch (event.target.value) {
|
switch (event.target.value) {
|
||||||
case cli.CLEAR: can.cli && can.cli.close(); break
|
case cli.CLEAR: can.cli && can.cli.close(); break
|
||||||
case cli.CLOSE: can.cli && can.cli.close(); break
|
case cli.CLOSE: can.cli && can.cli.close(); break
|
||||||
default:
|
default:
|
||||||
can.run(event, [ice.RUN].concat(can.core.Split(event.target.value, ice.SP)), function(msg) {
|
can.run(event, [ice.RUN].concat(can.core.Split(event.target.value, ice.SP)), function(msg) {
|
||||||
can.cli && can.cli.close()
|
can.cli && can.cli.close()
|
||||||
can.cli = can.onappend.float(can, msg, function(value, key, index, line, list) {
|
can.cli = can.onappend.float(can, msg, function(value, key, index, line, list) {
|
||||||
|
|
||||||
}), can.page.Modify(can, can.cli.first, {style: {bottom: can.onexport.height(can), top: ""}})
|
}), can.page.Modify(can, can.cli.first, {style: {bottom: can.onexport.height(can), top: ""}})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}}, "", target, "title cmd")
|
}}, "", target, "title cmd")
|
||||||
},
|
},
|
||||||
|
|
||||||
toast: function(can, msg, title, content, fileline, time) { can._toast = can._toast||can.request()
|
toast: function(can, msg, title, content, fileline, time) { can._toast = can._toast||can.request()
|
||||||
can.page.Modify(can, can.toast, [time.split(ice.SP).pop(), title, content].join(ice.SP))
|
can.page.Modify(can, can.toast, [time.split(ice.SP).pop(), title, content].join(ice.SP))
|
||||||
can._toast.Push({time: time, fileline: fileline, title: title, content: content})
|
can._toast.Push({time: time, fileline: fileline, title: title, content: content})
|
||||||
},
|
},
|
||||||
ncmd: function(can, msg, _follow, _cmds) { var NCMD = "ncmd"; can._cmds = can._cmds||can.request()
|
ncmd: function(can, msg, _follow, _cmds) { var NCMD = "ncmd"; can._cmds = can._cmds||can.request()
|
||||||
can._cmds.Push({time: can.base.Time(), follow: _follow, cmds: _cmds})
|
can._cmds.Push({time: can.base.Time(), follow: _follow, cmds: _cmds})
|
||||||
can.page.Select(can, can._output, can.core.Keys(html.SPAN, NCMD), function(item) {
|
can.page.Select(can, can._output, can.core.Keys(html.SPAN, NCMD), function(item) {
|
||||||
item.innerHTML = can.Conf(NCMD, parseInt(can.Conf(NCMD)||"0")+1+"")+""
|
item.innerHTML = can.Conf(NCMD, parseInt(can.Conf(NCMD)||"0")+1+"")+""
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, cb, target) {
|
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, cb, target) {
|
||||||
can.base.isFunc(cb) && cb()
|
can.base.isFunc(cb) && cb()
|
||||||
},
|
},
|
||||||
onlogin: function(can, msg) { can.run({}, [], function(msg) { can.onimport._init(can, msg, [], null, can._output) }) },
|
onlogin: function(can, msg) { can.run({}, [], function(msg) { can.onimport._init(can, msg, [], null, can._output) }) },
|
||||||
ontoast: function(can, msg) { can.core.CallFunc(can.onimport.toast, {can: can, msg: msg}) },
|
ontoast: function(can, msg) { can.core.CallFunc(can.onimport.toast, {can: can, msg: msg}) },
|
||||||
onremote: function(can, msg) { can.core.CallFunc(can.onimport.ncmd, {can: can, msg: msg}) },
|
onremote: function(can, msg) { can.core.CallFunc(can.onimport.ncmd, {can: can, msg: msg}) },
|
||||||
oncommandfocus: function(can) {
|
oncommandfocus: function(can) {
|
||||||
can.page.Select(can, can._output, "div.cmd input", function(target) { target.focus() })
|
can.page.Select(can, can._output, "div.cmd input", function(target) { target.focus() })
|
||||||
},
|
},
|
||||||
|
|
||||||
_cmd: function(can) {
|
_cmd: function(can) {
|
||||||
return can.onappend.float(can, can._cmds, function(value, key, index, line, list) {
|
return can.onappend.float(can, can._cmds, function(value, key, index, line, list) {
|
||||||
var cmds = can.base.Obj(line.cmds); switch (line.follow) {
|
var cmds = can.base.Obj(line.cmds); switch (line.follow) {
|
||||||
case "chat.Action": cmds = cmds.slice(2); break
|
case "chat.Action": cmds = cmds.slice(2); break
|
||||||
case "chat.Footer": cmds = cmds.slice(2); break
|
case "chat.Footer": cmds = cmds.slice(2); break
|
||||||
}
|
}
|
||||||
switch (cmds[0]) {
|
switch (cmds[0]) {
|
||||||
case "web.wiki.word": cmds = cmds.slice(5); break
|
case "web.wiki.word": cmds = cmds.slice(5); break
|
||||||
}
|
}
|
||||||
|
|
||||||
can.get("Action", "size", function(msg, top, left, width, height) {
|
can.get("Action", "size", function(msg, top, left, width, height) {
|
||||||
can.onappend.plugin(can, {index: cmds[0], args: cmds.slice(1), height: height-100, width: width}, function(sub) {
|
can.onappend.plugin(can, {index: cmds[0], args: cmds.slice(1), height: height-100, width: width}, function(sub) {
|
||||||
sub.run = function(event, cmd, cb) {
|
sub.run = function(event, cmd, cb) {
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, cmds[0]], cmd), cb)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, cmds[0]], cmd), cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
can.page.Modify(can, sub._target, {style: {top: top+100, left: left}})
|
can.page.Modify(can, sub._target, {style: {top: top+100, left: left}})
|
||||||
can.page.Modify(can, sub._legend, {style: {display: html.BLOCK}})
|
can.page.Modify(can, sub._legend, {style: {display: html.BLOCK}})
|
||||||
can.page.Modify(can, sub._output, {style: {"max-width": width}})
|
can.page.Modify(can, sub._output, {style: {"max-width": width}})
|
||||||
can.page.ClassList.add(can, sub._target, chat.FLOAT)
|
can.page.ClassList.add(can, sub._target, chat.FLOAT)
|
||||||
}, document.body)
|
}, document.body)
|
||||||
})
|
})
|
||||||
}).first
|
}).first
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
height: function(can) { return can._target.offsetHeight },
|
height: function(can) { return can._target.offsetHeight },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
426
panel/header.js
426
panel/header.js
@ -1,235 +1,235 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
||||||
can.Conf(aaa.USERNICK, msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNAME)||can.Conf(aaa.USERNICK))
|
can.Conf(aaa.USERNICK, msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNAME)||can.Conf(aaa.USERNICK))
|
||||||
|
|
||||||
can.onmotion.clear(can)
|
can.onmotion.clear(can)
|
||||||
can.onimport._agent(can, msg, target)
|
can.onimport._agent(can, msg, target)
|
||||||
can.onimport._grant(can, msg, target)
|
can.onimport._grant(can, msg, target)
|
||||||
can.onimport._title(can, msg, target)
|
can.onimport._title(can, msg, target)
|
||||||
can.onimport._state(can, msg, target)
|
can.onimport._state(can, msg, target)
|
||||||
can.onimport._search(can, msg, target)
|
can.onimport._search(can, msg, target)
|
||||||
can.onimport._background(can, msg, target)
|
can.onimport._background(can, msg, target)
|
||||||
can.onimport._avatar(can, msg, target)
|
can.onimport._avatar(can, msg, target)
|
||||||
can.onimport._menus(can, msg, target)
|
can.onimport._menus(can, msg, target)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
},
|
},
|
||||||
_agent: function(can, msg, target) {
|
_agent: function(can, msg, target) {
|
||||||
if (can.user.mod.isPod) {
|
if (can.user.mod.isPod) {
|
||||||
can.onaction.River(can)
|
can.onaction.River(can)
|
||||||
can.onaction.Footer(can)
|
can.onaction.Footer(can)
|
||||||
} else if (can.user.isMobile) {
|
} else if (can.user.isMobile) {
|
||||||
can.onaction.River(can)
|
can.onaction.River(can)
|
||||||
can.onaction.Footer(can)
|
can.onaction.Footer(can)
|
||||||
} else if (can.user.isExtension) {
|
} else if (can.user.isExtension) {
|
||||||
can.onaction.River(can)
|
can.onaction.River(can)
|
||||||
}
|
}
|
||||||
can.run({}, [chat.AGENT], function(msg) { if (!msg.Option(ssh.SCRIPT)) { return }
|
can.run({}, [chat.AGENT], function(msg) { if (!msg.Option(ssh.SCRIPT)) { return }
|
||||||
can.require(can.base.Obj(msg.Option(ssh.SCRIPT)), function(can) { can.onaction.source(can, msg) })
|
can.require(can.base.Obj(msg.Option(ssh.SCRIPT)), function(can) { can.onaction.source(can, msg) })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_grant: function(can, msg, target) {
|
_grant: function(can, msg, target) {
|
||||||
if (can.misc.Search(can, chat.GRANT)) {
|
if (can.misc.Search(can, chat.GRANT)) {
|
||||||
if (can.user.confirm(chat.GRANT+ice.SP+can.misc.Search(can, chat.GRANT))) {
|
if (can.user.confirm(chat.GRANT+ice.SP+can.misc.Search(can, chat.GRANT))) {
|
||||||
can.run(event, [ctx.ACTION, chat.GRANT, web.SPACE, can.misc.Search(can, chat.GRANT)])
|
can.run(event, [ctx.ACTION, chat.GRANT, web.SPACE, can.misc.Search(can, chat.GRANT)])
|
||||||
}
|
}
|
||||||
can.misc.Search(can, chat.GRANT, "")
|
can.misc.Search(can, chat.GRANT, "")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_title: function(can, msg, target) {
|
_title: function(can, msg, target) {
|
||||||
can.user.title(can.misc.Search(can, chat.TITLE)||can.misc.Search(can, ice.POD))
|
can.user.title(can.misc.Search(can, chat.TITLE)||can.misc.Search(can, ice.POD))
|
||||||
!can.user.isMobile && can.core.List(can.base.getValid(msg.result, can.Conf(chat.TITLE)||["shylinux.com/x/contexts"]), function(item) {
|
!can.user.isMobile && can.core.List(can.base.getValid(msg.result, can.Conf(chat.TITLE)||["shylinux.com/x/contexts"]), function(item) {
|
||||||
can.page.Append(can, target, [{view: [chat.TITLE, html.DIV, item], title: "返回主页", onclick: function(event) {
|
can.page.Append(can, target, [{view: [chat.TITLE, html.DIV, item], title: "返回主页", onclick: function(event) {
|
||||||
can.onaction.title(event, can)
|
can.onaction.title(event, can)
|
||||||
}, onmouseenter: function(event) { var list = msg.Table()
|
}, onmouseenter: function(event) { var list = msg.Table()
|
||||||
can.user.carte(event, can, {}, can.core.List(list, function(item) { return item.name }), function(event, item, meta, index) {
|
can.user.carte(event, can, {}, can.core.List(list, function(item) { return item.name }), function(event, item, meta, index) {
|
||||||
event.shiftKey? can.user.open(list[index].path): can.user.jumps(list[index].path)
|
event.shiftKey? can.user.open(list[index].path): can.user.jumps(list[index].path)
|
||||||
})
|
})
|
||||||
}}])
|
}}])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_state: function(can, msg, target) {
|
_state: function(can, msg, target) {
|
||||||
can.core.List(can.base.Obj(msg.Option(chat.STATE)||can.Conf(chat.STATE), [mdb.TIME, aaa.USERNICK]), function(item) {
|
can.core.List(can.base.Obj(msg.Option(chat.STATE)||can.Conf(chat.STATE), [mdb.TIME, aaa.USERNICK]), function(item) {
|
||||||
if (item == aaa.AVATAR ) { if (can.user.isLocalFile) { return }
|
if (item == aaa.AVATAR ) { if (can.user.isLocalFile) { return }
|
||||||
can.page.Append(can, target, [{view: can.base.join([chat.STATE, item]), list: [{img: ice.SP}], onmouseenter: function(event) {
|
can.page.Append(can, target, [{view: can.base.join([chat.STATE, item]), list: [{img: ice.SP}], onmouseenter: function(event) {
|
||||||
can.onaction.carte(event, can, [can.page.Format(html.IMG, "/share/local/avatar", 160)])
|
can.onaction.carte(event, can, [can.page.Format(html.IMG, "/share/local/avatar", 160)])
|
||||||
}}]); return
|
}}]); return
|
||||||
}
|
}
|
||||||
|
|
||||||
can.page.Append(can, target, [{view: [can.base.join([chat.STATE, item]), html.DIV, (can.Conf(item)||"").slice(0, 10)], onmouseenter: function(event) {
|
can.page.Append(can, target, [{view: [can.base.join([chat.STATE, item]), html.DIV, (can.Conf(item)||"").slice(0, 10)], onmouseenter: function(event) {
|
||||||
can.core.CallFunc([can.onaction, item], [event, can, item])
|
can.core.CallFunc([can.onaction, item], [event, can, item])
|
||||||
}, _init: function(target) { item == mdb.TIME && can.onimport._time(can, target) }}])
|
}, _init: function(target) { item == mdb.TIME && can.onimport._time(can, target) }}])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_search: function(can, msg, target) {
|
_search: function(can, msg, target) {
|
||||||
var ui = can.onappend.input(can, {type: html.TEXT, name: mdb.SEARCH, onkeydown: function(event) {
|
var ui = can.onappend.input(can, {type: html.TEXT, name: mdb.SEARCH, onkeydown: function(event) {
|
||||||
can.onkeymap.input(event, can); switch (event.key) {
|
can.onkeymap.input(event, can); switch (event.key) {
|
||||||
case lang.ENTER: can.onengine.signal(can, "onopensearch", can.request(event, {type: "*", word: event.target.value}))
|
case lang.ENTER: can.onengine.signal(can, "onopensearch", can.request(event, {type: "*", word: event.target.value}))
|
||||||
}
|
}
|
||||||
}}, "", target, "title search").parentNode
|
}}, "", target, "title search").parentNode
|
||||||
can.user.isMobile && can.page.Modify(can, ui, {style: {float: html.RIGHT}})
|
can.user.isMobile && can.page.Modify(can, ui, {style: {float: html.RIGHT}})
|
||||||
},
|
},
|
||||||
_background: function(can, msg) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
_background: function(can, msg) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
||||||
msg.Option(aaa.BACKGROUND) && can.onlayout.background(can, "/share/local/background", document.body)
|
msg.Option(aaa.BACKGROUND) && can.onlayout.background(can, "/share/local/background", document.body)
|
||||||
},
|
},
|
||||||
_avatar: function(can, msg) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
_avatar: function(can, msg) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
||||||
// can.page.Modify(can, "div.state.avatar>img", {src: "/share/local/avatar/"})
|
// can.page.Modify(can, "div.state.avatar>img", {src: "/share/local/avatar/"})
|
||||||
msg.Option(aaa.AVATAR) && can.page.Modify(can, "div.state.avatar>img", {src: "/share/local/avatar"})
|
msg.Option(aaa.AVATAR) && can.page.Modify(can, "div.state.avatar>img", {src: "/share/local/avatar"})
|
||||||
},
|
},
|
||||||
_menus: function(can, msg, target) {
|
_menus: function(can, msg, target) {
|
||||||
can.setHeaderMenu(can.user.mod.isPod||can.user.isMobile||can.user.isExtension? [chat.RIVER]:
|
can.setHeaderMenu(can.user.mod.isPod||can.user.isMobile||can.user.isExtension? [chat.RIVER]:
|
||||||
can.base.Obj(msg.Option(chat.MENUS)||can.Conf(chat.MENUS), can.onaction._menus), function(event, button) {
|
can.base.Obj(msg.Option(chat.MENUS)||can.Conf(chat.MENUS), can.onaction._menus), function(event, button) {
|
||||||
can.core.CallFunc(can.onaction[button]||function(event, can) {
|
can.core.CallFunc(can.onaction[button]||function(event, can) {
|
||||||
can.run(event, [button], function(msg) { can.user.toast(can, "执行成功", can.user.trans(can, button)) })
|
can.run(event, [button], function(msg) { can.user.toast(can, "执行成功", can.user.trans(can, button)) })
|
||||||
}, {event: event, can: can, button: button})
|
}, {event: event, can: can, button: button})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
_time: function(can, target) {
|
_time: function(can, target) {
|
||||||
can.core.Timer({interval: 500}, function() { can.onimport.time(can, target) })
|
can.core.Timer({interval: 500}, function() { can.onimport.time(can, target) })
|
||||||
can.onappend.figure(can, {action: "date", style: {"min-width": 306}}, target, function(sub) {
|
can.onappend.figure(can, {action: "date", style: {"min-width": 306}}, target, function(sub) {
|
||||||
can.get("Action", "size", function(msg, top) {
|
can.get("Action", "size", function(msg, top) {
|
||||||
can.page.Modify(can, sub._target, {style: {top: top, right: 0, left: null}})
|
can.page.Modify(can, sub._target, {style: {top: top, right: 0, left: null}})
|
||||||
})
|
})
|
||||||
}), target.onmouseenter = target.click
|
}), target.onmouseenter = target.click
|
||||||
},
|
},
|
||||||
time: function(can, target) { can.onlayout.topic(can)
|
time: function(can, target) { can.onlayout.topic(can)
|
||||||
target.innerHTML = can.user.time(can, null, "%w %H:%M:%S")
|
target.innerHTML = can.user.time(can, null, "%w %H:%M:%S")
|
||||||
},
|
},
|
||||||
topic: function(can, topic) { can.onlayout.topic(can, can._topic = topic) },
|
topic: function(can, topic) { can.onlayout.topic(can, can._topic = topic) },
|
||||||
background: function(event, can, url) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
background: function(event, can, url) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
||||||
can.run(event, [ctx.ACTION, aaa.BACKGROUND, url], function(msg) { can.onimport._background(can, msg) })
|
can.run(event, [ctx.ACTION, aaa.BACKGROUND, url], function(msg) { can.onimport._background(can, msg) })
|
||||||
},
|
},
|
||||||
avatar: function(event, can, url) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
avatar: function(event, can, url) { if (can.user.isExtension || can.user.isLocalFile) { return }
|
||||||
can.run(event, [ctx.ACTION, aaa.AVATAR, url], function(msg) { can.onimport._avatar(can, msg) })
|
can.run(event, [ctx.ACTION, aaa.AVATAR, url], function(msg) { can.onimport._avatar(can, msg) })
|
||||||
},
|
},
|
||||||
menu: function(can, cmds, cb, trans) {
|
menu: function(can, cmds, cb, trans) {
|
||||||
return can.page.Append(can, can._output, [{type: cmds[0], list: can.core.List(cmds.slice(1), function(item) {
|
return can.page.Append(can, can._output, [{type: cmds[0], list: can.core.List(cmds.slice(1), function(item) {
|
||||||
if (can.base.isString(item)) {
|
if (can.base.isString(item)) {
|
||||||
return {view: [html.MENU, html.DIV, can.user.trans(can, item, trans)], onclick: function(event) {
|
return {view: [html.MENU, html.DIV, can.user.trans(can, item, trans)], onclick: function(event) {
|
||||||
can.base.isFunc(cb) && cb(event, item, cmds)
|
can.base.isFunc(cb) && cb(event, item, cmds)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
} else if (can.base.isArray(item)) {
|
} else if (can.base.isArray(item)) {
|
||||||
var list = can.core.List(item, function(value, index) { return can.user.trans(can, value, trans) })
|
var list = can.core.List(item, function(value, index) { return can.user.trans(can, value, trans) })
|
||||||
return {view: [html.MENU, html.DIV, can.user.trans(can, list[0], trans)], onmouseenter: function(event) {
|
return {view: [html.MENU, html.DIV, can.user.trans(can, list[0], trans)], onmouseenter: function(event) {
|
||||||
can.onaction.carte(event, can, list.slice(1), function(event, button, meta, index) {
|
can.onaction.carte(event, can, list.slice(1), function(event, button, meta, index) {
|
||||||
can.base.isFunc(cb) && cb(event, item[index+1], item)
|
can.base.isFunc(cb) && cb(event, item[index+1], item)
|
||||||
}, trans)
|
}, trans)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
} else if (can.base.isObject(item)) {
|
} else if (can.base.isObject(item)) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
}) }]).first
|
}) }]).first
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, cb, target) {
|
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, cb, target) {
|
||||||
can.base.isFunc(cb) && cb()
|
can.base.isFunc(cb) && cb()
|
||||||
},
|
},
|
||||||
_menus: [["setting", chat.BLACK, chat.WHITE, chat.PRINT, "webpack", "devpack", "toimage"]],
|
_menus: [["setting", chat.BLACK, chat.WHITE, chat.PRINT, "webpack", "devpack", "toimage"]],
|
||||||
_trans: {
|
_trans: {
|
||||||
"river": "菜单",
|
"river": "菜单",
|
||||||
"search": "搜索",
|
"search": "搜索",
|
||||||
"create": "创建",
|
"create": "创建",
|
||||||
"share": "共享",
|
"share": "共享",
|
||||||
|
|
||||||
"setting": "设置",
|
"setting": "设置",
|
||||||
"black": "黑色主题",
|
"black": "黑色主题",
|
||||||
"white": "白色主题",
|
"white": "白色主题",
|
||||||
"print": "打印主题",
|
"print": "打印主题",
|
||||||
"toimage": "生成图片",
|
"toimage": "生成图片",
|
||||||
|
|
||||||
"shareuser": "共享用户",
|
"shareuser": "共享用户",
|
||||||
"setnick": "设置昵称",
|
"setnick": "设置昵称",
|
||||||
"language": "语言地区",
|
"language": "语言地区",
|
||||||
"chinese": "中文",
|
"chinese": "中文",
|
||||||
"clear": "清除背景",
|
"clear": "清除背景",
|
||||||
},
|
},
|
||||||
onmain: function(can, msg) {
|
onmain: function(can, msg) {
|
||||||
function init() { can.run({}, [], function(msg) {
|
function init() { can.run({}, [], function(msg) {
|
||||||
can.base.Copy(can.onaction._trans, can.base.Obj(msg.Option(chat.TRANS), {}))
|
can.base.Copy(can.onaction._trans, can.base.Obj(msg.Option(chat.TRANS), {}))
|
||||||
can.onimport._init(can, msg, function(msg) { can.onengine.signal(can, chat.ONLOGIN, msg) }, can._output)
|
can.onimport._init(can, msg, function(msg) { can.onengine.signal(can, chat.ONLOGIN, msg) }, can._output)
|
||||||
|
|
||||||
can.search({}, ["River.onmotion.toggle"])
|
can.search({}, ["River.onmotion.toggle"])
|
||||||
}) }; can.search({}, ["River.onmotion.hidden"])
|
}) }; can.search({}, ["River.onmotion.hidden"])
|
||||||
if (can.misc.Search(can, ice.MSG_SESSID)) {
|
if (can.misc.Search(can, ice.MSG_SESSID)) {
|
||||||
can.misc.CookieSessid(can, can.misc.Search(can, ice.MSG_SESSID))
|
can.misc.CookieSessid(can, can.misc.Search(can, ice.MSG_SESSID))
|
||||||
return can.misc.Search(can, ice.MSG_SESSID, "")
|
return can.misc.Search(can, ice.MSG_SESSID, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录检查
|
// 登录检查
|
||||||
can.user.isLocalFile? init(): can.run({}, [chat.CHECK], function(msg) {
|
can.user.isLocalFile? init(): can.run({}, [chat.CHECK], function(msg) {
|
||||||
can.Conf(aaa.USERNICK, msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME))? init():
|
can.Conf(aaa.USERNICK, msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME))? init():
|
||||||
msg.Option(chat.SSO)? can.user.jumps(msg.Option(chat.SSO)):
|
msg.Option(chat.SSO)? can.user.jumps(msg.Option(chat.SSO)):
|
||||||
can.user.login(can, init, msg.Option(aaa.LOGIN))
|
can.user.login(can, init, msg.Option(aaa.LOGIN))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onstorm_select: function(can, msg, river, storm) { can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm) },
|
onstorm_select: function(can, msg, river, storm) { can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm) },
|
||||||
onsearchfocus: function(can) {
|
onsearchfocus: function(can) {
|
||||||
can.page.Select(can, can._output, "div.search input", function(target) { target.focus() })
|
can.page.Select(can, can._output, "div.search input", function(target) { target.focus() })
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function(event, can) {
|
title: function(event, can) {
|
||||||
var args = {}; can.core.List([chat.TITLE, chat.TOPIC, chat.LAYOUT], function(key) {
|
var args = {}; can.core.List([chat.TITLE, chat.TOPIC, chat.LAYOUT], function(key) {
|
||||||
var value = can.misc.Search(can, key); value && (args[key] = value)
|
var value = can.misc.Search(can, key); value && (args[key] = value)
|
||||||
})
|
})
|
||||||
can.user.jumps(can.misc.MergeURL(can, args, true))
|
can.user.jumps(can.misc.MergeURL(can, args, true))
|
||||||
},
|
},
|
||||||
river: function(event, can) { can.onaction.River(can) },
|
river: function(event, can) { can.onaction.River(can) },
|
||||||
|
|
||||||
black: function(event, can, button) { can.onlayout.topic(can, button), can.onlayout._init(can) },
|
black: function(event, can, button) { can.onlayout.topic(can, button), can.onlayout._init(can) },
|
||||||
white: function(event, can, button) { can.onlayout.topic(can, button), can.onlayout._init(can) },
|
white: function(event, can, button) { can.onlayout.topic(can, button), can.onlayout._init(can) },
|
||||||
print: function(event, can, button) { can.onlayout.topic(can, can.base.join([chat.WHITE, button]))
|
print: function(event, can, button) { can.onlayout.topic(can, can.base.join([chat.WHITE, button]))
|
||||||
can.set("River", html.HEIGHT, -1), can.set("Action", html.HEIGHT, -1)
|
can.set("River", html.HEIGHT, -1), can.set("Action", html.HEIGHT, -1)
|
||||||
},
|
},
|
||||||
webpack: function(event, can) {
|
webpack: function(event, can) {
|
||||||
can.user.input(event, can, [{name: mdb.NAME, value: can.user.title()}], function(ev, button, meta, list) {
|
can.user.input(event, can, [{name: mdb.NAME, value: can.user.title()}], function(ev, button, meta, list) {
|
||||||
can.core.Item(Volcanos.meta.pack, function(key, msg) {
|
can.core.Item(Volcanos.meta.pack, function(key, msg) {
|
||||||
can.core.List(["_event", "_can", "_xhr", ice.MSG_SESSID, ""], function(key) { delete(msg[key]) })
|
can.core.List(["_event", "_can", "_xhr", ice.MSG_SESSID, ""], function(key) { delete(msg[key]) })
|
||||||
})
|
})
|
||||||
var msg = can.request(event, {
|
var msg = can.request(event, {
|
||||||
name: meta.name, content: JSON.stringify(Volcanos.meta.pack),
|
name: meta.name, content: JSON.stringify(Volcanos.meta.pack),
|
||||||
river: can.Conf(chat.RIVER), storm: can.Conf(chat.STORM),
|
river: can.Conf(chat.RIVER), storm: can.Conf(chat.STORM),
|
||||||
})
|
})
|
||||||
|
|
||||||
var toast = can.user.toast(can, "打包中...", code.WEBPACK, 1000000)
|
var toast = can.user.toast(can, "打包中...", code.WEBPACK, 1000000)
|
||||||
can.run(event, [code.WEBPACK], function(msg) {
|
can.run(event, [code.WEBPACK], function(msg) {
|
||||||
toast.close(), can.user.toast(can, "打包成功", code.WEBPACK)
|
toast.close(), can.user.toast(can, "打包成功", code.WEBPACK)
|
||||||
can.user.download(can, "/share/local/"+msg.Result(), name+".html")
|
can.user.download(can, "/share/local/"+msg.Result(), name+".html")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toimage: function(event, can, button) { can.onmotion.toimage(event, can, document.title, document.body) },
|
toimage: function(event, can, button) { can.onmotion.toimage(event, can, document.title, document.body) },
|
||||||
|
|
||||||
carte: function(event, can, list, cb, trans) { can.user.carte(event, can, can.onaction, list, cb) },
|
carte: function(event, can, list, cb, trans) { can.user.carte(event, can, can.onaction, list, cb) },
|
||||||
share: function(event, can, args) {
|
share: function(event, can, args) {
|
||||||
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE].concat(args||[],
|
can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE].concat(args||[],
|
||||||
[chat.RIVER, can.Conf(chat.RIVER), chat.STORM, can.Conf(chat.STORM)]))
|
[chat.RIVER, can.Conf(chat.RIVER), chat.STORM, can.Conf(chat.STORM)]))
|
||||||
},
|
},
|
||||||
|
|
||||||
usernick: function(event, can) {
|
usernick: function(event, can) {
|
||||||
can.onaction.carte(event, can, ["shareuser", "setnick", [aaa.LANGUAGE, aaa.CHINESE, aaa.ENGLISH], cli.CLEAR, aaa.LOGOUT])
|
can.onaction.carte(event, can, ["shareuser", "setnick", [aaa.LANGUAGE, aaa.CHINESE, aaa.ENGLISH], cli.CLEAR, aaa.LOGOUT])
|
||||||
},
|
},
|
||||||
shareuser: function(event, can) { can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE, mdb.TYPE, aaa.LOGIN]) },
|
shareuser: function(event, can) { can.user.share(can, can.request(event), [ctx.ACTION, chat.SHARE, mdb.TYPE, aaa.LOGIN]) },
|
||||||
setnick: function(event, can) {
|
setnick: function(event, can) {
|
||||||
var ui = can.user.input(event, can, [{name: aaa.USERNICK, value: can.Conf(aaa.USERNICK)}], function(ev, button, data, list, args) {
|
var ui = can.user.input(event, can, [{name: aaa.USERNICK, value: can.Conf(aaa.USERNICK)}], function(ev, button, data, list, args) {
|
||||||
can.run(event, [aaa.USERNICK, list[0]], function(msg) {
|
can.run(event, [aaa.USERNICK, list[0]], function(msg) {
|
||||||
can.page.Select(can, can._output, can.core.Keys(html.DIV, aaa.USERNICK), function(item) {
|
can.page.Select(can, can._output, can.core.Keys(html.DIV, aaa.USERNICK), function(item) {
|
||||||
can.page.Modify(can, item, can.Conf(aaa.USERNICK, list[0]))
|
can.page.Modify(can, item, can.Conf(aaa.USERNICK, list[0]))
|
||||||
}), can.user.toastSuccess(can)
|
}), can.user.toastSuccess(can)
|
||||||
}, true)
|
}, true)
|
||||||
})
|
})
|
||||||
can.user.isMobile && can.page.Modify(can, ui._target, {style: {top: 40, right: 0, left: ""}})
|
can.user.isMobile && can.page.Modify(can, ui._target, {style: {top: 40, right: 0, left: ""}})
|
||||||
},
|
},
|
||||||
chinese: function(event, can) { can.misc.Search(can, aaa.LANGUAGE, "zh") },
|
chinese: function(event, can) { can.misc.Search(can, aaa.LANGUAGE, "zh") },
|
||||||
english: function(event, can) { can.misc.Search(can, aaa.LANGUAGE, "en") },
|
english: function(event, can) { can.misc.Search(can, aaa.LANGUAGE, "en") },
|
||||||
clear: function(event, can) { can.onimport.background(event, can, ""), can.onimport.avatar(event, can, ""), can.user.reload(true) },
|
clear: function(event, can) { can.onimport.background(event, can, ""), can.onimport.avatar(event, can, ""), can.user.reload(true) },
|
||||||
logout: function(event, can) { can.user.logout(can) },
|
logout: function(event, can) { can.user.logout(can) },
|
||||||
|
|
||||||
River: function(can) { can.search({}, ["River.onmotion.toggle"]) },
|
River: function(can) { can.search({}, ["River.onmotion.toggle"]) },
|
||||||
Footer: function(can) { can.search({}, ["Footer.onmotion.toggle"]) },
|
Footer: function(can) { can.search({}, ["Footer.onmotion.toggle"]) },
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
height: function(can) { return can._target.offsetHeight },
|
height: function(can) { return can._target.offsetHeight },
|
||||||
topic: function(can) { return can._topic },
|
topic: function(can) { return can._topic },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
505
panel/river.js
505
panel/river.js
@ -1,284 +1,283 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
if (msg.Option(ice.MSG_RIVER) == "_share") { return can.onmotion.hidden(can) }
|
if (msg.Option(ice.MSG_RIVER) == "_share") { return can.onmotion.hidden(can) }
|
||||||
can.onmotion.clear(can), can.river_list = {}, can.storm_list = {}
|
can.onmotion.clear(can), can.river_list = {}, can.storm_list = {}
|
||||||
|
|
||||||
can.onimport._main(can, msg), can.onimport._menu(can, msg)
|
can.onimport._main(can, msg), can.onimport._menu(can, msg)
|
||||||
var select; can.page.Append(can, can._output, msg.Table(function(item, index) {
|
var select; can.page.Append(can, can._output, msg.Table(function(item, index) {
|
||||||
return can.onimport._river(can, item, function(target) {
|
return can.onimport._river(can, item, function(target) {
|
||||||
(index == 0 || item.hash == can._main_river) && (select = target)
|
(index == 0 || item.hash == can._main_river) && (select = target)
|
||||||
})
|
})
|
||||||
})), select && select.click()
|
})), select && select.click()
|
||||||
},
|
},
|
||||||
_main: function(can, msg) { can._main_river = "project", can._main_storm = "studio"
|
_main: function(can, msg) { can._main_river = "project", can._main_storm = "studio"
|
||||||
if (can.user.isExtension) { var args = Volcanos.meta.args
|
if (can.user.isExtension) { var args = Volcanos.meta.args
|
||||||
can._main_river = args.river||"product", can._main_storm = args.storm||"chrome"
|
can._main_river = args.river||"product", can._main_storm = args.storm||"chrome"
|
||||||
}
|
}
|
||||||
if (can.user.isMobile) { can._main_river = "product", can._main_storm = "office" }
|
if (can.user.isMobile) { can._main_river = "product", can._main_storm = "office" }
|
||||||
if (can.user.isWeiXin) { can._main_river = "service", can._main_storm = "wx" }
|
if (can.user.isWeiXin) { can._main_river = "service", can._main_storm = "wx" }
|
||||||
|
|
||||||
can._main_title = can.misc.Search(can, chat.TITLE)||msg.Option(ice.MSG_TITLE)||Volcanos.meta.args.title||can.misc.Search(can, ice.POD)||can._main_title
|
can._main_title = can.misc.Search(can, chat.TITLE)||msg.Option(ice.MSG_TITLE)||Volcanos.meta.args.title||can.misc.Search(can, ice.POD)||can._main_title
|
||||||
can._main_river = can.misc.Search(can, chat.RIVER)||msg.Option(ice.MSG_RIVER)||Volcanos.meta.args.river||can._main_river
|
can._main_river = can.misc.Search(can, chat.RIVER)||msg.Option(ice.MSG_RIVER)||Volcanos.meta.args.river||can._main_river
|
||||||
can._main_storm = can.misc.Search(can, chat.STORM)||msg.Option(ice.MSG_STORM)||Volcanos.meta.args.storm||can._main_storm
|
can._main_storm = can.misc.Search(can, chat.STORM)||msg.Option(ice.MSG_STORM)||Volcanos.meta.args.storm||can._main_storm
|
||||||
},
|
},
|
||||||
_menu: function(can, msg) { if (can.user.mod.isPod) { return }
|
_menu: function(can, msg) { if (can.user.mod.isPod) { return }
|
||||||
can.setHeaderMenu(can.base.Obj(msg.Option(chat.MENUS), can.Conf(chat.MENUS)||can.ondetail._menus), function(event, button) {
|
can.setHeaderMenu(can.base.Obj(msg.Option(chat.MENUS), can.Conf(chat.MENUS)||can.ondetail._menus), function(event, button) {
|
||||||
can.core.CallFunc([can.ondetail, button], [event, can, button, can.Conf(chat.RIVER), can.Conf(chat.STORM)])
|
can.core.CallFunc([can.ondetail, button], [event, can, button, can.Conf(chat.RIVER), can.Conf(chat.STORM)])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_carte: function(can, list, river, storm) { if (can.user.isMobile) { return }
|
_carte: function(can, list, river, storm) { if (can.user.isMobile) { return }
|
||||||
if (can.core.Value(can._root, can.core.Keys(chat.RIVER, river))) { return }
|
if (can.core.Value(can._root, can.core.Keys(chat.RIVER, river))) { return }
|
||||||
|
|
||||||
can.onaction.carte(event, can, list, function(event, button, module) {
|
can.onaction.carte(event, can, list, function(event, button, module) {
|
||||||
module[button](event, can, button, river, storm)
|
module[button](event, can, button, river, storm)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_river: function(can, meta, cb) {
|
_river: function(can, meta, cb) {
|
||||||
return {text: [meta.name, html.DIV, html.ITEM], onclick: function(event) {
|
return {text: [meta.name, html.DIV, html.ITEM], onclick: function(event) {
|
||||||
can.onaction.storm(event, can, meta.hash)
|
can.onaction.storm(event, can, meta.hash)
|
||||||
|
|
||||||
}, onmouseenter: function(event) {
|
}, onmouseenter: function(event) {
|
||||||
can.onimport._carte(can, can.ondetail.list, meta.hash)
|
can.onimport._carte(can, can.ondetail.list, meta.hash)
|
||||||
|
|
||||||
}, _init: function(target) { cb(target)
|
}, _init: function(target) { cb(target)
|
||||||
can.river_list[meta.hash] = target
|
can.river_list[meta.hash] = target
|
||||||
}}
|
}}
|
||||||
},
|
},
|
||||||
_storm: function(can, meta, river) {
|
_storm: function(can, meta, river) {
|
||||||
return {text: [meta.name, html.DIV, html.ITEM], onclick: function(event) {
|
return {text: [meta.name, html.DIV, html.ITEM], onclick: function(event) {
|
||||||
can.onaction.action(event, can, river, meta.hash)
|
can.onaction.action(event, can, river, meta.hash)
|
||||||
can.user.title(can._main_title||meta.name)
|
can.user.title(can._main_title||meta.name)
|
||||||
|
|
||||||
}, onmouseenter: function(event) {
|
}, onmouseenter: function(event) {
|
||||||
can.onimport._carte(can, can.ondetail.sublist, river, meta.hash)
|
can.onimport._carte(can, can.ondetail.sublist, river, meta.hash)
|
||||||
|
|
||||||
}, _init: function(target) {
|
}, _init: function(target) {
|
||||||
can.storm_list[can.core.Keys(river, meta.hash)] = target
|
can.storm_list[can.core.Keys(river, meta.hash)] = target
|
||||||
}}
|
}}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onengine", {help: "解析引擎", list: [], _engine: function(event, can, msg, panel, cmds, cb) {
|
Volcanos("onengine", {help: "解析引擎", list: [], _engine: function(event, can, msg, panel, cmds, cb) {
|
||||||
var list = can._root.river
|
var list = can._root.river
|
||||||
cmds.length == 0 && can.core.Item(list, function(key, value) {
|
cmds.length == 0 && can.core.Item(list, function(key, value) {
|
||||||
if (can.core.Item(value.storm).length == 0) { return }
|
if (can.core.Item(value.storm).length == 0) { return }
|
||||||
msg.Push({hash: key, name: can.user.language(can) == "en"? key: value.name}) // 群组列表
|
msg.Push({hash: key, name: can.user.language(can) == "en"? key: value.name}) // 群组列表
|
||||||
}); if (cmds.length != 1 && cmds[1] != chat.STORM) { return false }
|
}); if (cmds.length != 1 && cmds[1] != chat.STORM) { return false }
|
||||||
|
|
||||||
var river = list[cmds[0]]; if (!river) { return false }
|
var river = list[cmds[0]]; if (!river) { return false }
|
||||||
can.core.Item(river.storm, function(key, value) {
|
can.core.Item(river.storm, function(key, value) {
|
||||||
msg.Push({hash: key, name: can.user.language(can) == "en"? key: value.name}) // 应用列表
|
msg.Push({hash: key, name: can.user.language(can) == "en"? key: value.name}) // 应用列表
|
||||||
}), can.base.isFunc(cb) && cb(msg); return true
|
}), can.base.isFunc(cb) && cb(msg); return true
|
||||||
},
|
}})
|
||||||
})
|
|
||||||
Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, cb, target) {
|
Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, cb, target) {
|
||||||
can.onengine.plugin(can, "info", shy("信息", {}, ["text", "list", "back"], function(msg, cmds) {
|
can.onengine.plugin(can, "info", shy("信息", {}, ["text", "list", "back"], function(msg, cmds) {
|
||||||
msg.Echo(JSON.stringify(can))
|
msg.Echo(JSON.stringify(can))
|
||||||
}))
|
}))
|
||||||
can.onengine.plugin(can, "log", shy("日志", {}, ["text", "list", "back"], function(msg, cmds) {
|
can.onengine.plugin(can, "log", shy("日志", {}, ["text", "list", "back"], function(msg, cmds) {
|
||||||
console.log(cmds[0])
|
console.log(cmds[0])
|
||||||
msg.Option(ice.MSG_DISPLAY, "/plugin/story/pie.js")
|
msg.Option(ice.MSG_DISPLAY, "/plugin/story/pie.js")
|
||||||
}))
|
}))
|
||||||
can.onengine.plugin(can, "pie", shy("比例图", {}, ["list", "back"], function(msg, cmds) {
|
can.onengine.plugin(can, "pie", shy("比例图", {}, ["list", "back"], function(msg, cmds) {
|
||||||
msg.Option(ice.MSG_DISPLAY, "/plugin/story/pie.js")
|
msg.Option(ice.MSG_DISPLAY, "/plugin/story/pie.js")
|
||||||
msg.Push("value", 200)
|
msg.Push("value", 200)
|
||||||
msg.Push("value", 300)
|
msg.Push("value", 300)
|
||||||
msg.Push("value", 400)
|
msg.Push("value", 400)
|
||||||
}))
|
}))
|
||||||
can.base.isFunc(cb) && cb()
|
can.base.isFunc(cb) && cb()
|
||||||
},
|
},
|
||||||
onlogin: function(can, msg) {
|
onlogin: function(can, msg) {
|
||||||
can.onappend._action(can, can.Conf(ctx.ACTION)||can.onaction.list)
|
can.onappend._action(can, can.Conf(ctx.ACTION)||can.onaction.list)
|
||||||
can.run({}, [], function(msg) { can.onimport._init(can, msg, [], null, can._output) })
|
can.run({}, [], function(msg) { can.onimport._init(can, msg, [], null, can._output) })
|
||||||
},
|
},
|
||||||
onsearch: function(can, msg, word) {
|
onsearch: function(can, msg, word) {
|
||||||
if (word[0] == "*" || word[0] == chat.STORM) { can.onexport.storm(can, msg, word) }
|
if (word[0] == "*" || word[0] == chat.STORM) { can.onexport.storm(can, msg, word) }
|
||||||
},
|
},
|
||||||
onstorm_select: function(can, msg, river, storm) { var args = {river: river, storm: storm}
|
onstorm_select: function(can, msg, river, storm) { var args = {river: river, storm: storm}
|
||||||
if (can.user.isExtension) { localStorage.setItem(ctx.ARGS, JSON.stringify(args)) }
|
if (can.user.isExtension) { localStorage.setItem(ctx.ARGS, JSON.stringify(args)) }
|
||||||
},
|
},
|
||||||
onaction_touch: function(can, msg) {
|
onaction_touch: function(can, msg) {
|
||||||
can.onmotion.float.del(can, chat.CARTE)
|
can.onmotion.float.del(can, chat.CARTE)
|
||||||
can.user.isMobile && can.onmotion.hidden(can)
|
can.user.isMobile && can.onmotion.hidden(can)
|
||||||
},
|
},
|
||||||
onaction_notool: function(can, msg, river, storm) {
|
onaction_notool: function(can, msg, river, storm) {
|
||||||
can.ondetail["添加工具"](msg._event, can, "添加工具", river, storm)
|
can.ondetail["添加工具"](msg._event, can, "添加工具", river, storm)
|
||||||
},
|
},
|
||||||
|
|
||||||
carte: function(event, can, list, cb) {
|
carte: function(event, can, list, cb) {
|
||||||
can.user.carteRight(event, can, can.ondetail, list, cb)
|
can.user.carteRight(event, can, can.ondetail, list, cb)
|
||||||
},
|
},
|
||||||
storm: function(event, can, river) { can.sublist = can.sublist||{}
|
storm: function(event, can, river) { can.sublist = can.sublist||{}
|
||||||
can.onmotion.select(can, can._output, "div.item", can.river_list[river])
|
can.onmotion.select(can, can._output, "div.item", can.river_list[river])
|
||||||
var list = can.sublist[river]; if (list) { return can.onmotion.toggle(can, list) }
|
var list = can.sublist[river]; if (list) { return can.onmotion.toggle(can, list) }
|
||||||
|
|
||||||
can.run({}, [river, chat.STORM], function(msg) {
|
can.run({}, [river, chat.STORM], function(msg) {
|
||||||
var select = 0; list = can.page.Append(can, can._output, [{view: html.LIST, list: msg.Table(function(item, index) {
|
var select = 0; list = can.page.Append(can, can._output, [{view: html.LIST, list: msg.Table(function(item, index) {
|
||||||
river == can._main_river && item.hash == can._main_storm && (select = index)
|
river == can._main_river && item.hash == can._main_storm && (select = index)
|
||||||
return can.onimport._storm(can, item, river)
|
return can.onimport._storm(can, item, river)
|
||||||
}) }]).first, list.children.length > 0 && list.children[select].click()
|
}) }]).first, list.children.length > 0 && list.children[select].click()
|
||||||
|
|
||||||
event.target.nextSibling && can._output.insertBefore(list, event.target.nextSibling)
|
event.target.nextSibling && can._output.insertBefore(list, event.target.nextSibling)
|
||||||
can.sublist[river] = list
|
can.sublist[river] = list
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
action: function(event, can, river, storm) {
|
action: function(event, can, river, storm) {
|
||||||
can.page.Modify(can, can.sublist[river], {style: {display: html.BLOCK}})
|
can.page.Modify(can, can.sublist[river], {style: {display: html.BLOCK}})
|
||||||
can.onmotion.select(can, can._output, "div.item", can.river_list[river])
|
can.onmotion.select(can, can._output, "div.item", can.river_list[river])
|
||||||
can.onmotion.select(can, can._output, "div.list div.item", can.storm_list[can.core.Keys(river, storm)])
|
can.onmotion.select(can, can._output, "div.list div.item", can.storm_list[can.core.Keys(river, storm)])
|
||||||
|
|
||||||
can.onengine.signal(can, "onstorm_select", can.request(event, {
|
can.onengine.signal(can, "onstorm_select", can.request(event, {
|
||||||
river: can.Conf(chat.RIVER, river), storm: can.Conf(chat.STORM, storm),
|
river: can.Conf(chat.RIVER, river), storm: can.Conf(chat.STORM, storm),
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
|
||||||
create: function(event, can) {
|
create: function(event, can) {
|
||||||
can.user.trans(can, {"public": "公开群", "protected": "内部群", "private": "私有群"})
|
can.user.trans(can, {"public": "公开群", "protected": "内部群", "private": "私有群"})
|
||||||
can.user.input(event, can, [
|
can.user.input(event, can, [
|
||||||
{name: mdb.TYPE, values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"},
|
{name: mdb.TYPE, values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"},
|
||||||
{name: mdb.NAME, value: "hi", _trans: "群名"}, {name: mdb.TEXT, value: "hello", _trans: "简介"},
|
{name: mdb.NAME, value: "hi", _trans: "群名"}, {name: mdb.TEXT, value: "hello", _trans: "简介"},
|
||||||
], function(event, button, meta, list, args) {
|
], function(event, button, meta, list, args) {
|
||||||
can.run(event, [ctx.ACTION, mdb.CREATE].concat(args), function(msg) {
|
can.run(event, [ctx.ACTION, mdb.CREATE].concat(args), function(msg) {
|
||||||
can.misc.Search(can, {river: msg.Result()})
|
can.misc.Search(can, {river: msg.Result()})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
refresh: function(event, can) {
|
refresh: function(event, can) {
|
||||||
var args = {river: can.Conf(chat.RIVER), storm: can.Conf(chat.STORM),
|
var args = {river: can.Conf(chat.RIVER), storm: can.Conf(chat.STORM),
|
||||||
topic: can.getHeader(chat.TOPIC), layout: can.getAction(chat.LAYOUT),
|
topic: can.getHeader(chat.TOPIC), layout: can.getAction(chat.LAYOUT),
|
||||||
}
|
}
|
||||||
if (can.user.isExtension) { localStorage.setItem(ctx.ARGS, JSON.stringify(args)) }
|
if (can.user.isExtension) { localStorage.setItem(ctx.ARGS, JSON.stringify(args)) }
|
||||||
can.misc.Search(can, args)
|
can.misc.Search(can, args)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("ondetail", {help: "菜单交互",
|
Volcanos("ondetail", {help: "菜单交互",
|
||||||
list: ["共享群组", "添加应用", "添加设备", "添加用户", "重命名群组", "删除群组"],
|
list: ["共享群组", "添加应用", "添加设备", "添加用户", "重命名群组", "删除群组"],
|
||||||
sublist: ["共享应用", "添加工具", "保存参数", "重命名应用", "删除应用"],
|
sublist: ["共享应用", "添加工具", "保存参数", "重命名应用", "删除应用"],
|
||||||
_menus: [
|
_menus: [
|
||||||
["create", "创建群组", "添加应用", "添加工具", "添加设备", "创建空间"],
|
["create", "创建群组", "添加应用", "添加工具", "添加设备", "创建空间"],
|
||||||
["share", "共享群组", "共享应用", "共享工具", "共享主机", "访问空间"],
|
["share", "共享群组", "共享应用", "共享工具", "共享主机", "访问空间"],
|
||||||
],
|
],
|
||||||
|
|
||||||
"创建群组": function(event, can) { can.onaction.create(event, can) },
|
"创建群组": function(event, can) { can.onaction.create(event, can) },
|
||||||
"共享群组": function(event, can, button, river) {
|
"共享群组": function(event, can, button, river) {
|
||||||
can.onmotion.share(event, can, [{name: chat.TITLE, value: river}], [mdb.TYPE, chat.RIVER])
|
can.onmotion.share(event, can, [{name: chat.TITLE, value: river}], [mdb.TYPE, chat.RIVER])
|
||||||
},
|
},
|
||||||
"添加应用": function(event, can, button, river) { can.ondetail.create(event, can, button, river) },
|
"添加应用": function(event, can, button, river) { can.ondetail.create(event, can, button, river) },
|
||||||
"共享应用": function(event, can, button, river, storm) {
|
"共享应用": function(event, can, button, river, storm) {
|
||||||
can.onmotion.share(event, can, [{name: chat.TITLE, value: storm}], [mdb.TYPE, chat.STORM])
|
can.onmotion.share(event, can, [{name: chat.TITLE, value: storm}], [mdb.TYPE, chat.STORM])
|
||||||
},
|
},
|
||||||
"添加工具": function(event, can, button, river, storm) {
|
"添加工具": function(event, can, button, river, storm) {
|
||||||
can.user.select(event, can, ctx.COMMAND, "context,command", function(item, next) {
|
can.user.select(event, can, ctx.COMMAND, "context,command", function(item, next) {
|
||||||
can.run({}, [river, chat.STORM, ctx.ACTION, mdb.INSERT, mdb.HASH, storm].concat([ice.POD, "", ice.CTX, item[0], ice.CMD, item[1]]), function(msg) {
|
can.run({}, [river, chat.STORM, ctx.ACTION, mdb.INSERT, mdb.HASH, storm].concat([ice.POD, "", ice.CTX, item[0], ice.CMD, item[1]]), function(msg) {
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
}, function() {
|
}, function() {
|
||||||
can.misc.Search(can, {river: river, storm: storm})
|
can.misc.Search(can, {river: river, storm: storm})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"共享工具": function(event, can, button, river, storm) {
|
"共享工具": function(event, can, button, river, storm) {
|
||||||
can.user.select(event, can, mdb.PLUGIN, "name,context,command,argument", function(item, next) {
|
can.user.select(event, can, mdb.PLUGIN, "name,context,command,argument", function(item, next) {
|
||||||
can.user.share(can, can.request(event), [river, ctx.ACTION, chat.SHARE, mdb.TYPE, chat.FIELD,
|
can.user.share(can, can.request(event), [river, ctx.ACTION, chat.SHARE, mdb.TYPE, chat.FIELD,
|
||||||
mdb.NAME, item[2], mdb.TEXT, item[3], chat.TITLE, item[0], chat.RIVER, river, chat.STORM, storm,
|
mdb.NAME, item[2], mdb.TEXT, item[3], chat.TITLE, item[0], chat.RIVER, river, chat.STORM, storm,
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
"添加设备": function(event, can, button, river) {
|
"添加设备": function(event, can, button, river) {
|
||||||
can.user.select(event, can, web.SPACE, "type,name,text", function(item, next) {
|
can.user.select(event, can, web.SPACE, "type,name,text", function(item, next) {
|
||||||
can.run({}, [river, chat.NODE, ctx.ACTION, mdb.INSERT, mdb.TYPE, item[0], mdb.NAME, item[1]], function(msg) {
|
can.run({}, [river, chat.NODE, ctx.ACTION, mdb.INSERT, mdb.TYPE, item[0], mdb.NAME, item[1]], function(msg) {
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"共享主机": function(event, can, button, river, storm) {
|
"共享主机": function(event, can, button, river, storm) {
|
||||||
can.run(event, [ctx.ACTION, aaa.INVITE], function(msg) {
|
can.run(event, [ctx.ACTION, aaa.INVITE], function(msg) {
|
||||||
can.user.toast(can, {
|
can.user.toast(can, {
|
||||||
title: "共享主机", duration: -1, width: -300,
|
title: "共享主机", duration: -1, width: -300,
|
||||||
content: msg.Result(), action: [cli.CLOSE],
|
content: msg.Result(), action: [cli.CLOSE],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"创建空间": function(event, can, button, river, storm) { can.request(event, {action: button})
|
"创建空间": function(event, can, button, river, storm) { can.request(event, {action: button})
|
||||||
can.user.input(event, can, [{name: "name", value: "hi"}, {name: "repos"}, {name: "template"}], function(event, button, data, list, args) {
|
can.user.input(event, can, [{name: "name", value: "hi"}, {name: "repos"}, {name: "template"}], function(event, button, data, list, args) {
|
||||||
can.run(event, [ctx.ACTION, cli.START].concat(args, chat.RIVER, river), function(msg) {
|
can.run(event, [ctx.ACTION, cli.START].concat(args, chat.RIVER, river), function(msg) {
|
||||||
var link = can.misc.MergeURL(can, {_path: "/chat/pod/"+can.core.Keys(can.misc.Search(can, ice.POD), msg.Option(mdb.NAME))})
|
var link = can.misc.MergeURL(can, {_path: "/chat/pod/"+can.core.Keys(can.misc.Search(can, ice.POD), msg.Option(mdb.NAME))})
|
||||||
can.user.toast(can, link), can.user.open(link)
|
can.user.toast(can, link), can.user.open(link)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"访问空间": function(event, can, button, river, storm) {
|
"访问空间": function(event, can, button, river, storm) {
|
||||||
can.user.select({river: river}, can, web.SPACE, "time,type,name,text")
|
can.user.select({river: river}, can, web.SPACE, "time,type,name,text")
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
"添加用户": function(event, can, button, river) {
|
"添加用户": function(event, can, button, river) {
|
||||||
can.user.select(event, can, chat.USER, "usernick,username", function(item, next) {
|
can.user.select(event, can, chat.USER, "usernick,username", function(item, next) {
|
||||||
can.run({}, [river, chat.USER, ctx.ACTION, mdb.INSERT, aaa.USERNAME, item[0]], function(msg) {
|
can.run({}, [river, chat.USER, ctx.ACTION, mdb.INSERT, aaa.USERNAME, item[0]], function(msg) {
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"重命名群组": function(event, can, button, river) {
|
"重命名群组": function(event, can, button, river) {
|
||||||
can.user.input(event, can, [mdb.NAME], function(event, button, meta, list) {
|
can.user.input(event, can, [mdb.NAME], function(event, button, meta, list) {
|
||||||
can.run(can.request(event, {hash: river})._event, [ctx.ACTION, mdb.MODIFY, mdb.NAME, meta.name], function(msg) {
|
can.run(can.request(event, {hash: river})._event, [ctx.ACTION, mdb.MODIFY, mdb.NAME, meta.name], function(msg) {
|
||||||
can.misc.Search(can, {river: river})
|
can.misc.Search(can, {river: river})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"删除群组": function(event, can, button, river) {
|
"删除群组": function(event, can, button, river) {
|
||||||
can.run(can.request(event, {hash: river})._event, [ctx.ACTION, mdb.REMOVE], function(msg) { can.misc.Search(can, {}) })
|
can.run(can.request(event, {hash: river})._event, [ctx.ACTION, mdb.REMOVE], function(msg) { can.misc.Search(can, {}) })
|
||||||
},
|
},
|
||||||
|
|
||||||
"保存参数": function(event, can, button, river, storm) {
|
"保存参数": function(event, can, button, river, storm) {
|
||||||
can.getAction(ctx.ARGS, function(item, next, index, array) { var msg = can.request({}, {hash: storm, id: item.dataset.id})
|
can.getAction(ctx.ARGS, function(item, next, index, array) { var msg = can.request({}, {hash: storm, id: item.dataset.id})
|
||||||
var toast = can.user.toast(can, (index+1)+ice.PS+array.length, button, 10000, (index+1)*100/array.length)
|
var toast = can.user.toast(can, (index+1)+ice.PS+array.length, button, 10000, (index+1)*100/array.length)
|
||||||
can.run(msg._event, [river, chat.STORM, ctx.ACTION, mdb.MODIFY, ice.ARG, item.dataset.args], function(msg) {
|
can.run(msg._event, [river, chat.STORM, ctx.ACTION, mdb.MODIFY, ice.ARG, item.dataset.args], function(msg) {
|
||||||
can.core.Timer(200, function() {
|
can.core.Timer(200, function() {
|
||||||
toast.close(), next(), index == array.length-1 && can.user.toastSuccess(can, button)
|
toast.close(), next(), index == array.length-1 && can.user.toastSuccess(can, button)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"重命名应用": function(event, can, button, river, storm) {
|
"重命名应用": function(event, can, button, river, storm) {
|
||||||
can.user.input(event, can, [mdb.NAME], function(ev, button, meta, list, args) {
|
can.user.input(event, can, [mdb.NAME], function(ev, button, meta, list, args) {
|
||||||
can.run(can.request(event, {hash: storm})._event, [river, chat.STORM, ctx.ACTION, mdb.MODIFY].concat(args), function(msg) {
|
can.run(can.request(event, {hash: storm})._event, [river, chat.STORM, ctx.ACTION, mdb.MODIFY].concat(args), function(msg) {
|
||||||
can.misc.Search(can, {river: river, storm: storm})
|
can.misc.Search(can, {river: river, storm: storm})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"删除应用": function(event, can, button, river, storm) {
|
"删除应用": function(event, can, button, river, storm) {
|
||||||
can.run(can.request(event, {hash: storm})._event, [river, chat.STORM, ctx.ACTION, mdb.REMOVE], function(msg) {
|
can.run(can.request(event, {hash: storm})._event, [river, chat.STORM, ctx.ACTION, mdb.REMOVE], function(msg) {
|
||||||
can.misc.Search(can, {river: river})
|
can.misc.Search(can, {river: river})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
create: function(event, can, button, river) {
|
create: function(event, can, button, river) {
|
||||||
can.user.trans(can, {"public": "公开应用", "protected": "群组应用", "private": "个人应用"})
|
can.user.trans(can, {"public": "公开应用", "protected": "群组应用", "private": "个人应用"})
|
||||||
can.user.input(event, can, [
|
can.user.input(event, can, [
|
||||||
{name: mdb.TYPE, values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"},
|
{name: mdb.TYPE, values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"},
|
||||||
{name: mdb.NAME, value: "hi", _trans: "名称"}, {name: mdb.TEXT, value: "hello", _trans: "简介"},
|
{name: mdb.NAME, value: "hi", _trans: "名称"}, {name: mdb.TEXT, value: "hello", _trans: "简介"},
|
||||||
], function(event, button, meta, list, args) {
|
], function(event, button, meta, list, args) {
|
||||||
can.run({}, [river, chat.STORM, ctx.ACTION, mdb.CREATE].concat(args), function(msg) {
|
can.run({}, [river, chat.STORM, ctx.ACTION, mdb.CREATE].concat(args), function(msg) {
|
||||||
can.misc.Search(can, {river: river, storm: msg.Result()})
|
can.misc.Search(can, {river: river, storm: msg.Result()})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
width: function(can) { return can._target.offsetWidth },
|
width: function(can) { return can._target.offsetWidth },
|
||||||
storm: function(can, msg, word) {
|
storm: function(can, msg, word) {
|
||||||
var fields = (msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(",")
|
var fields = (msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(",")
|
||||||
can.core.Item(can._root.river, function(river, value) {
|
can.core.Item(can._root.river, function(river, value) {
|
||||||
can.core.Item(value.storm, function(storm, item) {
|
can.core.Item(value.storm, function(storm, item) {
|
||||||
if (word[1] != "" && word[1] != storm && word[1] != item.name) { return }
|
if (word[1] != "" && word[1] != storm && word[1] != item.name) { return }
|
||||||
|
|
||||||
var data = {ctx: "web.chat", cmd: chat.STORM,
|
var data = {ctx: "web.chat", cmd: chat.STORM,
|
||||||
type: river, name: storm, text: shy("跳转", function(event) {
|
type: river, name: storm, text: shy("跳转", function(event) {
|
||||||
can.onaction.action(event, can, river, storm)
|
can.onaction.action(event, can, river, storm)
|
||||||
}),
|
}),
|
||||||
}; can.core.List(fields, function(key) { msg.Push(key, data[key]||"") })
|
}; can.core.List(fields, function(key) { msg.Push(key, data[key]||"") })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
193
panel/search.js
193
panel/search.js
@ -1,117 +1,118 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.list = msg.Table(), can.onmotion.clear(can, can.ui.content)
|
can.list = msg.Table(), can.onmotion.clear(can, can.ui.content)
|
||||||
var table = can.onappend.table(can, msg, function(value, key, index, line, array) { can.Status(mdb.TOTAL, index+1)
|
var table = can.onappend.table(can, msg, function(value, key, index, line, array) { can.Status(mdb.TOTAL, index+1)
|
||||||
return {text: [key == mdb.TEXT && can.base.isFunc(line.text) && line.text.help || value, html.TD], onclick: function(event) {
|
return {text: [key == mdb.TEXT && can.base.isFunc(line.text) && line.text.help || value, html.TD], onclick: function(event) {
|
||||||
can.onaction[can.type == "*"||event.ctrlKey? chat.PLUGIN: mdb.SELECT](event, can, index)
|
can.onaction[can.type == "*"||event.ctrlKey? chat.PLUGIN: mdb.SELECT](event, can, index)
|
||||||
}}
|
}}
|
||||||
}, can.ui.content, can.core.List((msg.Option("sort")||"ctx,cmd,type,name,text").split(ice.FS), function(item) {
|
}, can.ui.content, can.core.List((msg.Option("sort")||"ctx,cmd,type,name,text").split(ice.FS), function(item) {
|
||||||
return list.indexOf(item)
|
return list.indexOf(item)
|
||||||
})); table && can.page.Modify(can, can.ui.display, {style: {width: table.offsetWidth}})
|
})); table && can.page.Modify(can, can.ui.display, {style: {width: table.offsetWidth}})
|
||||||
|
|
||||||
can.onappend._status(can, can.base.Obj(msg.Option("_status"), []).concat({name: "selected", value: "0"}))
|
can.onappend._status(can, can.base.Obj(msg.Option("_status"), []).concat({name: "selected", value: "0"}))
|
||||||
can.getActionSize(function(msg, height) {
|
can.getActionSize(function(msg, height) {
|
||||||
can.page.Modify(can, can.ui.profile, kit.Dict(html.MAX_HEIGHT, height-(table&&table.offsetHeight||0)))
|
can.page.Modify(can, can.ui.profile, kit.Dict(html.MAX_HEIGHT, height-(table&&table.offsetHeight||0)))
|
||||||
})
|
})
|
||||||
msg.Length() == 1 && can.page.Select(can, table, html.TD)[0].click()
|
msg.Length() == 1 && can.page.Select(can, table, html.TD)[0].click()
|
||||||
},
|
},
|
||||||
_word: function(can, msg, cmds, fields) { can.type = cmds[0]
|
_word: function(can, msg, cmds, fields) { can.type = cmds[0]
|
||||||
var cb = can.onaction[cmds[1]]; if (cb) { cb({}, can); return }
|
var cb = can.onaction[cmds[1]]; if (cb) { cb({}, can); return }
|
||||||
|
|
||||||
var res = can.request({}, {
|
var res = can.request({}, {
|
||||||
word: cmds, fields: fields.join(ice.FS), sort: msg.Option("sort"),
|
word: cmds, fields: fields.join(ice.FS), sort: msg.Option("sort"),
|
||||||
river: msg.Option(chat.RIVER), index: msg.Option("index"),
|
river: msg.Option(chat.RIVER), index: msg.Option("index"),
|
||||||
})
|
})
|
||||||
|
|
||||||
can.onengine.signal(can, chat.ONSEARCH, res)
|
can.onengine.signal(can, chat.ONSEARCH, res)
|
||||||
can.run(res._event, cmds, function(res) { can.onimport._init(can, res, fields) })
|
can.run(res._event, cmds, function(res) { can.onimport._init(can, res, fields) })
|
||||||
can.onmotion.show(can), can.onmotion.focus(can, can.ui.word)
|
can.onmotion.show(can), can.onmotion.focus(can, can.ui.word)
|
||||||
},
|
},
|
||||||
|
|
||||||
select: function(can, msg, cmds, cb) { can.ui.word.value = cmds[1]
|
select: function(can, msg, cmds, cb) { can.ui.word.value = cmds[1]
|
||||||
var fields = (cmds[2]||msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(ice.FS)
|
var fields = (cmds[2]||msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(ice.FS)
|
||||||
can.page.Appends(can, can.ui.display, [{th: fields}]), can.cb = function() {
|
can.page.Appends(can, can.ui.display, [{th: fields}]), can.cb = function() {
|
||||||
can.base.isFunc(cb) && cb(can.onexport.select(can)), can.onmotion.hide(can)
|
can.base.isFunc(cb) && cb(can.onexport.select(can)), can.onmotion.hide(can)
|
||||||
}
|
}
|
||||||
|
|
||||||
can.input = function(event, word) { cmds[1] = word||cmds[1]
|
can.input = function(event, word) { cmds[1] = word||cmds[1]
|
||||||
can.onimport._word(can, msg, cmds, fields)
|
can.onimport._word(can, msg, cmds, fields)
|
||||||
}, can.onimport._word(can, msg, cmds, fields)
|
}, can.onimport._word(can, msg, cmds, fields)
|
||||||
|
|
||||||
can.getActionSize(function(msg, top, left, width, height) {
|
can.getActionSize(function(msg, top, left, width, height) {
|
||||||
can.page.Modify(can, can._target, {style: {top: top, left: left}})
|
can.page.Modify(can, can._target, {style: {top: top, left: left}})
|
||||||
can.page.Modify(can, can._output, {style: kit.Dict(html.MAX_HEIGHT, height-71, html.MAX_WIDTH, width)})
|
can.page.Modify(can, can._output, {style: kit.Dict(html.MAX_HEIGHT, height-71, html.MAX_WIDTH, width)})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "交互操作", list: [cli.CLEAR, cli.CLOSE, cli.DONE], _init: function(can, cb, target) {
|
Volcanos("onaction", {help: "交互操作", list: [cli.CLEAR, cli.CLOSE, cli.DONE], _init: function(can, cb, target) {
|
||||||
can.base.isFunc(cb) && cb()
|
can.onmotion.hidden(can, can._target)
|
||||||
},
|
can.base.isFunc(cb) && cb()
|
||||||
onlogin: function(can, msg) {
|
},
|
||||||
can.onappend._action(can, can.Conf(html.ACTION)||can.onaction.list)
|
onlogin: function(can, msg) {
|
||||||
can.ui = can.page.Append(can, can._output, [
|
can.onappend._action(can, can.Conf(html.ACTION)||can.onaction.list)
|
||||||
{input: ["word", function(event) { can.onkeymap.input(event, can)
|
can.ui = can.page.Append(can, can._output, [
|
||||||
if (event.key == lang.ESCAPE) { can.onmotion.hide(can) }
|
{input: ["word", function(event) { can.onkeymap.input(event, can)
|
||||||
|
if (event.key == lang.ESCAPE) { can.onmotion.hide(can) }
|
||||||
|
|
||||||
if (event.key == lang.ENTER) { can.onkeymap.prevent(event)
|
if (event.key == lang.ENTER) { can.onkeymap.prevent(event)
|
||||||
if (event.shiftKey) { var first = can.page.Select(can, can.ui.content, html.TR)[1]
|
if (event.shiftKey) { var first = can.page.Select(can, can.ui.content, html.TR)[1]
|
||||||
return can.onaction[can.type == "*"? chat.PLUGIN: html.SELECT](event, can, first.dataset.index)
|
return can.onaction[can.type == "*"? chat.PLUGIN: html.SELECT](event, can, first.dataset.index)
|
||||||
}
|
}
|
||||||
if (event.ctrlKey) { return can.onaction[cli.DONE](event, can) }
|
if (event.ctrlKey) { return can.onaction[cli.DONE](event, can) }
|
||||||
can.input(event, event.target.value)
|
can.input(event, event.target.value)
|
||||||
}
|
}
|
||||||
can.page.Select(can, can.ui.content, html.TR, function(tr, index) {
|
can.page.Select(can, can.ui.content, html.TR, function(tr, index) {
|
||||||
if (index == 0) { return }
|
if (index == 0) { return }
|
||||||
var has = false; can.page.Select(can, tr, html.TD, function(td) {
|
var has = false; can.page.Select(can, tr, html.TD, function(td) {
|
||||||
has = has || td.innerText.indexOf(event.target.value) > -1
|
has = has || td.innerText.indexOf(event.target.value) > -1
|
||||||
})
|
})
|
||||||
can.page.ClassList.set(can, tr, html.HIDDEN, !has)
|
can.page.ClassList.set(can, tr, html.HIDDEN, !has)
|
||||||
})
|
})
|
||||||
}]},
|
}]},
|
||||||
{view: chat.CONTENT}, {view: html.STATUS}, {view: [chat.DISPLAY, html.TABLE]},{view: chat.PROFILE},
|
{view: chat.CONTENT}, {view: html.STATUS}, {view: [chat.DISPLAY, html.TABLE]},{view: chat.PROFILE},
|
||||||
]), can.page.ClassList.add(can, can.ui.display, chat.CONTENT)
|
]), can.page.ClassList.add(can, can.ui.display, chat.CONTENT)
|
||||||
},
|
},
|
||||||
onopensearch: function(can, msg, type, word) { can.onimport.select(can, msg, [type||"*", word||""]) },
|
onopensearch: function(can, msg, type, word) { can.onimport.select(can, msg, [type||"*", word||""]) },
|
||||||
|
|
||||||
clear: function(event, can) { can.onmotion.clear(can, can.ui.profile) },
|
clear: function(event, can) { can.onmotion.clear(can, can.ui.profile) },
|
||||||
done: function(event, can) { can.base.isFunc(can.cb) && can.cb() },
|
done: function(event, can) { can.base.isFunc(can.cb) && can.cb() },
|
||||||
close: function(event, can) { can.onmotion.hide(can) },
|
close: function(event, can) { can.onmotion.hide(can) },
|
||||||
|
|
||||||
select: function(event, can, index) { var line = can.list[index]
|
select: function(event, can, index) { var line = can.list[index]
|
||||||
if (can.base.isFunc(line.text)) { return can.onmotion.hide(can), line.text(event) }
|
if (can.base.isFunc(line.text)) { return can.onmotion.hide(can), line.text(event) }
|
||||||
|
|
||||||
if (line.ctx == "web.chat" && line.cmd == "/search") {
|
if (line.ctx == "web.chat" && line.cmd == "/search") {
|
||||||
return can.onimport.select(can, msg, [line.type, line.name, line.text], can.cb)
|
return can.onimport.select(can, msg, [line.type, line.name, line.text], can.cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
var fields = can.page.Select(can, can.ui.display, html.TH, function(item) { return item.innerText })
|
var fields = can.page.Select(can, can.ui.display, html.TH, function(item) { return item.innerText })
|
||||||
can.page.Append(can, can.ui.display, [{td: can.core.List(fields, function(item) {
|
can.page.Append(can, can.ui.display, [{td: can.core.List(fields, function(item) {
|
||||||
return line[item]
|
return line[item]
|
||||||
}), data: {index: index}, onclick: function(event) { can.page.Remove(can, event.target.parentNode)
|
}), data: {index: index}, onclick: function(event) { can.page.Remove(can, event.target.parentNode)
|
||||||
can.Status("selected", can.page.Select(can, can.ui.display, html.TR).length-1)
|
can.Status("selected", can.page.Select(can, can.ui.display, html.TR).length-1)
|
||||||
}}]), can.Status("selected", can.page.Select(can, can.ui.display, html.TR).length-1)
|
}}]), can.Status("selected", can.page.Select(can, can.ui.display, html.TR).length-1)
|
||||||
},
|
},
|
||||||
|
|
||||||
plugin: function(event, can, index) { var line = can.list[index]
|
plugin: function(event, can, index) { var line = can.list[index]
|
||||||
if (can.base.isFunc(line.text)) { return can.onmotion.hide(can), line.text(event) }
|
if (can.base.isFunc(line.text)) { return can.onmotion.hide(can), line.text(event) }
|
||||||
|
|
||||||
var cmd = line.cmd == ctx.COMMAND? can.core.Keys(line.type, line.name.split(ice.SP)[0]): can.core.Keys(line.ctx, line.cmd)
|
var cmd = line.cmd == ctx.COMMAND? can.core.Keys(line.type, line.name.split(ice.SP)[0]): can.core.Keys(line.ctx, line.cmd)
|
||||||
can.onappend.plugin(can, {type: chat.PLUGIN, index: cmd||msg.Option(mdb.INDEX)}, function(sub, meta) {
|
can.onappend.plugin(can, {type: chat.PLUGIN, index: cmd||msg.Option(mdb.INDEX)}, function(sub, meta) {
|
||||||
can.getActionSize(function(msg, height, width) { height -= can.ui.content.offsetHeight+204
|
can.getActionSize(function(msg, height, width) { height -= can.ui.content.offsetHeight+204
|
||||||
can.page.Modify(can, sub._output, {style: kit.Dict(html.MAX_HEIGHT, height-26, html.MAX_WIDTH, width-40)})
|
can.page.Modify(can, sub._output, {style: kit.Dict(html.MAX_HEIGHT, height-26, html.MAX_WIDTH, width-40)})
|
||||||
sub.Conf(html.HEIGHT, height+28), sub.Conf(html.WIDTH, width-60)
|
sub.Conf(html.HEIGHT, height+28), sub.Conf(html.WIDTH, width-60)
|
||||||
})
|
})
|
||||||
|
|
||||||
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
||||||
}
|
}
|
||||||
}, can.ui.profile)
|
}, can.ui.profile)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
select: function(can) {
|
select: function(can) {
|
||||||
return can.page.Select(can, can.ui.display, html.TR, function(tr) {
|
return can.page.Select(can, can.ui.display, html.TR, function(tr) {
|
||||||
return can.page.Select(can, tr, html.TD, function(td) { return td.innerHTML })
|
return can.page.Select(can, tr, html.TD, function(td) { return td.innerHTML })
|
||||||
}).slice(1)
|
}).slice(1)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,37 +1,36 @@
|
|||||||
Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, meta, list, cb, target) {
|
Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, meta, list, cb, target) {
|
||||||
can.base.isFunc(cb) && cb(); switch (meta.type) {
|
can.base.isFunc(cb) && cb(); switch (meta.type) {
|
||||||
case html.SELECT: meta.value && (target.value = meta.value); break
|
case html.SELECT: meta.value && (target.value = meta.value); break
|
||||||
case html.BUTTON: meta.action == ice.AUTO && target.click(); break
|
case html.BUTTON: meta.action == ice.AUTO && target.click(); break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
run: function(event, can) {
|
||||||
|
var title = can.sup._name+ice.SP+can.sup.Input([], true)
|
||||||
|
var toast = can.user.toast(can, "执行中...", title, -1)
|
||||||
|
can.run(event, [], function() { toast.close(), can.user.toastSuccess(can) })
|
||||||
|
},
|
||||||
|
list: function(event, can) { can.run(event) },
|
||||||
|
back: function(event, can) { can.sup.onimport._back(can.sup) },
|
||||||
|
refresh: function(event, can) { can.run(event) },
|
||||||
|
|
||||||
run: function(event, can) {
|
onclick: function(event, can) {
|
||||||
var title = can.sup._name+ice.SP+can.sup.Input([], true)
|
if (can.Conf(mdb.TYPE) == html.BUTTON) { can.run(event, [ctx.ACTION, can.Conf(mdb.NAME)].concat(can.sup.Input())) }
|
||||||
var toast = can.user.toast(can, "执行中...", title, -1)
|
},
|
||||||
can.run(event, [], function() { toast.close(), can.user.toastSuccess(can) })
|
onchange: function(event, can) {
|
||||||
},
|
if (can.Conf(mdb.TYPE) == html.SELECT) { can.run(event) }
|
||||||
list: function(event, can) { can.run(event) },
|
},
|
||||||
back: function(event, can) { can.sup.onimport._back(can.sup) },
|
onkeydown: function(event, can) { can.onkeymap.input(event, can, event.target)
|
||||||
refresh: function(event, can) { can.run(event) },
|
if (can.Conf(mdb.TYPE) == html.TEXTAREA) { if (!event.ctrlKey) { return } }
|
||||||
|
if (event.key == lang.ENTER) {
|
||||||
|
can.run(event), can.onmotion.focus(can, event.target)
|
||||||
|
can.onkeymap.prevent(event)
|
||||||
|
} if (!event.ctrlKey) { return }
|
||||||
|
|
||||||
onclick: function(event, can) {
|
switch (event.key) {
|
||||||
if (can.Conf(mdb.TYPE) == html.BUTTON) { can.run(event, [ctx.ACTION, can.Conf(mdb.NAME)].concat(can.sup.Input())) }
|
case "b": can.CloneInput(); break
|
||||||
},
|
case "m": can.CloneField(); break
|
||||||
onchange: function(event, can) {
|
default: return
|
||||||
if (can.Conf(mdb.TYPE) == html.SELECT) { can.run(event) }
|
} can.onkeymap.prevent(event)
|
||||||
},
|
},
|
||||||
onkeydown: function(event, can) { can.onkeymap.input(event, can, event.target)
|
|
||||||
if (can.Conf(mdb.TYPE) == html.TEXTAREA) { if (!event.ctrlKey) { return } }
|
|
||||||
if (event.key == lang.ENTER) {
|
|
||||||
can.run(event), can.onmotion.focus(can, event.target)
|
|
||||||
can.onkeymap.prevent(event)
|
|
||||||
} if (!event.ctrlKey) { return }
|
|
||||||
|
|
||||||
switch (event.key) {
|
|
||||||
case "b": can.CloneInput(); break
|
|
||||||
case "m": can.CloneField(); break
|
|
||||||
default: return
|
|
||||||
} can.onkeymap.prevent(event)
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,60 +1,60 @@
|
|||||||
Volcanos("onfigure", {help: "控件详情", list: [], date: {onclick: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
Volcanos("onfigure", {help: "控件详情", list: [], date: {onclick: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
||||||
function set(now) { target.value = can.user.time(can, now), can.close(), meta && meta.action == ice.AUTO && can.run({}) }
|
function set(now) { target.value = can.user.time(can, now), can.close(), meta && meta.action == ice.AUTO && can.run({}) }
|
||||||
|
|
||||||
// 添加控件
|
// 添加控件
|
||||||
var now = target.value? new Date(target.value): new Date()
|
var now = target.value? new Date(target.value): new Date()
|
||||||
can.onmotion.clear(can, can._action), can.onappend._action(can, [cli.CLOSE,
|
can.onmotion.clear(can, can._action), can.onappend._action(can, [cli.CLOSE,
|
||||||
["hour"].concat(can.core.List(24)), ["minute"].concat(can.core.List(0, 60, 5)), ["second"].concat(can.core.List(0, 60, 5)),
|
["hour"].concat(can.core.List(24)), ["minute"].concat(can.core.List(0, 60, 5)), ["second"].concat(can.core.List(0, 60, 5)),
|
||||||
"今天", "", "上一月", ["year"].concat(can.core.List(now.getFullYear() - 10, now.getFullYear() + 10)),
|
"今天", "", "上一月", ["year"].concat(can.core.List(now.getFullYear() - 10, now.getFullYear() + 10)),
|
||||||
["month"].concat(can.core.List(1, 13)), "下一月",
|
["month"].concat(can.core.List(1, 13)), "下一月",
|
||||||
], can._action, { close: function(event) { can.close() },
|
], can._action, { close: function(event) { can.close() },
|
||||||
"hour": function(event, can, key, value) { now.setHours(parseInt(value)||0), show(now) },
|
"hour": function(event, can, key, value) { now.setHours(parseInt(value)||0), show(now) },
|
||||||
"minute": function(event, can, key, value) { now.setMinutes(parseInt(value)||0), show(now) },
|
"minute": function(event, can, key, value) { now.setMinutes(parseInt(value)||0), show(now) },
|
||||||
"second": function(event, can, key, value) { now.setSeconds(parseInt(value)||0), show(now) },
|
"second": function(event, can, key, value) { now.setSeconds(parseInt(value)||0), show(now) },
|
||||||
"今天": function(event) { now = new Date(), set(show(now)) },
|
"今天": function(event) { now = new Date(), set(show(now)) },
|
||||||
|
|
||||||
"上一月": function(event) { now.setMonth(now.getMonth()-1), show(now) },
|
"上一月": function(event) { now.setMonth(now.getMonth()-1), show(now) },
|
||||||
"year": function(event, can, key, value) { now.setFullYear(parseInt(value)), show(now) },
|
"year": function(event, can, key, value) { now.setFullYear(parseInt(value)), show(now) },
|
||||||
"month": function(event, can, key, value) { now.setMonth(parseInt(value)-1), show(now) },
|
"month": function(event, can, key, value) { now.setMonth(parseInt(value)-1), show(now) },
|
||||||
"下一月": function(event) { now.setMonth(now.getMonth()+1), show(now) },
|
"下一月": function(event) { now.setMonth(now.getMonth()+1), show(now) },
|
||||||
|
|
||||||
"随机": function(event) { now.setDate((Math.random() * 100 - 50) + now.getDate()), show(now) },
|
"随机": function(event) { now.setDate((Math.random() * 100 - 50) + now.getDate()), show(now) },
|
||||||
"前一年": function(event) { now.setFullYear(now.getFullYear()-1), show(now) },
|
"前一年": function(event) { now.setFullYear(now.getFullYear()-1), show(now) },
|
||||||
"后一年": function(event) { now.setFullYear(now.getFullYear()+1), show(now) },
|
"后一年": function(event) { now.setFullYear(now.getFullYear()+1), show(now) },
|
||||||
})
|
})
|
||||||
|
|
||||||
can.onmotion.clear(can, can._status)
|
can.onmotion.clear(can, can._status)
|
||||||
can._table = can.page.Appends(can, can._output, [{view: [chat.CONTENT, html.TABLE]}]).first
|
can._table = can.page.Appends(can, can._output, [{view: [chat.CONTENT, html.TABLE]}]).first
|
||||||
var today = new Date(); function show(now) {
|
var today = new Date(); function show(now) {
|
||||||
// 设置控件
|
// 设置控件
|
||||||
can.Action("year", now.getFullYear())
|
can.Action("year", now.getFullYear())
|
||||||
can.Action("month", now.getMonth()+1)
|
can.Action("month", now.getMonth()+1)
|
||||||
can.Action("hour", now.getHours())
|
can.Action("hour", now.getHours())
|
||||||
can.Action("minute", parseInt(now.getMinutes()/5)*5)
|
can.Action("minute", parseInt(now.getMinutes()/5)*5)
|
||||||
can.Action("second", parseInt(now.getSeconds()/5)*5)
|
can.Action("second", parseInt(now.getSeconds()/5)*5)
|
||||||
|
|
||||||
// 设置组件
|
// 设置组件
|
||||||
can.page.Appends(can, can._table, [{th: ["日", "一", "二", "三", "四", "五", "六"]}])
|
can.page.Appends(can, can._table, [{th: ["日", "一", "二", "三", "四", "五", "六"]}])
|
||||||
var tr; function add(day, type) { if (day.getDay() == 0) { tr = can.page.Append(can, can._table, [{type: html.TR}]).last }
|
var tr; function add(day, type) { if (day.getDay() == 0) { tr = can.page.Append(can, can._table, [{type: html.TR}]).last }
|
||||||
can.page.Append(can, tr, [{text: [day.getDate(), html.TD, can.base.Time(today, "%y-%m-%d") == can.base.Time(day, "%y-%m-%d")? html.SELECT: type],
|
can.page.Append(can, tr, [{text: [day.getDate(), html.TD, can.base.Time(today, "%y-%m-%d") == can.base.Time(day, "%y-%m-%d")? html.SELECT: type],
|
||||||
dataset: {date: day.getTime()}, onclick: function(event) {
|
dataset: {date: day.getTime()}, onclick: function(event) {
|
||||||
set(now = new Date(parseInt(event.target.dataset.date)))
|
set(now = new Date(parseInt(event.target.dataset.date)))
|
||||||
},
|
},
|
||||||
}])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
// 时间区间
|
// 时间区间
|
||||||
var one = new Date(now); one.setDate(1)
|
var one = new Date(now); one.setDate(1)
|
||||||
var end = new Date(now); end.setMonth(now.getMonth()+1), end.setDate(1)
|
var end = new Date(now); end.setMonth(now.getMonth()+1), end.setDate(1)
|
||||||
var head = new Date(one); head.setDate(one.getDate()-one.getDay())
|
var head = new Date(one); head.setDate(one.getDate()-one.getDay())
|
||||||
var tail = new Date(end); tail.setDate(end.getDate()+7-end.getDay())
|
var tail = new Date(end); tail.setDate(end.getDate()+7-end.getDay())
|
||||||
|
|
||||||
// 时间序列
|
// 时间序列
|
||||||
for (var day = new Date(head); day < one; day.setDate(day.getDate()+1)) { add(day, mdb.PREV) }
|
for (var day = new Date(head); day < one; day.setDate(day.getDate()+1)) { add(day, mdb.PREV) }
|
||||||
for (var day = new Date(one); day < end; day.setDate(day.getDate()+1)) { add(day, mdb.MAIN) }
|
for (var day = new Date(one); day < end; day.setDate(day.getDate()+1)) { add(day, mdb.MAIN) }
|
||||||
for (var day = new Date(end); end.getDay() != 0 && day < tail; day.setDate(day.getDate()+1)) { add(day, mdb.NEXT) }
|
for (var day = new Date(end); end.getDay() != 0 && day < tail; day.setDate(day.getDate()+1)) { add(day, mdb.NEXT) }
|
||||||
|
|
||||||
return now
|
return now
|
||||||
} show(now), can.onlayout.figure(event, can), can.base.isFunc(cbs) && cbs(can)
|
} show(now), can.onlayout.figure(event, can), can.base.isFunc(cbs) && cbs(can)
|
||||||
})}} }, [""])
|
})}} }, [""])
|
||||||
|
|
||||||
|
@ -1,53 +1,53 @@
|
|||||||
Volcanos("onfigure", {help: "控件详情", list: [], key: {
|
Volcanos("onfigure", {help: "控件详情", list: [], key: {
|
||||||
_init: function(can, msg, target) { var call = arguments.callee
|
_init: function(can, msg, target) { var call = arguments.callee
|
||||||
can.onmotion.clear(can), can.onappend.table(can, msg, function(value, key, index, line) {
|
can.onmotion.clear(can), can.onappend.table(can, msg, function(value, key, index, line) {
|
||||||
return {text: [value, html.TD], onclick: function(event) { target.value = line[key]
|
return {text: [value, html.TD], onclick: function(event) { target.value = line[key]
|
||||||
if (msg.Option(ice.MSG_PROCESS) != ice.PROCESS_AGAIN) { return can.close() }
|
if (msg.Option(ice.MSG_PROCESS) != ice.PROCESS_AGAIN) { return can.close() }
|
||||||
can.run(event, [ctx.ACTION, mdb.INPUTS, can.Conf(mdb.NAME), target.value], function(msg) {
|
can.run(event, [ctx.ACTION, mdb.INPUTS, can.Conf(mdb.NAME), target.value], function(msg) {
|
||||||
call(can, msg, target)
|
call(can, msg, target)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_show: function(can, meta, cbs, target) {
|
_show: function(can, meta, cbs, target) {
|
||||||
can.run(event, [ctx.ACTION, mdb.INPUTS, meta.name, target.value], function(msg) {
|
can.run(event, [ctx.ACTION, mdb.INPUTS, meta.name, target.value], function(msg) {
|
||||||
if (msg.Length() == 0) { return can.close() }
|
if (msg.Length() == 0) { return can.close() }
|
||||||
target._can && target._can.close(), target._can = can
|
target._can && target._can.close(), target._can = can
|
||||||
can.onfigure.key._init(can, msg, target), can.Status(mdb.TOTAL, msg.Length())
|
can.onfigure.key._init(can, msg, target), can.Status(mdb.TOTAL, msg.Length())
|
||||||
target._msg = msg, can.base.isFunc(cbs) && cbs(can)
|
target._msg = msg, can.base.isFunc(cbs) && cbs(can)
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
onfocus: function(event, can, meta, cb, target) { if (target._figure) { return } target._figure = {}; cb(function(can, cbs) {
|
onfocus: function(event, can, meta, cb, target) { if (target._figure) { return } target._figure = {}; cb(function(can, cbs) {
|
||||||
target._figure = can.onlayout.figure(event, can, can._target, false, {top: can.page.offsetTop(target)+target.offsetHeight, left: can.page.offsetLeft(target)})
|
target._figure = can.onlayout.figure(event, can, can._target, false, {top: can.page.offsetTop(target)+target.offsetHeight, left: can.page.offsetLeft(target)})
|
||||||
can.onfigure.key._show(can, meta, cbs, target)
|
can.onfigure.key._show(can, meta, cbs, target)
|
||||||
can.onmotion.focus(can, target)
|
can.onmotion.focus(can, target)
|
||||||
}) },
|
}) },
|
||||||
onblur: function(event, can, meta, cb, target) { delete(target._figure), target._can && target._can.close() },
|
onblur: function(event, can, meta, cb, target) { delete(target._figure), target._can && target._can.close() },
|
||||||
onclick: function(event, can, meta, cb, target) { if (target._figure) { target._figure = can.onlayout.figure(event, can, can.core.Value(target, "_can._target")||{}); return } target._figure = {}; cb(function(can, cbs) {
|
onclick: function(event, can, meta, cb, target) { if (target._figure) { target._figure = can.onlayout.figure(event, can, can.core.Value(target, "_can._target")||{}); return } target._figure = {}; cb(function(can, cbs) {
|
||||||
target._figure = can.onlayout.figure(event, can)
|
target._figure = can.onlayout.figure(event, can)
|
||||||
can.onfigure.key._show(can, meta, cbs, target)
|
can.onfigure.key._show(can, meta, cbs, target)
|
||||||
}) },
|
}) },
|
||||||
onkeydown: function(event, can, meta, cb, target, last) {
|
onkeydown: function(event, can, meta, cb, target, last) {
|
||||||
if (target._figure && target._can) { can = target._can
|
if (target._figure && target._can) { can = target._can
|
||||||
switch (event.key) { case lang.ENTER: can.close(); return }
|
switch (event.key) { case lang.ENTER: can.close(); return }
|
||||||
can.onmotion.selectTableInput(event, can, target, function() {
|
can.onmotion.selectTableInput(event, can, target, function() {
|
||||||
can.run(event, [ctx.ACTION, mdb.INPUTS, meta.name, target.value], function(msg) {
|
can.run(event, [ctx.ACTION, mdb.INPUTS, meta.name, target.value], function(msg) {
|
||||||
can.onfigure.key._init(can, msg, target), can.Status(mdb.TOTAL, msg.Length())
|
can.onfigure.key._init(can, msg, target), can.Status(mdb.TOTAL, msg.Length())
|
||||||
target._msg = msg
|
target._msg = msg
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case lang.ESCAPE: event.target.blur(); return
|
case lang.ESCAPE: event.target.blur(); return
|
||||||
case lang.TAB:
|
case lang.TAB:
|
||||||
if (event.target.tagName == "TEXTAREA") {
|
if (event.target.tagName == "TEXTAREA") {
|
||||||
can.onkeymap.insertText(event.target, "\t")
|
can.onkeymap.insertText(event.target, "\t")
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
can.base.isFunc(last) && last(event, can)
|
can.base.isFunc(last) && last(event, can)
|
||||||
},
|
},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Volcanos("onfigure", {help: "控件详情", list: [], province: {onclick: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
Volcanos("onfigure", {help: "控件详情", list: [], province: {onclick: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
||||||
can.require(["/require/shylinux.com/x/echarts/echarts.js", "/require/shylinux.com/x/echarts/china.js"], function() {
|
can.require(["/require/shylinux.com/x/echarts/echarts.js", "/require/shylinux.com/x/echarts/china.js"], function() {
|
||||||
var china_chart = echarts.init(can.page.Append(can, can._output, [{type: html.DIV, style: {width: 600, height: 400}}]).first)
|
var china_chart = echarts.init(can.page.Append(can, can._output, [{type: html.DIV, style: {width: 600, height: 400}}]).first)
|
||||||
china_chart.setOption({geo: {map: 'china'}}), china_chart.on(html.CLICK, function (params) {
|
china_chart.setOption({geo: {map: 'china'}}), china_chart.on(html.CLICK, function (params) {
|
||||||
target.value = params.name, can.close()
|
target.value = params.name, can.close()
|
||||||
}), can.Status(mdb.TOTAL, 34), can.onlayout.figure(event, can), can.base.isFunc(cbs) && cbs(can)
|
}), can.Status(mdb.TOTAL, 34), can.onlayout.figure(event, can), can.base.isFunc(cbs) && cbs(can)
|
||||||
})
|
})
|
||||||
}) }}, })
|
}) }}, })
|
||||||
|
|
||||||
|
@ -1,95 +1,95 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
var meta = {}; msg.Table(function(value) { meta[value.key] = value.value })
|
var meta = {}; msg.Table(function(value) { meta[value.key] = value.value })
|
||||||
can._meta = can.base.Obj(meta.text, {meta: {name: meta.name||"hi"}, list: []})
|
can._meta = can.base.Obj(meta.text, {meta: {name: meta.name||"hi"}, list: []})
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
|
|
||||||
can.ui = can.page.Appends(can, target, [{view: [chat.LAYOUT, html.TABLE], list: [{type: html.TR, list: [
|
can.ui = can.page.Appends(can, target, [{view: [chat.LAYOUT, html.TABLE], list: [{type: html.TR, list: [
|
||||||
{type: html.TD, list: [{view: chat.PROJECT}]},
|
{type: html.TD, list: [{view: chat.PROJECT}]},
|
||||||
{type: html.TD, list: [{view: chat.DISPLAY}]},
|
{type: html.TD, list: [{view: chat.DISPLAY}]},
|
||||||
{type: html.TD, list: [{view: chat.PROFILE}]},
|
{type: html.TD, list: [{view: chat.PROFILE}]},
|
||||||
]}] }]), can.ui.project._fieldset = can.ui.display
|
]}] }]), can.ui.project._fieldset = can.ui.display
|
||||||
|
|
||||||
can.onimport._item(can, can._meta, can.ui.project, can.onimport._size(can)).click()
|
can.onimport._item(can, can._meta, can.ui.project, can.onimport._size(can)).click()
|
||||||
},
|
},
|
||||||
_size: function(can) {
|
_size: function(can) {
|
||||||
var width = can.Conf(html.WIDTH)-260, height = can.Conf(html.HEIGHT)-100
|
var width = can.Conf(html.WIDTH)-260, height = can.Conf(html.HEIGHT)-100
|
||||||
if (can.Conf("auto.cmd")) {
|
if (can.Conf("auto.cmd")) {
|
||||||
width = can.Conf(html.WIDTH), height = can.Conf(html.HEIGHT)
|
width = can.Conf(html.WIDTH), height = can.Conf(html.HEIGHT)
|
||||||
can.onmotion.hidden(can, can.ui.project)
|
can.onmotion.hidden(can, can.ui.project)
|
||||||
can.onmotion.hidden(can, can.ui.profile)
|
can.onmotion.hidden(can, can.ui.profile)
|
||||||
can.onmotion.hidden(can, can._option)
|
can.onmotion.hidden(can, can._option)
|
||||||
can.onmotion.hidden(can, can._action)
|
can.onmotion.hidden(can, can._action)
|
||||||
}
|
}
|
||||||
if (can.user.mod.isCmd || can.user.mod.isDiv) {
|
if (can.user.mod.isCmd || can.user.mod.isDiv) {
|
||||||
width = window.innerWidth, height = window.innerHeight
|
width = window.innerWidth, height = window.innerHeight
|
||||||
can.page.Modify(can, can._output, {style: {width: width, height: height}})
|
can.page.Modify(can, can._output, {style: {width: width, height: height}})
|
||||||
}
|
}
|
||||||
return width
|
return width
|
||||||
},
|
},
|
||||||
_item: function(can, node, target, width) { width = width||node.meta.width
|
_item: function(can, node, target, width) { width = width||node.meta.width
|
||||||
var ui = can.page.Append(can, target, [{view: [html.ITEM, html.DIV, node.meta.name||"hi"]}, {view: [html.LIST]}])
|
var ui = can.page.Append(can, target, [{view: [html.ITEM, html.DIV, node.meta.name||"hi"]}, {view: [html.LIST]}])
|
||||||
ui.list._fieldset = can.onimport._plugin(can, node.meta, target._fieldset, width)
|
ui.list._fieldset = can.onimport._plugin(can, node.meta, target._fieldset, width)
|
||||||
|
|
||||||
var msg = can.request({}); msg.Push(node.meta, "", true)
|
var msg = can.request({}); msg.Push(node.meta, "", true)
|
||||||
ui.item.onclick = function(event) {
|
ui.item.onclick = function(event) {
|
||||||
can.onmotion.select(can, can.ui.project, "div.item", ui.item)
|
can.onmotion.select(can, can.ui.project, "div.item", ui.item)
|
||||||
can.current = ui.item, can.onmotion.clear(can, can.ui.profile)
|
can.current = ui.item, can.onmotion.clear(can, can.ui.profile)
|
||||||
can.onappend.table(can, msg, function(value, key, index, line, array) {
|
can.onappend.table(can, msg, function(value, key, index, line, array) {
|
||||||
return {text: [value, html.TD], ondblclick: function(event) {
|
return {text: [value, html.TD], ondblclick: function(event) {
|
||||||
key == "value" && can.onmotion.modifys(can, event.target, function(event, value, old) {
|
key == "value" && can.onmotion.modifys(can, event.target, function(event, value, old) {
|
||||||
node.meta[line.key] = value
|
node.meta[line.key] = value
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
}, can.ui.profile)
|
}, can.ui.profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.item._add = function(data) {
|
ui.item._add = function(data) {
|
||||||
if (node.meta.style == html.SPAN) { width = width * node.list.length }
|
if (node.meta.style == html.SPAN) { width = width * node.list.length }
|
||||||
node.list.push(data)
|
node.list.push(data)
|
||||||
if (node.meta.style == html.SPAN) { width = width / node.list.length }
|
if (node.meta.style == html.SPAN) { width = width / node.list.length }
|
||||||
can.onmotion.clear(can, ui.list), can.onmotion.clear(can, ui.list._fieldset)
|
can.onmotion.clear(can, ui.list), can.onmotion.clear(can, ui.list._fieldset)
|
||||||
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
|
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
|
||||||
}
|
}
|
||||||
if (node.meta.style == html.SPAN) { width = width / node.list.length }
|
if (node.meta.style == html.SPAN) { width = width / node.list.length }
|
||||||
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
|
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
|
||||||
return ui.item
|
return ui.item
|
||||||
},
|
},
|
||||||
_plugin: function(can, meta, target, width) {
|
_plugin: function(can, meta, target, width) {
|
||||||
var size = {width: width, height: meta.height}
|
var size = {width: width, height: meta.height}
|
||||||
var field = can.onappend.field(can, chat.LAYOUT, {}, target).fieldset
|
var field = can.onappend.field(can, chat.LAYOUT, {}, target).fieldset
|
||||||
can.page.ClassList.add(can, field, meta.style)
|
can.page.ClassList.add(can, field, meta.style)
|
||||||
can.page.Modify(can, field, {style: size})
|
can.page.Modify(can, field, {style: size})
|
||||||
|
|
||||||
meta.index && can.run(event, [ctx.ACTION, ctx.COMMAND, meta.index], function(msg) {
|
meta.index && can.run(event, [ctx.ACTION, ctx.COMMAND, meta.index], function(msg) {
|
||||||
can.onappend._init(can, can.base.Copy({
|
can.onappend._init(can, can.base.Copy({
|
||||||
feature: can.base.Obj(msg.Append("meta")),
|
feature: can.base.Obj(msg.Append("meta")),
|
||||||
inputs: can.base.Obj(msg.Append("list")),
|
inputs: can.base.Obj(msg.Append("list")),
|
||||||
args: meta.args,
|
args: meta.args,
|
||||||
name: meta.name,
|
name: meta.name,
|
||||||
}, size), ["/plugin/state.js"], function(sub) {
|
}, size), ["/plugin/state.js"], function(sub) {
|
||||||
can.page.Modify(can, sub._output, {style: size})
|
can.page.Modify(can, sub._output, {style: size})
|
||||||
sub.run = function(event, cmds, cb) {
|
sub.run = function(event, cmds, cb) {
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
||||||
}
|
}
|
||||||
}, target, field)
|
}, target, field)
|
||||||
}, true)
|
}, true)
|
||||||
return field
|
return field
|
||||||
},
|
},
|
||||||
}, ["/plugin/local/chat/div.css"])
|
}, ["/plugin/local/chat/div.css"])
|
||||||
Volcanos("onaction", {help: "操作数据", list: [],
|
Volcanos("onaction", {help: "操作数据", list: [],
|
||||||
"添加": function(event, can) {
|
"添加": function(event, can) {
|
||||||
can.user.input(event, can, [mdb.NAME, ctx.INDEX, ctx.ARGS, ctx.STYLE, html.HEIGHT, html.WIDTH], function(event, button, data, list, args) {
|
can.user.input(event, can, [mdb.NAME, ctx.INDEX, ctx.ARGS, ctx.STYLE, html.HEIGHT, html.WIDTH], function(event, button, data, list, args) {
|
||||||
can.current._add({meta: data, list: []})
|
can.current._add({meta: data, list: []})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"保存": function(event, can) { var msg = can.request(event, can.Option())
|
"保存": function(event, can) { var msg = can.request(event, can.Option())
|
||||||
can.run(event, [mdb.MODIFY, mdb.TEXT, JSON.stringify(can._meta)], function(msg) {
|
can.run(event, [mdb.MODIFY, mdb.TEXT, JSON.stringify(can._meta)], function(msg) {
|
||||||
can.user.toastSuccess(can)
|
can.user.toastSuccess(can)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
"预览": function(event, can) {
|
"预览": function(event, can) {
|
||||||
can.onmotion.share(event, can, [], [mdb.LINK, can.misc.MergeURL(can, {_path: "/chat/div/"+can.Option("hash")})])
|
can.onmotion.share(event, can, [], [mdb.LINK, can.misc.MergeURL(can, {_path: "/chat/div/"+can.Option("hash")})])
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: []})
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
|
||||||
|
@ -1,36 +1,35 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.ui = can.onlayout.display(can, target)
|
can.ui = can.onlayout.display(can, target)
|
||||||
can.ui.canvas = can.page.Append(can, can.ui.display, [{type: "canvas", width: 320, height: 240, style: {display: "none"}}]).first
|
can.ui.canvas = can.page.Append(can, can.ui.display, [{type: "canvas", width: 320, height: 240, style: {display: "none"}}]).first
|
||||||
|
|
||||||
can.onappend.table(can, msg, function(value, key, index, line, array) {
|
can.onappend.table(can, msg, function(value, key, index, line, array) {
|
||||||
return {text: [value, "td"], onclick: function(event) {
|
return {text: [value, "td"], onclick: function(event) {
|
||||||
can.sup.onaction.change(event, can.sup, key, value, function(msg) {
|
can.sup.onaction.change(event, can.sup, key, value, function(msg) {
|
||||||
can.run(event)
|
can.run(event)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
}, can.ui.content)
|
}, can.ui.content)
|
||||||
|
|
||||||
can.onappend.board(can, msg.Result(), can.ui.display)
|
can.onappend.board(can, msg.Result(), can.ui.display)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "操作数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onaction", {help: "操作数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
|
},
|
||||||
|
|
||||||
},
|
open: function(event, can) {
|
||||||
|
navigator.getUserMedia({video: {width: 320, height: 240}}, function(stream) {
|
||||||
open: function(event, can) {
|
var video = can.page.Append(can, can.ui.content, "video")
|
||||||
navigator.getUserMedia({video: {width: 320, height: 240}}, function(stream) {
|
video.srcObject = stream, video.play()
|
||||||
var video = can.page.Append(can, can.ui.content, "video")
|
can.ui.video = video
|
||||||
video.srcObject = stream, video.play()
|
}, function(error) {
|
||||||
can.ui.video = video
|
can.misc.Log("open camera", error)
|
||||||
}, function(error) {
|
})
|
||||||
can.misc.Log("open camera", error)
|
},
|
||||||
})
|
snapshot: function(event, can) {
|
||||||
},
|
can.ui.canvas.getContext("2d").drawImage(can.ui.video, 0, 0)
|
||||||
snapshot: function(event, can) {
|
can.page.Append(can, can.ui.display, [{type: "img", src: can.ui.canvas.toDataURL('image/webp')}])
|
||||||
can.ui.canvas.getContext("2d").drawImage(can.ui.video, 0, 0)
|
},
|
||||||
can.page.Append(can, can.ui.display, [{type: "img", src: can.ui.canvas.toDataURL('image/webp')}])
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
})
|
})
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can)
|
can.onmotion.clear(can)
|
||||||
can.from = can.onimport._plugin(can, nfs.DIR, html.LEFT, "from", "to")
|
can.from = can.onimport._plugin(can, nfs.DIR, html.LEFT, "from", "to")
|
||||||
can.to = can.onimport._plugin(can, nfs.DIR, html.RIGHT, "to", "from")
|
can.to = can.onimport._plugin(can, nfs.DIR, html.RIGHT, "to", "from")
|
||||||
can.onimport._plugin(can, nfs.TRASH, html.LEFT, "from")
|
can.onimport._plugin(can, nfs.TRASH, html.LEFT, "from")
|
||||||
can.onimport._plugin(can, nfs.TRASH, html.RIGHT, "to")
|
can.onimport._plugin(can, nfs.TRASH, html.RIGHT, "to")
|
||||||
},
|
},
|
||||||
_plugin: function(can, index, pos, from, to) {
|
_plugin: function(can, index, pos, from, to) {
|
||||||
return can.onappend.plugin(can, {type: chat.STORY, index: index}, function(sub) {
|
return can.onappend.plugin(can, {type: chat.STORY, index: index}, function(sub) {
|
||||||
can.page.Modify(can, sub._target, {style: {float: pos, clear: pos}})
|
can.page.Modify(can, sub._target, {style: {float: pos, clear: pos}})
|
||||||
sub.Conf(html.WIDTH, can.Conf(html.WIDTH)/2)
|
sub.Conf(html.WIDTH, can.Conf(html.WIDTH)/2)
|
||||||
sub._legend.innerHTML = can.Option(from)+ice.SP+index
|
sub._legend.innerHTML = can.Option(from)+ice.SP+index
|
||||||
can.page.Modify(can, sub._output, {style: {"max-width": can.Conf(html.WIDTH)/2}})
|
can.page.Modify(can, sub._output, {style: {"max-width": can.Conf(html.WIDTH)/2}})
|
||||||
|
|
||||||
sub.run = function(event, cmds, cb) {
|
sub.run = function(event, cmds, cb) {
|
||||||
if (can.onaction[cmds[1]]) { return can.onaction[cmds[1]](can, from, to, event, cmds, cb) }
|
if (can.onaction[cmds[1]]) { return can.onaction[cmds[1]](can, from, to, event, cmds, cb) }
|
||||||
|
|
||||||
var msg = sub.request(event, {_pod: can.Option(from)})
|
var msg = sub.request(event, {_pod: can.Option(from)})
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, index], cmds), cb, true)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, index], cmds), cb, true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onaction", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
},
|
},
|
||||||
send: function(can, from, to, event, cmds, cb) { var _from = can[from], _to = can[to]
|
send: function(can, from, to, event, cmds, cb) { var _from = can[from], _to = can[to]
|
||||||
var path = can.request(event).Option(nfs.PATH)
|
var path = can.request(event).Option(nfs.PATH)
|
||||||
var msg = can.request(event, {_handle: ice.TRUE,
|
var msg = can.request(event, {_handle: ice.TRUE,
|
||||||
from: can.Option(from), from_path: path,
|
from: can.Option(from), from_path: path,
|
||||||
to: can.Option(to), to_path: _to.Option(nfs.PATH)+path.split(ice.PS).pop(),
|
to: can.Option(to), to_path: _to.Option(nfs.PATH)+path.split(ice.PS).pop(),
|
||||||
})
|
})
|
||||||
can.run(event, cmds, function() { _to.Update() }, true)
|
can.run(event, cmds, function() { _to.Update() }, true)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
Volcanos("onaction", {source: function(can, msg) {
|
Volcanos("onaction", {source: function(can, msg) {
|
||||||
can.require(["https://res.wx.qq.com/open/js/jweixin-1.6.0.js"], function(can) {
|
can.require(["https://res.wx.qq.com/open/js/jweixin-1.6.0.js"], function(can) {
|
||||||
wx.config({debug: msg.Option("debug") == ice.TRUE,
|
wx.config({debug: msg.Option("debug") == ice.TRUE,
|
||||||
appId: msg.Option("appid"), signature: msg.Option("signature"),
|
appId: msg.Option("appid"), signature: msg.Option("signature"),
|
||||||
nonceStr: msg.Option("noncestr"), timestamp: msg.Option("timestamp"),
|
nonceStr: msg.Option("noncestr"), timestamp: msg.Option("timestamp"),
|
||||||
|
|
||||||
jsApiList: can.core.Item({
|
jsApiList: can.core.Item({
|
||||||
scanQRCode: function(cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode","barCode"], success: function (res) {
|
scanQRCode: function(cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode","barCode"], success: function (res) {
|
||||||
can.base.isFunc(cb) && cb(res.resultStr, can.base.ParseJSON(res.resultStr))
|
can.base.isFunc(cb) && cb(res.resultStr, can.base.ParseJSON(res.resultStr))
|
||||||
} }) },
|
} }) },
|
||||||
getLocation: function(cb) { wx.getLocation({type: "gcj02", success: function (res) {
|
getLocation: function(cb) { wx.getLocation({type: "gcj02", success: function (res) {
|
||||||
can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) })
|
can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) })
|
||||||
} }) },
|
} }) },
|
||||||
openLocation: function(msg) { wx.openLocation({
|
openLocation: function(msg) { wx.openLocation({
|
||||||
latitude: parseInt(msg.Option("latitude"))/100000,
|
latitude: parseInt(msg.Option("latitude"))/100000,
|
||||||
longitude: parseInt(msg.Option("longitude"))/100000,
|
longitude: parseInt(msg.Option("longitude"))/100000,
|
||||||
name: msg.Option(mdb.NAME), address: msg.Option(mdb.TEXT),
|
name: msg.Option(mdb.NAME), address: msg.Option(mdb.TEXT),
|
||||||
scale: msg.Option("scale")||14, infoUrl: msg.Option(mdb.LINK),
|
scale: msg.Option("scale")||14, infoUrl: msg.Option(mdb.LINK),
|
||||||
}) },
|
}) },
|
||||||
chooseImage: function(cb, count) { wx.chooseImage({count: count||9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) {
|
chooseImage: function(cb, count) { wx.chooseImage({count: count||9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) {
|
||||||
can.base.isFunc(cb) && cb(res.localIds)
|
can.base.isFunc(cb) && cb(res.localIds)
|
||||||
} }) },
|
} }) },
|
||||||
}, function(key, value) { return can.user.agent[key] = value, key }),
|
}, function(key, value) { return can.user.agent[key] = value, key }),
|
||||||
})
|
})
|
||||||
wx.error(function(err) { can.user.toast(err, "wx load") })
|
wx.error(function(err) { can.user.toast(err, "wx load") })
|
||||||
wx.ready(function() { can.misc.Log("ready") })
|
wx.ready(function() { can.misc.Log("ready") })
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
@ -1,482 +1,482 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, cb, target) {
|
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||||
can.onengine.plugin(can, "can.code.inner.plugin", shy("插件", {}, [{type: "button", name: "list", action: "auto"}, "back"], function(msg, cmds) {
|
can.onengine.plugin(can, "can.code.inner.plugin", shy("插件", {}, [{type: "button", name: "list", action: "auto"}, "back"], function(msg, cmds) {
|
||||||
msg.Echo("can.code.inner.plugin")
|
msg.Echo("can.code.inner.plugin")
|
||||||
msg.result = msg.result.concat(cmds||[])
|
msg.result = msg.result.concat(cmds||[])
|
||||||
}))
|
}))
|
||||||
|
|
||||||
var paths = can.core.Split(can.Option(nfs.PATH), ice.FS); can.Option(nfs.PATH, paths[0])
|
var paths = can.core.Split(can.Option(nfs.PATH), ice.FS); can.Option(nfs.PATH, paths[0])
|
||||||
var files = can.core.Split(can.Option(nfs.FILE), ice.FS); can.Option(nfs.FILE, files[0])
|
var files = can.core.Split(can.Option(nfs.FILE), ice.FS); can.Option(nfs.FILE, files[0])
|
||||||
can.tabview = can.tabview||{}, can.tabview[can.onexport.keys(can)] = msg
|
can.tabview = can.tabview||{}, can.tabview[can.onexport.keys(can)] = msg
|
||||||
can.history = can.history||[], can.toolkit = {}, can.extentions = {}, can.profile_size = {}
|
can.history = can.history||[], can.toolkit = {}, can.extentions = {}, can.profile_size = {}
|
||||||
|
|
||||||
can.onmotion.clear(can), can.onlayout.profile(can)
|
can.onmotion.clear(can), can.onlayout.profile(can)
|
||||||
can.onimport._project(can, can.ui.project)
|
can.onimport._project(can, can.ui.project)
|
||||||
can.onimport._profile(can, can.ui.profile)
|
can.onimport._profile(can, can.ui.profile)
|
||||||
can.onimport._display(can, can.ui.display)
|
can.onimport._display(can, can.ui.display)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
|
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), can.Option(nfs.FILE), can.Option(nfs.LINE))
|
can.onimport.tabview(can, can.Option(nfs.PATH), can.Option(nfs.FILE), can.Option(nfs.LINE))
|
||||||
can.onimport.project(can, paths, function() {
|
can.onimport.project(can, paths, function() {
|
||||||
can.onimport._toolkit(can, can.ui.toolkit), can.onimport._session(can, msg), can.onimport._keydown(can)
|
can.onimport._toolkit(can, can.ui.toolkit), can.onimport._session(can, msg), can.onimport._keydown(can)
|
||||||
can.onmotion.delay(can, function() {
|
can.onmotion.delay(can, function() {
|
||||||
can.core.Next(files.slice(1), function(file, next) {
|
can.core.Next(files.slice(1), function(file, next) {
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), file, can.Option(nfs.LINE), next)
|
can.onimport.tabview(can, can.Option(nfs.PATH), file, can.Option(nfs.LINE), next)
|
||||||
}, function() { can.onimport.tabview(can, paths[0], files[0]) })
|
}, function() { can.onimport.tabview(can, paths[0], files[0]) })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_project: function(can, target) {
|
_project: function(can, target) {
|
||||||
target._toggle = function(event) { can.onmotion.toggle(can, target), can.onimport.layout(can) }
|
target._toggle = function(event) { can.onmotion.toggle(can, target), can.onimport.layout(can) }
|
||||||
},
|
},
|
||||||
_profile: function(can, target) {
|
_profile: function(can, target) {
|
||||||
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}]); can.ui.profile_output = ui.output
|
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}]); can.ui.profile_output = ui.output
|
||||||
var action = can.onappend._action(can, [cli.SHOW, cli.CLEAR, mdb.PLUGIN, cli.CLOSE, "size"], ui.action, kit.Dict(
|
var action = can.onappend._action(can, [cli.SHOW, cli.CLEAR, mdb.PLUGIN, cli.CLOSE, "size"], ui.action, kit.Dict(
|
||||||
cli.SHOW, function(event) { can.onaction["展示"](event, can) },
|
cli.SHOW, function(event) { can.onaction["展示"](event, can) },
|
||||||
cli.CLEAR, function(event) { can.onmotion.clear(can, ui.output) },
|
cli.CLEAR, function(event) { can.onmotion.clear(can, ui.output) },
|
||||||
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport.layout(can) },
|
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport.layout(can) },
|
||||||
"size", function(event) {
|
"size", function(event) {
|
||||||
can.user.input(event, can, ["size"], function(event, button, data) {
|
can.user.input(event, can, ["size"], function(event, button, data) {
|
||||||
can.profile_size[can.onexport.keys(can)] = can.ConfWidth()*parseInt(data.size)/100
|
can.profile_size[can.onexport.keys(can)] = can.ConfWidth()*parseInt(data.size)/100
|
||||||
can.onaction["展示"](event, can)
|
can.onaction["展示"](event, can)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
mdb.PLUGIN, function(event) {
|
mdb.PLUGIN, function(event) {
|
||||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
||||||
can.onimport.plugin(can, data, ui.output)
|
can.onimport.plugin(can, data, ui.output)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
target._toggle = function(event, show) { action[show? cli.SHOW: cli.CLOSE](event) }
|
target._toggle = function(event, show) { action[show? cli.SHOW: cli.CLOSE](event) }
|
||||||
},
|
},
|
||||||
_display: function(can, target) {
|
_display: function(can, target) {
|
||||||
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}, {}]); can.ui.display_output = ui.output
|
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}, {}]); can.ui.display_output = ui.output
|
||||||
var action = can.onappend._action(can, [cli.EXEC, cli.CLEAR, mdb.PLUGIN, cli.CLOSE], ui.action, kit.Dict(
|
var action = can.onappend._action(can, [cli.EXEC, cli.CLEAR, mdb.PLUGIN, cli.CLOSE], ui.action, kit.Dict(
|
||||||
cli.EXEC, function(event) { can.onaction["执行"](event, can) },
|
cli.EXEC, function(event) { can.onaction["执行"](event, can) },
|
||||||
cli.CLEAR, function(event) { can.onmotion.clear(can, ui.output) },
|
cli.CLEAR, function(event) { can.onmotion.clear(can, ui.output) },
|
||||||
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport.layout(can) },
|
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport.layout(can) },
|
||||||
mdb.PLUGIN, function(event) {
|
mdb.PLUGIN, function(event) {
|
||||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
||||||
can.onimport.plugin(can, data, ui.output)
|
can.onimport.plugin(can, data, ui.output)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
target._toggle = function(event, show) { action[show? cli.EXEC: cli.CLOSE](event) }
|
target._toggle = function(event, show) { action[show? cli.EXEC: cli.CLOSE](event) }
|
||||||
},
|
},
|
||||||
_toolkit: function(can, target) {
|
_toolkit: function(can, target) {
|
||||||
can.ui.toolkit = can.onappend.field(can, "toolkit", {}, can._output)
|
can.ui.toolkit = can.onappend.field(can, "toolkit", {}, can._output)
|
||||||
},
|
},
|
||||||
_session: function(can, msg) { can.onimport.sess(can, "", function() { can.onimport.sess(can, {
|
_session: function(can, msg) { can.onimport.sess(can, "", function() { can.onimport.sess(can, {
|
||||||
plug: can.core.Split(msg.OptionOrSearch("plug")).reverse(),
|
plug: can.core.Split(msg.OptionOrSearch("plug")).reverse(),
|
||||||
exts: can.core.Split(msg.OptionOrSearch("exts")).reverse(),
|
exts: can.core.Split(msg.OptionOrSearch("exts")).reverse(),
|
||||||
tabs: can.core.Split(msg.OptionOrSearch("tabs")),
|
tabs: can.core.Split(msg.OptionOrSearch("tabs")),
|
||||||
}) }) },
|
}) }) },
|
||||||
_keydown: function(can) { can.onkeymap._build(can)
|
_keydown: function(can) { can.onkeymap._build(can)
|
||||||
can.user.mod.isCmd && can.onengine.listen(can, chat.ONKEYDOWN, function(event) {
|
can.user.mod.isCmd && can.onengine.listen(can, chat.ONKEYDOWN, function(event) {
|
||||||
can._key_list = can.onkeymap._parse(event, can, "plugin", can._key_list, can.ui.content)
|
can._key_list = can.onkeymap._parse(event, can, "plugin", can._key_list, can.ui.content)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
project: function(can, path, cb) { can.onmotion.clear(can, can.ui.project)
|
project: function(can, path, cb) { can.onmotion.clear(can, can.ui.project)
|
||||||
can.core.Next(path, function(path, next, index, array) {
|
can.core.Next(path, function(path, next, index, array) {
|
||||||
var list = can.ui.project; if (array.length > 1) {
|
var list = can.ui.project; if (array.length > 1) {
|
||||||
var ui = can.page.Append(can, can.ui.project, [{view: [html.ITEM, html.DIV, path], onclick: function(event) {
|
var ui = can.page.Append(can, can.ui.project, [{view: [html.ITEM, html.DIV, path], onclick: function(event) {
|
||||||
can.onmotion.toggle(can, ui.list)
|
can.onmotion.toggle(can, ui.list)
|
||||||
}}, {view: html.LIST}]); list = ui.list
|
}}, {view: html.LIST}]); list = ui.list
|
||||||
if (index > 0) { ui.item.click() }
|
if (index > 0) { ui.item.click() }
|
||||||
}
|
}
|
||||||
can.run(can.request({}, {dir_root: path, dir_deep: true})._event, [ice.PWD], function(msg) {
|
can.run(can.request({}, {dir_root: path, dir_deep: true})._event, [ice.PWD], function(msg) {
|
||||||
can.onappend.tree(can, can._file = msg.Table(), nfs.PATH, ice.PS, function(event, item) {
|
can.onappend.tree(can, can._file = msg.Table(), nfs.PATH, ice.PS, function(event, item) {
|
||||||
can.onimport.tabview(can, path, item.path)
|
can.onimport.tabview(can, path, item.path)
|
||||||
}, list), can.onimport.layout(can), can.Status("文件数", msg.Length()), next()
|
}, list), can.onimport.layout(can), can.Status("文件数", msg.Length()), next()
|
||||||
}, true)
|
}, true)
|
||||||
}, function() {
|
}, function() {
|
||||||
can.base.isFunc(cb) && cb()
|
can.base.isFunc(cb) && cb()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
tabview: function(can, path, file, line, cb, skip, skip2) { var key = can.onexport.keys(can, file, path)
|
tabview: function(can, path, file, line, cb, skip, skip2) { var key = can.onexport.keys(can, file, path)
|
||||||
if (!skip && can.tabview[key]) { can.user.mod.isCmd && can.user.title(path+file)
|
if (!skip && can.tabview[key]) { can.user.mod.isCmd && can.user.title(path+file)
|
||||||
can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.tabview[key]
|
can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.tabview[key]
|
||||||
can.Option({path: path, file: file, line: line||can._msg.Option(nfs.LINE)||1})
|
can.Option({path: path, file: file, line: line||can._msg.Option(nfs.LINE)||1})
|
||||||
return can._msg.Option(can.Option()), can.onsyntax._init(can, can._msg, cb, skip2)
|
return can._msg.Option(can.Option()), can.onsyntax._init(can, can._msg, cb, skip2)
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(msg) { can.tabview[key] = msg
|
function show(msg) { can.tabview[key] = msg
|
||||||
var skip2 = skip
|
var skip2 = skip
|
||||||
msg._tab = can.onappend.tabs(can, [{name: file.split(ice.PS).pop(), text: file}], function(event, meta) {
|
msg._tab = can.onappend.tabs(can, [{name: file.split(ice.PS).pop(), text: file}], function(event, meta) {
|
||||||
can.onimport.tabview(can, path, file, "", cb, false, skip2), cb = null, skip2 = false
|
can.onimport.tabview(can, path, file, "", cb, false, skip2), cb = null, skip2 = false
|
||||||
}, function(item) { delete(can.tabview[key]) })
|
}, function(item) { delete(can.tabview[key]) })
|
||||||
}
|
}
|
||||||
|
|
||||||
can.Option({path: path, file: file, line: line||1})
|
can.Option({path: path, file: file, line: line||1})
|
||||||
line == ctx.INDEX? show(can.request({}, {index: file, line: line})): can.run({}, [path, file], show, true)
|
line == ctx.INDEX? show(can.request({}, {index: file, line: line})): can.run({}, [path, file], show, true)
|
||||||
},
|
},
|
||||||
profile: function(can, msg) {
|
profile: function(can, msg) {
|
||||||
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/2
|
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/2
|
||||||
msg && can.onimport.process(can, msg, can.ui.profile_output, width-32)
|
msg && can.onimport.process(can, msg, can.ui.profile_output, width-32)
|
||||||
can.onmotion.hidden(can, can.ui.profile, true), can.onimport.layout(can)
|
can.onmotion.hidden(can, can.ui.profile, true), can.onimport.layout(can)
|
||||||
},
|
},
|
||||||
display: function(can, msg) {
|
display: function(can, msg) {
|
||||||
msg && can.onimport.process(can, msg, can.ui.display_output, can.ConfWidth())
|
msg && can.onimport.process(can, msg, can.ui.display_output, can.ConfWidth())
|
||||||
can.page.style(can, can.ui.display_output, html.MAX_HEIGHT, can.ConfHeight()/4)
|
can.page.style(can, can.ui.display_output, html.MAX_HEIGHT, can.ConfHeight()/4)
|
||||||
can.onmotion.hidden(can, can.ui.display, true), can.onimport.layout(can)
|
can.onmotion.hidden(can, can.ui.display, true), can.onimport.layout(can)
|
||||||
},
|
},
|
||||||
toolkit: function(can, meta, cb) {
|
toolkit: function(can, meta, cb) {
|
||||||
meta.opts = meta.opts||{repos: can.base.trimSuffix(can.base.trimPrefix(can.Option(nfs.PATH), "usr/"), ice.PS) }
|
meta.opts = meta.opts||{repos: can.base.trimSuffix(can.base.trimPrefix(can.Option(nfs.PATH), "usr/"), ice.PS) }
|
||||||
can.onimport.plugin(can, meta, can.ui.toolkit.output, function(sub) {
|
can.onimport.plugin(can, meta, can.ui.toolkit.output, function(sub) {
|
||||||
sub.ConfHeight(can.ConfHeight()-4*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth())
|
sub.ConfHeight(can.ConfHeight()-4*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth())
|
||||||
sub.page.style(sub, sub._output, html.MAX_HEIGHT, sub.ConfHeight())
|
sub.page.style(sub, sub._output, html.MAX_HEIGHT, sub.ConfHeight())
|
||||||
sub.page.style(sub, sub._output, html.MAX_WIDTH, sub.ConfWidth())
|
sub.page.style(sub, sub._output, html.MAX_WIDTH, sub.ConfWidth())
|
||||||
sub.select = function() { return sub._legend.click(), sub }
|
sub.select = function() { return sub._legend.click(), sub }
|
||||||
|
|
||||||
var status = can.user.mod.isCmd? can._status: can.ui.toolkit.status
|
var status = can.user.mod.isCmd? can._status: can.ui.toolkit.status
|
||||||
status.appendChild(sub._legend), sub._legend.onclick = function(event) {
|
status.appendChild(sub._legend), sub._legend.onclick = function(event) {
|
||||||
if (can.page.Select(can, status, ice.PT+html.SELECT)[0] == event.target) {
|
if (can.page.Select(can, status, ice.PT+html.SELECT)[0] == event.target) {
|
||||||
can.page.ClassList.del(can, event.target, html.SELECT)
|
can.page.ClassList.del(can, event.target, html.SELECT)
|
||||||
can.page.ClassList.del(can, sub._target, html.SELECT)
|
can.page.ClassList.del(can, sub._target, html.SELECT)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
can.onmotion.select(can, status, html.LEGEND, event.target)
|
can.onmotion.select(can, status, html.LEGEND, event.target)
|
||||||
can.onmotion.select(can, can.ui.toolkit.output, html.FIELDSET, sub._target)
|
can.onmotion.select(can, can.ui.toolkit.output, html.FIELDSET, sub._target)
|
||||||
can.onmotion.focus(can, can.page.Select(can, sub._option, html.OPTION_ARGS)[0])
|
can.onmotion.focus(can, can.page.Select(can, sub._option, html.OPTION_ARGS)[0])
|
||||||
}, can.base.isFunc(cb) && cb(sub)
|
}, can.base.isFunc(cb) && cb(sub)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
process: function(can, msg, target, width) {
|
process: function(can, msg, target, width) {
|
||||||
can.user.toastSuccess(can)
|
can.user.toastSuccess(can)
|
||||||
can.onmotion.clear(can, target)
|
can.onmotion.clear(can, target)
|
||||||
if (msg.Option("_process") == "_field") {
|
if (msg.Option("_process") == "_field") {
|
||||||
msg.Table(function(meta) { meta.display = msg.Option("_display")
|
msg.Table(function(meta) { meta.display = msg.Option("_display")
|
||||||
// delete(Volcanos.meta.cache[meta.display])
|
// delete(Volcanos.meta.cache[meta.display])
|
||||||
can.onimport.plugin(can, meta, target, function(sub) {
|
can.onimport.plugin(can, meta, target, function(sub) {
|
||||||
can.onmotion.focus(can, can.page.Select(can, sub._option, html.OPTION_ARGS)[0])
|
can.onmotion.focus(can, can.page.Select(can, sub._option, html.OPTION_ARGS)[0])
|
||||||
width && sub.ConfWidth(width)
|
width && sub.ConfWidth(width)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
can.onappend.table(can, msg, null, target)
|
can.onappend.table(can, msg, null, target)
|
||||||
can.onappend.board(can, msg.Result(), target)
|
can.onappend.board(can, msg.Result(), target)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugin: function(can, meta, target, cb) {
|
plugin: function(can, meta, target, cb) {
|
||||||
can.onappend.plugin(can, meta, function(sub) {
|
can.onappend.plugin(can, meta, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) {
|
sub.run = function(event, cmds, cb) {
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
||||||
}, can.base.isFunc(cb) && cb(sub)
|
}, can.base.isFunc(cb) && cb(sub)
|
||||||
}, target)
|
}, target)
|
||||||
},
|
},
|
||||||
layout: function(can) { var height = can.ConfHeight(), width = can.ConfWidth()
|
layout: function(can) { var height = can.ConfHeight(), width = can.ConfWidth()
|
||||||
can.page.style(can, can.ui.content, can.user.mod.isCmd? html.HEIGHT: html.MAX_HEIGHT, height)
|
can.page.style(can, can.ui.content, can.user.mod.isCmd? html.HEIGHT: html.MAX_HEIGHT, height)
|
||||||
if (can.ui.project.style.display != html.NONE) {
|
if (can.ui.project.style.display != html.NONE) {
|
||||||
can.page.styleHeight(can, can.ui.project, can.ui.content.offsetHeight)
|
can.page.styleHeight(can, can.ui.project, can.ui.content.offsetHeight)
|
||||||
}
|
}
|
||||||
if (can.user.mod.isCmd) {
|
if (can.user.mod.isCmd) {
|
||||||
can.page.styleHeight(can, can.ui.content, (can.ui.project.offsetHeight||height)-can.ui.display.offsetHeight)
|
can.page.styleHeight(can, can.ui.content, (can.ui.project.offsetHeight||height)-can.ui.display.offsetHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
can.page.styleWidth(can, can.ui.profile_output, can.profile_size[can.onexport.keys(can)]||(width-can.ui.project.offsetWidth)/2)
|
can.page.styleWidth(can, can.ui.profile_output, can.profile_size[can.onexport.keys(can)]||(width-can.ui.project.offsetWidth)/2)
|
||||||
can.page.styleWidth(can, can.ui.content, width-can.ui.project.offsetWidth-can.ui.profile.offsetWidth-26)
|
can.page.styleWidth(can, can.ui.content, width-can.ui.project.offsetWidth-can.ui.profile.offsetWidth-26)
|
||||||
|
|
||||||
if (can.page.ClassList.has(can, can._fields, "full")) {
|
if (can.page.ClassList.has(can, can._fields, "full")) {
|
||||||
can.page.styleHeight(can, can.ui.profile_output, can.ui.content.offsetHeight)
|
can.page.styleHeight(can, can.ui.profile_output, can.ui.content.offsetHeight)
|
||||||
} else {
|
} else {
|
||||||
can.page.styleHeight(can, can.ui.profile_output, can.ui.content.offsetHeight-html.ACTION_HEIGHT)
|
can.page.styleHeight(can, can.ui.profile_output, can.ui.content.offsetHeight-html.ACTION_HEIGHT)
|
||||||
}
|
}
|
||||||
can.page.Select(can, can.ui.profile_output, html.IFRAME, function(item) {
|
can.page.Select(can, can.ui.profile_output, html.IFRAME, function(item) {
|
||||||
can.page.style(can, item,
|
can.page.style(can, item,
|
||||||
html.HEIGHT, can.ui.profile_output.offsetHeight-4,
|
html.HEIGHT, can.ui.profile_output.offsetHeight-4,
|
||||||
html.WIDTH, can.ui.profile_output.offsetWidth-5,
|
html.WIDTH, can.ui.profile_output.offsetWidth-5,
|
||||||
"margin-left", "-10px", "margin-top", "-10px",
|
"margin-left", "-10px", "margin-top", "-10px",
|
||||||
"position", "absolute",
|
"position", "absolute",
|
||||||
"border", "0",
|
"border", "0",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
exts: function(can, url, cb) {
|
exts: function(can, url, cb) {
|
||||||
can.require([url], function() {}, function(can, name, sub) { sub._init(can, can.base.ParseURL(sub._path), function(sub) {
|
can.require([url], function() {}, function(can, name, sub) { sub._init(can, can.base.ParseURL(sub._path), function(sub) {
|
||||||
can.extentions[url.split("?")[0]] = sub, can.base.isFunc(cb) && cb(sub)
|
can.extentions[url.split("?")[0]] = sub, can.base.isFunc(cb) && cb(sub)
|
||||||
}) })
|
}) })
|
||||||
},
|
},
|
||||||
sess: function(can, sess, cb) { sess = sess||can.base.Obj(localStorage.getItem("web.code.inner.sess"), {})
|
sess: function(can, sess, cb) { sess = sess||can.base.Obj(localStorage.getItem("web.code.inner.sess"), {})
|
||||||
can.core.Next(sess.plug, function(item, next) { can.onimport.toolkit(can, {index: item}, function(sub) { can.toolkit[item] = sub, next() }) }, function() {
|
can.core.Next(sess.plug, function(item, next) { can.onimport.toolkit(can, {index: item}, function(sub) { can.toolkit[item] = sub, next() }) }, function() {
|
||||||
can.core.Next(sess.exts, function(item, next) { can.onimport.exts(can, item, next) }, function() {
|
can.core.Next(sess.exts, function(item, next) { can.onimport.exts(can, item, next) }, function() {
|
||||||
can.core.Next(sess.tabs, function(item, next) { var ls = item.split(ice.DF); can.onimport.tabview(can, ls[0], ls[1], ls[2], next) }, cb)
|
can.core.Next(sess.tabs, function(item, next) { var ls = item.split(ice.DF); can.onimport.tabview(can, ls[0], ls[1], ls[2], next) }, cb)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg, cb, skip) {
|
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg, cb, skip) {
|
||||||
if (can.onmotion.cache(can, function(cache_data) {
|
if (can.onmotion.cache(can, function(cache_data) {
|
||||||
can.file && (cache_data[can.file] = {current: can.current, max: can.max,
|
can.file && (cache_data[can.file] = {current: can.current, max: can.max,
|
||||||
profile_display: can.ui.profile.style.display, display_display: can.ui.display.style.display,
|
profile_display: can.ui.profile.style.display, display_display: can.ui.display.style.display,
|
||||||
})
|
})
|
||||||
can.file = can.base.Path(msg.Option(nfs.PATH), msg.Option(nfs.FILE))
|
can.file = can.base.Path(msg.Option(nfs.PATH), msg.Option(nfs.FILE))
|
||||||
can.parse = can.base.Ext(can.file), can.Status("模式", "plugin")
|
can.parse = can.base.Ext(can.file), can.Status("模式", "plugin")
|
||||||
|
|
||||||
var p = cache_data[can.file]; p && (can.current = p.current, can.max = p.max)
|
var p = cache_data[can.file]; p && (can.current = p.current, can.max = p.max)
|
||||||
can.page.Modify(can, can.ui.profile, {style: {display: p? p.profile_display: html.NONE}})
|
can.page.Modify(can, can.ui.profile, {style: {display: p? p.profile_display: html.NONE}})
|
||||||
can.page.Modify(can, can.ui.display, {style: {display: p? p.display_display: html.NONE}})
|
can.page.Modify(can, can.ui.display, {style: {display: p? p.display_display: html.NONE}})
|
||||||
can.onmotion.select(can, can._action, chat.DIV_TABS, msg._tab)
|
can.onmotion.select(can, can._action, chat.DIV_TABS, msg._tab)
|
||||||
can.onmotion.delay(can, function() { can.onimport.layout(can)
|
can.onmotion.delay(can, function() { can.onimport.layout(can)
|
||||||
msg.Option(ctx.INDEX) && can.onmotion.focus(can, can.page.Select(can, can.ui.content, html.OPTION_ARGS)[0])
|
msg.Option(ctx.INDEX) && can.onmotion.focus(can, can.page.Select(can, can.ui.content, html.OPTION_ARGS)[0])
|
||||||
})
|
})
|
||||||
return can.file
|
return can.file
|
||||||
}, can.ui.content, can.ui.profile_output, can.ui.display_output) && !skip) {
|
}, can.ui.content, can.ui.profile_output, can.ui.display_output) && !skip) {
|
||||||
return can.onaction.selectLine(null, can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb()
|
return can.onaction.selectLine(null, can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.Option(ctx.INDEX)) {
|
if (msg.Option(ctx.INDEX)) {
|
||||||
can.onimport.plugin(can, {index: msg.Option(ctx.INDEX)}, can.ui.content, function(sub) {
|
can.onimport.plugin(can, {index: msg.Option(ctx.INDEX)}, can.ui.content, function(sub) {
|
||||||
can.onmotion.delay(can, function() {
|
can.onmotion.delay(can, function() {
|
||||||
can.onmotion.focus(can, can.page.Select(can, can.ui.content, html.OPTION_ARGS)[0])
|
can.onmotion.focus(can, can.page.Select(can, can.ui.content, html.OPTION_ARGS)[0])
|
||||||
}), can.base.isFunc(cb) && cb()
|
}), can.base.isFunc(cb) && cb()
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
can.onmotion.clear(can, can.ui.content)
|
can.onmotion.clear(can, can.ui.content)
|
||||||
|
|
||||||
function init(p) { can.max = 0, can.core.List(can.ls = msg.Result().split(ice.NL), function(item) {
|
function init(p) { can.max = 0, can.core.List(can.ls = msg.Result().split(ice.NL), function(item) {
|
||||||
can.onaction.appendLine(can, item)
|
can.onaction.appendLine(can, item)
|
||||||
}), can.onaction.selectLine(null, can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb() }
|
}), can.onaction.selectLine(null, can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb() }
|
||||||
|
|
||||||
var p = can.onsyntax[can.parse]; !p? can.run({}, [ctx.ACTION, mdb.PLUGIN, can.parse, msg.Option(nfs.FILE), msg.Option(nfs.PATH)], function(msg) {
|
var p = can.onsyntax[can.parse]; !p? can.run({}, [ctx.ACTION, mdb.PLUGIN, can.parse, msg.Option(nfs.FILE), msg.Option(nfs.PATH)], function(msg) {
|
||||||
init(p = can.onsyntax[can.parse] = can.base.Obj(msg.Result()))
|
init(p = can.onsyntax[can.parse] = can.base.Obj(msg.Result()))
|
||||||
}, true): init(p)
|
}, true): init(p)
|
||||||
},
|
},
|
||||||
_parse: function(can, line) { if (line.indexOf("<html") == 0) { return line }
|
_parse: function(can, line) { if (line.indexOf("<html") == 0) { return line }
|
||||||
line = can.page.replace(can, line||"")
|
line = can.page.replace(can, line||"")
|
||||||
|
|
||||||
function wrap(type, str) { return type? '<span class="'+type+'">'+str+'</span>': str }
|
function wrap(type, str) { return type? '<span class="'+type+'">'+str+'</span>': str }
|
||||||
var p = can.onsyntax[can.parse]; if (!p) { return line } p = can.onsyntax[p.link]||p, p.split = p.split||{}
|
var p = can.onsyntax[can.parse]; if (!p) { return line } p = can.onsyntax[p.link]||p, p.split = p.split||{}
|
||||||
p.keyword && (line = can.core.List(can.core.Split(line, p.split.space||ice.SP, p.split.operator||"{[(|)]}", {detail: true}), function(item, index, array) {
|
p.keyword && (line = can.core.List(can.core.Split(line, p.split.space||ice.SP, p.split.operator||"{[(|)]}", {detail: true}), function(item, index, array) {
|
||||||
item = can.base.isObject(item)? item: {text: item}
|
item = can.base.isObject(item)? item: {text: item}
|
||||||
var text = item.text; var type = item.keyword||p.keyword[text]
|
var text = item.text; var type = item.keyword||p.keyword[text]
|
||||||
|
|
||||||
switch (item.type) { case html.SPACE: return text
|
switch (item.type) { case html.SPACE: return text
|
||||||
case lang.STRING: return wrap(lang.STRING, item.left+text+item.right)
|
case lang.STRING: return wrap(lang.STRING, item.left+text+item.right)
|
||||||
default: return wrap(type, text)
|
default: return wrap(type, text)
|
||||||
}
|
}
|
||||||
}).join(""))
|
}).join(""))
|
||||||
|
|
||||||
p.prefix && can.core.Item(p.prefix, function(pre, type) {
|
p.prefix && can.core.Item(p.prefix, function(pre, type) {
|
||||||
if (can.base.beginWith(line, pre)) {
|
if (can.base.beginWith(line, pre)) {
|
||||||
line = wrap(type, line)
|
line = wrap(type, line)
|
||||||
} else {
|
} else {
|
||||||
var ls = line.split(pre); if (ls.length > 1) {
|
var ls = line.split(pre); if (ls.length > 1) {
|
||||||
line = ls[0] + wrap(type, pre + ls[1])
|
line = ls[0] + wrap(type, pre + ls[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
p.suffix && can.core.Item(p.suffix, function(end, type) {
|
p.suffix && can.core.Item(p.suffix, function(end, type) {
|
||||||
if (can.base.endWith(line, end)) { line = wrap(type, line) }
|
if (can.base.endWith(line, end)) { line = wrap(type, line) }
|
||||||
})
|
})
|
||||||
return line
|
return line
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onkeymap", {help: "导入数据", _init: function(can, msg, cb, target) {
|
Volcanos("onkeymap", {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||||
},
|
},
|
||||||
_plugin: function(event, can) {},
|
_plugin: function(event, can) {},
|
||||||
_normal: function(event, can) {},
|
_normal: function(event, can) {},
|
||||||
_insert: function(event, can) {},
|
_insert: function(event, can) {},
|
||||||
_mode: {
|
_mode: {
|
||||||
plugin: {
|
plugin: {
|
||||||
Escape: function(event, can) { can.onaction["清屏"](event, can) },
|
Escape: function(event, can) { can.onaction["清屏"](event, can) },
|
||||||
g: function(event, can) { can.onaction["搜索"](event, can) },
|
g: function(event, can) { can.onaction["搜索"](event, can) },
|
||||||
f: function(event, can) { can.onaction["打开"](event, can) },
|
f: function(event, can) { can.onaction["打开"](event, can) },
|
||||||
t: function(event, can) { can.onaction["添加"](event, can) },
|
t: function(event, can) { can.onaction["添加"](event, can) },
|
||||||
p: function(event, can) { can.onaction["插件"](event, can) },
|
p: function(event, can) { can.onaction["插件"](event, can) },
|
||||||
e: function(event, can) { can.onaction["扩展"](event, can) },
|
e: function(event, can) { can.onaction["扩展"](event, can) },
|
||||||
|
|
||||||
q: function(event, can) { can.onaction["全屏"](event, can) },
|
q: function(event, can) { can.onaction["全屏"](event, can) },
|
||||||
r: function(event, can) { can.onaction["执行"](event, can) },
|
r: function(event, can) { can.onaction["执行"](event, can) },
|
||||||
v: function(event, can) { can.onaction["展示"](event, can) },
|
v: function(event, can) { can.onaction["展示"](event, can) },
|
||||||
s: function(event, can) { can.onaction["保存"](event, can) },
|
s: function(event, can) { can.onaction["保存"](event, can) },
|
||||||
|
|
||||||
j: function(event, can) { can.current.scroll(1) },
|
j: function(event, can) { can.current.scroll(1) },
|
||||||
k: function(event, can) { can.current.scroll(-1) },
|
k: function(event, can) { can.current.scroll(-1) },
|
||||||
J: function(event, can) { can.current.scroll(can.current.window()-3) },
|
J: function(event, can) { can.current.scroll(can.current.window()-3) },
|
||||||
K: function(event, can) { can.current.scroll(-can.current.window()+3) },
|
K: function(event, can) { can.current.scroll(-can.current.window()+3) },
|
||||||
|
|
||||||
i: function(event, can) { can.onkeymap._insert(event, can) },
|
i: function(event, can) { can.onkeymap._insert(event, can) },
|
||||||
n: function(event, can) { can.onkeymap._normal(event, can) },
|
n: function(event, can) { can.onkeymap._normal(event, can) },
|
||||||
":": function(event, can) { can.onimport.toolkit(can, {index: "cli.system"}, function(sub) { can.toolkit["cli.system"] = sub.select() }) },
|
":": function(event, can) { can.onimport.toolkit(can, {index: "cli.system"}, function(sub) { can.toolkit["cli.system"] = sub.select() }) },
|
||||||
},
|
},
|
||||||
}, _engine: {},
|
}, _engine: {},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "控件交互", list: ["搜索", "打开", "添加", "插件", "扩展", "刷新"],
|
Volcanos("onaction", {help: "控件交互", list: ["搜索", "打开", "添加", "插件", "扩展", "刷新"],
|
||||||
"刷新": function(event, can) {
|
"刷新": function(event, can) {
|
||||||
can.onimport.tabview(can, "src/", "main.go", "", function() {}, skip)
|
can.onimport.tabview(can, "src/", "main.go", "", function() {}, skip)
|
||||||
},
|
},
|
||||||
"搜索": function(event, can) {
|
"搜索": function(event, can) {
|
||||||
can.user.input(event, can, [mdb.NAME, [ctx.ACTION, nfs.TAGS, nfs.GREP, cli.MAKE]], function(event, button, data) {
|
can.user.input(event, can, [mdb.NAME, [ctx.ACTION, nfs.TAGS, nfs.GREP, cli.MAKE]], function(event, button, data) {
|
||||||
can.ui.search.Update({}, [ctx.ACTION, data.action, data.name])
|
can.ui.search.Update({}, [ctx.ACTION, data.action, data.name])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"打开": function(event, can) {
|
"打开": function(event, can) {
|
||||||
can.user.input(event, can, [nfs.FILE], function(event, button, data) {
|
can.user.input(event, can, [nfs.FILE], function(event, button, data) {
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), data.file)
|
can.onimport.tabview(can, can.Option(nfs.PATH), data.file)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"添加": function(event, can) {
|
"添加": function(event, can) {
|
||||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), data.index, ctx.INDEX)
|
can.onimport.tabview(can, can.Option(nfs.PATH), data.index, ctx.INDEX)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"插件": function(event, can) {
|
"插件": function(event, can) {
|
||||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
can.user.input(event, can, [ctx.INDEX], function(event, button, data) {
|
||||||
var sub = can.toolkit[data.index]; if (sub) { sub.select(); return }
|
var sub = can.toolkit[data.index]; if (sub) { sub.select(); return }
|
||||||
can.onimport.toolkit(can, data, function(sub) { can.toolkit[data.index] = sub.select() })
|
can.onimport.toolkit(can, data, function(sub) { can.toolkit[data.index] = sub.select() })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"扩展": function(event, can) {
|
"扩展": function(event, can) {
|
||||||
can.user.input(event, can, ["url"], function(event, button, data) {
|
can.user.input(event, can, ["url"], function(event, button, data) {
|
||||||
var sub = can.extentions[data.url]; if (sub) { sub.select(); return }
|
var sub = can.extentions[data.url]; if (sub) { sub.select(); return }
|
||||||
can.onimport.exts(can, data.url, function(sub) { can.extentions[data.url] = sub.select() })
|
can.onimport.exts(can, data.url, function(sub) { can.extentions[data.url] = sub.select() })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"保存": function(event, can) { can.onexport.sess(can), can.user.toastSuccess(can) },
|
"保存": function(event, can) { can.onexport.sess(can), can.user.toastSuccess(can) },
|
||||||
"项目": function(event, can) { can.onmotion.toggle(can, can.ui.project), can.onimport.layout(can) },
|
"项目": function(event, can) { can.onmotion.toggle(can, can.ui.project), can.onimport.layout(can) },
|
||||||
"工具": function(event, can) { can.onmotion.toggle(can, can.ui.toolkit.fieldset) },
|
"工具": function(event, can) { can.onmotion.toggle(can, can.ui.toolkit.fieldset) },
|
||||||
"执行": function(event, can) { can.onimport.display(can), can.request(event, {_toast: "执行中..."})
|
"执行": function(event, can) { can.onimport.display(can), can.request(event, {_toast: "执行中..."})
|
||||||
can.run(event, [ctx.ACTION, mdb.ENGINE, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
can.run(event, [ctx.ACTION, mdb.ENGINE, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
||||||
can.onimport.display(can, msg)
|
can.onimport.display(can, msg)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
"展示": function(event, can) { can.onimport.profile(can), can.request(event, {_toast: "渲染中..."})
|
"展示": function(event, can) { can.onimport.profile(can), can.request(event, {_toast: "渲染中..."})
|
||||||
if (can.Option(nfs.FILE).indexOf("website/") == 0) {
|
if (can.Option(nfs.FILE).indexOf("website/") == 0) {
|
||||||
can.profile_size[can.onexport.keys(can)] = can.profile_size[can.onexport.keys(can)] || can.ConfWidth()*parseInt(70)/100
|
can.profile_size[can.onexport.keys(can)] = can.profile_size[can.onexport.keys(can)] || can.ConfWidth()*parseInt(70)/100
|
||||||
}
|
}
|
||||||
can.run(event, [ctx.ACTION, mdb.RENDER, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
can.run(event, [ctx.ACTION, mdb.RENDER, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
||||||
can.onimport.profile(can, msg)
|
can.onimport.profile(can, msg)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
"清屏": function(event, can) {
|
"清屏": function(event, can) {
|
||||||
if (can.page.Select(can, document.body, ".input.float", function(item) {
|
if (can.page.Select(can, document.body, ".input.float", function(item) {
|
||||||
return can.page.Remove(can, item)
|
return can.page.Remove(can, item)
|
||||||
}).length > 0) { return }
|
}).length > 0) { return }
|
||||||
|
|
||||||
if (can.page.Select(can, can.ui.toolkit.status, "legend.select", function(item) {
|
if (can.page.Select(can, can.ui.toolkit.status, "legend.select", function(item) {
|
||||||
return item.click(), item
|
return item.click(), item
|
||||||
}).length > 0) { return }
|
}).length > 0) { return }
|
||||||
if (can.page.Select(can, can._status, "legend.select", function(item) {
|
if (can.page.Select(can, can._status, "legend.select", function(item) {
|
||||||
return item.click(), item
|
return item.click(), item
|
||||||
}).length > 0) { return }
|
}).length > 0) { return }
|
||||||
|
|
||||||
if (can.ui.profile.style.display == "") {
|
if (can.ui.profile.style.display == "") {
|
||||||
can.onmotion.hidden(can, can.ui.profile)
|
can.onmotion.hidden(can, can.ui.profile)
|
||||||
} else if (can.ui.display.style.display == "") {
|
} else if (can.ui.display.style.display == "") {
|
||||||
can.onmotion.hidden(can, can.ui.display)
|
can.onmotion.hidden(can, can.ui.display)
|
||||||
} else if (can.ui.project.style.display == "") {
|
} else if (can.ui.project.style.display == "") {
|
||||||
can.onmotion.hidden(can, can.ui.project)
|
can.onmotion.hidden(can, can.ui.project)
|
||||||
} else {
|
} else {
|
||||||
can.onaction["全屏"](event, can)
|
can.onaction["全屏"](event, can)
|
||||||
}
|
}
|
||||||
can.onimport.layout(can)
|
can.onimport.layout(can)
|
||||||
},
|
},
|
||||||
"全屏": function(event, can) {
|
"全屏": function(event, can) {
|
||||||
if (can.page.ClassList.neg(can, can._fields, "full")) {
|
if (can.page.ClassList.neg(can, can._fields, "full")) {
|
||||||
can.onmotion.hidden(can, can.ui.project)
|
can.onmotion.hidden(can, can.ui.project)
|
||||||
can.ConfHeight(window.innerHeight)
|
can.ConfHeight(window.innerHeight)
|
||||||
} else {
|
} else {
|
||||||
can.onmotion.hidden(can, can.ui.project, true)
|
can.onmotion.hidden(can, can.ui.project, true)
|
||||||
can.ConfHeight(window.innerHeight-2*html.ACTION_HEIGHT)
|
can.ConfHeight(window.innerHeight-2*html.ACTION_HEIGHT)
|
||||||
}
|
}
|
||||||
can.onimport.layout(can)
|
can.onimport.layout(can)
|
||||||
},
|
},
|
||||||
back: function(event, can) { can.history.pop(); var last = can.history.pop()
|
back: function(event, can) { can.history.pop(); var last = can.history.pop()
|
||||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||||
can.Status("跳转数", can.history.length)
|
can.Status("跳转数", can.history.length)
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollLine: function(can, count) { var size = 20; can.current.scroll(count*size) },
|
scrollLine: function(can, count) { var size = 20; can.current.scroll(count*size) },
|
||||||
appendLine: function(can, value) {
|
appendLine: function(can, value) {
|
||||||
var ui = can.page.Append(can, can.ui.content, [{type: html.TR, list: [
|
var ui = can.page.Append(can, can.ui.content, [{type: html.TR, list: [
|
||||||
{view: ["line unselectable", html.TD, ++can.max], onclick: function(event) {
|
{view: ["line unselectable", html.TD, ++can.max], onclick: function(event) {
|
||||||
can.onaction.selectLine(event, can, ui.tr)
|
can.onaction.selectLine(event, can, ui.tr)
|
||||||
}, ondblclick: function(event) {
|
}, ondblclick: function(event) {
|
||||||
can.onaction.favorLine(can, ui.text.innerText)
|
can.onaction.favorLine(can, ui.text.innerText)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
{view: [html.TEXT, html.TD], list: [can.onsyntax._parse(can, value)], onclick: function(event) {
|
{view: [html.TEXT, html.TD], list: [can.onsyntax._parse(can, value)], onclick: function(event) {
|
||||||
can.onaction.selectLine(event, can, ui.tr)
|
can.onaction.selectLine(event, can, ui.tr)
|
||||||
|
|
||||||
}, ondblclick: function(event) {
|
}, ondblclick: function(event) {
|
||||||
var s = document.getSelection().toString(), str = ui.text.innerText
|
var s = document.getSelection().toString(), str = ui.text.innerText
|
||||||
var begin = str.indexOf(s), end = begin+s.length
|
var begin = str.indexOf(s), end = begin+s.length
|
||||||
|
|
||||||
for (var i = begin; i >= 0; i--) {
|
for (var i = begin; i >= 0; i--) {
|
||||||
if (str[i].match(/[a-zA-Z0-9_.]/)) { s = str.slice(i, end) } else { break }
|
if (str[i].match(/[a-zA-Z0-9_.]/)) { s = str.slice(i, end) } else { break }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.indexOf("kit.") == 0) { s = s.replace("kit.", "toolkits.") }
|
if (s.indexOf("kit.") == 0) { s = s.replace("kit.", "toolkits.") }
|
||||||
if (s.indexOf(".") == 0) { s = s.slice(1) }
|
if (s.indexOf(".") == 0) { s = s.slice(1) }
|
||||||
can.onaction.searchLine(event, can, s)
|
can.onaction.searchLine(event, can, s)
|
||||||
}}
|
}}
|
||||||
]}]); return ui.tr
|
]}]); return ui.tr
|
||||||
},
|
},
|
||||||
selectLine: function(event, can, line) { if (!line) { return parseInt(can.core.Value(can.page.Select(can, can.ui.content, [[[html.TR, html.SELECT], [html.TD, "line"]]])[0], "innerText")) }
|
selectLine: function(event, can, line) { if (!line) { return parseInt(can.core.Value(can.page.Select(can, can.ui.content, [[[html.TR, html.SELECT], [html.TD, "line"]]])[0], "innerText")) }
|
||||||
can.page.Select(can, can.ui.content, html.TR, function(item, index, array) { if (line < 0 || line > array.length) { return }
|
can.page.Select(can, can.ui.content, html.TR, function(item, index, array) { if (line < 0 || line > array.length) { return }
|
||||||
if (!can.page.ClassList.set(can, item, html.SELECT, item == line || index+1 == line)) { return }
|
if (!can.page.ClassList.set(can, item, html.SELECT, item == line || index+1 == line)) { return }
|
||||||
line = item, can.Status(kit.Dict("文件名", can.file, "解析器", can.parse, "当前行", can.onexport.position(can, can.Option(nfs.LINE, index+1))))
|
line = item, can.Status(kit.Dict("文件名", can.file, "解析器", can.parse, "当前行", can.onexport.position(can, can.Option(nfs.LINE, index+1))))
|
||||||
})
|
})
|
||||||
|
|
||||||
can.base.isObject(line) && can.page.Select(can, line, "td.text", function(item) {
|
can.base.isObject(line) && can.page.Select(can, line, "td.text", function(item) {
|
||||||
can.current = {
|
can.current = {
|
||||||
window: function() { return parseInt(can.ui.content.offsetHeight/can.current.line.offsetHeight) },
|
window: function() { return parseInt(can.ui.content.offsetHeight/can.current.line.offsetHeight) },
|
||||||
scroll: function(count) { if (count) { can.ui.content.scrollTop += count*can.current.line.offsetHeight }
|
scroll: function(count) { if (count) { can.ui.content.scrollTop += count*can.current.line.offsetHeight }
|
||||||
return parseInt((can.current.line.offsetTop-can.ui.content.scrollTop)/can.current.line.offsetHeight)
|
return parseInt((can.current.line.offsetTop-can.ui.content.scrollTop)/can.current.line.offsetHeight)
|
||||||
},
|
},
|
||||||
|
|
||||||
prev: function() { return line.previousSibling },
|
prev: function() { return line.previousSibling },
|
||||||
next: function() { return line.nextSibling },
|
next: function() { return line.nextSibling },
|
||||||
line: line, text: function(text) {
|
line: line, text: function(text) {
|
||||||
return text != undefined && can.onaction.modifyLine(can, line, text), item.innerText
|
return text != undefined && can.onaction.modifyLine(can, line, text), item.innerText
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event) {
|
if (!event) {
|
||||||
var scroll = can.current.scroll(); if (scroll < 5) { can.current.scroll(scroll-5) } else {
|
var scroll = can.current.scroll(); if (scroll < 5) { can.current.scroll(scroll-5) } else {
|
||||||
var window = can.current.window(); if (scroll > window/2) { can.current.scroll(scroll-window/2) }
|
var window = can.current.window(); if (scroll > window/2) { can.current.scroll(scroll-window/2) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var scroll = can.current.scroll(); if (scroll < 3) { can.current.scroll(scroll-3) } else {
|
var scroll = can.current.scroll(); if (scroll < 3) { can.current.scroll(scroll-3) } else {
|
||||||
var window = can.current.window(); if (scroll > window-4) { can.current.scroll(scroll-window+4) }
|
var window = can.current.window(); if (scroll > window-4) { can.current.scroll(scroll-window+4) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var push = {path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE), text: can.current.text()}
|
var push = {path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE), text: can.current.text()}
|
||||||
can.base.Eq({path: push.path, file: push.file, line: push.line}, can.history[can.history.length-1]) || can.history.push(push)
|
can.base.Eq({path: push.path, file: push.file, line: push.line}, can.history[can.history.length-1]) || can.history.push(push)
|
||||||
can.Status("跳转数", can.history.length)
|
can.Status("跳转数", can.history.length)
|
||||||
can.onaction._selectLine(event, can)
|
can.onaction._selectLine(event, can)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_selectLine: function(event, can) { },
|
_selectLine: function(event, can) { },
|
||||||
searchLine: function(event, can, value) { if (!can.ui.search) { return }
|
searchLine: function(event, can, value) { if (!can.ui.search) { return }
|
||||||
can.ui.search.Update(event, [ctx.ACTION, nfs.TAGS, value.trim()])
|
can.ui.search.Update(event, [ctx.ACTION, nfs.TAGS, value.trim()])
|
||||||
},
|
},
|
||||||
favorLine: function(can, value) {
|
favorLine: function(can, value) {
|
||||||
can.user.input(event, can, [{name: "zone", value: "hi"}, {name: "name", value: "hello"}], function(event, button, data) {
|
can.user.input(event, can, [{name: "zone", value: "hi"}, {name: "name", value: "hello"}], function(event, button, data) {
|
||||||
can.run(event, [ctx.ACTION, code.FAVOR, ctx.ACTION, mdb.INSERT, mdb.ZONE, data.zone||"",
|
can.run(event, [ctx.ACTION, code.FAVOR, ctx.ACTION, mdb.INSERT, mdb.ZONE, data.zone||"",
|
||||||
mdb.TYPE, can.parse, mdb.NAME, data.name||"", mdb.TEXT, (value||"").trimRight(),
|
mdb.TYPE, can.parse, mdb.NAME, data.name||"", mdb.TEXT, (value||"").trimRight(),
|
||||||
nfs.PATH, can.Option(nfs.PATH), nfs.FILE, can.Option(nfs.FILE), nfs.LINE, can.Option(nfs.LINE),
|
nfs.PATH, can.Option(nfs.PATH), nfs.FILE, can.Option(nfs.FILE), nfs.LINE, can.Option(nfs.LINE),
|
||||||
], function(msg) { can.user.toastSuccess(can) }, true)
|
], function(msg) { can.user.toastSuccess(can) }, true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: ["文件数", "解析器", "文件名", "当前行", "跳转数", "标签数"],
|
Volcanos("onexport", {help: "导出数据", list: ["文件数", "解析器", "文件名", "当前行", "跳转数", "标签数"],
|
||||||
sess: function(can) {
|
sess: function(can) {
|
||||||
localStorage.setItem("web.code.inner.sess", JSON.stringify({
|
localStorage.setItem("web.code.inner.sess", JSON.stringify({
|
||||||
"tabs": can.onexport.tabs(can), "plug": can.onexport.plug(can), "exts": can.onexport.exts(can),
|
"tabs": can.onexport.tabs(can), "plug": can.onexport.plug(can), "exts": can.onexport.exts(can),
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
keys: function(can, file, path) { return (path||can.Option(nfs.PATH))+":"+(file||can.Option(nfs.FILE)) },
|
keys: function(can, file, path) { return (path||can.Option(nfs.PATH))+":"+(file||can.Option(nfs.FILE)) },
|
||||||
tabs: function(can) { return can.core.Item(can.tabview, function(key, msg) { return key+ice.DF+msg.Option(nfs.LINE) }) },
|
tabs: function(can) { return can.core.Item(can.tabview, function(key, msg) { return key+ice.DF+msg.Option(nfs.LINE) }) },
|
||||||
plug: function(can) { return can.core.Item(can.toolkit) },
|
plug: function(can) { return can.core.Item(can.toolkit) },
|
||||||
exts: function(can) { return can.core.Item(can.plugins) },
|
exts: function(can) { return can.core.Item(can.plugins) },
|
||||||
position: function(can, index, total) { total = total||can.max
|
position: function(can, index, total) { total = total||can.max
|
||||||
return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%"
|
return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%"
|
||||||
},
|
},
|
||||||
content: function(can) {
|
content: function(can) {
|
||||||
return can.page.Select(can, can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL)+ice.NL
|
return can.page.Select(can, can.ui.content, "td.text", function(item) { return item.innerText }).join(ice.NL)+ice.NL
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) {
|
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) {
|
||||||
can.onimport.toolkit(can, {index: "web.code.favor"}, function(sub) {
|
can.onimport.toolkit(can, {index: "web.code.favor"}, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
||||||
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||||
code.INNER, function(cmds) {
|
code.INNER, function(cmds) {
|
||||||
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), msg.Option(nfs.LINE))
|
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), msg.Option(nfs.LINE))
|
||||||
},
|
},
|
||||||
))) { return }
|
))) { return }
|
||||||
|
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, code.FAVOR], cmds), function(msg) { var sub = msg._can
|
can.run(event, can.misc.concat(can, [ctx.ACTION, code.FAVOR], cmds), function(msg) { var sub = msg._can
|
||||||
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
|
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
|
||||||
if (msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE) {
|
if (msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE) {
|
||||||
if (key == mdb.VALUE) { key = line.key }
|
if (key == mdb.VALUE) { key = line.key }
|
||||||
}
|
}
|
||||||
if (key != ctx.ACTION) { value = sub.page.replace(sub, value, ice.PWD, "") }
|
if (key != ctx.ACTION) { value = sub.page.replace(sub, value, ice.PWD, "") }
|
||||||
|
|
||||||
return {text: ["", html.TD], list: [{text: [value, html.DIV]}], onclick: function(event) { var target = event.target
|
return {text: ["", html.TD], list: [{text: [value, html.DIV]}], onclick: function(event) { var target = event.target
|
||||||
if ([mdb.ZONE, mdb.ID].indexOf(key) > -1) { return sub.onaction.change(event, sub, key, value) }
|
if ([mdb.ZONE, mdb.ID].indexOf(key) > -1) { return sub.onaction.change(event, sub, key, value) }
|
||||||
|
|
||||||
if (target.tagName == "INPUT" && target.type == html.BUTTON) { var msg = sub.request(event, line, sub.Option())
|
if (target.tagName == "INPUT" && target.type == html.BUTTON) { var msg = sub.request(event, line, sub.Option())
|
||||||
return sub.run(event, [ctx.ACTION, target.name], function(msg) { sub.run() }, true)
|
return sub.run(event, [ctx.ACTION, target.name], function(msg) { sub.run() }, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
line.line && can.onimport.tabview(can, line.path, line.file.replace(ice.PWD, ""), parseInt(line.line))
|
line.line && can.onimport.tabview(can, line.path, line.file.replace(ice.PWD, ""), parseInt(line.line))
|
||||||
}}
|
}}
|
||||||
}, sub._output), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length())
|
}, sub._output), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length())
|
||||||
}, true)
|
}, true)
|
||||||
}, can.base.isFunc(cb) && cb(sub)
|
}, can.base.isFunc(cb) && cb(sub)
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
@ -1,59 +1,59 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) { var history = []; const SEARCH = "can.code.inner.search"
|
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) { var history = []; const SEARCH = "can.code.inner.search"
|
||||||
function show(msg, word) { if (!msg) { return } history.push(msg); var sub = msg._can; sub.Option("word", word||msg._word)
|
function show(msg, word) { if (!msg) { return } history.push(msg); var sub = msg._can; sub.Option("word", word||msg._word)
|
||||||
!sub.page.ClassList.has(sub, sub._legend, "select") && can.ui.search.select()
|
!sub.page.ClassList.has(sub, sub._legend, "select") && can.ui.search.select()
|
||||||
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
|
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
|
||||||
return {text: ["", html.TD], list: [{text: [can.page.replace(can, value, ice.PWD, ""), html.DIV]}], onclick: function(event) {
|
return {text: ["", html.TD], list: [{text: [can.page.replace(can, value, ice.PWD, ""), html.DIV]}], onclick: function(event) {
|
||||||
line.line && can.onimport.tabview(can, can.Option(nfs.PATH), line.file.replace(ice.PWD, ""), parseInt(line.line))
|
line.line && can.onimport.tabview(can, can.Option(nfs.PATH), line.file.replace(ice.PWD, ""), parseInt(line.line))
|
||||||
}}
|
}}
|
||||||
}, sub._output), sub.onappend.board(sub, msg.Result()), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length())
|
}, sub._output), sub.onappend.board(sub, msg.Result()), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length())
|
||||||
}
|
}
|
||||||
can.onengine.plugin(can, SEARCH, shy("搜索", {}, [
|
can.onengine.plugin(can, SEARCH, shy("搜索", {}, [
|
||||||
{type: html.TEXT, name: "word", value: cli.MAIN, onkeydown: function(event, can) {
|
{type: html.TEXT, name: "word", value: cli.MAIN, onkeydown: function(event, can) {
|
||||||
can.onmotion.selectTable(event, can.sup, event.target, function(tr) {
|
can.onmotion.selectTable(event, can.sup, event.target, function(tr) {
|
||||||
can.page.Select(can, tr, html.TD, function(td, index) { index == 0 && td.click() })
|
can.page.Select(can, tr, html.TD, function(td, index) { index == 0 && td.click() })
|
||||||
tr.scrollIntoView(), can._output.scrollTop -= 60
|
tr.scrollIntoView(), can._output.scrollTop -= 60
|
||||||
})
|
})
|
||||||
if (event.key == lang.ENTER) { can.sup.Update(event, [ctx.ACTION, event.ctrlKey? nfs.GREP: nfs.TAGS, can.sup.Option("word")]) }
|
if (event.key == lang.ENTER) { can.sup.Update(event, [ctx.ACTION, event.ctrlKey? nfs.GREP: nfs.TAGS, can.sup.Option("word")]) }
|
||||||
if (event.key == lang.ESCAPE) { event.target.blur() }
|
if (event.key == lang.ESCAPE) { event.target.blur() }
|
||||||
}},
|
}},
|
||||||
{type: html.TEXT, name: "filter", value: "", onkeydown: function(event, can) {
|
{type: html.TEXT, name: "filter", value: "", onkeydown: function(event, can) {
|
||||||
can.onmotion.selectTableInput(event, can.sup, event.target)
|
can.onmotion.selectTableInput(event, can.sup, event.target)
|
||||||
if (event.key == lang.ENTER) { can.sup.Update(event, [ctx.ACTION, event.ctrlKey? nfs.GREP: nfs.TAGS, can.sup.Option("word")]) }
|
if (event.key == lang.ENTER) { can.sup.Update(event, [ctx.ACTION, event.ctrlKey? nfs.GREP: nfs.TAGS, can.sup.Option("word")]) }
|
||||||
if (event.key == lang.ESCAPE) { event.target.blur() }
|
if (event.key == lang.ESCAPE) { event.target.blur() }
|
||||||
}},
|
}},
|
||||||
{type: html.BUTTON, name: nfs.TAGS},
|
{type: html.BUTTON, name: nfs.TAGS},
|
||||||
{type: html.BUTTON, name: nfs.GREP},
|
{type: html.BUTTON, name: nfs.GREP},
|
||||||
{type: html.BUTTON, name: cli.MAKE},
|
{type: html.BUTTON, name: cli.MAKE},
|
||||||
{type: html.BUTTON, name: "history"},
|
{type: html.BUTTON, name: "history"},
|
||||||
{type: html.BUTTON, name: "last", _trans: "返回"},
|
{type: html.BUTTON, name: "last", _trans: "返回"},
|
||||||
], function(msg, cmds, cb) { if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
], function(msg, cmds, cb) { if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||||
"history", function(cmds) {
|
"history", function(cmds) {
|
||||||
can.core.List(can.history, function(item) {
|
can.core.List(can.history, function(item) {
|
||||||
msg.Push(nfs.FILE, item.file)
|
msg.Push(nfs.FILE, item.file)
|
||||||
msg.Push(nfs.LINE, item.line)
|
msg.Push(nfs.LINE, item.line)
|
||||||
msg.Push(mdb.TEXT, item.text)
|
msg.Push(mdb.TEXT, item.text)
|
||||||
})
|
})
|
||||||
show(msg)
|
show(msg)
|
||||||
},
|
},
|
||||||
nfs.TAGS, function(cmds) { msg.Option(kit.Dict(ice.MSG_HANDLE, ice.TRUE, ice.MSG_FIELDS, "file,line,text"))
|
nfs.TAGS, function(cmds) { msg.Option(kit.Dict(ice.MSG_HANDLE, ice.TRUE, ice.MSG_FIELDS, "file,line,text"))
|
||||||
can.run(msg._event, [ctx.ACTION, mdb.SEARCH, can.parse, cmds[0], can.Option(nfs.PATH)], function(msg) { var sub = msg._can
|
can.run(msg._event, [ctx.ACTION, mdb.SEARCH, can.parse, cmds[0], can.Option(nfs.PATH)], function(msg) { var sub = msg._can
|
||||||
can.page.style(can, sub._output, html.MAX_HEIGHT, can.ConfHeight()/4), show(msg, msg._word = cmds[0])
|
can.page.style(can, sub._output, html.MAX_HEIGHT, can.ConfHeight()/4), show(msg, msg._word = cmds[0])
|
||||||
can.page.ClassList.has(sub, sub._target, html.SELECT) || sub._legend.click()
|
can.page.ClassList.has(sub, sub._target, html.SELECT) || sub._legend.click()
|
||||||
can.onmotion.focus(can, msg._can._inputs["word"]._target)
|
can.onmotion.focus(can, msg._can._inputs["word"]._target)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
nfs.GREP, function(cmds) { msg.Option(kit.Dict(ice.MSG_HANDLE, ice.TRUE, ice.MSG_FIELDS, "file,line,text", nfs.PATH, can.Option(nfs.PATH)))
|
nfs.GREP, function(cmds) { msg.Option(kit.Dict(ice.MSG_HANDLE, ice.TRUE, ice.MSG_FIELDS, "file,line,text", nfs.PATH, can.Option(nfs.PATH)))
|
||||||
can.run(msg._event, [ctx.ACTION, nfs.GREP, cmds[0]], function(msg) { var sub = msg._can
|
can.run(msg._event, [ctx.ACTION, nfs.GREP, cmds[0]], function(msg) { var sub = msg._can
|
||||||
can.page.style(can, sub._output, html.MAX_HEIGHT, can.ConfHeight()/4), show(msg, msg._word = cmds[0])
|
can.page.style(can, sub._output, html.MAX_HEIGHT, can.ConfHeight()/4), show(msg, msg._word = cmds[0])
|
||||||
can.page.ClassList.has(sub, sub._target, html.SELECT) || sub._legend.click()
|
can.page.ClassList.has(sub, sub._target, html.SELECT) || sub._legend.click()
|
||||||
can.onmotion.focus(can, msg._can._inputs["word"]._target)
|
can.onmotion.focus(can, msg._can._inputs["word"]._target)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
"last", function(cmds) { history.pop(), show(history.pop()) },
|
"last", function(cmds) { history.pop(), show(history.pop()) },
|
||||||
))) { return } can.run(msg._event, cmds, function(msg) { show(msg) }, true) }))
|
))) { return } can.run(msg._event, cmds, function(msg) { show(msg) }, true) }))
|
||||||
can.onimport.toolkit(can, {index: SEARCH}, function(sub) {
|
can.onimport.toolkit(can, {index: SEARCH}, function(sub) {
|
||||||
can.ui.search = sub, can.base.isFunc(cb) && cb(sub)
|
can.ui.search = sub, can.base.isFunc(cb) && cb(sub)
|
||||||
can.ui.search._show = show
|
can.ui.search._show = show
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) { var SESS = "web.code.sess"
|
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) { var SESS = "web.code.sess"
|
||||||
can.onimport.toolkit(can, {index: SESS}, function(sub) {
|
can.onimport.toolkit(can, {index: SESS}, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
||||||
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||||
nfs.SAVE, function(cmds) {
|
nfs.SAVE, function(cmds) {
|
||||||
can.run(event, [ctx.ACTION, ice.RUN, SESS].concat([ctx.ACTION, mdb.CREATE,
|
can.run(event, [ctx.ACTION, ice.RUN, SESS].concat([ctx.ACTION, mdb.CREATE,
|
||||||
"tool", JSON.stringify(can.onexport.tool(can)),
|
"tool", JSON.stringify(can.onexport.tool(can)),
|
||||||
"tabs", JSON.stringify(can.onexport.tabs(can)),
|
"tabs", JSON.stringify(can.onexport.tabs(can)),
|
||||||
]), cb, true)
|
]), cb, true)
|
||||||
},
|
},
|
||||||
nfs.LOAD, function(cmds) {
|
nfs.LOAD, function(cmds) {
|
||||||
can.onimport.sess(can, {
|
can.onimport.sess(can, {
|
||||||
tool: JSON.parse(msg.Option("tool")),
|
tool: JSON.parse(msg.Option("tool")),
|
||||||
tabs: JSON.parse(msg.Option("tabs")),
|
tabs: JSON.parse(msg.Option("tabs")),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
))) { return }
|
))) { return }
|
||||||
can.run(event, [ctx.ACTION, ice.RUN, SESS].concat(cmds), cb, true)
|
can.run(event, [ctx.ACTION, ice.RUN, SESS].concat(cmds), cb, true)
|
||||||
}, can.base.isFunc(cb) && cb(sub)
|
}, can.base.isFunc(cb) && cb(sub)
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) {
|
Volcanos("onimport", {help: "导入数据", _init: function(can, args, cb) {
|
||||||
can.onimport.toolkit(can, {index: "web.code.template"}, function(sub) {
|
can.onimport.toolkit(can, {index: "web.code.template"}, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) { var msg = sub.request(event, can.Option())
|
sub.run = function(event, cmds, cb) { var msg = sub.request(event, can.Option())
|
||||||
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||||
nfs.DEFS, function(cmds) {
|
nfs.DEFS, function(cmds) {
|
||||||
can.user.input(event, can, can.base.Obj(msg.Option("args")||"[]"), function(ev, button, data, list, args) {
|
can.user.input(event, can, can.base.Obj(msg.Option("args")||"[]"), function(ev, button, data, list, args) {
|
||||||
var msg = can.request(event); can.core.Item(data, function(key, value) { msg.Option(key, value) })
|
var msg = can.request(event); can.core.Item(data, function(key, value) { msg.Option(key, value) })
|
||||||
can.run(event, [ctx.ACTION, ice.RUN, "web.code.template", nfs.DEFS].concat(cmds), function(msg) {
|
can.run(event, [ctx.ACTION, ice.RUN, "web.code.template", nfs.DEFS].concat(cmds), function(msg) {
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
can.onimport.project(can, can.Option(nfs.PATH))
|
can.onimport.project(can, can.Option(nfs.PATH))
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Option("main"), "", function() {
|
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Option("main"), "", function() {
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), cmds[1], 1, function() {})
|
can.onimport.tabview(can, can.Option(nfs.PATH), cmds[1], 1, function() {})
|
||||||
}, true)
|
}, true)
|
||||||
}, true)
|
}, true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
))) { return }
|
))) { return }
|
||||||
can.run(event, [ctx.ACTION, ice.RUN, "web.code.template"].concat(cmds), function(msg) {
|
can.run(event, [ctx.ACTION, ice.RUN, "web.code.template"].concat(cmds), function(msg) {
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
}, true)
|
}, true)
|
||||||
}, can.base.isFunc(cb) && cb(sub)
|
}, can.base.isFunc(cb) && cb(sub)
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can)
|
can.onmotion.clear(can)
|
||||||
if (msg.Option("content")) {
|
if (msg.Option("content")) {
|
||||||
can.onappend.plugin(can, {index: "web.code.vimer", style: "full"}, function(sub) {
|
can.onappend.plugin(can, {index: "web.code.vimer", style: "full"}, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) { var res = can.request(event)
|
sub.run = function(event, cmds, cb) { var res = can.request(event)
|
||||||
if (cmds[1] == "plugin") {
|
if (cmds[1] == "plugin") {
|
||||||
can.run(event, can.misc.concat(can, ["action", "vimer"], cmds), cb, true)
|
can.run(event, can.misc.concat(can, ["action", "vimer"], cmds), cb, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (cmds[1] == "main.go") { res.Echo(msg.Option("content"))
|
if (cmds[1] == "main.go") { res.Echo(msg.Option("content"))
|
||||||
can.core.Timer(100, function() { can.sub && can.sub.onaction["项目"]({}, can.sub) })
|
can.core.Timer(100, function() { can.sub && can.sub.onaction["项目"]({}, can.sub) })
|
||||||
}
|
}
|
||||||
cb(res), can.sub = can.core.Value(sub, "_outputs.-1")
|
cb(res), can.sub = can.core.Value(sub, "_outputs.-1")
|
||||||
}
|
}
|
||||||
}, can._output)
|
}, can._output)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
can.onappend.table(can, msg)
|
can.onappend.table(can, msg)
|
||||||
can.onappend.board(can, msg)
|
can.onappend.board(can, msg)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "操作数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onaction", {help: "操作数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
},
|
},
|
||||||
run: function(event, can, msg) {
|
run: function(event, can, msg) {
|
||||||
can.run(event, [ctx.ACTION, ice.RUN, "go", "hi.go", can.sub.onexport.content(can.sub)], function(msg) {
|
can.run(event, [ctx.ACTION, ice.RUN, "go", "hi.go", can.sub.onexport.content(can.sub)], function(msg) {
|
||||||
can.onappend.board(can, msg)
|
can.onappend.board(can, msg)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
}})
|
}})
|
||||||
|
@ -1,196 +1,196 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
||||||
can.require(["inner.js"], function(can) { can.onimport.inner_init(can, msg, function() {
|
can.require(["inner.js"], function(can) { can.onimport.inner_init(can, msg, function() {
|
||||||
can.onkeymap._build(can), can.onimport._input(can), can.onkeymap._plugin({}, can), can.base.isFunc(cb) && cb(msg)
|
can.onkeymap._build(can), can.onimport._input(can), can.onkeymap._plugin({}, can), can.base.isFunc(cb) && cb(msg)
|
||||||
}, target) }, function(can, name, sub) { name == chat.ONIMPORT && (can.onimport.inner_init = sub._init)
|
}, target) }, function(can, name, sub) { name == chat.ONIMPORT && (can.onimport.inner_init = sub._init)
|
||||||
if (name == chat.ONKEYMAP) {
|
if (name == chat.ONKEYMAP) {
|
||||||
can.base.Copy(can.onkeymap._mode, sub._mode)
|
can.base.Copy(can.onkeymap._mode, sub._mode)
|
||||||
can.core.Item(can.onkeymap._mode.normal, function(k, v) {
|
can.core.Item(can.onkeymap._mode.normal, function(k, v) {
|
||||||
if (!sub._mode.plugin[k]) { sub._mode.plugin[k] = v }
|
if (!sub._mode.plugin[k]) { sub._mode.plugin[k] = v }
|
||||||
})
|
})
|
||||||
can.core.Item(sub._mode.plugin, function(k, v) {
|
can.core.Item(sub._mode.plugin, function(k, v) {
|
||||||
if (!can.onkeymap._mode.normal[k]) { can.onkeymap._mode.normal[k] = v }
|
if (!can.onkeymap._mode.normal[k]) { can.onkeymap._mode.normal[k] = v }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_input: function(can) {
|
_input: function(can) {
|
||||||
can.ui.current = can.page.Append(can, can.ui.content.parentNode, [
|
can.ui.current = can.page.Append(can, can.ui.content.parentNode, [
|
||||||
{view: ["current", html.INPUT], onkeydown: function(event) { if (event.metaKey) { return }
|
{view: ["current", html.INPUT], onkeydown: function(event) { if (event.metaKey) { return }
|
||||||
can.misc.Debug("key", event.key)
|
can.misc.Debug("key", event.key)
|
||||||
can._keylist = can.onkeymap._parse(event, can, can.mode+(event.ctrlKey? "_ctrl": ""), can._keylist, can.ui.current)
|
can._keylist = can.onkeymap._parse(event, can, can.mode+(event.ctrlKey? "_ctrl": ""), can._keylist, can.ui.current)
|
||||||
can.mode == "insert" && can.core.Timer(10, function() { can.current.text(can.ui.current.value) })
|
can.mode == "insert" && can.core.Timer(10, function() { can.current.text(can.ui.current.value) })
|
||||||
can.mode == "normal" && can.Status("按键", can._keylist.join(""))
|
can.mode == "normal" && can.Status("按键", can._keylist.join(""))
|
||||||
can.mode == "normal" && can.onkeymap.prevent(event)
|
can.mode == "normal" && can.onkeymap.prevent(event)
|
||||||
}, onclick: function(event) { can.onkeymap._insert(event, can) },
|
}, onclick: function(event) { can.onkeymap._insert(event, can) },
|
||||||
ondblclick: function(event) { var target = event.target
|
ondblclick: function(event) { var target = event.target
|
||||||
can.onaction.searchLine(event, can, target.value.slice(target.selectionStart, target.selectionEnd))
|
can.onaction.searchLine(event, can, target.value.slice(target.selectionStart, target.selectionEnd))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]).first
|
]).first
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onkeymap", {help: "键盘交互", list: [],
|
Volcanos("onkeymap", {help: "键盘交互", list: [],
|
||||||
_model: function(can, value) { can.Status("模式", can.mode = value)
|
_model: function(can, value) { can.Status("模式", can.mode = value)
|
||||||
return can.page.Modify(can, can.ui.current, {className: "current"+ice.SP+can.mode}), value
|
return can.page.Modify(can, can.ui.current, {className: "current"+ice.SP+can.mode}), value
|
||||||
},
|
},
|
||||||
_plugin: function(event, can) { can.onkeymap._model(can, "plugin")
|
_plugin: function(event, can) { can.onkeymap._model(can, "plugin")
|
||||||
can.ui.current.blur()
|
can.ui.current.blur()
|
||||||
},
|
},
|
||||||
_normal: function(event, can) { can.onkeymap._model(can, "normal")
|
_normal: function(event, can) { can.onkeymap._model(can, "normal")
|
||||||
can.ui.current.focus(), can.ui.content.scrollLeft -= 10000
|
can.ui.current.focus(), can.ui.content.scrollLeft -= 10000
|
||||||
},
|
},
|
||||||
_insert: function(event, can) { can.onkeymap._model(can, "insert")
|
_insert: function(event, can) { can.onkeymap._model(can, "insert")
|
||||||
can.ui.current.focus(), can.ui.content.scrollLeft -= 10000
|
can.ui.current.focus(), can.ui.content.scrollLeft -= 10000
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
},
|
},
|
||||||
|
|
||||||
_mode: {
|
_mode: {
|
||||||
normal_ctrl: {
|
normal_ctrl: {
|
||||||
f: function(event, can, target, count) {
|
f: function(event, can, target, count) {
|
||||||
var line = can.onaction.selectLine(event, can)+can.current.window()-3-can.current.scroll()
|
var line = can.onaction.selectLine(event, can)+can.current.window()-3-can.current.scroll()
|
||||||
return can.current.scroll(line), can.onaction.selectLine(event, can, line), true
|
return can.current.scroll(line), can.onaction.selectLine(event, can, line), true
|
||||||
},
|
},
|
||||||
b: function(event, can, target, count) {
|
b: function(event, can, target, count) {
|
||||||
var line = can.onaction.selectLine(event, can)-can.current.window()+3
|
var line = can.onaction.selectLine(event, can)-can.current.window()+3
|
||||||
return can.current.scroll(line), can.onaction.selectLine(event, can, line), true
|
return can.current.scroll(line), can.onaction.selectLine(event, can, line), true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
normal: {
|
normal: {
|
||||||
escape: function(event, can) { can.onkeymap._plugin(event, can) },
|
escape: function(event, can) { can.onkeymap._plugin(event, can) },
|
||||||
ArrowLeft: function(event, can, target) { can.onkeymap.cursorMove(can, target, -1) },
|
ArrowLeft: function(event, can, target) { can.onkeymap.cursorMove(can, target, -1) },
|
||||||
ArrowRight: function(event, can, target) { can.onkeymap.cursorMove(can, target, 1) },
|
ArrowRight: function(event, can, target) { can.onkeymap.cursorMove(can, target, 1) },
|
||||||
ArrowDown: function(event, can) { can.onaction.selectLine(event, can, can.current.next()) },
|
ArrowDown: function(event, can) { can.onaction.selectLine(event, can, can.current.next()) },
|
||||||
ArrowUp: function(event, can) { can.onaction.selectLine(event, can, can.current.prev()) },
|
ArrowUp: function(event, can) { can.onaction.selectLine(event, can, can.current.prev()) },
|
||||||
|
|
||||||
H: function(event, can, target) { can.onkeymap.cursorMove(can, target, 0, 0) },
|
H: function(event, can, target) { can.onkeymap.cursorMove(can, target, 0, 0) },
|
||||||
h: function(event, can, target) { can.onkeymap.cursorMove(can, target, -1) },
|
h: function(event, can, target) { can.onkeymap.cursorMove(can, target, -1) },
|
||||||
l: function(event, can, target) { can.onkeymap.cursorMove(can, target, 1) },
|
l: function(event, can, target) { can.onkeymap.cursorMove(can, target, 1) },
|
||||||
L: function(event, can, target) { can.onkeymap.cursorMove(can, target, 0, -1) },
|
L: function(event, can, target) { can.onkeymap.cursorMove(can, target, 0, -1) },
|
||||||
j: function(event, can) { can.onaction.selectLine(event, can, can.current.next()) },
|
j: function(event, can) { can.onaction.selectLine(event, can, can.current.next()) },
|
||||||
k: function(event, can) { can.onaction.selectLine(event, can, can.current.prev()) },
|
k: function(event, can) { can.onaction.selectLine(event, can, can.current.prev()) },
|
||||||
|
|
||||||
gg: function(event, can, target, count) { return can.onaction.selectLine(event, can, count), true },
|
gg: function(event, can, target, count) { return can.onaction.selectLine(event, can, count), true },
|
||||||
G: function(event, can, target, count) { return can.onaction.selectLine(event, can, count = count>1? count: can.max), true },
|
G: function(event, can, target, count) { return can.onaction.selectLine(event, can, count = count>1? count: can.max), true },
|
||||||
zt: function(event, can, target, count) { return can.current.scroll(can.current.scroll()-(count>1? count: 3)), true },
|
zt: function(event, can, target, count) { return can.current.scroll(can.current.scroll()-(count>1? count: 3)), true },
|
||||||
zz: function(event, can, target, count) { return can.current.scroll(can.current.scroll()-(count = count>1? count: can.current.window()/2)), true },
|
zz: function(event, can, target, count) { return can.current.scroll(can.current.scroll()-(count = count>1? count: can.current.window()/2)), true },
|
||||||
zb: function(event, can, target, count) { return can.current.scroll(can.current.scroll()-can.current.window()+(count>1? count: 5)), true },
|
zb: function(event, can, target, count) { return can.current.scroll(can.current.scroll()-can.current.window()+(count>1? count: 5)), true },
|
||||||
|
|
||||||
i: function(event, can) { can.onkeymap._insert(event, can) },
|
i: function(event, can) { can.onkeymap._insert(event, can) },
|
||||||
I: function(event, can, target) { can.onkeymap._insert(event, can), can.onkeymap.cursorMove(can, target, 0, 0) },
|
I: function(event, can, target) { can.onkeymap._insert(event, can), can.onkeymap.cursorMove(can, target, 0, 0) },
|
||||||
a: function(event, can, target) { can.onkeymap._insert(event, can), can.onkeymap.cursorMove(can, target, 1) },
|
a: function(event, can, target) { can.onkeymap._insert(event, can), can.onkeymap.cursorMove(can, target, 1) },
|
||||||
A: function(event, can, target) { can.onkeymap._insert(event, can), can.onkeymap.cursorMove(can, target, 0, -1) },
|
A: function(event, can, target) { can.onkeymap._insert(event, can), can.onkeymap.cursorMove(can, target, 0, -1) },
|
||||||
o: function(event, can) { can.onkeymap._insert(event, can), can.onaction.selectLine(event, can, can.onaction.insertLine(can, "", can.current.next())) },
|
o: function(event, can) { can.onkeymap._insert(event, can), can.onaction.selectLine(event, can, can.onaction.insertLine(can, "", can.current.next())) },
|
||||||
O: function(event, can) { can.onkeymap._insert(event, can), can.onaction.selectLine(event, can, can.onaction.insertLine(can, "", can.current.line)) },
|
O: function(event, can) { can.onkeymap._insert(event, can), can.onaction.selectLine(event, can, can.onaction.insertLine(can, "", can.current.line)) },
|
||||||
|
|
||||||
yy: function(event, can, target, count) { can._last_text = can.current.text() },
|
yy: function(event, can, target, count) { can._last_text = can.current.text() },
|
||||||
dd: function(event, can, target, count) { can._last_text = can.current.text(), can.onaction.selectLine(event, can, can.onaction.deleteLine(can, can.current.line)) },
|
dd: function(event, can, target, count) { can._last_text = can.current.text(), can.onaction.selectLine(event, can, can.onaction.deleteLine(can, can.current.line)) },
|
||||||
p: function(event, can) { can.onaction.insertLine(can, can._last_text, can.current.next()) },
|
p: function(event, can) { can.onaction.insertLine(can, can._last_text, can.current.next()) },
|
||||||
P: function(event, can) { can.onaction.insertLine(can, can._last_text, can.current.line) },
|
P: function(event, can) { can.onaction.insertLine(can, can._last_text, can.current.line) },
|
||||||
|
|
||||||
s: function(event, can) { can.onaction.save(event, can) },
|
s: function(event, can) { can.onaction.save(event, can) },
|
||||||
m: function(event, can) { can.onaction.autogen(event, can, "autogen") },
|
m: function(event, can) { can.onaction.autogen(event, can, "autogen") },
|
||||||
c: function(event, can) { can.onaction.compile(event, can, "compile") },
|
c: function(event, can) { can.onaction.compile(event, can, "compile") },
|
||||||
},
|
},
|
||||||
insert: {
|
insert: {
|
||||||
jk: function(event, can, target) { can.onkeymap._normal(event, can),
|
jk: function(event, can, target) { can.onkeymap._normal(event, can),
|
||||||
can.onkeymap.deleteText(target, target.selectionStart-1, 1)
|
can.onkeymap.deleteText(target, target.selectionStart-1, 1)
|
||||||
can.current.text(can.ui.current.value)
|
can.current.text(can.ui.current.value)
|
||||||
},
|
},
|
||||||
Escape: function(event, can) { can.onkeymap._normal(event, can) },
|
Escape: function(event, can) { can.onkeymap._normal(event, can) },
|
||||||
Tab: function(event, can) {
|
Tab: function(event, can) {
|
||||||
can.onkeymap.insertText(can.ui.current, "\t")
|
can.onkeymap.insertText(can.ui.current, "\t")
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
},
|
},
|
||||||
|
|
||||||
Enter: function(event, can, target) {
|
Enter: function(event, can, target) {
|
||||||
var line = can.onaction.insertLine(can, can.onkeymap.deleteText(target, target.selectionEnd), can.current.next())
|
var line = can.onaction.insertLine(can, can.onkeymap.deleteText(target, target.selectionEnd), can.current.next())
|
||||||
can.current.text(can.ui.current.value), can.onaction.selectLine(event, can, line)
|
can.current.text(can.ui.current.value), can.onaction.selectLine(event, can, line)
|
||||||
},
|
},
|
||||||
Backspace: function(event, can, target) {
|
Backspace: function(event, can, target) {
|
||||||
if (target.selectionStart > 0) { return }
|
if (target.selectionStart > 0) { return }
|
||||||
if (!can.current.prev()) { return }
|
if (!can.current.prev()) { return }
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
|
|
||||||
var rest = can.current.text()
|
var rest = can.current.text()
|
||||||
can.onaction.selectLine(event, can, can.current.prev())
|
can.onaction.selectLine(event, can, can.current.prev())
|
||||||
can.onaction.deleteLine(can, can.current.next())
|
can.onaction.deleteLine(can, can.current.next())
|
||||||
var pos = can.current.text().length
|
var pos = can.current.text().length
|
||||||
|
|
||||||
can.ui.current.value = can.current.text()+rest
|
can.ui.current.value = can.current.text()+rest
|
||||||
can.onkeymap.cursorMove(can, can.ui.current, 0, pos)
|
can.onkeymap.cursorMove(can, can.ui.current, 0, pos)
|
||||||
},
|
},
|
||||||
ArrowUp: function(event, can) { can.onaction.selectLine(event, can, can.current.prev()) },
|
ArrowUp: function(event, can) { can.onaction.selectLine(event, can, can.current.prev()) },
|
||||||
ArrowDown: function(event, can) { can.onaction.selectLine(event, can, can.current.next()) },
|
ArrowDown: function(event, can) { can.onaction.selectLine(event, can, can.current.next()) },
|
||||||
},
|
},
|
||||||
}, _engine: {},
|
}, _engine: {},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "控件交互", list: ["加载", nfs.SAVE, "autogen", "compile", "binpack", "刷新"],
|
Volcanos("onaction", {help: "控件交互", list: ["加载", nfs.SAVE, "autogen", "compile", "binpack", "刷新"],
|
||||||
"刷新": function(event, can) {
|
"刷新": function(event, can) {
|
||||||
can.onimport.tabview(can, "src/", "main.go", "", function() {}, true)
|
can.onimport.tabview(can, "src/", "main.go", "", function() {}, true)
|
||||||
},
|
},
|
||||||
"加载": function(event, can) {
|
"加载": function(event, can) {
|
||||||
var file = "/share/local/"+can.Option(nfs.PATH)+can.Option(nfs.FILE)
|
var file = "/share/local/"+can.Option(nfs.PATH)+can.Option(nfs.FILE)
|
||||||
delete(Volcanos.meta.cache[file])
|
delete(Volcanos.meta.cache[file])
|
||||||
var script = `\n_can_name = "`+file+`"\n`+
|
var script = `\n_can_name = "`+file+`"\n`+
|
||||||
can.onexport.content(can)+
|
can.onexport.content(can)+
|
||||||
`\n_can_name = ""\nconsole.log("once")`
|
`\n_can_name = ""\nconsole.log("once")`
|
||||||
eval(script)
|
eval(script)
|
||||||
},
|
},
|
||||||
save: function(event, can) { var msg = can.request(event, {content: can.onexport.content(can)})
|
save: function(event, can) { var msg = can.request(event, {content: can.onexport.content(can)})
|
||||||
can.run(event, [ctx.ACTION, nfs.SAVE, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
can.run(event, [ctx.ACTION, nfs.SAVE, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
||||||
can.user.toastSuccess(can)
|
can.user.toastSuccess(can)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
autogen: function(event, can, button) { var meta = can.Conf(), msg = can.request(event, {_handle: ice.TRUE})
|
autogen: function(event, can, button) { var meta = can.Conf(), msg = can.request(event, {_handle: ice.TRUE})
|
||||||
can.user.input(event, can, meta.feature[button], function(ev, btn, data, list, args) {
|
can.user.input(event, can, meta.feature[button], function(ev, btn, data, list, args) {
|
||||||
can.run(event, [ctx.ACTION, button].concat(args), function(msg) {
|
can.run(event, [ctx.ACTION, button].concat(args), function(msg) {
|
||||||
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Option(nfs.FILE))
|
can.onimport.tabview(can, can.Option(nfs.PATH), msg.Option(nfs.FILE))
|
||||||
can.onimport.project(can, can.Option(nfs.PATH))
|
can.onimport.project(can, can.Option(nfs.PATH))
|
||||||
}, true)
|
}, true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
compile: function(event, can, button) { var msg = can.ui.search.request(event, {_handle: ice.TRUE, _toast: "编译中..."})
|
compile: function(event, can, button) { var msg = can.ui.search.request(event, {_handle: ice.TRUE, _toast: "编译中..."})
|
||||||
can.run(event, [ctx.ACTION, button], function(msg) {
|
can.run(event, [ctx.ACTION, button], function(msg) {
|
||||||
if (msg.Length() == 0) { var toast = can.user.toast(can, "重启中...", "", -1)
|
if (msg.Length() == 0) { var toast = can.user.toast(can, "重启中...", "", -1)
|
||||||
can.core.Timer(5000, function() { toast.close(), can.onaction["展示"]({}, can) })
|
can.core.Timer(5000, function() { toast.close(), can.onaction["展示"]({}, can) })
|
||||||
} else {
|
} else {
|
||||||
can.ui.search._show(msg)
|
can.ui.search._show(msg)
|
||||||
}
|
}
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
|
|
||||||
_selectLine: function(event, can) {
|
_selectLine: function(event, can) {
|
||||||
can.page.Select(can, can.current.line, "td.text", function(td) { can.current.line.appendChild(can.ui.current)
|
can.page.Select(can, can.current.line, "td.text", function(td) { can.current.line.appendChild(can.ui.current)
|
||||||
can.page.Modify(can, can.ui.current, {style: kit.Dict(html.LEFT, td.offsetLeft-1, html.WIDTH,td.offsetWidth-12), value: td.innerText})
|
can.page.Modify(can, can.ui.current, {style: kit.Dict(html.LEFT, td.offsetLeft-1, html.WIDTH,td.offsetWidth-12), value: td.innerText})
|
||||||
if (event) { if (can.mode == "plugin") { can.onkeymap._insert(event, can) }
|
if (event) { if (can.mode == "plugin") { can.onkeymap._insert(event, can) }
|
||||||
can.ui.current.focus(), can.onkeymap.cursorMove(can, can.ui.current, 0, (event.offsetX)/13-1)
|
can.ui.current.focus(), can.onkeymap.cursorMove(can, can.ui.current, 0, (event.offsetX)/13-1)
|
||||||
can.ui.content.scrollLeft -= 10000
|
can.ui.content.scrollLeft -= 10000
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
rerankLine: function(can, value) { can.max = 0
|
rerankLine: function(can, value) { can.max = 0
|
||||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||||
can.max++, can.page.Select(can, item, "td.line", function(item) { item.innerText = index+1 })
|
can.max++, can.page.Select(can, item, "td.line", function(item) { item.innerText = index+1 })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
insertLine: function(can, value, before) {
|
insertLine: function(can, value, before) {
|
||||||
var line = can.onaction.appendLine(can, value)
|
var line = can.onaction.appendLine(can, value)
|
||||||
before && can.ui.content.insertBefore(line, before)
|
before && can.ui.content.insertBefore(line, before)
|
||||||
return can.onaction.rerankLine(can), line
|
return can.onaction.rerankLine(can), line
|
||||||
},
|
},
|
||||||
deleteLine: function(can, line) {
|
deleteLine: function(can, line) {
|
||||||
var next = line.nextSibling||line.previousSibling
|
var next = line.nextSibling||line.previousSibling
|
||||||
can.page.Remove(can, line), can.onaction.rerankLine(can)
|
can.page.Remove(can, line), can.onaction.rerankLine(can)
|
||||||
return next
|
return next
|
||||||
},
|
},
|
||||||
modifyLine: function(can, line, value) {
|
modifyLine: function(can, line, value) {
|
||||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||||
if (item != line && index+1 != line) { return }
|
if (item != line && index+1 != line) { return }
|
||||||
can.page.Select(can, item, "td.text", function(item) {
|
can.page.Select(can, item, "td.text", function(item) {
|
||||||
can.page.Appends(can, item, [can.onsyntax._parse(can, value)])
|
can.page.Appends(can, item, [can.onsyntax._parse(can, value)])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: ["文件数", "模式", "按键", "解析器", "文件名", "当前行", "跳转数"]})
|
Volcanos("onexport", {help: "导出数据", list: ["文件数", "模式", "按键", "解析器", "文件名", "当前行", "跳转数"]})
|
||||||
|
|
||||||
|
@ -1,199 +1,199 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can, target)
|
can.onmotion.clear(can, target)
|
||||||
can.ui = can.onlayout.profile(can)
|
can.ui = can.onlayout.profile(can)
|
||||||
can.onmotion.hidden(can, can._action)
|
can.onmotion.hidden(can, can._action)
|
||||||
can.onimport[can.Option("scale")||"week"](can, msg)
|
can.onimport[can.Option("scale")||"week"](can, msg)
|
||||||
can.page.Modify(can, can.ui.project, {style: {"max-height": can.ui.content.offsetHeight}})
|
can.page.Modify(can, can.ui.project, {style: {"max-height": can.ui.content.offsetHeight}})
|
||||||
can.page.Modify(can, can.ui.profile, {style: {"max-height": can.ui.content.offsetHeight}})
|
can.page.Modify(can, can.ui.profile, {style: {"max-height": can.ui.content.offsetHeight}})
|
||||||
can.page.Modify(can, can.ui.profile, {style: {display: "block"}})
|
can.page.Modify(can, can.ui.profile, {style: {display: "block"}})
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
},
|
},
|
||||||
_content: function(can, msg, head, list, key, get, set) {
|
_content: function(can, msg, head, list, key, get, set) {
|
||||||
var hash = {}; msg.Table(function(value, index) {
|
var hash = {}; msg.Table(function(value, index) {
|
||||||
var k = key(can.base.Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
|
var k = key(can.base.Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
|
||||||
})
|
})
|
||||||
|
|
||||||
can.sup.task && (can.sup.task._target = null)
|
can.sup.task && (can.sup.task._target = null)
|
||||||
var begin_time = can.base.Date(can.Option("begin_time"))
|
var begin_time = can.base.Date(can.Option("begin_time"))
|
||||||
can.page.Append(can, can.ui.content, [{view: [chat.CONTENT, html.TABLE], list: can.core.List(list, function(hour, row) {
|
can.page.Append(can, can.ui.content, [{view: [chat.CONTENT, html.TABLE], list: can.core.List(list, function(hour, row) {
|
||||||
return {type: html.TR, list: can.core.List(head, function(week, col) {
|
return {type: html.TR, list: can.core.List(head, function(week, col) {
|
||||||
if (row == 0) { return {text: [week, html.TH]} }
|
if (row == 0) { return {text: [week, html.TH]} }
|
||||||
if (col == 0) { return {text: [hour, html.TD]} }
|
if (col == 0) { return {text: [hour, html.TD]} }
|
||||||
return can.onimport._task(can, msg, get(begin_time, col, row, hash), set(begin_time, col, row))
|
return can.onimport._task(can, msg, get(begin_time, col, row, hash), set(begin_time, col, row))
|
||||||
})}
|
})}
|
||||||
}) }])
|
}) }])
|
||||||
can.core.Timer(10, function() { if (!can.sup.task) { return }
|
can.core.Timer(10, function() { if (!can.sup.task) { return }
|
||||||
var target = can.sup.task._target||can.task._target
|
var target = can.sup.task._target||can.task._target
|
||||||
can.sup.task = null, target.click()
|
can.sup.task = null, target.click()
|
||||||
can.Status("count", msg.Length())
|
can.Status("count", msg.Length())
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_task: function(can, msg, list, time) { return {text: ["", html.TD],
|
_task: function(can, msg, list, time) { return {text: ["", html.TD],
|
||||||
ondblclick: function(event) {
|
ondblclick: function(event) {
|
||||||
can.onaction.insertTask(event, can, time+can.base.Time(null, "%y-%m-%d %H:%M:%S").slice(time.length))
|
can.onaction.insertTask(event, can, time+can.base.Time(null, "%y-%m-%d %H:%M:%S").slice(time.length))
|
||||||
},
|
},
|
||||||
ondrop: function(event) { event.preventDefault()
|
ondrop: function(event) { event.preventDefault()
|
||||||
can.drop(event, event.target, time)
|
can.drop(event, event.target, time)
|
||||||
},
|
},
|
||||||
ondragover: function(event) { event.preventDefault()
|
ondragover: function(event) { event.preventDefault()
|
||||||
can.page.Select(can, can.ui.content, html.TD, function(item) {
|
can.page.Select(can, can.ui.content, html.TD, function(item) {
|
||||||
can.page.ClassList[event.target == item? "add": "del"](can, item, "over")
|
can.page.ClassList[event.target == item? "add": "del"](can, item, "over")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
list: can.core.List(list, function(task) { return can.base.isString(task)? {text: [task, html.DIV, "date"]}:
|
list: can.core.List(list, function(task) { return can.base.isString(task)? {text: [task, html.DIV, "date"]}:
|
||||||
{text: [can.onexport[can.Action("view")||"text"](can, task), html.DIV, can.onexport.style(can, task)],
|
{text: [can.onexport[can.Action("view")||"text"](can, task), html.DIV, can.onexport.style(can, task)],
|
||||||
ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { td.append(target)
|
ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { td.append(target)
|
||||||
can.onaction.modifyTask(event, can, task, "begin_time", time+task.begin_time.slice(time.length), task.begin_time)
|
can.onaction.modifyTask(event, can, task, "begin_time", time+task.begin_time.slice(time.length), task.begin_time)
|
||||||
} }, draggable: time != undefined,
|
} }, draggable: time != undefined,
|
||||||
|
|
||||||
title: can.onexport.title(can, task), _init: function(target) {
|
title: can.onexport.title(can, task), _init: function(target) {
|
||||||
var item = can.onappend.item(can, html.ITEM, {nick: task.name+":"+task.text}, function() {
|
var item = can.onappend.item(can, html.ITEM, {nick: task.name+":"+task.text}, function() {
|
||||||
can.core.Timer(10, function() { can.onmotion.select(can, can.ui.content, html.TD, target.parentNode) })
|
can.core.Timer(10, function() { can.onmotion.select(can, can.ui.content, html.TD, target.parentNode) })
|
||||||
can.onimport._profile(can, task)
|
can.onimport._profile(can, task)
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
||||||
}, can.ui.project); task._target = target, can.task = can.task||task, can.sup.task = can.sup.task||task
|
}, can.ui.project); task._target = target, can.task = can.task||task, can.sup.task = can.sup.task||task
|
||||||
can.sup.task.zone == task.zone && can.sup.task.id == task.id && (can.sup.task._target = target)
|
can.sup.task.zone == task.zone && can.sup.task.id == task.id && (can.sup.task._target = target)
|
||||||
target.onclick = function(event) { item.click() }
|
target.onclick = function(event) { item.click() }
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
} },
|
} },
|
||||||
_profile: function(can, task) {
|
_profile: function(can, task) {
|
||||||
if (can.sup.task && can.sup.task.pod == task.pod && can.sup.task.id == task.id) { return }
|
if (can.sup.task && can.sup.task.pod == task.pod && can.sup.task.id == task.id) { return }
|
||||||
if (can.onmotion.cache(can, function() { return can.sup.task = task, can.Status(task), [task.pod, task.zone, task.id].join(ice.PT) }, can.ui.profile, can.ui.display)) { return }
|
if (can.onmotion.cache(can, function() { return can.sup.task = task, can.Status(task), [task.pod, task.zone, task.id].join(ice.PT) }, can.ui.profile, can.ui.display)) { return }
|
||||||
|
|
||||||
task.extra && can.core.Item(can.base.Obj(task.extra), function(key, value) { task["extra."+key] = value }), delete(task.extra)
|
task.extra && can.core.Item(can.base.Obj(task.extra), function(key, value) { task["extra."+key] = value }), delete(task.extra)
|
||||||
var table = can.page.Appends(can, can.ui.profile, [{view: [chat.CONTENT, html.TABLE], list: [{th: ["key", "value"]}]}]).first
|
var table = can.page.Appends(can, can.ui.profile, [{view: [chat.CONTENT, html.TABLE], list: [{th: ["key", "value"]}]}]).first
|
||||||
can.core.Item(task, function(key, value) { key != "_target" && can.page.Append(can, table, [{
|
can.core.Item(task, function(key, value) { key != "_target" && can.page.Append(can, table, [{
|
||||||
td: [key, key == "pod" && value != ""? can.page.Format("a", can.misc.MergeURL(can, {pod: value}), value): value],
|
td: [key, key == "pod" && value != ""? can.page.Format("a", can.misc.MergeURL(can, {pod: value}), value): value],
|
||||||
onclick: function(event) { if (event.target.type == "button") { var msg = can.request(event, can.sup.task)
|
onclick: function(event) { if (event.target.type == "button") { var msg = can.request(event, can.sup.task)
|
||||||
can.run(event, [ctx.ACTION, event.target.name], function(msg) { can.Update() }, true)
|
can.run(event, [ctx.ACTION, event.target.name], function(msg) { can.Update() }, true)
|
||||||
} },
|
} },
|
||||||
ondblclick: function(event) { can.onmotion.modify(can, event.target, function(ev, value, old) {
|
ondblclick: function(event) { can.onmotion.modify(can, event.target, function(ev, value, old) {
|
||||||
can.onaction.modifyTask(event, can, task, key, value)
|
can.onaction.modifyTask(event, can, task, key, value)
|
||||||
}, {name: key, action: key.indexOf("time") > 0? "date": "key"}) },
|
}, {name: key, action: key.indexOf("time") > 0? "date": "key"}) },
|
||||||
}]) }), can.onimport._display(can, task)
|
}]) }), can.onimport._display(can, task)
|
||||||
},
|
},
|
||||||
_display: function(can, task) { if (!task["extra.cmd"]) { return }
|
_display: function(can, task) { if (!task["extra.cmd"]) { return }
|
||||||
can.onappend.plugin(can, {type: chat.STORY, ctx: task["extra.ctx"], cmd: task["extra.cmd"], arg: task["extra.arg"]}, function(sub, meta) {
|
can.onappend.plugin(can, {type: chat.STORY, ctx: task["extra.ctx"], cmd: task["extra.cmd"], arg: task["extra.arg"]}, function(sub, meta) {
|
||||||
sub.run = function(event, cmds, cb) { var msg = can.request(event, kit.Dict("task.pod", task["pod"], "task.zone", task.zone, "task.id", task.id))
|
sub.run = function(event, cmds, cb) { var msg = can.request(event, kit.Dict("task.pod", task["pod"], "task.zone", task.zone, "task.id", task.id))
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, task[mdb.ZONE], task[mdb.ID]], cmds), cb, true)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, task[mdb.ZONE], task[mdb.ID]], cmds), cb, true)
|
||||||
}
|
}
|
||||||
}, can.ui.display)
|
}, can.ui.display)
|
||||||
can.page.Modify(can, can.ui.display, {style: {display: html.BLOCK}})
|
can.page.Modify(can, can.ui.display, {style: {display: html.BLOCK}})
|
||||||
},
|
},
|
||||||
|
|
||||||
day: function(can, msg) {
|
day: function(can, msg) {
|
||||||
var head = ["hour", "task"]
|
var head = ["hour", "task"]
|
||||||
var list = [0]; for (var i = 7; i < 24; i++) { list.push(can.base.Number(i, 2)) }
|
var list = [0]; for (var i = 7; i < 24; i++) { list.push(can.base.Number(i, 2)) }
|
||||||
|
|
||||||
function key(time) { return can.base.Number(time.getHours(), 2) }
|
function key(time) { return can.base.Number(time.getHours(), 2) }
|
||||||
function get(begin_time, col, row, hash) { return hash[list[row]] }
|
function get(begin_time, col, row, hash) { return hash[list[row]] }
|
||||||
function set(begin_time, col, row) { return can.base.Time(begin_time, "%y-%m-%d ")+list[row] }
|
function set(begin_time, col, row) { return can.base.Time(begin_time, "%y-%m-%d ")+list[row] }
|
||||||
|
|
||||||
can.onimport._content(can, msg, head, list, key, get, set)
|
can.onimport._content(can, msg, head, list, key, get, set)
|
||||||
},
|
},
|
||||||
week: function(can, msg) {
|
week: function(can, msg) {
|
||||||
var head = ["hour"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"])
|
var head = ["hour"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"])
|
||||||
var list = [0]; for (var i = 7; i < 24; i++) { list.push(can.base.Number(i, 2)) }
|
var list = [0]; for (var i = 7; i < 24; i++) { list.push(can.base.Number(i, 2)) }
|
||||||
|
|
||||||
function key(time) { return time.getDay()+" "+can.base.Number(time.getHours(), 2) }
|
function key(time) { return time.getDay()+" "+can.base.Number(time.getHours(), 2) }
|
||||||
function get(begin_time, col, row, hash) { return hash[col-1+" "+list[row]] }
|
function get(begin_time, col, row, hash) { return hash[col-1+" "+list[row]] }
|
||||||
function set(begin_time, col, row) { return can.base.Time(can.base.TimeAdd(begin_time, -begin_time.getDay()+col-1), "%y-%m-%d ")+list[row] }
|
function set(begin_time, col, row) { return can.base.Time(can.base.TimeAdd(begin_time, -begin_time.getDay()+col-1), "%y-%m-%d ")+list[row] }
|
||||||
|
|
||||||
can.onimport._content(can, msg, head, list, key, get, set)
|
can.onimport._content(can, msg, head, list, key, get, set)
|
||||||
},
|
},
|
||||||
month: function(can, msg) {
|
month: function(can, msg) {
|
||||||
var head = ["order"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"])
|
var head = ["order"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"])
|
||||||
var list = [0]; for (var i = 1; i < 6; i++) { list.push(i) }
|
var list = [0]; for (var i = 1; i < 6; i++) { list.push(i) }
|
||||||
|
|
||||||
function key(time) { return can.base.Time(time, "%y-%m-%d") }
|
function key(time) { return can.base.Time(time, "%y-%m-%d") }
|
||||||
function get(begin_time, col, row, hash) {
|
function get(begin_time, col, row, hash) {
|
||||||
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
|
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
|
||||||
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
|
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
|
||||||
var day = can.base.TimeAdd(last, (row-1)*7+col)
|
var day = can.base.TimeAdd(last, (row-1)*7+col)
|
||||||
return [day.getDate()+""].concat(hash[key(day)]||[])
|
return [day.getDate()+""].concat(hash[key(day)]||[])
|
||||||
}
|
}
|
||||||
function set(begin_time, col, row) {
|
function set(begin_time, col, row) {
|
||||||
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
|
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
|
||||||
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
|
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
|
||||||
var day = can.base.TimeAdd(last, (row-1)*7+col)
|
var day = can.base.TimeAdd(last, (row-1)*7+col)
|
||||||
return key(day)
|
return key(day)
|
||||||
}
|
}
|
||||||
|
|
||||||
can.onimport._content(can, msg, head, list, key, get, set)
|
can.onimport._content(can, msg, head, list, key, get, set)
|
||||||
},
|
},
|
||||||
year: function(can, msg) {
|
year: function(can, msg) {
|
||||||
var head = ["month"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"]);
|
var head = ["month"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"]);
|
||||||
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
|
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
|
||||||
|
|
||||||
function key(time) { return can.base.Time(time, "%y-%m ")+time.getDay() }
|
function key(time) { return can.base.Time(time, "%y-%m ")+time.getDay() }
|
||||||
function get(begin_time, col, row, hash) { return hash[begin_time.getFullYear()+"-"+can.base.Number(row, 2)+" "+(col-1)] }
|
function get(begin_time, col, row, hash) { return hash[begin_time.getFullYear()+"-"+can.base.Number(row, 2)+" "+(col-1)] }
|
||||||
function set(begin_time, col, row) { return begin_time.getFullYear()+"-"+can.base.Number(list[row], 2) }
|
function set(begin_time, col, row) { return begin_time.getFullYear()+"-"+can.base.Number(list[row], 2) }
|
||||||
|
|
||||||
can.onimport._content(can, msg, head, list, key, get, set)
|
can.onimport._content(can, msg, head, list, key, get, set)
|
||||||
},
|
},
|
||||||
long: function(can, msg) {
|
long: function(can, msg) {
|
||||||
var begin_time = can.base.Date(can.base.Time(can.Option("begin_time"), "%y-%m-%d %H:%M:%S"))
|
var begin_time = can.base.Date(can.base.Time(can.Option("begin_time"), "%y-%m-%d %H:%M:%S"))
|
||||||
var begin = begin_time.getFullYear() - 5
|
var begin = begin_time.getFullYear() - 5
|
||||||
|
|
||||||
var head = ["month"]; for (var i = 0; i < 10; i++) { head.push(begin+i) }
|
var head = ["month"]; for (var i = 0; i < 10; i++) { head.push(begin+i) }
|
||||||
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
|
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
|
||||||
|
|
||||||
function key(time) { return can.base.Time(time, "%y-%m") }
|
function key(time) { return can.base.Time(time, "%y-%m") }
|
||||||
function get(begin_time, col, row, hash) { return hash[begin+col-1+"-"+can.base.Number(row, 2)] }
|
function get(begin_time, col, row, hash) { return hash[begin+col-1+"-"+can.base.Number(row, 2)] }
|
||||||
function set(begin_time, col, row) { return begin+col-1+"-"+can.base.Number(row, 2) }
|
function set(begin_time, col, row) { return begin+col-1+"-"+can.base.Number(row, 2) }
|
||||||
|
|
||||||
can.onimport._content(can, msg, head, list, key, get, set)
|
can.onimport._content(can, msg, head, list, key, get, set)
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onaction", {help: "组件交互", list: [
|
Volcanos("onaction", {help: "组件交互", list: [
|
||||||
["level", "all", "l1", "l2", "l3", "l4", "l5"],
|
["level", "all", "l1", "l2", "l3", "l4", "l5"],
|
||||||
["status", "all", "prepare", "process", "cancel", "finish"],
|
["status", "all", "prepare", "process", "cancel", "finish"],
|
||||||
["score", "all", "s1", "s2", "s3", "s4", "s5"],
|
["score", "all", "s1", "s2", "s3", "s4", "s5"],
|
||||||
["view", "", "name", "text", "level", "score"],
|
["view", "", "name", "text", "level", "score"],
|
||||||
],
|
],
|
||||||
insertTask: function(event, can, time) { var msg = can.sup.request(event, {begin_time: time})
|
insertTask: function(event, can, time) { var msg = can.sup.request(event, {begin_time: time})
|
||||||
can.user.input(event, can, can.Conf("feature.insert"), function(event, button, data, list) {
|
can.user.input(event, can, can.Conf("feature.insert"), function(event, button, data, list) {
|
||||||
can.run(event, can.base.Simple(ctx.ACTION, mdb.INSERT, data, "begin_time", time), true)
|
can.run(event, can.base.Simple(ctx.ACTION, mdb.INSERT, data, "begin_time", time), true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
modifyTask: function(event, can, task, key, value) { var msg = can.request(event, task)
|
modifyTask: function(event, can, task, key, value) { var msg = can.request(event, task)
|
||||||
can.run(event, [ctx.ACTION, mdb.MODIFY, key, value, task[key]])
|
can.run(event, [ctx.ACTION, mdb.MODIFY, key, value, task[key]])
|
||||||
},
|
},
|
||||||
|
|
||||||
_filter: function(event, can, key, value) { var count = 0
|
_filter: function(event, can, key, value) { var count = 0
|
||||||
if (value == "all") {
|
if (value == "all") {
|
||||||
can.page.Select(can, can.ui.content, "div.item", function(item) {
|
can.page.Select(can, can.ui.content, "div.item", function(item) {
|
||||||
can.page.ClassList.del(can, item, "hide"), count++
|
can.page.ClassList.del(can, item, "hide"), count++
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
can.page.Select(can, can.ui.content, "div.item", function(item) {
|
can.page.Select(can, can.ui.content, "div.item", function(item) {
|
||||||
can.page.ClassList.add(can, item, "hide")
|
can.page.ClassList.add(can, item, "hide")
|
||||||
})
|
})
|
||||||
can.page.Select(can, can.ui.content, "div."+value, function(item) {
|
can.page.Select(can, can.ui.content, "div."+value, function(item) {
|
||||||
can.page.ClassList.del(can, item, "hide"), count++
|
can.page.ClassList.del(can, item, "hide"), count++
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
can.Action(key, value), can.Status("count", count)
|
can.Action(key, value), can.Status("count", count)
|
||||||
},
|
},
|
||||||
level: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
|
level: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
|
||||||
status: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
|
status: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
|
||||||
score: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
|
score: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
|
||||||
view: function(event, can, key, value) {
|
view: function(event, can, key, value) {
|
||||||
can.Action(key, value)
|
can.Action(key, value)
|
||||||
can.onmotion.clear(can, can.ui.project)
|
can.onmotion.clear(can, can.ui.project)
|
||||||
can.onmotion.clear(can, can.ui.content)
|
can.onmotion.clear(can, can.ui.content)
|
||||||
can.onimport[can.Option("scale")](can, can._msg)
|
can.onimport[can.Option("scale")](can, can._msg)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: ["count", "begin_time", "zone", "id", "type", "name", "text"],
|
Volcanos("onexport", {help: "导出数据", list: ["count", "begin_time", "zone", "id", "type", "name", "text"],
|
||||||
name: function(can, task) { return task.name },
|
name: function(can, task) { return task.name },
|
||||||
text: function(can, task) { return task.name+": "+(task.text||"") },
|
text: function(can, task) { return task.name+": "+(task.text||"") },
|
||||||
level: function(can, task) { return "l-"+(task.level||3)+": "+(task.name||"") },
|
level: function(can, task) { return "l-"+(task.level||3)+": "+(task.name||"") },
|
||||||
score: function(can, task) { return "s-"+(task.level||3)+": "+(task.name||"") },
|
score: function(can, task) { return "s-"+(task.level||3)+": "+(task.name||"") },
|
||||||
title: function(can, task) { return task.zone+": "+(task.type||"") },
|
title: function(can, task) { return task.zone+": "+(task.type||"") },
|
||||||
style: function(can, task) { return ["item", task.status, "id"+task.id, "l"+(task.level||""), "s"+(task.score||"")].join(" ") },
|
style: function(can, task) { return ["item", task.status, "id"+task.id, "l"+(task.level||""), "s"+(task.score||"")].join(" ") },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,143 +1,143 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb) {
|
||||||
can.ui = can.onlayout.display(can)
|
can.ui = can.onlayout.display(can)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
|
|
||||||
can.table = can.onappend.table(can, msg, function(value, key, index, line) {
|
can.table = can.onappend.table(can, msg, function(value, key, index, line) {
|
||||||
return {text: [value, "td"], oncontextmenu: function(event) {
|
return {text: [value, "td"], oncontextmenu: function(event) {
|
||||||
can.user.carte(event, can, can.ondetail, can.ondetail.list, function(ev, cmd, meta) {
|
can.user.carte(event, can, can.ondetail, can.ondetail.list, function(ev, cmd, meta) {
|
||||||
var cb = meta[cmd]; cb && cb(event, can, cmd, value, key, index, line)
|
var cb = meta[cmd]; cb && cb(event, can, cmd, value, key, index, line)
|
||||||
})
|
})
|
||||||
}, ondblclick: function(event) {
|
}, ondblclick: function(event) {
|
||||||
can.page.Modify(can, event.target, {contenteditable: true})
|
can.page.Modify(can, event.target, {contenteditable: true})
|
||||||
}, onclick: function(event) {
|
}, onclick: function(event) {
|
||||||
if (key == "path") { can.run(event, [can.Option("path", value)]) }
|
if (key == "path") { can.run(event, [can.Option("path", value)]) }
|
||||||
}}
|
}}
|
||||||
}, can.ui.content)
|
}, can.ui.content)
|
||||||
|
|
||||||
can.onexport.list = msg.append
|
can.onexport.list = msg.append
|
||||||
can.onaction._compute(event, can)
|
can.onaction._compute(event, can)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onfigure", {help: "组件菜单", list: [],
|
Volcanos("onfigure", {help: "组件菜单", list: [],
|
||||||
"求和": function(event, can, res, td, index) {
|
"求和": function(event, can, res, td, index) {
|
||||||
res[index] = parseInt(td.innerText) + (res[index]||0);
|
res[index] = parseInt(td.innerText) + (res[index]||0);
|
||||||
},
|
},
|
||||||
"最大": function(event, can, res, td, index) {
|
"最大": function(event, can, res, td, index) {
|
||||||
var n = parseInt(td.innerText);
|
var n = parseInt(td.innerText);
|
||||||
n > (res[index]||-10000) && (res[index] = n);
|
n > (res[index]||-10000) && (res[index] = n);
|
||||||
},
|
},
|
||||||
"最小": function(event, can, res, td, index) {
|
"最小": function(event, can, res, td, index) {
|
||||||
var n = parseInt(td.innerText);
|
var n = parseInt(td.innerText);
|
||||||
n < (res[index]||10000) && (res[index] = n);
|
n < (res[index]||10000) && (res[index] = n);
|
||||||
},
|
},
|
||||||
"平均": function(event, can, res, td, ncol, cols, rows, nrow) {
|
"平均": function(event, can, res, td, ncol, cols, rows, nrow) {
|
||||||
res[ncol] = parseInt(td.innerText) + (res[ncol]||0);
|
res[ncol] = parseInt(td.innerText) + (res[ncol]||0);
|
||||||
if (nrow == rows.length - 1) {
|
if (nrow == rows.length - 1) {
|
||||||
res[ncol] = res[ncol] / nrow
|
res[ncol] = res[ncol] / nrow
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "全选", "块选", "反选", "多选", "拖动", "编辑"], ["some", "求和", "最大", "最小", "平均"]],
|
Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "全选", "块选", "反选", "多选", "拖动", "编辑"], ["some", "求和", "最大", "最小", "平均"]],
|
||||||
_compute: function(event, can) {
|
_compute: function(event, can) {
|
||||||
var mul = "tr" + (can.Action("mode") == "全选"? "": ".select")
|
var mul = "tr" + (can.Action("mode") == "全选"? "": ".select")
|
||||||
var method = can.onfigure[can.Action("some")], res = {}
|
var method = can.onfigure[can.Action("some")], res = {}
|
||||||
|
|
||||||
can.page.Select(can, can.ui.content, mul, function(tr, nrow, rows) {
|
can.page.Select(can, can.ui.content, mul, function(tr, nrow, rows) {
|
||||||
(mul != "tr" || nrow > 0) && can.page.Select(can, tr, "td", function(td, ncol, cols) {
|
(mul != "tr" || nrow > 0) && can.page.Select(can, tr, "td", function(td, ncol, cols) {
|
||||||
method && method(event, can, res, td, ncol, cols, rows, nrow)
|
method && method(event, can, res, td, ncol, cols, rows, nrow)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
can.core.Item(res, function(key, value) {
|
can.core.Item(res, function(key, value) {
|
||||||
can.Status(can._msg.append[key], value||"")
|
can.Status(can._msg.append[key], value||"")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
"保存": function(event, can, cmd) {
|
"保存": function(event, can, cmd) {
|
||||||
can.run(event, [ctx.ACTION, cmd, can.Option("path"), can.onexport.file(can)], function(msg) {
|
can.run(event, [ctx.ACTION, cmd, can.Option("path"), can.onexport.file(can)], function(msg) {
|
||||||
can.user.toastSuccess(can)
|
can.user.toastSuccess(can)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
some: function(event, can, cmd) {
|
some: function(event, can, cmd) {
|
||||||
can.onaction._compute(event, can)
|
can.onaction._compute(event, can)
|
||||||
},
|
},
|
||||||
|
|
||||||
"全选": function(event, can, cmd) {
|
"全选": function(event, can, cmd) {
|
||||||
cmd && can.Action("mode", cmd)
|
cmd && can.Action("mode", cmd)
|
||||||
can.page.Select(can, can.ui.content, "tr", function(item) {
|
can.page.Select(can, can.ui.content, "tr", function(item) {
|
||||||
can.page.ClassList.del(can, item, "over")
|
can.page.ClassList.del(can, item, "over")
|
||||||
can.page.ClassList.del(can, item, "select")
|
can.page.ClassList.del(can, item, "select")
|
||||||
item.setAttribute("contenteditable", false)
|
item.setAttribute("contenteditable", false)
|
||||||
item.setAttribute("draggable", false)
|
item.setAttribute("draggable", false)
|
||||||
item.onmouseenter = null
|
item.onmouseenter = null
|
||||||
item.onclick = null
|
item.onclick = null
|
||||||
})
|
})
|
||||||
can.onaction._compute(event, can)
|
can.onaction._compute(event, can)
|
||||||
},
|
},
|
||||||
"块选": function(event, can, cmd) {
|
"块选": function(event, can, cmd) {
|
||||||
cmd && can.Action("mode", cmd)
|
cmd && can.Action("mode", cmd)
|
||||||
can.page.Select(can, can.ui.content, "tr", function(item) {
|
can.page.Select(can, can.ui.content, "tr", function(item) {
|
||||||
item.onmouseenter = function() {
|
item.onmouseenter = function() {
|
||||||
can.page.ClassList.add(can, item, "select")
|
can.page.ClassList.add(can, item, "select")
|
||||||
can.onaction._compute(event, can)
|
can.onaction._compute(event, can)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"反选": function(event, can, cmd) {
|
"反选": function(event, can, cmd) {
|
||||||
cmd && can.Action("mode", cmd)
|
cmd && can.Action("mode", cmd)
|
||||||
can.page.Select(can, can.ui.content, "tr", function(item) {
|
can.page.Select(can, can.ui.content, "tr", function(item) {
|
||||||
item.onmouseenter = function() {
|
item.onmouseenter = function() {
|
||||||
can.page.ClassList.del(can, item, "select")
|
can.page.ClassList.del(can, item, "select")
|
||||||
can.onaction._compute(event, can)
|
can.onaction._compute(event, can)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"多选": function(event, can, cmd) {
|
"多选": function(event, can, cmd) {
|
||||||
cmd && can.Action("mode", cmd)
|
cmd && can.Action("mode", cmd)
|
||||||
can.page.Select(can, can.ui.content, "tr", function(item) {
|
can.page.Select(can, can.ui.content, "tr", function(item) {
|
||||||
item.onclick = function() {
|
item.onclick = function() {
|
||||||
can.page.ClassList.neg(can, item, "select")
|
can.page.ClassList.neg(can, item, "select")
|
||||||
can.onaction._compute(event, can)
|
can.onaction._compute(event, can)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"拖动": function(event, can, cmd) {
|
"拖动": function(event, can, cmd) {
|
||||||
can.onaction["全选"](event, can, cmd)
|
can.onaction["全选"](event, can, cmd)
|
||||||
can.page.Select(can, can.ui.content, "tr", function(item) {
|
can.page.Select(can, can.ui.content, "tr", function(item) {
|
||||||
item.setAttribute("draggable", true)
|
item.setAttribute("draggable", true)
|
||||||
item.ondragstart = function(event) { can.drag = item }
|
item.ondragstart = function(event) { can.drag = item }
|
||||||
item.ondragover = function(event) { event.preventDefault(), can.page.ClassList.add(can, item, "over")}
|
item.ondragover = function(event) { event.preventDefault(), can.page.ClassList.add(can, item, "over")}
|
||||||
item.ondragleave = function(event) { can.page.ClassList.del(can, item, "over") }
|
item.ondragleave = function(event) { can.page.ClassList.del(can, item, "over") }
|
||||||
item.ondrop = function(event) { event.preventDefault()
|
item.ondrop = function(event) { event.preventDefault()
|
||||||
can.page.Select(can, can.ui.content, "table", function(table) {
|
can.page.Select(can, can.ui.content, "table", function(table) {
|
||||||
table.insertBefore(can.drag, item)
|
table.insertBefore(can.drag, item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"编辑": function(event, can, cmd) {
|
"编辑": function(event, can, cmd) {
|
||||||
cmd && can.Action("mode", cmd)
|
cmd && can.Action("mode", cmd)
|
||||||
can.page.Select(can, can.ui.content, "tr", function(item) {
|
can.page.Select(can, can.ui.content, "tr", function(item) {
|
||||||
item.setAttribute("contenteditable", true)
|
item.setAttribute("contenteditable", true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("ondetail", {help: "组件详情", list: ["复制", "删除"],
|
Volcanos("ondetail", {help: "组件详情", list: ["复制", "删除"],
|
||||||
"复制": function(event, can, cmd, value, key, index, line) {
|
"复制": function(event, can, cmd, value, key, index, line) {
|
||||||
var end = can.page.Append(can, can.table, [{type: "tr", list: can.core.List(can._msg.append, function(key) {
|
var end = can.page.Append(can, can.table, [{type: "tr", list: can.core.List(can._msg.append, function(key) {
|
||||||
return {text: [line[key], "td"]}
|
return {text: [line[key], "td"]}
|
||||||
})}]).tr
|
})}]).tr
|
||||||
can.table.insertBefore(end, event.target.parentNode)
|
can.table.insertBefore(end, event.target.parentNode)
|
||||||
},
|
},
|
||||||
"删除": function(event, can, cmd) {
|
"删除": function(event, can, cmd) {
|
||||||
can.page.Remove(can, event.target.parentNode)
|
can.page.Remove(can, event.target.parentNode)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
file: function(can) {
|
file: function(can) {
|
||||||
return can.page.Select(can, can.ui.content, "tr", function(tr) {
|
return can.page.Select(can, can.ui.content, "tr", function(tr) {
|
||||||
return can.page.Select(can, tr, "th,td", function(td) {return td.innerHTML}).join(",")
|
return can.page.Select(can, tr, "th,td", function(td) {return td.innerHTML}).join(",")
|
||||||
}).join("\n")
|
}).join("\n")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,125 +1,125 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.path = can.request(), can.list = [], msg.Table(function(value) {
|
can.path = can.request(), can.list = [], msg.Table(function(value) {
|
||||||
value.path.lastIndexOf(ice.PS)==value.path.length-1? can.path.Push(value): can.list.push(value)
|
value.path.lastIndexOf(ice.PS)==value.path.length-1? can.path.Push(value): can.list.push(value)
|
||||||
})
|
})
|
||||||
|
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
can.ui = can.onlayout.display(can, target)
|
can.ui = can.onlayout.display(can, target)
|
||||||
can.onappend.table(can, can.path, null, can.ui.content)
|
can.onappend.table(can, can.path, null, can.ui.content)
|
||||||
can.dir_root = msg.Option("dir_root")
|
can.dir_root = msg.Option("dir_root")
|
||||||
|
|
||||||
can.Action("height", msg.Option("height")||"100")
|
can.Action("height", msg.Option("height")||"100")
|
||||||
can.Action("limit", msg.Option("limit")||"6")
|
can.Action("limit", msg.Option("limit")||"6")
|
||||||
can.Action("rate", msg.Option("rate")||"1")
|
can.Action("rate", msg.Option("rate")||"1")
|
||||||
can.onmotion.hidden(can, can._action)
|
can.onmotion.hidden(can, can._action)
|
||||||
|
|
||||||
can.begin = msg.Option("begin")||"0"
|
can.begin = msg.Option("begin")||"0"
|
||||||
can.onimport.page(can, can.list)
|
can.onimport.page(can, can.list)
|
||||||
},
|
},
|
||||||
_file: function(can, path, index) { var p = location.href.indexOf("http") == 0? "": "http://localhost:9020"
|
_file: function(can, path, index) { var p = location.href.indexOf("http") == 0? "": "http://localhost:9020"
|
||||||
return path.indexOf("http") == 0? path: p+can.base.Path("/share/local", can.dir_root||"", path)
|
return path.indexOf("http") == 0? path: p+can.base.Path("/share/local", can.dir_root||"", path)
|
||||||
},
|
},
|
||||||
file: function(can, path, index) { path = can.onimport._file(can, path, index)
|
file: function(can, path, index) { path = can.onimport._file(can, path, index)
|
||||||
var cb = can.onfigure[can.base.Ext(path)]; can.Status("file", path)
|
var cb = can.onfigure[can.base.Ext(path)]; can.Status("file", path)
|
||||||
can.base.isFunc(cb) && can.page.Append(can, can.ui.display, [cb(can, path, index)])
|
can.base.isFunc(cb) && can.page.Append(can, can.ui.display, [cb(can, path, index)])
|
||||||
},
|
},
|
||||||
page: function(can, list, begin, limit) { can.onmotion.clear(can, can.ui.display)
|
page: function(can, list, begin, limit) { can.onmotion.clear(can, can.ui.display)
|
||||||
begin = parseInt(begin||can.begin), limit = parseInt(limit||can.Action("limit"))
|
begin = parseInt(begin||can.begin), limit = parseInt(limit||can.Action("limit"))
|
||||||
for (var i = begin; i < begin+limit; i++) { list && list[i] && can.onimport.file(can, list[i].path, i) }
|
for (var i = begin; i < begin+limit; i++) { list && list[i] && can.onimport.file(can, list[i].path, i) }
|
||||||
can.Status({begin: begin, limit: limit, total: can.list.length})
|
can.Status({begin: begin, limit: limit, total: can.list.length})
|
||||||
},
|
},
|
||||||
}, ["/plugin/local/wiki/feel.css"])
|
}, ["/plugin/local/wiki/feel.css"])
|
||||||
Volcanos("onfigure", {help: "组件菜单", list: [],
|
Volcanos("onfigure", {help: "组件菜单", list: [],
|
||||||
png: function(can, path, index) { return can.onfigure.image(can, path, index) },
|
png: function(can, path, index) { return can.onfigure.image(can, path, index) },
|
||||||
jpg: function(can, path, index) { return can.onfigure.image(can, path, index) },
|
jpg: function(can, path, index) { return can.onfigure.image(can, path, index) },
|
||||||
jpeg: function(can, path, index) { return can.onfigure.image(can, path, index) },
|
jpeg: function(can, path, index) { return can.onfigure.image(can, path, index) },
|
||||||
image: function(can, path, index) { return {img: path, height: can.Action("height"), onclick: function(event) {
|
image: function(can, path, index) { return {img: path, height: can.Action("height"), onclick: function(event) {
|
||||||
can.ondetail._init(can, index)
|
can.ondetail._init(can, index)
|
||||||
}, _init: function(target) { can.Status("file", path) },
|
}, _init: function(target) { can.Status("file", path) },
|
||||||
onmouseover: function(event) { can.Status("file", path) },
|
onmouseover: function(event) { can.Status("file", path) },
|
||||||
} },
|
} },
|
||||||
|
|
||||||
video: function(can, path) { var auto = can.user.isMobile&&can.Action("limit")!="1"? false: true, loop = true, total = 0; function cb(event) { }
|
video: function(can, path) { var auto = can.user.isMobile&&can.Action("limit")!="1"? false: true, loop = true, total = 0; function cb(event) { }
|
||||||
return {type: "video", style: {height: parseInt(can.Action("height"))}, className: "preview",
|
return {type: "video", style: {height: parseInt(can.Action("height"))}, className: "preview",
|
||||||
data: {src: path, controls: "controls", autoplay: auto, loop: loop, playbackRate: parseFloat(can.Action("rate"))},
|
data: {src: path, controls: "controls", autoplay: auto, loop: loop, playbackRate: parseFloat(can.Action("rate"))},
|
||||||
oncontextmenu: cb, onplay: cb, onpause: cb, onended: cb,
|
oncontextmenu: cb, onplay: cb, onpause: cb, onended: cb,
|
||||||
onmouseover: function(event) { can.Status("file", path) },
|
onmouseover: function(event) { can.Status("file", path) },
|
||||||
onloadedmetadata: function(event) { total = event.timeStamp
|
onloadedmetadata: function(event) { total = event.timeStamp
|
||||||
event.target.currentTime = can._msg.currentTime || 0
|
event.target.currentTime = can._msg.currentTime || 0
|
||||||
}, onloadeddata: cb, ontimeupdate: function(event) {
|
}, onloadeddata: cb, ontimeupdate: function(event) {
|
||||||
can.Status("file") == path && can.Status("position", can.onexport.position(can, (can._msg.currentTime=event.target.currentTime)-1, event.target.duration))
|
can.Status("file") == path && can.Status("position", can.onexport.position(can, (can._msg.currentTime=event.target.currentTime)-1, event.target.duration))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mp4: function(can, path) { return can.onfigure.video(can, path) },
|
mp4: function(can, path) { return can.onfigure.video(can, path) },
|
||||||
m4v: function(can, path) { return can.onfigure.video(can, path) },
|
m4v: function(can, path) { return can.onfigure.video(can, path) },
|
||||||
mov: function(can, path) { return can.onfigure.video(can, path) },
|
mov: function(can, path) { return can.onfigure.video(can, path) },
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "组件菜单", list: [
|
Volcanos("onaction", {help: "组件菜单", list: [
|
||||||
["height", 100, 200, 400, 600, 800],
|
["height", 100, 200, 400, 600, 800],
|
||||||
["limit", 1, 3, 6, 9, 12, 15, 20, 30],
|
["limit", 1, 3, 6, 9, 12, 15, 20, 30],
|
||||||
["rate", 0.1, 0.2, 0.5, 1, 2, 3, 5, 10],
|
["rate", 0.1, 0.2, 0.5, 1, 2, 3, 5, 10],
|
||||||
],
|
],
|
||||||
"上一页": function(event, can, key, value) {
|
"上一页": function(event, can, key, value) {
|
||||||
can.begin > 0 && (can.begin -= parseInt(can.Action("limit")), can.onimport.page(can, can.list))
|
can.begin > 0 && (can.begin -= parseInt(can.Action("limit")), can.onimport.page(can, can.list))
|
||||||
},
|
},
|
||||||
"下一页": function(event, can, key, value) {
|
"下一页": function(event, can, key, value) {
|
||||||
can.begin + parseInt(can.Action("limit")) < can.list.length && (can.begin += parseInt(can.Action("limit")), can.onimport.page(can, can.list))
|
can.begin + parseInt(can.Action("limit")) < can.list.length && (can.begin += parseInt(can.Action("limit")), can.onimport.page(can, can.list))
|
||||||
},
|
},
|
||||||
|
|
||||||
"height": function(event, can, key, value) {
|
"height": function(event, can, key, value) {
|
||||||
can.Action("height", value), can.onimport.page(can, can.list)
|
can.Action("height", value), can.onimport.page(can, can.list)
|
||||||
},
|
},
|
||||||
"limit": function(event, can, key, value) {
|
"limit": function(event, can, key, value) {
|
||||||
can.Action("limit", value), can.onimport.page(can, can.list)
|
can.Action("limit", value), can.onimport.page(can, can.list)
|
||||||
},
|
},
|
||||||
"rate": function(event, can, key, value) {
|
"rate": function(event, can, key, value) {
|
||||||
can.Action("rate", value), can.onimport.page(can, can.list)
|
can.Action("rate", value), can.onimport.page(can, can.list)
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseImage: function(event, can) { var msg = can.request(event)
|
chooseImage: function(event, can) { var msg = can.request(event)
|
||||||
can.user.agent.chooseImage(function(list) { can.core.List(list, function(item) {
|
can.user.agent.chooseImage(function(list) { can.core.List(list, function(item) {
|
||||||
can.page.Append(can, can._output, [{img: item, height: 200}])
|
can.page.Append(can, can._output, [{img: item, height: 200}])
|
||||||
}) })
|
}) })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("ondetail", {help: "组件菜单", list: ["关闭", "下载", "删除", "上一个", "下一个", "设置头像", "设置背景", "复制链接"], _init: function(can, index) {
|
Volcanos("ondetail", {help: "组件菜单", list: ["关闭", "下载", "删除", "上一个", "下一个", "设置头像", "设置背景", "复制链接"], _init: function(can, index) {
|
||||||
can.onappend._init(can, {type: "story feel float"}, [], function(sub) { can.sub = sub
|
can.onappend._init(can, {type: "story feel float"}, [], function(sub) { can.sub = sub
|
||||||
sub.run = function(event, cmds, cb) { return can.run(event, cmds, cb, true) }
|
sub.run = function(event, cmds, cb) { return can.run(event, cmds, cb, true) }
|
||||||
|
|
||||||
sub.search({}, ["Action.onexport.size"], function(msg, left, top, width, height) {
|
sub.search({}, ["Action.onexport.size"], function(msg, left, top, width, height) {
|
||||||
sub.page.Modify(sub, sub._target, {style: {left: left, top: top}})
|
sub.page.Modify(sub, sub._target, {style: {left: left, top: top}})
|
||||||
sub.page.Modify(sub, sub._output, {style: {"max-width": width, "max-height": height}})
|
sub.page.Modify(sub, sub._output, {style: {"max-width": width, "max-height": height}})
|
||||||
sub.onappend._action(can, can.ondetail.list, sub._action, can.ondetail)
|
sub.onappend._action(can, can.ondetail.list, sub._action, can.ondetail)
|
||||||
|
|
||||||
can.order = index, can.show = function(order) {
|
can.order = index, can.show = function(order) {
|
||||||
path = can.onimport._file(can, can.list[order].path)
|
path = can.onimport._file(can, can.list[order].path)
|
||||||
sub.page.Appends(sub, sub._output, [{img: path, style: {"max-width": width-40, "max-height": height-55}}])
|
sub.page.Appends(sub, sub._output, [{img: path, style: {"max-width": width-40, "max-height": height-55}}])
|
||||||
sub.Status("begin", order+1+ice.PS+can.list.length), sub.Status("file", path)
|
sub.Status("begin", order+1+ice.PS+can.list.length), sub.Status("file", path)
|
||||||
}, can.show(can.order)
|
}, can.show(can.order)
|
||||||
})
|
})
|
||||||
}, document.body)
|
}, document.body)
|
||||||
},
|
},
|
||||||
"关闭": function(event, can) { can.page.Remove(can, can.sub._target) },
|
"关闭": function(event, can) { can.page.Remove(can, can.sub._target) },
|
||||||
"下载": function(event, can) { can.user.download(can, path = can.onimport._file(can, can.list[can.order].path)) },
|
"下载": function(event, can) { can.user.download(can, path = can.onimport._file(can, can.list[can.order].path)) },
|
||||||
"删除": function(event, can) {
|
"删除": function(event, can) {
|
||||||
can.run(event, [ctx.ACTION, mdb.REMOVE, can.Status("file")], function(msg) { can.user.toast(can, "删除成功") }, true)
|
can.run(event, [ctx.ACTION, mdb.REMOVE, can.Status("file")], function(msg) { can.user.toast(can, "删除成功") }, true)
|
||||||
},
|
},
|
||||||
"上一个": function(event, can) { can.order > 0? can.show(--can.order): can.user.toast(can, "已经是第一张啦!") },
|
"上一个": function(event, can) { can.order > 0? can.show(--can.order): can.user.toast(can, "已经是第一张啦!") },
|
||||||
"下一个": function(event, can) { can.order < can.list.length-1? can.show(++can.order): can.user.toast(can, "已经是最后一张啦!") },
|
"下一个": function(event, can) { can.order < can.list.length-1? can.show(++can.order): can.user.toast(can, "已经是最后一张啦!") },
|
||||||
"设置头像": function(event, can) { var msg = can.request(event, {url: can.onimport._file(can, can.list[can.order].path)})
|
"设置头像": function(event, can) { var msg = can.request(event, {url: can.onimport._file(can, can.list[can.order].path)})
|
||||||
can.search(event, ["Header.onimport.avatar"], null, true)
|
can.search(event, ["Header.onimport.avatar"], null, true)
|
||||||
},
|
},
|
||||||
"设置背景": function(event, can) { var msg = can.request(event, {url: can.onimport._file(can, can.list[can.order].path)})
|
"设置背景": function(event, can) { var msg = can.request(event, {url: can.onimport._file(can, can.list[can.order].path)})
|
||||||
can.search(event, ["Header.onimport.background"], null, true)
|
can.search(event, ["Header.onimport.background"], null, true)
|
||||||
},
|
},
|
||||||
"复制链接": function(event, can) {
|
"复制链接": function(event, can) {
|
||||||
can.user.copy(event, can, can.misc.MergeURL(can, {_path: can.onimport._file(can, can.list[can.order].path)}, true))
|
can.user.copy(event, can, can.misc.MergeURL(can, {_path: can.onimport._file(can, can.list[can.order].path)}, true))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: ["begin", "limit", "total", "position", "file"],
|
Volcanos("onexport", {help: "导出数据", list: ["begin", "limit", "total", "position", "file"],
|
||||||
position: function(can, index, total) { total = total || can.max
|
position: function(can, index, total) { total = total || can.max
|
||||||
return parseInt((index+1)*100/total)+"%"+" = "+(parseInt(index)+1)+ice.PS+parseInt(total)
|
return parseInt((index+1)*100/total)+"%"+" = "+(parseInt(index)+1)+ice.PS+parseInt(total)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,189 +1,189 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, cb, target) {
|
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
if (msg.Length() > 0) { return can.onappend.table(can, msg) }
|
if (msg.Length() > 0) { return can.onappend.table(can, msg) }
|
||||||
|
|
||||||
can.page.Modify(can, target, msg.Result())
|
can.page.Modify(can, target, msg.Result())
|
||||||
can.page.Select(can, target, wiki.ITEM, function(item) { var data = item.dataset||{}
|
can.page.Select(can, target, wiki.ITEM, function(item) { var data = item.dataset||{}
|
||||||
can.core.CallFunc([can.onimport, data.type], [can, data, item])
|
can.core.CallFunc([can.onimport, data.type], [can, data, item])
|
||||||
can.page.Modify(can, item, {style: can.base.Obj(data.style)})
|
can.page.Modify(can, item, {style: can.base.Obj(data.style)})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
navmenu: function(can, data, target) { var nav = can.sup._navmenu
|
navmenu: function(can, data, target) { var nav = can.sup._navmenu
|
||||||
nav = nav||can.page.Append(can, can._fields, [{view: wiki.NAVMENU}]).first
|
nav = nav||can.page.Append(can, can._fields, [{view: wiki.NAVMENU}]).first
|
||||||
can.onmotion.clear(can, nav), can._fields.insertBefore(nav, can._output)
|
can.onmotion.clear(can, nav), can._fields.insertBefore(nav, can._output)
|
||||||
|
|
||||||
can.onappend.list(can, can.base.Obj(data.data), function(event, item) {
|
can.onappend.list(can, can.base.Obj(data.data), function(event, item) {
|
||||||
var link = item.meta.link, list = can.core.Split(item.meta.link)
|
var link = item.meta.link, list = can.core.Split(item.meta.link)
|
||||||
if (can.core.Value(can, list[0])) { return can.core.CallFunc([can, list[0]], list.slice(1)) }
|
if (can.core.Value(can, list[0])) { return can.core.CallFunc([can, list[0]], list.slice(1)) }
|
||||||
if (!link || link == can.Option(nfs.PATH)) { return false }
|
if (!link || link == can.Option(nfs.PATH)) { return false }
|
||||||
|
|
||||||
if (can.onmotion.cache(can, function() { can.user.mod.isCmd && can.user.title(item.meta.name); return can.Option(nfs.PATH, link) })) { return }
|
if (can.onmotion.cache(can, function() { can.user.mod.isCmd && can.user.title(item.meta.name); return can.Option(nfs.PATH, link) })) { return }
|
||||||
return can.sup.Update(event, [link])
|
return can.sup.Update(event, [link])
|
||||||
}, nav), can.sup._navmenu = nav
|
}, nav), can.sup._navmenu = nav
|
||||||
|
|
||||||
can.getActionSize(function(msg) {
|
can.getActionSize(function(msg) {
|
||||||
can.page.style(can, nav, html.HEIGHT, can.Conf(html.HEIGHT)+(can.user.mod.isCmd? msg.Option(html.MARGIN_Y): 0))
|
can.page.style(can, nav, html.HEIGHT, can.Conf(html.HEIGHT)+(can.user.mod.isCmd? msg.Option(html.MARGIN_Y): 0))
|
||||||
can.Conf(html.WIDTH, can.Conf(html.WIDTH)-nav.offsetWidth-(can.user.mod.isCmd? 10: 20))
|
can.Conf(html.WIDTH, can.Conf(html.WIDTH)-nav.offsetWidth-(can.user.mod.isCmd? 10: 20))
|
||||||
can.page.Modify(can, can._output, {style: kit.Dict(
|
can.page.Modify(can, can._output, {style: kit.Dict(
|
||||||
html.HEIGHT, can.sup._navmenu.offsetHeight, html.MAX_WIDTH, can.Conf(html.WIDTH),
|
html.HEIGHT, can.sup._navmenu.offsetHeight, html.MAX_WIDTH, can.Conf(html.WIDTH),
|
||||||
html.FLOAT, html.LEFT, html.CLEAR, html.NONE
|
html.FLOAT, html.LEFT, html.CLEAR, html.NONE
|
||||||
)})
|
)})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
premenu: function(can, data, target) {
|
premenu: function(can, data, target) {
|
||||||
can.page.Select(can, can._output, can.page.Keys(wiki.H2, wiki.H3), function(item) {
|
can.page.Select(can, can._output, can.page.Keys(wiki.H2, wiki.H3), function(item) {
|
||||||
can.page.Append(can, target, [{text: [item.innerHTML, html.LI, item.tagName], onclick: function() {
|
can.page.Append(can, target, [{text: [item.innerHTML, html.LI, item.tagName], onclick: function() {
|
||||||
item.scrollIntoView()
|
item.scrollIntoView()
|
||||||
}}]), item.onclick = function(event) { target.scrollIntoView() }
|
}}]), item.onclick = function(event) { target.scrollIntoView() }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
title: function(can, data, target) {
|
title: function(can, data, target) {
|
||||||
can.user.mod.isCmd && target.tagName == "H1" && can.user.title(data.text)
|
can.user.mod.isCmd && target.tagName == "H1" && can.user.title(data.text)
|
||||||
},
|
},
|
||||||
spark: function(can, data, target) {
|
spark: function(can, data, target) {
|
||||||
if (data[mdb.NAME] == html.INNER) { return can.onmotion.copy(can, target) }
|
if (data[mdb.NAME] == html.INNER) { return can.onmotion.copy(can, target) }
|
||||||
can.page.Select(can, target, html.A, function(item) { can.onmotion.link(can, item) })
|
can.page.Select(can, target, html.A, function(item) { can.onmotion.link(can, item) })
|
||||||
can.page.Select(can, target, html.SPAN, function(item) { can.onmotion.copy(can, item) })
|
can.page.Select(can, target, html.SPAN, function(item) { can.onmotion.copy(can, item) })
|
||||||
},
|
},
|
||||||
chart: function(can, data, target) {
|
chart: function(can, data, target) {
|
||||||
target.oncontextmenu = function(event) {
|
target.oncontextmenu = function(event) {
|
||||||
can.user.carteClient(event, can, kit.Dict(mdb.EXPORT, function(event, can, button) {
|
can.user.carteClient(event, can, kit.Dict(mdb.EXPORT, function(event, can, button) {
|
||||||
can.user.toPNG(can, can.user.prompt("please input file name", "hi")+".png", target.outerHTML,
|
can.user.toPNG(can, can.user.prompt("please input file name", "hi")+".png", target.outerHTML,
|
||||||
parseInt(target.getAttribute(html.HEIGHT))||200, parseInt(target.getAttribute(html.WIDTH))||200)
|
parseInt(target.getAttribute(html.HEIGHT))||200, parseInt(target.getAttribute(html.WIDTH))||200)
|
||||||
}), [mdb.EXPORT])
|
}), [mdb.EXPORT])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
table: function(can, data, target) {
|
table: function(can, data, target) {
|
||||||
can.page.OrderTable(can, target), can.page.ClassList.add(can, target, chat.CONTENT)
|
can.page.OrderTable(can, target), can.page.ClassList.add(can, target, chat.CONTENT)
|
||||||
can.page.Select(can, target, html.TD, function(item) { can.onmotion.copy(can, item) })
|
can.page.Select(can, target, html.TD, function(item) { can.onmotion.copy(can, item) })
|
||||||
},
|
},
|
||||||
field: function(can, data, target, width) { var item = can.base.Obj(data.meta)
|
field: function(can, data, target, width) { var item = can.base.Obj(data.meta)
|
||||||
can.onappend._init(can, item, [chat.PLUGIN_STATE_JS], function(sub) {
|
can.onappend._init(can, item, [chat.PLUGIN_STATE_JS], function(sub) {
|
||||||
sub.run = function(event, cmds, cb, silent) {
|
sub.run = function(event, cmds, cb, silent) {
|
||||||
can.run(event, can.misc.concat(can, [ctx.ACTION, chat.STORY, data.type, data.name, data.text], cmds), cb, true)
|
can.run(event, can.misc.concat(can, [ctx.ACTION, chat.STORY, data.type, data.name, data.text], cmds), cb, true)
|
||||||
}
|
}
|
||||||
sub.Conf(html.HEIGHT, can.Conf(html.HEIGHT))
|
sub.Conf(html.HEIGHT, can.Conf(html.HEIGHT))
|
||||||
sub.Conf(html.WIDTH, item.width = (width||can.Conf(html.WIDTH))-20)
|
sub.Conf(html.WIDTH, item.width = (width||can.Conf(html.WIDTH))-20)
|
||||||
|
|
||||||
can.core.Value(item, "auto.cmd") && can.core.Timer300ms(function() {
|
can.core.Value(item, "auto.cmd") && can.core.Timer300ms(function() {
|
||||||
var msg = sub.request({}, can.core.Value(item, "opts")); msg.Option(ice.MSG_HANDLE, ice.TRUE)
|
var msg = sub.request({}, can.core.Value(item, "opts")); msg.Option(ice.MSG_HANDLE, ice.TRUE)
|
||||||
sub.Update(msg._event, [ctx.ACTION, can.core.Value(item, "auto.cmd")])
|
sub.Update(msg._event, [ctx.ACTION, can.core.Value(item, "auto.cmd")])
|
||||||
})
|
})
|
||||||
}, can._output, target)
|
}, can._output, target)
|
||||||
},
|
},
|
||||||
iframe: function(can, data, target) { var meta = can.base.Obj(data.meta)
|
iframe: function(can, data, target) { var meta = can.base.Obj(data.meta)
|
||||||
can.page.Modify(can, target, {width: can.Conf(html.WIDTH)-200})
|
can.page.Modify(can, target, {width: can.Conf(html.WIDTH)-200})
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onkeymap", {help: "键盘交互", list: [],
|
Volcanos("onkeymap", {help: "键盘交互", list: [],
|
||||||
_mode: {
|
_mode: {
|
||||||
normal: {
|
normal: {
|
||||||
"n": function(event, can) { can.ondetail.next(can.sub) },
|
"n": function(event, can) { can.ondetail.next(can.sub) },
|
||||||
"j": function(event, can) { can.ondetail.next(can.sub) },
|
"j": function(event, can) { can.ondetail.next(can.sub) },
|
||||||
"ArrowRight": function(event, can) { can.ondetail.next(can.sub) },
|
"ArrowRight": function(event, can) { can.ondetail.next(can.sub) },
|
||||||
"ArrowLeft": function(event, can) { can.ondetail.prev(can.sub) },
|
"ArrowLeft": function(event, can) { can.ondetail.prev(can.sub) },
|
||||||
"k": function(event, can) { can.ondetail.prev(can.sub) },
|
"k": function(event, can) { can.ondetail.prev(can.sub) },
|
||||||
"p": function(event, can) { can.ondetail.prev(can.sub) },
|
"p": function(event, can) { can.ondetail.prev(can.sub) },
|
||||||
|
|
||||||
"q": function(event, can) { can.ondetail["结束"](event, can.sub) },
|
"q": function(event, can) { can.ondetail["结束"](event, can.sub) },
|
||||||
"h": function(event, can) { can.ondetail["隐藏"](event, can.sub) },
|
"h": function(event, can) { can.ondetail["隐藏"](event, can.sub) },
|
||||||
},
|
},
|
||||||
}, _engine: {},
|
}, _engine: {},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "控件交互", list: [],
|
Volcanos("onaction", {help: "控件交互", list: [],
|
||||||
play: function(event, can) { var list = [], current = []
|
play: function(event, can) { var list = [], current = []
|
||||||
can.page.Select(can, can._output, wiki.ITEM, function(item) {
|
can.page.Select(can, can._output, wiki.ITEM, function(item) {
|
||||||
switch (item.tagName) {
|
switch (item.tagName) {
|
||||||
case "H1":
|
case "H1":
|
||||||
case "H2":
|
case "H2":
|
||||||
case "H3":
|
case "H3":
|
||||||
list.push(current = [])
|
list.push(current = [])
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
current.push(item)
|
current.push(item)
|
||||||
})
|
})
|
||||||
|
|
||||||
can.onappend._init(can, {type: "story word float"}, [], function(sub) {
|
can.onappend._init(can, {type: "story word float"}, [], function(sub) {
|
||||||
sub.run = can.run, sub.sup = can, can.sub = sub, can.onappend._action(sub, [
|
sub.run = can.run, sub.sup = can, can.sub = sub, can.onappend._action(sub, [
|
||||||
["布局", "开讲", "快闪", "网格"], "大纲", "首页", "上一页",
|
["布局", "开讲", "快闪", "网格"], "大纲", "首页", "上一页",
|
||||||
["菜单"].concat(can.core.List(list, function(page) { return page[0].innerHTML })),
|
["菜单"].concat(can.core.List(list, function(page) { return page[0].innerHTML })),
|
||||||
"下一页", "隐藏", "结束",
|
"下一页", "隐藏", "结束",
|
||||||
], sub._action, can.ondetail)
|
], sub._action, can.ondetail)
|
||||||
|
|
||||||
can.onengine.signal(can, "keymap.focus", can.request(event, {cb: function(event) {
|
can.onengine.signal(can, "keymap.focus", can.request(event, {cb: function(event) {
|
||||||
can.keylist = can.onkeymap._parse(event, can, "normal", can.keylist)
|
can.keylist = can.onkeymap._parse(event, can, "normal", can.keylist)
|
||||||
}})), can.onkeymap._build(can)
|
}})), can.onkeymap._build(can)
|
||||||
|
|
||||||
sub.page.style(sub, sub._target, html.BACKGROUND, document.body.style.background)
|
sub.page.style(sub, sub._target, html.BACKGROUND, document.body.style.background)
|
||||||
sub.page.style(sub, sub._output, html.HEIGHT, window.innerHeight-4*html.PLUGIN_MARGIN-2*html.ACTION_HEIGHT)
|
sub.page.style(sub, sub._output, html.HEIGHT, window.innerHeight-4*html.PLUGIN_MARGIN-2*html.ACTION_HEIGHT)
|
||||||
sub.page.style(sub, sub._output, html.WIDTH, window.innerWidth-4*html.PLUGIN_MARGIN)
|
sub.page.style(sub, sub._output, html.WIDTH, window.innerWidth-4*html.PLUGIN_MARGIN)
|
||||||
|
|
||||||
sub.ui = sub.page.Append(sub, sub._output, [{view: chat.PROJECT}, {view: chat.CONTENT}])
|
sub.ui = sub.page.Append(sub, sub._output, [{view: chat.PROJECT}, {view: chat.CONTENT}])
|
||||||
can.core.List(sub.list = list, function(page, index) {
|
can.core.List(sub.list = list, function(page, index) {
|
||||||
can.onappend.item(can, html.ITEM, {name: page[0].innerHTML}, function(event) {
|
can.onappend.item(can, html.ITEM, {name: page[0].innerHTML}, function(event) {
|
||||||
can.ondetail.show(sub, index)
|
can.ondetail.show(sub, index)
|
||||||
}, function(event) {}, sub.ui.project)
|
}, function(event) {}, sub.ui.project)
|
||||||
|
|
||||||
sub.page.Append(sub, sub.ui.content, [{view: "page"+(index==0? " first": ""), list: can.core.List(page, function(item) { var data = item.dataset||{}
|
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) {
|
switch (data.type) {
|
||||||
case wiki.PREMENU: item = item.cloneNode(false); break
|
case wiki.PREMENU: item = item.cloneNode(false); break
|
||||||
case chat.FIELD: item = can.onappend.field(can, chat.STORY, can.base.Obj(data.meta), sub.ui.content).first; break
|
case chat.FIELD: item = can.onappend.field(can, chat.STORY, can.base.Obj(data.meta), sub.ui.content).first; break
|
||||||
default: item = item.cloneNode(true)
|
default: item = item.cloneNode(true)
|
||||||
}
|
}
|
||||||
return can.core.CallFunc([can.onimport, data.type], [sub, data, item, window.innerWidth-4*html.PLUGIN_MARGIN]), item
|
return can.core.CallFunc([can.onimport, data.type], [sub, data, item, window.innerWidth-4*html.PLUGIN_MARGIN]), item
|
||||||
}), }])
|
}), }])
|
||||||
}), can.onmotion.hidden(can, sub.ui.project), can.ondetail.show(sub, 0)
|
}), can.onmotion.hidden(can, sub.ui.project), can.ondetail.show(sub, 0)
|
||||||
|
|
||||||
sub.onappend._status(sub, [mdb.PAGE, cli.FROM, cli.COST]), sub.Status(cli.FROM, can.base.Time())
|
sub.onappend._status(sub, [mdb.PAGE, cli.FROM, cli.COST]), sub.Status(cli.FROM, can.base.Time())
|
||||||
var from = new Date(); can.core.Timer({interval: 100}, function() { var now = new Date()
|
var from = new Date(); can.core.Timer({interval: 100}, function() { var now = new Date()
|
||||||
sub.Status(cli.COST, can.base.Duration(now-from))
|
sub.Status(cli.COST, can.base.Duration(now-from))
|
||||||
})
|
})
|
||||||
}, document.body)
|
}, document.body)
|
||||||
},
|
},
|
||||||
|
|
||||||
})
|
})
|
||||||
Volcanos("ondetail", {help: "交互操作", list: ["删除"], _init: function(can, msg, list, cb, target) {
|
Volcanos("ondetail", {help: "交互操作", list: ["删除"], _init: function(can, msg, list, cb, target) {
|
||||||
},
|
},
|
||||||
show: function(sub, which) { sub.page.Modify(sub, sub.ui.content, {className: chat.CONTENT})
|
show: function(sub, which) { sub.page.Modify(sub, sub.ui.content, {className: chat.CONTENT})
|
||||||
sub.page.Select(sub, sub.ui.content, wiki.DIV_PAGE, function(page, index) {
|
sub.page.Select(sub, sub.ui.content, wiki.DIV_PAGE, function(page, index) {
|
||||||
if (index == which || page == which) {
|
if (index == which || page == which) {
|
||||||
sub.page.Select(sub, page, sub.page.Keys(html.H1, html.H2, html.H3), function(item) { sub.Action("菜单", item.innerHTML) })
|
sub.page.Select(sub, page, sub.page.Keys(html.H1, html.H2, html.H3), function(item) { sub.Action("菜单", item.innerHTML) })
|
||||||
sub.onmotion.select(sub, sub.ui.project, html.DIV_ITEM, index)
|
sub.onmotion.select(sub, sub.ui.project, html.DIV_ITEM, index)
|
||||||
sub.Status(mdb.PAGE, index+1+ice.PS+sub.list.length)
|
sub.Status(mdb.PAGE, index+1+ice.PS+sub.list.length)
|
||||||
sub.page.ClassList.add(sub, page, html.SHOW)
|
sub.page.ClassList.add(sub, page, html.SHOW)
|
||||||
} else {
|
} else {
|
||||||
sub.page.ClassList.del(sub, page, html.SHOW)
|
sub.page.ClassList.del(sub, page, html.SHOW)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
next: function(sub) {
|
next: function(sub) {
|
||||||
sub.page.Select(sub, sub.ui.content, sub.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
sub.page.Select(sub, sub.ui.content, sub.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
||||||
page.nextSibling? sub.sup.ondetail.show(sub, page.nextSibling): sub.user.toast(sub, cli.END)
|
page.nextSibling? sub.sup.ondetail.show(sub, page.nextSibling): sub.user.toast(sub, cli.END)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
prev: function(sub) {
|
prev: function(sub) {
|
||||||
sub.page.Select(sub, sub.ui.content, sub.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
sub.page.Select(sub, sub.ui.content, sub.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
||||||
page.previousSibling? sub.sup.ondetail.show(sub, page.previousSibling): sub.user.toast(sub, cli.END)
|
page.previousSibling? sub.sup.ondetail.show(sub, page.previousSibling): sub.user.toast(sub, cli.END)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
flash: function(sub) {
|
flash: function(sub) {
|
||||||
sub.core.Next(sub.page.Select(sub, sub.ui.content, wiki.DIV_PAGE), function(page, next) {
|
sub.core.Next(sub.page.Select(sub, sub.ui.content, wiki.DIV_PAGE), function(page, next) {
|
||||||
sub.sup.ondetail.show(sub, page), sub.core.Timer(500, function() { next() })
|
sub.sup.ondetail.show(sub, page), sub.core.Timer(500, function() { next() })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
grid: function(sub) { sub.page.Modify(sub, sub.ui.content, {className: "content grid"}) },
|
grid: function(sub) { sub.page.Modify(sub, sub.ui.content, {className: "content grid"}) },
|
||||||
|
|
||||||
"开讲": function(event, can) { can.sup.ondetail.show(can, 0) },
|
"开讲": function(event, can) { can.sup.ondetail.show(can, 0) },
|
||||||
"快闪": function(event, can) { can.sup.ondetail.flash(can) },
|
"快闪": function(event, can) { can.sup.ondetail.flash(can) },
|
||||||
"网格": function(event, can) { can.sup.ondetail.grid(can) },
|
"网格": function(event, can) { can.sup.ondetail.grid(can) },
|
||||||
|
|
||||||
"大纲": function(event, can) { can.onmotion.toggle(can, can.ui.project) },
|
"大纲": function(event, can) { can.onmotion.toggle(can, can.ui.project) },
|
||||||
"首页": function(event, can) { can.sup.ondetail.show(can, 0) },
|
"首页": function(event, can) { can.sup.ondetail.show(can, 0) },
|
||||||
"上一页": function(event, can) { can.sup.ondetail.prev(can, can.ui.content) },
|
"上一页": function(event, can) { can.sup.ondetail.prev(can, can.ui.content) },
|
||||||
"菜单": function(event, can) { can.sup.ondetail.show(can, event.target.selectedIndex) },
|
"菜单": function(event, can) { can.sup.ondetail.show(can, event.target.selectedIndex) },
|
||||||
"下一页": function(event, can) { can.sup.ondetail.next(can, can.ui.content) },
|
"下一页": function(event, can) { can.sup.ondetail.next(can, can.ui.content) },
|
||||||
"隐藏": function(event, can) { can.onmotion.toggle(can, can._output) },
|
"隐藏": function(event, can) { can.onmotion.toggle(can, can._output) },
|
||||||
"结束": function(event, can) { can.page.Remove(can, can._target) },
|
"结束": function(event, can) { can.page.Remove(can, can._target) },
|
||||||
"删除": function(event, sub) { sub.page.Remove(sub, sub._target) },
|
"删除": function(event, sub) { sub.page.Remove(sub, sub._target) },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
418
plugin/state.js
418
plugin/state.js
@ -1,227 +1,227 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, list, cb, target) {},
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, list, cb, target) {},
|
||||||
_process: function(can, msg) {
|
_process: function(can, msg) {
|
||||||
msg.OptionStatus() && can.onmotion.clear(can, can._status) && can.onappend._status(can, can.base.Obj(msg.OptionStatus()))
|
msg.OptionStatus() && can.onmotion.clear(can, can._status) && can.onappend._status(can, can.base.Obj(msg.OptionStatus()))
|
||||||
return can.core.CallFunc([can.onimport, msg.OptionProcess()], [can, msg])
|
return can.core.CallFunc([can.onimport, msg.OptionProcess()], [can, msg])
|
||||||
},
|
},
|
||||||
|
|
||||||
_location: function(can, msg) { location.href = msg._arg[0] },
|
_location: function(can, msg) { location.href = msg._arg[0] },
|
||||||
_rewrite: function(can, msg) {
|
_rewrite: function(can, msg) {
|
||||||
for (var i = 0; i < msg._arg.length; i += 2) {
|
for (var i = 0; i < msg._arg.length; i += 2) {
|
||||||
can.Option(msg._arg[i], msg._arg[i+1])
|
can.Option(msg._arg[i], msg._arg[i+1])
|
||||||
}
|
}
|
||||||
can.Update()
|
can.Update()
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
_refresh: function(can, msg) {
|
_refresh: function(can, msg) {
|
||||||
can.core.Timer(parseInt(msg.Option("_delay")||"500"), function() {
|
can.core.Timer(parseInt(msg.Option("_delay")||"500"), function() {
|
||||||
var sub = can.request({}, {_count: parseInt(msg.Option("_count"))-1})
|
var sub = can.request({}, {_count: parseInt(msg.Option("_count"))-1})
|
||||||
can.Update()
|
can.Update()
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
_display: function(can, msg) {
|
_display: function(can, msg) {
|
||||||
Volcanos("some", {}, [msg.Option(ice.MSG_DISPLAY)].concat(Volcanos.meta.libs, Volcanos.meta.volcano), function(sub) {
|
Volcanos("some", {}, [msg.Option(ice.MSG_DISPLAY)].concat(Volcanos.meta.libs, Volcanos.meta.volcano), function(sub) {
|
||||||
sub.Conf(can.Conf()), sub.run = can.run
|
sub.Conf(can.Conf()), sub.run = can.run
|
||||||
sub._option = can._option, sub._action = can._action
|
sub._option = can._option, sub._action = can._action
|
||||||
sub.onimport._init(sub, msg, [], function() {}, can._output)
|
sub.onimport._init(sub, msg, [], function() {}, can._output)
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
_field: function(can, msg) {
|
_field: function(can, msg) {
|
||||||
msg.Table(function(item) { can.onappend._plugin(can, item, {arg: can.base.Obj(item[ice.ARG], [])}, function(sub, meta) {
|
msg.Table(function(item) { can.onappend._plugin(can, item, {arg: can.base.Obj(item[ice.ARG], [])}, function(sub, meta) {
|
||||||
var opt = can.base.Obj(item[ice.OPT], [])
|
var opt = can.base.Obj(item[ice.OPT], [])
|
||||||
sub.Conf(html.HEIGHT, can.Conf(html.HEIGHT))
|
sub.Conf(html.HEIGHT, can.Conf(html.HEIGHT))
|
||||||
sub.Conf(html.WIDTH, can.Conf(html.WIDTH))
|
sub.Conf(html.WIDTH, can.Conf(html.WIDTH))
|
||||||
sub.run = function(event, cmds, cb, silent) {
|
sub.run = function(event, cmds, cb, silent) {
|
||||||
var res = can.request(event, can.Option())
|
var res = can.request(event, can.Option())
|
||||||
for (var i = 0; i < opt.length; i += 2) { res.Option(opt[i], opt[i+1]) }
|
for (var i = 0; i < opt.length; i += 2) { res.Option(opt[i], opt[i+1]) }
|
||||||
can.run(event, (msg[ice.MSG_PREFIX]||[]).concat(cmds), cb, true)
|
can.run(event, (msg[ice.MSG_PREFIX]||[]).concat(cmds), cb, true)
|
||||||
}
|
}
|
||||||
}) })
|
}) })
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
_inner: function(can, msg) {
|
_inner: function(can, msg) {
|
||||||
can.onappend.table(can, msg)
|
can.onappend.table(can, msg)
|
||||||
can.onappend.board(can, msg)
|
can.onappend.board(can, msg)
|
||||||
can.onmotion.story.auto(can)
|
can.onmotion.story.auto(can)
|
||||||
can.page.Modify(can, can._output, {style: {display: html.BLOCK}})
|
can.page.Modify(can, can._output, {style: {display: html.BLOCK}})
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
|
||||||
_open: function(can, msg) { can.user.open(msg.Option("_arg")); return true },
|
_open: function(can, msg) { can.user.open(msg.Option("_arg")); return true },
|
||||||
_hold: function(can, msg) { return true },
|
_hold: function(can, msg) { return true },
|
||||||
_back: function(can) {
|
_back: function(can) {
|
||||||
can._history.pop(); for (var his = can._history.pop(); his; his = can._history.pop()) {
|
can._history.pop(); for (var his = can._history.pop(); his; his = can._history.pop()) {
|
||||||
if (his[0] == ctx.ACTION) { continue }
|
if (his[0] == ctx.ACTION) { continue }
|
||||||
can.page.SelectArgs(can, can._option, "", function(item, index) { item.value = his[index]||"" }), can.Update()
|
can.page.SelectArgs(can, can._option, "", function(item, index) { item.value = his[index]||"" }), can.Update()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
!his && can.Update()
|
!his && can.Update()
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
|
||||||
_grow: function(can, str) {
|
_grow: function(can, str) {
|
||||||
if (can.page.Select(can, can._output, "div.code", function(div) {
|
if (can.page.Select(can, can._output, "div.code", function(div) {
|
||||||
can.page.Modify(can, div, {style: {"max-height": 400}})
|
can.page.Modify(can, div, {style: {"max-height": 400}})
|
||||||
can.page.Append(can, div, [{text: [str]}])
|
can.page.Append(can, div, [{text: [str]}])
|
||||||
div.scrollBy(0, 10000)
|
div.scrollBy(0, 10000)
|
||||||
return true
|
return true
|
||||||
}).length == 0) {
|
}).length == 0) {
|
||||||
can.onappend.board(can, str)
|
can.onappend.board(can, str)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "交互操作", list: [
|
Volcanos("onaction", {help: "交互操作", list: [
|
||||||
"共享工具", "打开链接", "生成链接", "生成脚本", "生成图片", "清空参数", "刷新数据", [
|
"共享工具", "打开链接", "生成链接", "生成脚本", "生成图片", "清空参数", "刷新数据", [
|
||||||
"其它 ->", "复制数据", "下载数据", "清空数据", "删除工具", "摄像头", "生成图片",
|
"其它 ->", "复制数据", "下载数据", "清空数据", "删除工具", "摄像头", "生成图片",
|
||||||
],
|
],
|
||||||
], _init: function(can, msg, list, cb, target) {},
|
], _init: function(can, msg, list, cb, target) {},
|
||||||
_engine: function(event, can, button) {
|
_engine: function(event, can, button) {
|
||||||
can.Update(event, [ctx.ACTION, button].concat(can.Input([], true)))
|
can.Update(event, [ctx.ACTION, button].concat(can.Input([], true)))
|
||||||
},
|
},
|
||||||
"共享工具": function(event, can) { var meta = can.Conf()
|
"共享工具": function(event, can) { var meta = can.Conf()
|
||||||
can.onmotion.share(event, can, [{name: chat.TITLE, value: meta.name}, {name: chat.TOPIC, values: [cli.WHITE, cli.BLACK]}], [
|
can.onmotion.share(event, can, [{name: chat.TITLE, value: meta.name}, {name: chat.TOPIC, values: [cli.WHITE, cli.BLACK]}], [
|
||||||
mdb.NAME, meta.index, mdb.TEXT, JSON.stringify(can.Input([], true)),
|
mdb.NAME, meta.index, mdb.TEXT, JSON.stringify(can.Input([], true)),
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
"打开链接": function(event, can) { var meta = can.Conf()
|
"打开链接": function(event, can) { var meta = can.Conf()
|
||||||
var pre = "/chat/cmd/"; if (can.user.mod.isPod) { pre = "/chat/pod/"+can.misc.Search(can, ice.POD)+"/cmd/" }
|
var pre = "/chat/cmd/"; if (can.user.mod.isPod) { pre = "/chat/pod/"+can.misc.Search(can, ice.POD)+"/cmd/" }
|
||||||
var args = can.Option(); args._path = pre+(meta.index||can.core.Keys(meta.ctx, meta.cmd))
|
var args = can.Option(); args._path = pre+(meta.index||can.core.Keys(meta.ctx, meta.cmd))
|
||||||
args._path.indexOf("/cmd/web.wiki.word") > -1 && (args = {_path: pre+args.path})
|
args._path.indexOf("/cmd/web.wiki.word") > -1 && (args = {_path: pre+args.path})
|
||||||
|
|
||||||
can.user.open(can.misc.MergeURL(can, args))
|
can.user.open(can.misc.MergeURL(can, args))
|
||||||
},
|
},
|
||||||
"生成链接": function(event, can) { var meta = can.Conf()
|
"生成链接": function(event, can) { var meta = can.Conf()
|
||||||
var pre = "/chat/cmd/"; if (can.user.mod.isPod) { pre = "/chat/pod/"+can.misc.Search(can, ice.POD)+"/cmd/" }
|
var pre = "/chat/cmd/"; if (can.user.mod.isPod) { pre = "/chat/pod/"+can.misc.Search(can, ice.POD)+"/cmd/" }
|
||||||
var args = can.Option(); args._path = pre+(meta.index||can.core.Keys(meta.ctx, meta.cmd))
|
var args = can.Option(); args._path = pre+(meta.index||can.core.Keys(meta.ctx, meta.cmd))
|
||||||
args._path.indexOf("/cmd/web.wiki.word") > -1 && (args = {_path: pre+args.path})
|
args._path.indexOf("/cmd/web.wiki.word") > -1 && (args = {_path: pre+args.path})
|
||||||
var url = can.misc.MergeURL(can, args)
|
var url = can.misc.MergeURL(can, args)
|
||||||
can.user.copy(event, can, url)
|
can.user.copy(event, can, url)
|
||||||
can.onmotion.share(event, can, [], [mdb.LINK, url])
|
can.onmotion.share(event, can, [], [mdb.LINK, url])
|
||||||
},
|
},
|
||||||
"生成脚本": function(event, can, button) { var conf = can.Conf()
|
"生成脚本": function(event, can, button) { var conf = can.Conf()
|
||||||
var args = can.Input("", true).join(ice.SP); var list = [
|
var args = can.Input("", true).join(ice.SP); var list = [
|
||||||
"export ctx_dev="+location.origin+"; ctx_temp=$(mktemp); curl -fsSL $ctx_dev -o $ctx_temp;"+" source $ctx_temp "+(conf.index||"")+ice.SP+args,
|
"export ctx_dev="+location.origin+"; ctx_temp=$(mktemp); curl -fsSL $ctx_dev -o $ctx_temp;"+" source $ctx_temp "+(conf.index||"")+ice.SP+args,
|
||||||
"ish_sys_dev_run_command "+args, "ish_sys_dev_run_action", "ish_sys_dev_run_source",
|
"ish_sys_dev_run_command "+args, "ish_sys_dev_run_action", "ish_sys_dev_run_source",
|
||||||
]
|
]
|
||||||
var ui = can.user.toast(can, {title: button, duration: -1, width: -300,
|
var ui = can.user.toast(can, {title: button, duration: -1, width: -300,
|
||||||
content: '<div class="story" data-type="spark", data-name="shell">'+
|
content: '<div class="story" data-type="spark", data-name="shell">'+
|
||||||
'<label>$ </label>'+'<span>'+list.join("</span><br/><label>$ </label><span>")+'</span>'+'</div>',
|
'<label>$ </label>'+'<span>'+list.join("</span><br/><label>$ </label><span>")+'</span>'+'</div>',
|
||||||
action: [cli.CLOSE],
|
action: [cli.CLOSE],
|
||||||
})
|
})
|
||||||
can.onmotion.story.auto(can, ui._target)
|
can.onmotion.story.auto(can, ui._target)
|
||||||
can.user.copy(event, can, list[0])
|
can.user.copy(event, can, list[0])
|
||||||
},
|
},
|
||||||
"生成图片": function(event, can) { can.onmotion.toimage(event, can, can._name) },
|
"生成图片": function(event, can) { can.onmotion.toimage(event, can, can._name) },
|
||||||
"保存参数": function(event, can) { can.search(event, ["River.ondetail.保存参数"]) },
|
"保存参数": function(event, can) { can.search(event, ["River.ondetail.保存参数"]) },
|
||||||
"清空参数": function(event, can) {
|
"清空参数": function(event, can) {
|
||||||
can.page.SelectArgs(can, can._option, "", function(item) { return item.value = "" })
|
can.page.SelectArgs(can, can._option, "", function(item) { return item.value = "" })
|
||||||
},
|
},
|
||||||
"刷新数据": function(event, can) { can.Update({}, can.Input([], true)) },
|
"刷新数据": function(event, can) { can.Update({}, can.Input([], true)) },
|
||||||
|
|
||||||
"复制数据": function(event, can) { var meta = can.Conf(), msg = can._msg
|
"复制数据": function(event, can) { var meta = can.Conf(), msg = can._msg
|
||||||
var res = [msg.append && msg.append.join(",")]; msg.Table(function(line, index, array) {
|
var res = [msg.append && msg.append.join(",")]; msg.Table(function(line, index, array) {
|
||||||
res.push(can.core.Item(line, function(key, value) { return value }).join(","))
|
res.push(can.core.Item(line, function(key, value) { return value }).join(","))
|
||||||
})
|
})
|
||||||
|
|
||||||
res.length > 1 && can.user.copy(event, can, res.join(ice.SP))
|
res.length > 1 && can.user.copy(event, can, res.join(ice.SP))
|
||||||
msg.result && can.user.copy(event, can, msg.Result())
|
msg.result && can.user.copy(event, can, msg.Result())
|
||||||
},
|
},
|
||||||
"下载数据": function(event, can) { var meta = can.Conf(), msg = can._msg
|
"下载数据": function(event, can) { var meta = can.Conf(), msg = can._msg
|
||||||
var res = [msg.append && msg.append.join(",")]; msg.Table(function(line, index, array) {
|
var res = [msg.append && msg.append.join(",")]; msg.Table(function(line, index, array) {
|
||||||
res.push(can.core.Item(line, function(key, value) { return value }).join(","))
|
res.push(can.core.Item(line, function(key, value) { return value }).join(","))
|
||||||
})
|
})
|
||||||
|
|
||||||
res.length > 1 && can.user.downloads(can, res.join("\n"), meta.name+".csv")
|
res.length > 1 && can.user.downloads(can, res.join("\n"), meta.name+".csv")
|
||||||
msg.result && can.user.downloads(can, msg.Result(), meta.name+".txt")
|
msg.result && can.user.downloads(can, msg.Result(), meta.name+".txt")
|
||||||
},
|
},
|
||||||
"清空数据": function(event, can) { can.onmotion.clear(can, can._output) },
|
"清空数据": function(event, can) { can.onmotion.clear(can, can._output) },
|
||||||
"删除工具": function(event, can) { can.page.Remove(can, can._target) },
|
"删除工具": function(event, can) { can.page.Remove(can, can._target) },
|
||||||
// "生成图片": function(event, can) {
|
// "生成图片": function(event, can) {
|
||||||
// can.user.toPNG(can, "hi.png", can._target.outerHTML, can.Conf(html.HEIGHT), can.Conf(html.WIDTH))
|
// can.user.toPNG(can, "hi.png", can._target.outerHTML, can.Conf(html.HEIGHT), can.Conf(html.WIDTH))
|
||||||
// },
|
// },
|
||||||
|
|
||||||
"摄像头": function(event, can) {
|
"摄像头": function(event, can) {
|
||||||
var constraints = {audio: false, video: {width: 200, height: 200}}
|
var constraints = {audio: false, video: {width: 200, height: 200}}
|
||||||
var ui = can.page.Append(can, can._output, [{view: ctx.ACTION}, {view: "capture", list: [{type: "video", _init: function(item) {
|
var ui = can.page.Append(can, can._output, [{view: ctx.ACTION}, {view: "capture", list: [{type: "video", _init: function(item) {
|
||||||
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
|
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
|
||||||
item.srcObject = stream, item.onloadedmetadata = function(e) {
|
item.srcObject = stream, item.onloadedmetadata = function(e) {
|
||||||
item.play()
|
item.play()
|
||||||
}, ui.stream = stream
|
}, ui.stream = stream
|
||||||
}).catch(function(err) { console.log(err.name + ": " + err.message); })
|
}).catch(function(err) { console.log(err.name + ": " + err.message); })
|
||||||
}}]}])
|
}}]}])
|
||||||
|
|
||||||
can.onappend._action(can, ["关闭", "抓拍"], ui.action, {
|
can.onappend._action(can, ["关闭", "抓拍"], ui.action, {
|
||||||
"抓拍": function(event) {
|
"抓拍": function(event) {
|
||||||
var canvas = can.page.Append(can, ui.capture, [{type: "canvas", width: ui.video.offsetWidth, height: ui.video.offsetHeight}]).first
|
var canvas = can.page.Append(can, ui.capture, [{type: "canvas", width: ui.video.offsetWidth, height: ui.video.offsetHeight}]).first
|
||||||
canvas.getContext("2d").drawImage(ui.video, 0, 0)
|
canvas.getContext("2d").drawImage(ui.video, 0, 0)
|
||||||
can.page.Append(can, ui.capture, [{img: canvas.toDataURL('image/png'), style: {width: ui.video.offsetWidth, height: ui.video.offsetHeight}}])
|
can.page.Append(can, ui.capture, [{img: canvas.toDataURL('image/png'), style: {width: ui.video.offsetWidth, height: ui.video.offsetHeight}}])
|
||||||
can.page.Remove(can, canvas)
|
can.page.Remove(can, canvas)
|
||||||
},
|
},
|
||||||
"关闭": function(event) {
|
"关闭": function(event) {
|
||||||
can.core.List(ui.stream.getTracks(), function(track) { track.stop() })
|
can.core.List(ui.stream.getTracks(), function(track) { track.stop() })
|
||||||
can.page.Remove(can, ui.action)
|
can.page.Remove(can, ui.action)
|
||||||
can.page.Remove(can, ui.video)
|
can.page.Remove(can, ui.video)
|
||||||
can.page.Remove(can, ui.capture)
|
can.page.Remove(can, ui.capture)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: function(event, can) { can.onmotion.toggle(can, can._action) },
|
actions: function(event, can) { can.onmotion.toggle(can, can._action) },
|
||||||
clear: function(event, can, name) { can.onmotion.clear(can, can._output) },
|
clear: function(event, can, name) { can.onmotion.clear(can, can._output) },
|
||||||
close: function(event, can) { can.page.Remove(can, can._target) },
|
close: function(event, can) { can.page.Remove(can, can._target) },
|
||||||
upload: function(event, can) { can.user.upload(event, can) },
|
upload: function(event, can) { can.user.upload(event, can) },
|
||||||
change: function(event, can, name, value, cb) {
|
change: function(event, can, name, value, cb) {
|
||||||
return can.page.SelectArgs(can, can._option, "", function(input) {
|
return can.page.SelectArgs(can, can._option, "", function(input) {
|
||||||
if (input.name == name && value != input.value) { input.value = value
|
if (input.name == name && value != input.value) { input.value = value
|
||||||
var data = input.dataset||{}; can.Update(event, can.Input(), cb)
|
var data = input.dataset||{}; can.Update(event, can.Input(), cb)
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
next: function(event, can) {
|
next: function(event, can) {
|
||||||
can.Update(event, [ctx.ACTION, "next", can.Status("total")||0, can.Option("limit"), can.Option("offend")])
|
can.Update(event, [ctx.ACTION, "next", can.Status("total")||0, can.Option("limit"), can.Option("offend")])
|
||||||
},
|
},
|
||||||
prev: function(event, can) {
|
prev: function(event, can) {
|
||||||
can.Update(event, [ctx.ACTION, "prev", can.Status("total")||0, can.Option("limit"), can.Option("offend")])
|
can.Update(event, [ctx.ACTION, "prev", can.Status("total")||0, can.Option("limit"), can.Option("offend")])
|
||||||
},
|
},
|
||||||
|
|
||||||
listTags: function(event, can, button) { var list = []
|
listTags: function(event, can, button) { var list = []
|
||||||
can.core.List([can.base, can.core, can.misc, can.page, can.user,
|
can.core.List([can.base, can.core, can.misc, can.page, can.user,
|
||||||
can.onengine, can.ondaemon, can.onappend, can.onlayout, can.onmotion, can.onkeymap,
|
can.onengine, can.ondaemon, can.onappend, can.onlayout, can.onmotion, can.onkeymap,
|
||||||
], function(lib) {
|
], function(lib) {
|
||||||
can.core.Item(lib, function(key, value) { if (key.indexOf("_") == 0 || !lib.hasOwnProperty(key)) { return }
|
can.core.Item(lib, function(key, value) { if (key.indexOf("_") == 0 || !lib.hasOwnProperty(key)) { return }
|
||||||
list.push({zone: lib._name, type: typeof value, name: key, text: can.base.isObject(value)? "": (value+"").split(ice.NL)[0],
|
list.push({zone: lib._name, type: typeof value, name: key, text: can.base.isObject(value)? "": (value+"").split(ice.NL)[0],
|
||||||
path: "usr/volcanos/", file: lib._path, line: 1,
|
path: "usr/volcanos/", file: lib._path, line: 1,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
var msg = can.request(event, {_handle: true, text: can.base.Format(list)})
|
var msg = can.request(event, {_handle: true, text: can.base.Format(list)})
|
||||||
can.run(event, [ctx.ACTION, button], function() { can.user.toastSuccess(can) })
|
can.run(event, [ctx.ACTION, button], function() { can.user.toastSuccess(can) })
|
||||||
},
|
},
|
||||||
getClipboardData: function(event, can, button) {
|
getClipboardData: function(event, can, button) {
|
||||||
function add(text) {
|
function add(text) {
|
||||||
can.run(event, can.base.Simple(ctx.ACTION, button, can.base.ParseJSON(text)), function(msg) {
|
can.run(event, can.base.Simple(ctx.ACTION, button, can.base.ParseJSON(text)), function(msg) {
|
||||||
can.user.toastSuccess(can), can.Update()
|
can.user.toastSuccess(can), can.Update()
|
||||||
}, true)
|
}, true)
|
||||||
}
|
}
|
||||||
if (navigator.clipboard) {
|
if (navigator.clipboard) {
|
||||||
navigator.clipboard.readText().then(add).catch(function(err) { can.misc.Log(err) })
|
navigator.clipboard.readText().then(add).catch(function(err) { can.misc.Log(err) })
|
||||||
} else {
|
} else {
|
||||||
can.user.input(event, can, [{type: html.TEXTAREA, name: mdb.TEXT}], function(ev, button, data, list, args) { add(list[0]) })
|
can.user.input(event, can, [{type: html.TEXTAREA, name: mdb.TEXT}], function(ev, button, data, list, args) { add(list[0]) })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getLocation: function(event, can, button) {
|
getLocation: function(event, can, button) {
|
||||||
can.user.agent.getLocation(function(data) { can.request(event, data)
|
can.user.agent.getLocation(function(data) { can.request(event, data)
|
||||||
can.user.input(event, can, [mdb.TYPE, mdb.NAME, mdb.TEXT, "latitude", "longitude"], function(ev, bu, data, list, args) {
|
can.user.input(event, can, [mdb.TYPE, mdb.NAME, mdb.TEXT, "latitude", "longitude"], function(ev, bu, data, list, args) {
|
||||||
can.run(event, [ctx.ACTION, button].concat(can.base.Simple(args, data)), function(msg) {
|
can.run(event, [ctx.ACTION, button].concat(can.base.Simple(args, data)), function(msg) {
|
||||||
can.user.toastSuccess(can), can.Update()
|
can.user.toastSuccess(can), can.Update()
|
||||||
}, true)
|
}, true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
openLocation: function(event, can) { can.user.agent.openLocation(can.request(event)) },
|
openLocation: function(event, can) { can.user.agent.openLocation(can.request(event)) },
|
||||||
|
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: []})
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
@ -1,60 +1,60 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
can.onimport.show(can, can.base.Obj(msg.Result(), {}), target)
|
can.onimport.show(can, can.base.Obj(msg.Result(), {}), target)
|
||||||
},
|
},
|
||||||
show: function(can, data, target) {
|
show: function(can, data, target) {
|
||||||
function show(data, target, index, total) { var list
|
function show(data, target, index, total) { var list
|
||||||
switch (typeof data) {
|
switch (typeof data) {
|
||||||
case lang.OBJECT:
|
case lang.OBJECT:
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return can.page.Append(can, list, [{text: "null"}]).item
|
return can.page.Append(can, list, [{text: "null"}]).item
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
function wrap(begin, end, add, cb) {
|
function wrap(begin, end, add, cb) {
|
||||||
can.page.Append(can, target, [{text: begin}])
|
can.page.Append(can, target, [{text: begin}])
|
||||||
add && can.page.Append(can, target, [{text: ["...", html.SPAN, "nonce"]}]), cb()
|
add && can.page.Append(can, target, [{text: ["...", html.SPAN, "nonce"]}]), cb()
|
||||||
can.page.Append(can, target, [{text: end}])
|
can.page.Append(can, target, [{text: end}])
|
||||||
}
|
}
|
||||||
function toggle(list) { list && can.onmotion.toggle(can, list) }
|
function toggle(list) { list && can.onmotion.toggle(can, list) }
|
||||||
function _item() {
|
function _item() {
|
||||||
list = list || can.page.Append(can, target, [{view: html.LIST}]).list
|
list = list || can.page.Append(can, target, [{view: html.LIST}]).list
|
||||||
return can.page.Append(can, list, [{view: html.ITEM}]).item
|
return can.page.Append(can, list, [{view: html.ITEM}]).item
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can.base.isArray(data)) { // 数组
|
if (can.base.isArray(data)) { // 数组
|
||||||
wrap("[", "]", data.length > 0, function() { can.core.List(data, function(value, index) { var item = _item()
|
wrap("[", "]", data.length > 0, function() { can.core.List(data, function(value, index) { var item = _item()
|
||||||
show(value, item, index, data.length)
|
show(value, item, index, data.length)
|
||||||
}) })
|
}) })
|
||||||
} else { // 对象
|
} else { // 对象
|
||||||
var length = can.core.Item(data).length, count = 0
|
var length = can.core.Item(data).length, count = 0
|
||||||
wrap("{", "}", length > 0, function() { can.core.Item(data, function(key, value) { var item = _item()
|
wrap("{", "}", length > 0, function() { can.core.Item(data, function(key, value) { var item = _item()
|
||||||
can.page.Append(can, item, [{text: ['"'+key+'"', html.SPAN, "key"], onclick: function(event) { toggle(sub) }}, {text: ': '}])
|
can.page.Append(can, item, [{text: ['"'+key+'"', html.SPAN, "key"], onclick: function(event) { toggle(sub) }}, {text: ': '}])
|
||||||
var sub = show(value, item, count++, length)
|
var sub = show(value, item, count++, length)
|
||||||
}) })
|
}) })
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case lang.STRING: /* 字串 */ can.page.Append(can, target, [{text: ['"'+data+'"', html.SPAN, lang.STRING]}]); break
|
case lang.STRING: /* 字串 */ can.page.Append(can, target, [{text: ['"'+data+'"', html.SPAN, lang.STRING]}]); break
|
||||||
default: /* 其它 */ can.page.Append(can, target, [{text: [''+data+'', html.SPAN, "const"]}])
|
default: /* 其它 */ can.page.Append(can, target, [{text: [''+data+'', html.SPAN, "const"]}])
|
||||||
}
|
}
|
||||||
(index < total-1) && can.page.Append(can, target, [{text: ice.FS}])
|
(index < total-1) && can.page.Append(can, target, [{text: ice.FS}])
|
||||||
return list
|
return list
|
||||||
}; show(data, can.page.Append(can, target, [{view: html.ITEM}]).item, 0, 0)
|
}; show(data, can.page.Append(can, target, [{view: html.ITEM}]).item, 0, 0)
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onaction", {help: "组件菜单", list: ["展开", "折叠", "复制"],
|
Volcanos("onaction", {help: "组件菜单", list: ["展开", "折叠", "复制"],
|
||||||
"展开": function(event, can) {
|
"展开": function(event, can) {
|
||||||
can.page.Select(can, can._output, "div.list div.list", function(list) {
|
can.page.Select(can, can._output, "div.list div.list", function(list) {
|
||||||
can.onmotion.hidden(can, list, true)
|
can.onmotion.hidden(can, list, true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"折叠": function(event, can) {
|
"折叠": function(event, can) {
|
||||||
can.page.Select(can, can._output, "div.list div.list", function(list) {
|
can.page.Select(can, can._output, "div.list div.list", function(list) {
|
||||||
can.onmotion.hidden(can, list)
|
can.onmotion.hidden(can, list)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"复制": function(event, can) {
|
"复制": function(event, can) {
|
||||||
can.user.copy(event, can, can._msg.Result())
|
can.user.copy(event, can, can._msg.Result())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: []})
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
can.onmotion.clear(can), can.onimport._show(can, msg)
|
can.onmotion.clear(can), can.onimport._show(can, msg)
|
||||||
var r = 200, margin = 20; can.svg.Val(html.WIDTH, 2*(r+margin)), can.svg.Val(html.HEIGHT, 2*(r+margin))
|
var r = 200, margin = 20; can.svg.Val(html.WIDTH, 2*(r+margin)), can.svg.Val(html.HEIGHT, 2*(r+margin))
|
||||||
can._args = can.base.Copy({field: "value"}, can.base.ParseURL(can._display))
|
can._args = can.base.Copy({field: "value"}, can.base.ParseURL(can._display))
|
||||||
can.onimport._draw(can, msg, can._args.field, r+margin, r+margin, r, margin, 0)
|
can.onimport._draw(can, msg, can._args.field, r+margin, r+margin, r, margin, 0)
|
||||||
can.onmotion.clear(can, can.ui.project), can.onappend.table(can, msg, null, can.ui.project)
|
can.onmotion.clear(can, can.ui.project), can.onappend.table(can, msg, null, can.ui.project)
|
||||||
can.onmotion.hidden(can, can.ui.project, true)
|
can.onmotion.hidden(can, can.ui.project, true)
|
||||||
can.page.Modify(can, can.ui.project, {style: {"max-width": 480}})
|
can.page.Modify(can, can.ui.project, {style: {"max-width": 480}})
|
||||||
can.page.Select(can, can.ui.project, html.TR, function(tr, index) {
|
can.page.Select(can, can.ui.project, html.TR, function(tr, index) {
|
||||||
can.page.Modify(can, tr, {onmouseenter: function(event) {
|
can.page.Modify(can, tr, {onmouseenter: function(event) {
|
||||||
can.onmotion.clear(can, can.svg), can.onimport._draw(can, msg, can._args.field, r+margin, r+margin, r, margin, index-1)
|
can.onmotion.clear(can, can.svg), can.onimport._draw(can, msg, can._args.field, r+margin, r+margin, r, margin, index-1)
|
||||||
}})
|
}})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_draw: function(can, msg, field, x, y, r, margin, which) {
|
_draw: function(can, msg, field, x, y, r, margin, which) {
|
||||||
function pos(x, y, r, angle) { angle -= 90
|
function pos(x, y, r, angle) { angle -= 90
|
||||||
return [x + r * Math.cos(angle * Math.PI / 180), y + r * Math.sin(angle * Math.PI / 180)]
|
return [x + r * Math.cos(angle * Math.PI / 180), y + r * Math.sin(angle * Math.PI / 180)]
|
||||||
}
|
}
|
||||||
function pie(x, y, r, begin, span, color, cb) { can.onimport.draw({}, can, {shape: "path", style: {
|
function pie(x, y, r, begin, span, color, cb) { can.onimport.draw({}, can, {shape: "path", style: {
|
||||||
"stroke-width": 1, stroke: color, fill: color, d: can.base.joins([
|
"stroke-width": 1, stroke: color, fill: color, d: can.base.joins([
|
||||||
["M", x, y], ["L"].concat(pos(x, y, r, begin)), ["A", r, r, "0", span>180? "1": "0", "1"].concat(pos(x, y, r, begin+span)), ["Z"]
|
["M", x, y], ["L"].concat(pos(x, y, r, begin)), ["A", r, r, "0", span>180? "1": "0", "1"].concat(pos(x, y, r, begin+span)), ["Z"]
|
||||||
], ice.SP, ice.FS),
|
], ice.SP, ice.FS),
|
||||||
}, onmouseenter: function(event) {
|
}, onmouseenter: function(event) {
|
||||||
can.base.isFunc(cb) && cb(event)
|
can.base.isFunc(cb) && cb(event)
|
||||||
} }) }
|
} }) }
|
||||||
|
|
||||||
var total = 0; msg.Table(function(value) { total += parseInt(value[field]) })
|
var total = 0; msg.Table(function(value) { total += parseInt(value[field]) })
|
||||||
var color = [cli.RED, cli.YELLOW, cli.GREEN, cli.CYAN, cli.BLUE, cli.PURPLE, cli.WHITE, cli.BLACK]
|
var color = [cli.RED, cli.YELLOW, cli.GREEN, cli.CYAN, cli.BLUE, cli.PURPLE, cli.WHITE, cli.BLACK]
|
||||||
var begin = 0; msg["color"] = [], msg["weight"] = [], msg.Table(function(value, index) { var span = parseInt(value[field])/total*360
|
var begin = 0; msg["color"] = [], msg["weight"] = [], msg.Table(function(value, index) { var span = parseInt(value[field])/total*360
|
||||||
var p = index==which? pos(x, y, margin, begin+span/2): [x, y]; index == which && can.Status(value)
|
var p = index==which? pos(x, y, margin, begin+span/2): [x, y]; index == which && can.Status(value)
|
||||||
var c = color[index%color.length]; pie(p[0], p[1], r, begin, span, c, function(event) {
|
var c = color[index%color.length]; pie(p[0], p[1], r, begin, span, c, function(event) {
|
||||||
if (index == can._last) { return } can._last = index
|
if (index == can._last) { return } can._last = index
|
||||||
can.onmotion.clear(can, can.svg), can.svg.Value("count", 0)
|
can.onmotion.clear(can, can.svg), can.svg.Value("count", 0)
|
||||||
can.onimport._draw(can, msg, field, x, y, r, margin, index)
|
can.onimport._draw(can, msg, field, x, y, r, margin, index)
|
||||||
can.onimport._profile(can, event.target)
|
can.onimport._profile(can, event.target)
|
||||||
}), begin += span, msg.Push("color", '<span style="background-color:'+c+'"> </span>')
|
}), begin += span, msg.Push("color", '<span style="background-color:'+c+'"> </span>')
|
||||||
msg.Push("weight", parseInt(parseInt(value[field])*10000/total)/100+"%")
|
msg.Push("weight", parseInt(parseInt(value[field])*10000/total)/100+"%")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,191 +1,191 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
if (msg.Length() == 0) { return }
|
if (msg.Length() == 0) { return }
|
||||||
|
|
||||||
can._args = can.base.Copy({root: "ice", field: msg.append[0], split: ice.PS}, can.base.ParseURL(can._display))
|
can._args = can.base.Copy({root: "ice", field: msg.append[0], split: ice.PS}, can.base.ParseURL(can._display))
|
||||||
can.dir_root = msg.Option(nfs.DIR_ROOT)||can._args.root||""
|
can.dir_root = msg.Option(nfs.DIR_ROOT)||can._args.root||""
|
||||||
can._tree = can.onimport._tree(can, msg.Table(), can._args.field, can._args.split)
|
can._tree = can.onimport._tree(can, msg.Table(), can._args.field, can._args.split)
|
||||||
if (!can._tree[""]) { return }
|
if (!can._tree[""]) { return }
|
||||||
can._tree[""].name = can._args.root
|
can._tree[""].name = can._args.root
|
||||||
|
|
||||||
can.size = 30, can.margin = 30
|
can.size = 30, can.margin = 30
|
||||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||||
can.page.ClassList.add(can, can._fields, "draw")
|
can.page.ClassList.add(can, can._fields, "draw")
|
||||||
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
||||||
var p = can.Action(ice.VIEW, can.sup.view||can.Action(ice.VIEW))
|
var p = can.Action(ice.VIEW, can.sup.view||can.Action(ice.VIEW))
|
||||||
can.onaction[p](event, can, p)
|
can.onaction[p](event, can, p)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
_tree: function(can, list, field, split) {
|
_tree: function(can, list, field, split) {
|
||||||
var node = {}; can.core.List(list, function(item) { if (!item[field]) { return }
|
var node = {}; can.core.List(list, function(item) { if (!item[field]) { return }
|
||||||
can.core.List(can.base.trimPrefix(item[field], can.dir_root+can._args.split).split(split), function(value, index, array) {
|
can.core.List(can.base.trimPrefix(item[field], can.dir_root+can._args.split).split(split), function(value, index, array) {
|
||||||
var last = array.slice(0, index).join(split)||"", name = array.slice(0, index+1).join(split)
|
var last = array.slice(0, index).join(split)||"", name = array.slice(0, index+1).join(split)
|
||||||
if (!value || node[name]) { return }
|
if (!value || node[name]) { return }
|
||||||
|
|
||||||
node[last] = node[last]||{name: last, meta: {}, list: []}
|
node[last] = node[last]||{name: last, meta: {}, list: []}
|
||||||
node[last].list.push(node[name] = {
|
node[last].list.push(node[name] = {
|
||||||
name: value+(index==array.length-1? "": split),
|
name: value+(index==array.length-1? "": split),
|
||||||
meta: item, list: [], last: node[last],
|
meta: item, list: [], last: node[last],
|
||||||
file: item[field]||item.file, hide: true,
|
file: item[field]||item.file, hide: true,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return node
|
return node
|
||||||
},
|
},
|
||||||
_height: function(can, tree, deep) { if (!tree) { return 0 }
|
_height: function(can, tree, deep) { if (!tree) { return 0 }
|
||||||
tree.deep = deep||0
|
tree.deep = deep||0
|
||||||
if (tree.list.length == 0 || tree.hide) { return tree.height = 1 }
|
if (tree.list.length == 0 || tree.hide) { return tree.height = 1 }
|
||||||
|
|
||||||
var height = 0; can.core.List(tree.list, function(item) {
|
var height = 0; can.core.List(tree.list, function(item) {
|
||||||
height += can.onimport._height(can, item, (deep||0)+1)
|
height += can.onimport._height(can, item, (deep||0)+1)
|
||||||
})
|
})
|
||||||
return tree.height = height
|
return tree.height = height
|
||||||
},
|
},
|
||||||
_width: function(can, tree, deep) { if (!tree) { return 0 }
|
_width: function(can, tree, deep) { if (!tree) { return 0 }
|
||||||
tree.deep = deep||0
|
tree.deep = deep||0
|
||||||
if (tree.list.length == 0 || tree.hide) {
|
if (tree.list.length == 0 || tree.hide) {
|
||||||
tree.view = can.onimport.draw({}, can, {shape: html.TEXT, point: [{x: 0, y: 0}], style: {inner: tree.name}})
|
tree.view = can.onimport.draw({}, can, {shape: html.TEXT, point: [{x: 0, y: 0}], style: {inner: tree.name}})
|
||||||
return tree.width = tree.view.Val("textLength")+can.margin
|
return tree.width = tree.view.Val("textLength")+can.margin
|
||||||
}
|
}
|
||||||
|
|
||||||
var width = 0; can.core.List(tree.list, function(item) {
|
var width = 0; can.core.List(tree.list, function(item) {
|
||||||
width += can.onimport._width(can, item, (deep||0)+1)
|
width += can.onimport._width(can, item, (deep||0)+1)
|
||||||
})
|
})
|
||||||
return tree.width = width
|
return tree.width = width
|
||||||
},
|
},
|
||||||
_color: function(can, tree) {
|
_color: function(can, tree) {
|
||||||
return tree.meta&&tree.meta.color || (tree.list == 0? cli.PURPLE: cli.YELLOW)
|
return tree.meta&&tree.meta.color || (tree.list == 0? cli.PURPLE: cli.YELLOW)
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onaction", {help: "用户操作", list: ["编辑", [ice.VIEW, "横向", "纵向"], "生成图片"],
|
Volcanos("onaction", {help: "用户操作", list: ["编辑", [ice.VIEW, "横向", "纵向"], "生成图片"],
|
||||||
"编辑": function(event, can) {
|
"编辑": function(event, can) {
|
||||||
can.onmotion.toggle(can, can._action)
|
can.onmotion.toggle(can, can._action)
|
||||||
can.onmotion.toggle(can, can._status)
|
can.onmotion.toggle(can, can._status)
|
||||||
},
|
},
|
||||||
"横向": function(event, can) {
|
"横向": function(event, can) {
|
||||||
can.onimport._height(can, can._tree[""])
|
can.onimport._height(can, can._tree[""])
|
||||||
can.sup.view = "横向", can.onmotion.clear(can, can.svg)
|
can.sup.view = "横向", can.onmotion.clear(can, can.svg)
|
||||||
|
|
||||||
can.svg.Val(html.HEIGHT, can._tree[""].height*can.size+2*can.margin)
|
can.svg.Val(html.HEIGHT, can._tree[""].height*can.size+2*can.margin)
|
||||||
can.width = 0, can.onaction._draw_horizontal(can, can._tree[""], can.margin, can.margin)
|
can.width = 0, can.onaction._draw_horizontal(can, can._tree[""], can.margin, can.margin)
|
||||||
can.svg.Val(html.WIDTH, can.width+can.margin)
|
can.svg.Val(html.WIDTH, can.width+can.margin)
|
||||||
},
|
},
|
||||||
"纵向": function(event, can) {
|
"纵向": function(event, can) {
|
||||||
can.onimport._width(can, can._tree[""])
|
can.onimport._width(can, can._tree[""])
|
||||||
can.sup.view = "纵向", can.onmotion.clear(can, can.svg)
|
can.sup.view = "纵向", can.onmotion.clear(can, can.svg)
|
||||||
|
|
||||||
can.svg.Val(html.WIDTH, can._tree[""].width+2*can.margin)
|
can.svg.Val(html.WIDTH, can._tree[""].width+2*can.margin)
|
||||||
can.height = 0, can.onaction._draw_vertical(can, can._tree[""], can.margin, can.margin+can.size)
|
can.height = 0, can.onaction._draw_vertical(can, can._tree[""], can.margin, can.margin+can.size)
|
||||||
can.svg.Val(html.HEIGHT, can.height+can.margin)
|
can.svg.Val(html.HEIGHT, can.height+can.margin)
|
||||||
},
|
},
|
||||||
"生成图片": function(event, can) {
|
"生成图片": function(event, can) {
|
||||||
can.user.toPNG(can, "hi.png", can.svg.outerHTML, can.svg.Val(html.HEIGHT), can.svg.Val(html.WIDTH))
|
can.user.toPNG(can, "hi.png", can.svg.outerHTML, can.svg.Val(html.HEIGHT), can.svg.Val(html.WIDTH))
|
||||||
},
|
},
|
||||||
_draw: function(can, tree, x, y, style) {
|
_draw: function(can, tree, x, y, style) {
|
||||||
var color = can.onimport._color(can, tree)
|
var color = can.onimport._color(can, tree)
|
||||||
tree.view = can.onimport.draw({}, can, {
|
tree.view = can.onimport.draw({}, can, {
|
||||||
shape: html.TEXT, point: [{x: x, y: y}], style: can.base.Copy({
|
shape: html.TEXT, point: [{x: x, y: y}], style: can.base.Copy({
|
||||||
stroke: color, fill: color, "text-anchor": "start", inner: tree.name||tree.file,
|
stroke: color, fill: color, "text-anchor": "start", inner: tree.name||tree.file,
|
||||||
}, style),
|
}, style),
|
||||||
}), can.core.ItemCB(can.ondetail, tree.view, can, tree)
|
}), can.core.ItemCB(can.ondetail, tree.view, can, tree)
|
||||||
},
|
},
|
||||||
_draw_vertical: function(can, tree, x, y) { tree.x = x, tree.y = y
|
_draw_vertical: function(can, tree, x, y) { tree.x = x, tree.y = y
|
||||||
can.onaction._draw(can, tree, x+tree.width/2, y, {"text-anchor": "middle"})
|
can.onaction._draw(can, tree, x+tree.width/2, y, {"text-anchor": "middle"})
|
||||||
|
|
||||||
tree.height = can.size
|
tree.height = can.size
|
||||||
if (y+tree.height > can.height) { can.height = y+tree.height }
|
if (y+tree.height > can.height) { can.height = y+tree.height }
|
||||||
if (tree.hide) { return }
|
if (tree.hide) { return }
|
||||||
|
|
||||||
var offset = 0; can.core.List(tree.list, function(item) {
|
var offset = 0; can.core.List(tree.list, function(item) {
|
||||||
can.onimport.draw({}, can, {shape: "path2v", point: [
|
can.onimport.draw({}, can, {shape: "path2v", point: [
|
||||||
{x: x+tree.width/2, y: y+tree.height-can.margin/2},
|
{x: x+tree.width/2, y: y+tree.height-can.margin/2},
|
||||||
{x: x+offset+item.width/2, y: y+tree.height+can.margin/2},
|
{x: x+offset+item.width/2, y: y+tree.height+can.margin/2},
|
||||||
], style: {stroke: cli.CYAN}})
|
], style: {stroke: cli.CYAN}})
|
||||||
|
|
||||||
can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin)
|
can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin)
|
||||||
offset += item.width
|
offset += item.width
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_draw_horizontal: function(can, tree, x, y) { tree.x = x, tree.y = y
|
_draw_horizontal: function(can, tree, x, y) { tree.x = x, tree.y = y
|
||||||
can.onaction._draw(can, tree, x, y+tree.height*can.size/2, {"text-anchor": "start"})
|
can.onaction._draw(can, tree, x, y+tree.height*can.size/2, {"text-anchor": "start"})
|
||||||
|
|
||||||
tree.width = tree.view.Val("textLength")||(tree.name||"").length*10
|
tree.width = tree.view.Val("textLength")||(tree.name||"").length*10
|
||||||
if (x+tree.width > can.width) { can.width = x+tree.width }
|
if (x+tree.width > can.width) { can.width = x+tree.width }
|
||||||
if (tree.hide) { return }
|
if (tree.hide) { return }
|
||||||
|
|
||||||
var offset = 0; can.core.List(tree.list, function(item) {
|
var offset = 0; can.core.List(tree.list, function(item) {
|
||||||
can.onimport.draw({}, can, {shape: "path2h", point: [
|
can.onimport.draw({}, can, {shape: "path2h", point: [
|
||||||
{x: x+tree.width+can.margin/8, y: y+tree.height*can.size/2},
|
{x: x+tree.width+can.margin/8, y: y+tree.height*can.size/2},
|
||||||
{x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.size/2}
|
{x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.size/2}
|
||||||
], style: {stroke: cli.CYAN}})
|
], style: {stroke: cli.CYAN}})
|
||||||
|
|
||||||
can.onaction._draw_horizontal(can, item, x+tree.width+2*can.margin, y+offset)
|
can.onaction._draw_horizontal(can, item, x+tree.width+2*can.margin, y+offset)
|
||||||
offset += item.height*can.size
|
offset += item.height*can.size
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("ondetail", {help: "用户交互", list: [],
|
Volcanos("ondetail", {help: "用户交互", list: [],
|
||||||
onmouseenter: function(event, can, tree) { var y = tree.y+tree.height*can.size/2
|
onmouseenter: function(event, can, tree) { var y = tree.y+tree.height*can.size/2
|
||||||
can.page.Remove(can, can.pos), can.pos = can.onimport.draw({}, can, {
|
can.page.Remove(can, can.pos), can.pos = can.onimport.draw({}, can, {
|
||||||
shape: svg.RECT, point: [
|
shape: svg.RECT, point: [
|
||||||
{x: tree.x-can.margin/4, y: y-can.size/2},
|
{x: tree.x-can.margin/4, y: y-can.size/2},
|
||||||
{x: tree.x+tree.width+can.margin/8, y: y+can.size/2},
|
{x: tree.x+tree.width+can.margin/8, y: y+can.size/2},
|
||||||
], style: {stroke: cli.RED, fill: html.NONE},
|
], style: {stroke: cli.RED, fill: html.NONE},
|
||||||
}), can.onkeymap.prevent(event)
|
}), can.onkeymap.prevent(event)
|
||||||
},
|
},
|
||||||
onclick: function(event, can, tree) {
|
onclick: function(event, can, tree) {
|
||||||
if (tree.list.length > 0 || tree.tags || tree.name.endsWith(can._args.split)) {
|
if (tree.list.length > 0 || tree.tags || tree.name.endsWith(can._args.split)) {
|
||||||
return tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
return tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var node = tree; node; node = node.last) {
|
for (var node = tree; node; node = node.last) {
|
||||||
can.request(event, node.meta)
|
can.request(event, node.meta)
|
||||||
}
|
}
|
||||||
var msg = can.request(event, can.Option())
|
var msg = can.request(event, can.Option())
|
||||||
can.run(event, can.base.Obj(can._args.prefix, []).concat([can.Option("repos")||"", tree.file||"", tree.name]), function(msg) {
|
can.run(event, can.base.Obj(can._args.prefix, []).concat([can.Option("repos")||"", tree.file||"", tree.name]), function(msg) {
|
||||||
if (msg.Length() == 0) {
|
if (msg.Length() == 0) {
|
||||||
return can.ondetail.plugin(can, tree, {}, "web.code.inner", [can.dir_root, tree.file, tree.line], [ctx.ACTION, "inner"])
|
return can.ondetail.plugin(can, tree, {}, "web.code.inner", [can.dir_root, tree.file, tree.line], [ctx.ACTION, "inner"])
|
||||||
}
|
}
|
||||||
if (msg.Append(mdb.INDEX)) { msg.Table(function(value) {
|
if (msg.Append(mdb.INDEX)) { msg.Table(function(value) {
|
||||||
can.ondetail.plugin(can, tree, value, value.index, [], [ctx.ACTION, ice.RUN, value.index])
|
can.ondetail.plugin(can, tree, value, value.index, [], [ctx.ACTION, ice.RUN, value.index])
|
||||||
}); return }
|
}); return }
|
||||||
|
|
||||||
tree.tags = true
|
tree.tags = true
|
||||||
if (msg.Option("split")) {
|
if (msg.Option("split")) {
|
||||||
tree.list = can.onimport._tree(can, msg.Table(), msg.Option("field")||msg.append[0], msg.Option("split"))[""].list||[]
|
tree.list = can.onimport._tree(can, msg.Table(), msg.Option("field")||msg.append[0], msg.Option("split"))[""].list||[]
|
||||||
can.core.List(tree.list, function(item) { item.last = tree })
|
can.core.List(tree.list, function(item) { item.last = tree })
|
||||||
} else {
|
} else {
|
||||||
msg.Table(function(item) { tree.list.push({
|
msg.Table(function(item) { tree.list.push({
|
||||||
type: "tags", name: item.name||item.file||item[msg.append[0]],
|
type: "tags", name: item.name||item.file||item[msg.append[0]],
|
||||||
meta: item, list: [], last: tree,
|
meta: item, list: [], last: tree,
|
||||||
file: item.file, line: item.line, hide: true,
|
file: item.file, line: item.line, hide: true,
|
||||||
}) })
|
}) })
|
||||||
}
|
}
|
||||||
tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
|
|
||||||
plugin: function(can, tree, value, index, args, prefix) {
|
plugin: function(can, tree, value, index, args, prefix) {
|
||||||
for (var node = tree; node; node = node.last) {
|
for (var node = tree; node; node = node.last) {
|
||||||
can.base.Copy(value, node.meta)
|
can.base.Copy(value, node.meta)
|
||||||
}
|
}
|
||||||
can.onappend.plugin(can, can.base.Copy({type: chat.FLOAT, index: index, args: args}, value), function(sub) {
|
can.onappend.plugin(can, can.base.Copy({type: chat.FLOAT, index: index, args: args}, value), function(sub) {
|
||||||
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
||||||
can.run(event, can.misc.concat(can, prefix, cmds), cb, true)
|
can.run(event, can.misc.concat(can, prefix, cmds), cb, true)
|
||||||
}, can.ondetail.figure(can, sub)
|
}, can.ondetail.figure(can, sub)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
figure: function(can, sub, msg, cb) {
|
figure: function(can, sub, msg, cb) {
|
||||||
can.getActionSize(function(left, top, width, height) { left = left||0
|
can.getActionSize(function(left, top, width, height) { left = left||0
|
||||||
var top = 120, margin = 20; if (can.user.isMobile) { margin = 0
|
var top = 120, margin = 20; if (can.user.isMobile) { margin = 0
|
||||||
top = can.user.isLandscape()? 24: 48
|
top = can.user.isLandscape()? 24: 48
|
||||||
}
|
}
|
||||||
can.onmotion.move(can, sub._target, {position: html.FIXED, left: left+margin, top: top})
|
can.onmotion.move(can, sub._target, {position: html.FIXED, left: left+margin, top: top})
|
||||||
can.page.style(can, sub._output, html.MAX_WIDTH, width-margin*2)
|
can.page.style(can, sub._output, html.MAX_WIDTH, width-margin*2)
|
||||||
sub.Conf(html.HEIGHT, height-top-2*html.ACTION_HEIGHT)
|
sub.Conf(html.HEIGHT, height-top-2*html.ACTION_HEIGHT)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,153 +1,153 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
if (msg.Option("branch")) { return can.onappend.table(can, msg) }
|
if (msg.Option("branch")) { return can.onappend.table(can, msg) }
|
||||||
can.onappend._status(can, ["from", "commit", "total", "max", "date", "text", "add", "del"])
|
can.onappend._status(can, ["from", "commit", "total", "max", "date", "text", "add", "del"])
|
||||||
can.Conf(html.HEIGHT, can.Conf(html.HEIGHT)||200)
|
can.Conf(html.HEIGHT, can.Conf(html.HEIGHT)||200)
|
||||||
|
|
||||||
can.msg = msg, can.data = msg.Table(), can.onimport._sum(can)
|
can.msg = msg, can.data = msg.Table(), can.onimport._sum(can)
|
||||||
can.Action(html.HEIGHT, msg.Option(html.HEIGHT)||can.user.mod.isCmd? "max": can.user.isMobile&&can.user.isLandscape()? "200": "400")
|
can.Action(html.HEIGHT, msg.Option(html.HEIGHT)||can.user.mod.isCmd? "max": can.user.isMobile&&can.user.isLandscape()? "200": "400")
|
||||||
can.Action("speed", parseInt(msg.Option("speed")||"100"))
|
can.Action("speed", parseInt(msg.Option("speed")||"100"))
|
||||||
|
|
||||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||||
can.page.ClassList.add(can, can._fields, "draw")
|
can.page.ClassList.add(can, can._fields, "draw")
|
||||||
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
||||||
can.onaction[can.Action("view")](event, can)
|
can.onaction[can.Action("view")](event, can)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_sum: function(can) {
|
_sum: function(can) {
|
||||||
var begin = "", count = 0, rest = 0, add = 0, del = 0, max = 0
|
var begin = "", count = 0, rest = 0, add = 0, del = 0, max = 0
|
||||||
can.max = 0, can.min = 0, can.list = can.core.List(can.data, function(value, index) {
|
can.max = 0, can.min = 0, can.list = can.core.List(can.data, function(value, index) {
|
||||||
var line = {
|
var line = {
|
||||||
date: value[can.msg.append[0]],
|
date: value[can.msg.append[0]],
|
||||||
text: value[can.msg.append[4]],
|
text: value[can.msg.append[4]],
|
||||||
add: parseInt(value[can.msg.append[1]]),
|
add: parseInt(value[can.msg.append[1]]),
|
||||||
del: parseInt(value[can.msg.append[2]]),
|
del: parseInt(value[can.msg.append[2]]),
|
||||||
}
|
}
|
||||||
|
|
||||||
line.begin = rest
|
line.begin = rest
|
||||||
line.max = rest + line.add
|
line.max = rest + line.add
|
||||||
line.min = rest - line.del
|
line.min = rest - line.del
|
||||||
line.close = rest + line.add - line.del
|
line.close = rest + line.add - line.del
|
||||||
|
|
||||||
begin = begin || value.date, count++
|
begin = begin || value.date, count++
|
||||||
rest = line.close, add += line.add, del += line.del
|
rest = line.close, add += line.add, del += line.del
|
||||||
|
|
||||||
if (line.max - line.min > max) { max = line.max - line.min }
|
if (line.max - line.min > max) { max = line.max - line.min }
|
||||||
if (line.max > can.max) { can.max = line.max }
|
if (line.max > can.max) { can.max = line.max }
|
||||||
if (line.min < can.min) { can.min = line.min }
|
if (line.min < can.min) { can.min = line.min }
|
||||||
return line
|
return line
|
||||||
})
|
})
|
||||||
can.Status({"from": begin, "commit": count, "total": add+del, "max": max})
|
can.Status({"from": begin, "commit": count, "total": add+del, "max": max})
|
||||||
},
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "趋势图", "柱状图", "数据源"], ["height", "100", "200", "400", "600", "800", "max"], ["speed", "10", "20", "50", "100"]],
|
Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "趋势图", "柱状图", "数据源"], ["height", "100", "200", "400", "600", "800", "max"], ["speed", "10", "20", "50", "100"]],
|
||||||
"编辑": function(event, can) {
|
"编辑": function(event, can) {
|
||||||
can.onmotion.toggle(can, can._action)
|
can.onmotion.toggle(can, can._action)
|
||||||
can.onmotion.toggle(can, can._status)
|
can.onmotion.toggle(can, can._status)
|
||||||
},
|
},
|
||||||
"趋势图": function(event, can) { var height = can.Action(html.HEIGHT)
|
"趋势图": function(event, can) { var height = can.Action(html.HEIGHT)
|
||||||
if (height == "max") { height = can.Conf(html.HEIGHT) }
|
if (height == "max") { height = can.Conf(html.HEIGHT) }
|
||||||
height = parseInt(height)
|
height = parseInt(height)
|
||||||
|
|
||||||
var space = 10, width = parseInt(can.Conf(html.WIDTH))
|
var space = 10, width = parseInt(can.Conf(html.WIDTH))
|
||||||
var step = parseInt((width-2*space) / can.list.length)
|
var step = parseInt((width-2*space) / can.list.length)
|
||||||
|
|
||||||
can.onmotion.clear(can, can.svg)
|
can.onmotion.clear(can, can.svg)
|
||||||
can.svg.Val(html.HEIGHT, height)
|
can.svg.Val(html.HEIGHT, height)
|
||||||
can.svg.Val(html.WIDTH, width)
|
can.svg.Val(html.WIDTH, width)
|
||||||
|
|
||||||
function scale(y) { return (y - can.min)/(can.max - can.min)*(height-2*space) }
|
function scale(y) { return (y - can.min)/(can.max - can.min)*(height-2*space) }
|
||||||
function order(index, x, y) { return {x: space+step*index+x, y: height-space-scale(y)} }
|
function order(index, x, y) { return {x: space+step*index+x, y: height-space-scale(y)} }
|
||||||
|
|
||||||
can.core.Next(can.list, function(line, next, index) { can.Status(line, ["date", "text", "add", "del"])
|
can.core.Next(can.list, function(line, next, index) { can.Status(line, ["date", "text", "add", "del"])
|
||||||
can.onimport.draw({}, can, {
|
can.onimport.draw({}, can, {
|
||||||
shape: "line", point: [
|
shape: "line", point: [
|
||||||
order(index, step/2, line.min), order(index, step/2, line.max),
|
order(index, step/2, line.min), order(index, step/2, line.max),
|
||||||
], style: {
|
], style: {
|
||||||
"stroke-width": 1, "stroke": line.begin < line.close? chat.WHITE: chat.BLACK,
|
"stroke-width": 1, "stroke": line.begin < line.close? chat.WHITE: chat.BLACK,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
can.onimport.draw({}, can, {
|
can.onimport.draw({}, can, {
|
||||||
shape: "rect", point: [
|
shape: "rect", point: [
|
||||||
order(index, step/4, line.close), order(index, step/4*3, line.begin),
|
order(index, step/4, line.close), order(index, step/4*3, line.begin),
|
||||||
], style: can.base.Copy({"stroke-width": 1, "rx": 0, "ry": 0}, line.begin < line.close? {
|
], style: can.base.Copy({"stroke-width": 1, "rx": 0, "ry": 0}, line.begin < line.close? {
|
||||||
"stroke": chat.WHITE, "fill": chat.WHITE,
|
"stroke": chat.WHITE, "fill": chat.WHITE,
|
||||||
}: {
|
}: {
|
||||||
"stroke": chat.BLACK, "fill": chat.BLACK,
|
"stroke": chat.BLACK, "fill": chat.BLACK,
|
||||||
}),
|
}),
|
||||||
_init: function(view) {
|
_init: function(view) {
|
||||||
can.core.ItemCB(can.ondetail, function(key, cb) {
|
can.core.ItemCB(can.ondetail, function(key, cb) {
|
||||||
view[key] = function(event) { cb(event, can, line) }
|
view[key] = function(event) { cb(event, can, line) }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
can.core.Timer(parseInt(can.Action("speed")), next)
|
can.core.Timer(parseInt(can.Action("speed")), next)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"柱状图": function(event, can) {
|
"柱状图": function(event, can) {
|
||||||
var max = {}, min = {}
|
var max = {}, min = {}
|
||||||
can.core.List(can.msg.append, function(key, which) {
|
can.core.List(can.msg.append, function(key, which) {
|
||||||
can.core.List(can.data, function(value, index) {
|
can.core.List(can.data, function(value, index) {
|
||||||
var v = parseInt(value[key])||0; if (index == 0) {
|
var v = parseInt(value[key])||0; if (index == 0) {
|
||||||
max[key] = v, min[key] = v
|
max[key] = v, min[key] = v
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (v > max[key]) { max[key] = v }
|
if (v > max[key]) { max[key] = v }
|
||||||
if (v < min[key]) { min[key] = v }
|
if (v < min[key]) { min[key] = v }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
var height = parseInt(can.Action(html.HEIGHT))
|
var height = parseInt(can.Action(html.HEIGHT))
|
||||||
var space = 10, width = parseInt(can.Conf(html.WIDTH))
|
var space = 10, width = parseInt(can.Conf(html.WIDTH))
|
||||||
var step = parseInt((width-2*space) / can.list.length)
|
var step = parseInt((width-2*space) / can.list.length)
|
||||||
|
|
||||||
can.onmotion.clear(can, can.svg)
|
can.onmotion.clear(can, can.svg)
|
||||||
can.svg.Val(html.HEIGHT, height)
|
can.svg.Val(html.HEIGHT, height)
|
||||||
can.svg.Val(html.WIDTH, width)
|
can.svg.Val(html.WIDTH, width)
|
||||||
|
|
||||||
function scale(key, y) { return (y - min[key])/(max[key] - min[key])*(height-2*space) }
|
function scale(key, y) { return (y - min[key])/(max[key] - min[key])*(height-2*space) }
|
||||||
function order(index, key, x, y) { return {x: space+step*index+x, y: space+scale(key, y)} }
|
function order(index, key, x, y) { return {x: space+step*index+x, y: space+scale(key, y)} }
|
||||||
|
|
||||||
var width = (step-4)/can.msg.append.length
|
var width = (step-4)/can.msg.append.length
|
||||||
can.core.List(can.msg.append, function(key, which) {
|
can.core.List(can.msg.append, function(key, which) {
|
||||||
max[key] != min[key] && can.core.Next(can.data, function(line, next, index) {
|
max[key] != min[key] && can.core.Next(can.data, function(line, next, index) {
|
||||||
var y = scale(key, parseFloat(line[key]))
|
var y = scale(key, parseFloat(line[key]))
|
||||||
y && can.onimport.draw({}, can, {
|
y && can.onimport.draw({}, can, {
|
||||||
shape: "rect", point: [
|
shape: "rect", point: [
|
||||||
order(index, key, width*which+2, 0), order(index, key, width*which+2+width, y),
|
order(index, key, width*which+2, 0), order(index, key, width*which+2+width, y),
|
||||||
], style: {
|
], style: {
|
||||||
"stroke-width": 1, "stroke": chat.WHITE, "fill": chat.WHITE, "rx": 0, "ry": 0,
|
"stroke-width": 1, "stroke": chat.WHITE, "fill": chat.WHITE, "rx": 0, "ry": 0,
|
||||||
},
|
},
|
||||||
_init: function(view) {
|
_init: function(view) {
|
||||||
can.core.ItemCB(can.ondetail, function(key, cb) {
|
can.core.ItemCB(can.ondetail, function(key, cb) {
|
||||||
view[key] = function(event) { cb(event, can, line) }
|
view[key] = function(event) { cb(event, can, line) }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
can.core.Timer(parseInt(can.Action("speed")), next)
|
can.core.Timer(parseInt(can.Action("speed")), next)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"数据源": function(event, can) {
|
"数据源": function(event, can) {
|
||||||
can.onmotion.clear(can, can.ui.display)
|
can.onmotion.clear(can, can.ui.display)
|
||||||
can.onappend.table(can, can.msg, null, can.ui.display)
|
can.onappend.table(can, can.msg, null, can.ui.display)
|
||||||
can.onmotion.show(can, can.ui.display)
|
can.onmotion.show(can, can.ui.display)
|
||||||
},
|
},
|
||||||
|
|
||||||
height: function(event, can) {
|
height: function(event, can) {
|
||||||
can.onaction[can.Action("view")](event, can)
|
can.onaction[can.Action("view")](event, can)
|
||||||
},
|
},
|
||||||
speed: function(event, can) {
|
speed: function(event, can) {
|
||||||
can.onaction[can.Action("view")](event, can)
|
can.onaction[can.Action("view")](event, can)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("ondetail", {help: "用户交互", list: [],
|
Volcanos("ondetail", {help: "用户交互", list: [],
|
||||||
onmouseenter: function(event, can, line) {
|
onmouseenter: function(event, can, line) {
|
||||||
can.Status(line, ["date", "text", "add", "del"])
|
can.Status(line, ["date", "text", "add", "del"])
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: []})
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.onimport.select(can, msg)
|
can.onimport.select(can, msg)
|
||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
can.onappend.table(can, msg), can.onappend.board(can, msg)
|
can.onappend.table(can, msg), can.onappend.board(can, msg)
|
||||||
can.core.Timer(12000, function() { can.onaction.play(event, can) })
|
can.core.Timer(12000, function() { can.onaction.play(event, can) })
|
||||||
can.page.Select(can, can._output, "td a", function(a) {
|
can.page.Select(can, can._output, "td a", function(a) {
|
||||||
can.page.Modify(can, a, {target: ""})
|
can.page.Modify(can, a, {target: ""})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
select: function(can, msg) {
|
select: function(can, msg) {
|
||||||
msg.Clear(), can.page.Select(can, document.body, can.Option("tags"), function(a, index) {
|
msg.Clear(), can.page.Select(can, document.body, can.Option("tags"), function(a, index) {
|
||||||
msg.Push(mdb.INDEX, index)
|
msg.Push(mdb.INDEX, index)
|
||||||
msg.Push(mdb.NAME, a.innerText)
|
msg.Push(mdb.NAME, a.innerText)
|
||||||
msg.Push(mdb.LINK, a.href)
|
msg.Push(mdb.LINK, a.href)
|
||||||
a.href == location.href && can.core.Timer(100, function() {
|
a.href == location.href && can.core.Timer(100, function() {
|
||||||
can.page.Select(can, can._output, html.TR, function(tr, i) {
|
can.page.Select(can, can._output, html.TR, function(tr, i) {
|
||||||
i-1 == index && can.page.ClassList.add(can, tr, "select")
|
i-1 == index && can.page.ClassList.add(can, tr, "select")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
msg.Option(ice.MSG_STATUS, JSON.stringify([
|
msg.Option(ice.MSG_STATUS, JSON.stringify([
|
||||||
{name: "time", value: can.base.Time(null, "%y-%m-%d %H:%M:%S")},
|
{name: "time", value: can.base.Time(null, "%y-%m-%d %H:%M:%S")},
|
||||||
{name: "count", value: msg.Length()},
|
{name: "count", value: msg.Length()},
|
||||||
]))
|
]))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "控件交互", list: [],
|
Volcanos("onaction", {help: "控件交互", list: [],
|
||||||
next: function(event, can) { var msg = can._msg
|
next: function(event, can) { var msg = can._msg
|
||||||
msg.Table(function(line, index) {
|
msg.Table(function(line, index) {
|
||||||
if (line.link == location.href) {
|
if (line.link == location.href) {
|
||||||
location.href = msg.link[index+1]
|
location.href = msg.link[index+1]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
play: function(event, can) {
|
play: function(event, can) {
|
||||||
can.page.SelectAll(can, document.body, html.VIDEO, function(video) {
|
can.page.SelectAll(can, document.body, html.VIDEO, function(video) {
|
||||||
video.playbackRate = parseFloat(can.Option("rate"))
|
video.playbackRate = parseFloat(can.Option("rate"))
|
||||||
video.currentTime = parseInt(can.Option("skip"))
|
video.currentTime = parseInt(can.Option("skip"))
|
||||||
video.ontimeupdate = function(event) {
|
video.ontimeupdate = function(event) {
|
||||||
if (video.currentTime > parseInt(can.Option("next"))) {
|
if (video.currentTime > parseInt(can.Option("next"))) {
|
||||||
can.onaction.next(event, can)
|
can.onaction.next(event, can)
|
||||||
}
|
}
|
||||||
}, video.play(), video.requestFullscreen()
|
}, video.play(), video.requestFullscreen()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: []})
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
||||||
can.onmotion.clear(can)
|
can.onmotion.clear(can)
|
||||||
can.onappend.table(can, msg)
|
can.onappend.table(can, msg)
|
||||||
can.onappend.board(can, msg)
|
can.onappend.board(can, msg)
|
||||||
can.onmotion.story.auto(can)
|
can.onmotion.story.auto(can)
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
},
|
},
|
||||||
|
|
||||||
_process: function(can, msg) {
|
_process: function(can, msg) {
|
||||||
msg.Option(ice.MSG_TOAST) && can.user.toast(can, msg.Option(ice.MSG_TOAST))
|
msg.Option(ice.MSG_TOAST) && can.user.toast(can, msg.Option(ice.MSG_TOAST))
|
||||||
return can.core.CallFunc([can.onimport, msg.Option(ice.MSG_PROCESS)], [can, msg])
|
return can.core.CallFunc([can.onimport, msg.Option(ice.MSG_PROCESS)], [can, msg])
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "控件交互", list: []})
|
Volcanos("onaction", {help: "控件交互", list: []})
|
||||||
Volcanos("onexport", {help: "导出数据", list: []})
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
614
proto.js
614
proto.js
@ -1,398 +1,398 @@
|
|||||||
var kit = {
|
var kit = {
|
||||||
Dict: function() { var res = {}
|
Dict: function() { var res = {}
|
||||||
for (var i = 0; i < arguments.length; i += 2) {
|
for (var i = 0; i < arguments.length; i += 2) {
|
||||||
res[arguments[i]] = arguments[i+1]
|
res[arguments[i]] = arguments[i+1]
|
||||||
} return res
|
} return res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ice = {
|
var ice = {
|
||||||
SP: " ", PS: "/", PT: ".", DF: ":", FS: ",", NL: "\n", LT: "<", GT: ">",
|
SP: " ", PS: "/", PT: ".", DF: ":", FS: ",", NL: "\n", LT: "<", GT: ">",
|
||||||
POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg", OPT: "opt",
|
POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg", OPT: "opt",
|
||||||
RUN: "run", RES: "res", ERR: "err",
|
RUN: "run", RES: "res", ERR: "err",
|
||||||
|
|
||||||
OK: "ok", TRUE: "true", FALSE: "false", SUCCESS: "success", FAILURE: "failure", PROCESS: "process",
|
OK: "ok", TRUE: "true", FALSE: "false", SUCCESS: "success", FAILURE: "failure", PROCESS: "process",
|
||||||
PWD: "./",
|
PWD: "./",
|
||||||
|
|
||||||
AUTO: "auto", HELP: "help", HTTP: "http",
|
AUTO: "auto", HELP: "help", HTTP: "http",
|
||||||
VIEW: "view", MODE: "mode", SHIP: "ship",
|
VIEW: "view", MODE: "mode", SHIP: "ship",
|
||||||
COPY: "copy", SHOW: "show", HIDE: "hide",
|
COPY: "copy", SHOW: "show", HIDE: "hide",
|
||||||
|
|
||||||
MSG_DETAIL: "detail",
|
MSG_DETAIL: "detail",
|
||||||
MSG_OPTION: "option",
|
MSG_OPTION: "option",
|
||||||
MSG_APPEND: "append",
|
MSG_APPEND: "append",
|
||||||
MSG_RESULT: "result",
|
MSG_RESULT: "result",
|
||||||
MSG_FIELDS: "fields",
|
MSG_FIELDS: "fields",
|
||||||
MSG_SESSID: "sessid",
|
MSG_SESSID: "sessid",
|
||||||
|
|
||||||
MSG_SOURCE: "_source",
|
MSG_SOURCE: "_source",
|
||||||
MSG_TARGET: "_target",
|
MSG_TARGET: "_target",
|
||||||
MSG_HANDLE: "_handle",
|
MSG_HANDLE: "_handle",
|
||||||
MSG_UPLOAD: "_upload",
|
MSG_UPLOAD: "_upload",
|
||||||
MSG_DAEMON: "_daemon",
|
MSG_DAEMON: "_daemon",
|
||||||
MSG_ACTION: "_action",
|
MSG_ACTION: "_action",
|
||||||
MSG_STATUS: "_status",
|
MSG_STATUS: "_status",
|
||||||
|
|
||||||
MSG_DISPLAY: "_display",
|
MSG_DISPLAY: "_display",
|
||||||
MSG_PROCESS: "_process",
|
MSG_PROCESS: "_process",
|
||||||
|
|
||||||
MSG_USERNAME: "user.name",
|
MSG_USERNAME: "user.name",
|
||||||
MSG_USERNICK: "user.nick",
|
MSG_USERNICK: "user.nick",
|
||||||
|
|
||||||
MSG_TITLE: "sess.title",
|
MSG_TITLE: "sess.title",
|
||||||
MSG_TOPIC: "sess.topic",
|
MSG_TOPIC: "sess.topic",
|
||||||
MSG_RIVER: "sess.river",
|
MSG_RIVER: "sess.river",
|
||||||
MSG_STORM: "sess.storm",
|
MSG_STORM: "sess.storm",
|
||||||
MSG_TOAST: "sess.toast",
|
MSG_TOAST: "sess.toast",
|
||||||
|
|
||||||
PROCESS_AGAIN: "_again",
|
PROCESS_AGAIN: "_again",
|
||||||
MSG_PREFIX: "_prefix",
|
MSG_PREFIX: "_prefix",
|
||||||
|
|
||||||
ErrWarn: "warn: ",
|
ErrWarn: "warn: ",
|
||||||
ErrNotFound: "not found: ",
|
ErrNotFound: "not found: ",
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctx = {
|
var ctx = {
|
||||||
CONTEXT: "context", COMMAND: "command", ACTION: "action", CONFIG: "config",
|
CONTEXT: "context", COMMAND: "command", ACTION: "action", CONFIG: "config",
|
||||||
INDEX: "index", ARGS: "args", STYLE: "style",
|
INDEX: "index", ARGS: "args", STYLE: "style",
|
||||||
INPUTS: "inputs", FEATURE: "feature",
|
INPUTS: "inputs", FEATURE: "feature",
|
||||||
}
|
}
|
||||||
var cli = {
|
var cli = {
|
||||||
CODE: "code", COST: "cost", FROM: "from", BACK: "back",
|
CODE: "code", COST: "cost", FROM: "from", BACK: "back",
|
||||||
OPEN: "open", CLOSE: "close", BEGIN: "begin", END: "end",
|
OPEN: "open", CLOSE: "close", BEGIN: "begin", END: "end",
|
||||||
START: "start", STOP: "stop", DONE: "done", ERROR: "error",
|
START: "start", STOP: "stop", DONE: "done", ERROR: "error",
|
||||||
CLEAR: "clear", REFRESH: "refresh",
|
CLEAR: "clear", REFRESH: "refresh",
|
||||||
EXEC: "exec",
|
EXEC: "exec",
|
||||||
SHOW: "show",
|
SHOW: "show",
|
||||||
MAIN: "main",
|
MAIN: "main",
|
||||||
MAKE: "make",
|
MAKE: "make",
|
||||||
|
|
||||||
RED: "red", GREEN: "green", BLUE: "blue",
|
RED: "red", GREEN: "green", BLUE: "blue",
|
||||||
YELLOW: "yellow", CYAN: "cyan", PURPLE: "purple", MAGENTA: "magenta",
|
YELLOW: "yellow", CYAN: "cyan", PURPLE: "purple", MAGENTA: "magenta",
|
||||||
WHITE: "white", BLACK: "black",
|
WHITE: "white", BLACK: "black",
|
||||||
}
|
}
|
||||||
var web = {
|
var web = {
|
||||||
SPACE: "space", SHARE: "share",
|
SPACE: "space", SHARE: "share",
|
||||||
}
|
}
|
||||||
var aaa = {
|
var aaa = {
|
||||||
USERNAME: "username", USERNICK: "usernick", BACKGROUND: "background", AVATAR: "avatar",
|
USERNAME: "username", USERNICK: "usernick", BACKGROUND: "background", AVATAR: "avatar",
|
||||||
LANGUAGE: "language", ENGLISH: "english", CHINESE: "chinese",
|
LANGUAGE: "language", ENGLISH: "english", CHINESE: "chinese",
|
||||||
LOGIN: "login", LOGOUT: "logout", INVITE: "invite",
|
LOGIN: "login", LOGOUT: "logout", INVITE: "invite",
|
||||||
}
|
}
|
||||||
var mdb = {
|
var mdb = {
|
||||||
DICT: "dict", META: "meta", HASH: "hash", LIST: "list",
|
DICT: "dict", META: "meta", HASH: "hash", LIST: "list",
|
||||||
|
|
||||||
ID: "id", KEY: "key", TIME: "time", ZONE: "zone", TYPE: "type", NAME: "name", TEXT: "text",
|
ID: "id", KEY: "key", TIME: "time", ZONE: "zone", TYPE: "type", NAME: "name", TEXT: "text",
|
||||||
LINK: "link", SCAN: "scan", SHOW: "show", HELP: "help",
|
LINK: "link", SCAN: "scan", SHOW: "show", HELP: "help",
|
||||||
SHORT: "short", FIELD: "field", TOTAL: "total", COUNT: "count", LIMIT: "limit",
|
SHORT: "short", FIELD: "field", TOTAL: "total", COUNT: "count", LIMIT: "limit",
|
||||||
INDEX: "index", VALUE: "value", EXTRA: "extra", ALIAS: "alias", EXPIRE: "expire",
|
INDEX: "index", VALUE: "value", EXTRA: "extra", ALIAS: "alias", EXPIRE: "expire",
|
||||||
|
|
||||||
CREATE: "create", REMOVE: "remove", INSERT: "insert", DELETE: "delete",
|
CREATE: "create", REMOVE: "remove", INSERT: "insert", DELETE: "delete",
|
||||||
MODIFY: "modify", SELECT: "select",
|
MODIFY: "modify", SELECT: "select",
|
||||||
INPUTS: "inputs", PRUNES: "prunes", EXPORT: "export", IMPORT: "import",
|
INPUTS: "inputs", PRUNES: "prunes", EXPORT: "export", IMPORT: "import",
|
||||||
|
|
||||||
PLUGIN: "plugin", RENDER: "render", SEARCH: "search", ENGINE: "engine",
|
PLUGIN: "plugin", RENDER: "render", SEARCH: "search", ENGINE: "engine",
|
||||||
NEXT: "next", PREV: "prev", PAGE: "page", MAIN: "main",
|
NEXT: "next", PREV: "prev", PAGE: "page", MAIN: "main",
|
||||||
|
|
||||||
FOREACH: "*", RANDOMS: "%",
|
FOREACH: "*", RANDOMS: "%",
|
||||||
}
|
}
|
||||||
var ssh = {
|
var ssh = {
|
||||||
SCRIPT: "script",
|
SCRIPT: "script",
|
||||||
}
|
}
|
||||||
var nfs = {
|
var nfs = {
|
||||||
DEFS: "defs",
|
DEFS: "defs",
|
||||||
HTML: "html", CSS: "css", JS: "js", GO: "go", SH: "sh", CSV: "csv", JSON: "json",
|
HTML: "html", CSS: "css", JS: "js", GO: "go", SH: "sh", CSV: "csv", JSON: "json",
|
||||||
PATH: "path", FILE: "file", LINE: "line", SIZE: "size",
|
PATH: "path", FILE: "file", LINE: "line", SIZE: "size",
|
||||||
DIR: "dir", CAT: "cat", TRASH: "trash",
|
DIR: "dir", CAT: "cat", TRASH: "trash",
|
||||||
DIR_ROOT: "dir_root",
|
DIR_ROOT: "dir_root",
|
||||||
FIND: "find", GREP: "grep",
|
FIND: "find", GREP: "grep",
|
||||||
SAVE: "save", LOAD: "load",
|
SAVE: "save", LOAD: "load",
|
||||||
TAGS: "tags",
|
TAGS: "tags",
|
||||||
}
|
}
|
||||||
var tcp = {
|
var tcp = {
|
||||||
HOST: "host", PORT: "port",
|
HOST: "host", PORT: "port",
|
||||||
}
|
}
|
||||||
|
|
||||||
var code = {
|
var code = {
|
||||||
VIMER: "vimer", INNER: "inner", FAVOR: "favor",
|
VIMER: "vimer", INNER: "inner", FAVOR: "favor",
|
||||||
WEBPACK: "webpack",
|
WEBPACK: "webpack",
|
||||||
}
|
}
|
||||||
var wiki = {
|
var wiki = {
|
||||||
TITLE: "title", BRIEF: "brief", REFER: "refer", SPARK: "spark",
|
TITLE: "title", BRIEF: "brief", REFER: "refer", SPARK: "spark",
|
||||||
ORDER: "order", TABLE: "table", CHART: "chart", IMAGE: "image", VIDEO: "video",
|
ORDER: "order", TABLE: "table", CHART: "chart", IMAGE: "image", VIDEO: "video",
|
||||||
FIELD: "field", SHELL: "shell", LOCAL: "local", PARSE: "parse",
|
FIELD: "field", SHELL: "shell", LOCAL: "local", PARSE: "parse",
|
||||||
|
|
||||||
NAVMENU: "navmenu", PREMENU: "premenu",
|
NAVMENU: "navmenu", PREMENU: "premenu",
|
||||||
|
|
||||||
ITEM: ".story",
|
ITEM: ".story",
|
||||||
H2: "h2.story",
|
H2: "h2.story",
|
||||||
H3: "h3.story",
|
H3: "h3.story",
|
||||||
DIV_PAGE: "div.page",
|
DIV_PAGE: "div.page",
|
||||||
}
|
}
|
||||||
var chat = {ONIMPORT: "onimport", ONACTION: "onaction", ONKEYMAP: "onkeymap", ONEXPORT: "onexport",
|
var chat = {ONIMPORT: "onimport", ONACTION: "onaction", ONKEYMAP: "onkeymap", ONEXPORT: "onexport",
|
||||||
LIB: "lib", PAGE: "page", PANEL: "panel", PLUGIN: "plugin", OUTPUT: "output", INPUT: "input", UPLOAD: "upload",
|
LIB: "lib", PAGE: "page", PANEL: "panel", PLUGIN: "plugin", OUTPUT: "output", INPUT: "input", UPLOAD: "upload",
|
||||||
STORY: "story", FLOAT: "float", CONTEXTS: "contexts", CARTE: "carte", TOAST: "toast",
|
STORY: "story", FLOAT: "float", CONTEXTS: "contexts", CARTE: "carte", TOAST: "toast",
|
||||||
LEGNED: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status",
|
LEGNED: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status",
|
||||||
LAYOUT: "layout", PROJECT: "project", CONTENT: "content", DISPLAY: "display", PROFILE: "profile",
|
LAYOUT: "layout", PROJECT: "project", CONTENT: "content", DISPLAY: "display", PROFILE: "profile",
|
||||||
|
|
||||||
TITLE: "title", TOPIC: "topic", BLACK: "black", WHITE: "white", PRINT: "print",
|
TITLE: "title", TOPIC: "topic", BLACK: "black", WHITE: "white", PRINT: "print",
|
||||||
SHARE: "share", RIVER: "river", STORM: "storm", FIELD: "field", TOAST: "toast",
|
SHARE: "share", RIVER: "river", STORM: "storm", FIELD: "field", TOAST: "toast",
|
||||||
PUBLIC: "public", PROTECTED: "protected", PRIVATE: "private",
|
PUBLIC: "public", PROTECTED: "protected", PRIVATE: "private",
|
||||||
USER: "user", TOOL: "tool", NODE: "node",
|
USER: "user", TOOL: "tool", NODE: "node",
|
||||||
|
|
||||||
AGENT: "agent", CHECK: "check", GRANT: "grant",
|
AGENT: "agent", CHECK: "check", GRANT: "grant",
|
||||||
STATE: "state", MENUS: "menus", TRANS: "trans",
|
STATE: "state", MENUS: "menus", TRANS: "trans",
|
||||||
|
|
||||||
ONMAIN: "onmain", ONLOGIN: "onlogin", ONSEARCH: "onsearch",
|
ONMAIN: "onmain", ONLOGIN: "onlogin", ONSEARCH: "onsearch",
|
||||||
ONSIZE: "onsize", ONTOAST: "ontoast", ONREMOTE: "onremote",
|
ONSIZE: "onsize", ONTOAST: "ontoast", ONREMOTE: "onremote",
|
||||||
ONKEYDOWN: "onkeydown",
|
ONKEYDOWN: "onkeydown",
|
||||||
|
|
||||||
HEAD: "head", LEFT: "left", MAIN: "main", AUTO: "auto", HIDE: "hide", FOOT: "foot",
|
HEAD: "head", LEFT: "left", MAIN: "main", AUTO: "auto", HIDE: "hide", FOOT: "foot",
|
||||||
SCROLL: "scroll", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom",
|
SCROLL: "scroll", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom",
|
||||||
HEADER: "header", FOOTER: "footer",
|
HEADER: "header", FOOTER: "footer",
|
||||||
|
|
||||||
TABS: "tabs", DIV_TABS: "div.tabs",
|
TABS: "tabs", DIV_TABS: "div.tabs",
|
||||||
|
|
||||||
SSO: "sso",
|
SSO: "sso",
|
||||||
|
|
||||||
PLUGIN_STATE_JS: "/plugin/state.js",
|
PLUGIN_STATE_JS: "/plugin/state.js",
|
||||||
PLUGIN_INPUT_JS: "/plugin/input.js",
|
PLUGIN_INPUT_JS: "/plugin/input.js",
|
||||||
PLUGIN_TABLE_JS: "/plugin/table.js",
|
PLUGIN_TABLE_JS: "/plugin/table.js",
|
||||||
|
|
||||||
libs: ["/lib/base.js", "/lib/core.js", "/lib/misc.js", "/lib/page.js", "/lib/user.js"],
|
libs: ["/lib/base.js", "/lib/core.js", "/lib/misc.js", "/lib/page.js", "/lib/user.js"],
|
||||||
panel_list: [
|
panel_list: [
|
||||||
{name: "Header", help: "标题栏", pos: "head", state: ["time", "usernick", "avatar"]},
|
{name: "Header", help: "标题栏", pos: "head", state: ["time", "usernick", "avatar"]},
|
||||||
{name: "River", help: "群聊组", pos: "left", action: ["create", "refresh"]},
|
{name: "River", help: "群聊组", pos: "left", action: ["create", "refresh"]},
|
||||||
{name: "Action", help: "工作台", pos: "main"},
|
{name: "Action", help: "工作台", pos: "main"},
|
||||||
{name: "Search", help: "搜索框", pos: "auto"},
|
{name: "Search", help: "搜索框", pos: "auto"},
|
||||||
{name: "Footer", help: "状态条", pos: "foot", state: ["ncmd"]},
|
{name: "Footer", help: "状态条", pos: "foot", state: ["ncmd"]},
|
||||||
],
|
],
|
||||||
plugin_list: [
|
plugin_list: [
|
||||||
"/plugin/state.js",
|
"/plugin/state.js",
|
||||||
"/plugin/input.js",
|
"/plugin/input.js",
|
||||||
"/plugin/table.js",
|
"/plugin/table.js",
|
||||||
"/plugin/input/key.js",
|
"/plugin/input/key.js",
|
||||||
"/plugin/input/date.js",
|
"/plugin/input/date.js",
|
||||||
"/plugin/story/spide.js",
|
"/plugin/story/spide.js",
|
||||||
"/plugin/story/trend.js",
|
"/plugin/story/trend.js",
|
||||||
"/plugin/local/code/inner.js",
|
"/plugin/local/code/inner.js",
|
||||||
"/plugin/local/code/vimer.js",
|
"/plugin/local/code/vimer.js",
|
||||||
"/plugin/local/wiki/draw/path.js",
|
"/plugin/local/wiki/draw/path.js",
|
||||||
"/plugin/local/wiki/draw.js",
|
"/plugin/local/wiki/draw.js",
|
||||||
"/plugin/local/wiki/word.js",
|
"/plugin/local/wiki/word.js",
|
||||||
"/plugin/local/chat/div.js",
|
"/plugin/local/chat/div.js",
|
||||||
"/plugin/local/team/plan.js",
|
"/plugin/local/team/plan.js",
|
||||||
"/plugin/input/province.js",
|
"/plugin/input/province.js",
|
||||||
],
|
],
|
||||||
ACTION_LAYOUT_FMT: `
|
ACTION_LAYOUT_FMT: `
|
||||||
fieldset.Action.grid>div.output fieldset.plugin {
|
fieldset.Action.grid>div.output fieldset.plugin {
|
||||||
width:_width; height:_height;
|
width:_width; height:_height;
|
||||||
}
|
}
|
||||||
fieldset.Action.grid>div.output fieldset.plugin>div.output {
|
fieldset.Action.grid>div.output fieldset.plugin>div.output {
|
||||||
width:_width; height:_height;
|
width:_width; height:_height;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
var team = {
|
var team = {
|
||||||
TASK: "task", PLAN: "plan",
|
TASK: "task", PLAN: "plan",
|
||||||
}
|
}
|
||||||
var mall = {
|
var mall = {
|
||||||
ASSET: "asset", SALARY: "salary",
|
ASSET: "asset", SALARY: "salary",
|
||||||
}
|
}
|
||||||
|
|
||||||
var svg = {
|
var svg = {
|
||||||
G: "g", X: "x", Y: "y", R: "r", RECT: "rect",
|
G: "g", X: "x", Y: "y", R: "r", RECT: "rect",
|
||||||
M: "M", Q: "Q", T: "T",
|
M: "M", Q: "Q", T: "T",
|
||||||
}
|
}
|
||||||
var html = {
|
var html = {
|
||||||
FIELDSET: "fieldset", LEGEND: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status",
|
FIELDSET: "fieldset", LEGEND: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status",
|
||||||
FORM_OPTION: "form.option", DIV_ACTION: "div.action", DIV_OUTPUT: "div.output", DIV_STATUS: "div.status",
|
FORM_OPTION: "form.option", DIV_ACTION: "div.action", DIV_OUTPUT: "div.output", DIV_STATUS: "div.status",
|
||||||
FIELDSET_PANEL: "fieldset.panel", FIELDSET_PLUGIN: "fieldset.plugin", FIELDSET_STORY: "fieldset.story",
|
FIELDSET_PANEL: "fieldset.panel", FIELDSET_PLUGIN: "fieldset.plugin", FIELDSET_STORY: "fieldset.story",
|
||||||
|
|
||||||
FIELDSET_HEAD: "fieldset.head", FIELDSET_FOOT: "fieldset.foot",
|
FIELDSET_HEAD: "fieldset.head", FIELDSET_FOOT: "fieldset.foot",
|
||||||
FIELDSET_LEFT: "fieldset.left", FIELDSET_MAIN: "fieldset.main",
|
FIELDSET_LEFT: "fieldset.left", FIELDSET_MAIN: "fieldset.main",
|
||||||
FIELDSET_AUTO: "fieldset.auto", FIELDSET_FLOAT: "fieldset.float",
|
FIELDSET_AUTO: "fieldset.auto", FIELDSET_FLOAT: "fieldset.float",
|
||||||
|
|
||||||
OPTION_ARGS: "select.args,input.args,textarea.args",
|
OPTION_ARGS: "select.args,input.args,textarea.args",
|
||||||
INPUT_ARGS: "input.args,textarea.args",
|
INPUT_ARGS: "input.args,textarea.args",
|
||||||
DIV_ITEM: "div.item", DIV_FLOAT: "div.float",
|
DIV_ITEM: "div.item", DIV_FLOAT: "div.float",
|
||||||
|
|
||||||
INPUT_BUTTON: "input[type=button]",
|
INPUT_BUTTON: "input[type=button]",
|
||||||
UPLOAD: "upload", USERNAME: "username", PASSWORD: "password",
|
UPLOAD: "upload", USERNAME: "username", PASSWORD: "password",
|
||||||
INPUT: "input", TEXT: "text", TEXTAREA: "textarea", SELECT: "select", BUTTON: "button",
|
INPUT: "input", TEXT: "text", TEXTAREA: "textarea", SELECT: "select", BUTTON: "button",
|
||||||
FORM: "form", FILE: "file", SPACE: "space", CLICK: "click", SUBMIT: "submit", CANCEL: "cancel",
|
FORM: "form", FILE: "file", SPACE: "space", CLICK: "click", SUBMIT: "submit", CANCEL: "cancel",
|
||||||
DIV: "div", IMG: "img", CODE: "code", SPAN: "span", VIDEO: "video",
|
DIV: "div", IMG: "img", CODE: "code", SPAN: "span", VIDEO: "video",
|
||||||
TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br", UL: "ul", LI: "li",
|
TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br", UL: "ul", LI: "li",
|
||||||
A: "a", LABEL: "label", INNER: "inner", TITLE: "title",
|
A: "a", LABEL: "label", INNER: "inner", TITLE: "title",
|
||||||
|
|
||||||
CLASS: "class", FLOAT: "float", CLEAR: "clear", BOTH: "both",
|
CLASS: "class", FLOAT: "float", CLEAR: "clear", BOTH: "both",
|
||||||
BACKGROUND: "background", SELECT: "select", HIDDEN: "hidden",
|
BACKGROUND: "background", SELECT: "select", HIDDEN: "hidden",
|
||||||
DISPLAY: "display", BLOCK: "block", NONE: "none",
|
DISPLAY: "display", BLOCK: "block", NONE: "none",
|
||||||
STROKE_WIDTH: "stroke-width", STROKE: "stroke", FILL: "fill", FONT_SIZE: "font-size", MONOSPACE: "monospace",
|
STROKE_WIDTH: "stroke-width", STROKE: "stroke", FILL: "fill", FONT_SIZE: "font-size", MONOSPACE: "monospace",
|
||||||
SCROLL: "scroll", HEIGHT: "height", WIDTH: "width", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom",
|
SCROLL: "scroll", HEIGHT: "height", WIDTH: "width", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom",
|
||||||
MAX_HEIGHT: "max-height", MAX_WIDTH: "max-width", MARGIN_X: "margin-x", MARGIN_Y: "margin-y",
|
MAX_HEIGHT: "max-height", MAX_WIDTH: "max-width", MARGIN_X: "margin-x", MARGIN_Y: "margin-y",
|
||||||
PLUGIN_MARGIN: 10, ACTION_HEIGHT: 27, ACTION_MARGIN: 200,
|
PLUGIN_MARGIN: 10, ACTION_HEIGHT: 27, ACTION_MARGIN: 200,
|
||||||
|
|
||||||
FIXED: "fixed",
|
FIXED: "fixed",
|
||||||
|
|
||||||
WSS: "wss", SVG: "svg", CANVAS: "canvas", IFRAME: "iframe", CHROME: "chrome",
|
WSS: "wss", SVG: "svg", CANVAS: "canvas", IFRAME: "iframe", CHROME: "chrome",
|
||||||
LIST: "list", ITEM: "item", MENU: "menu", NODE: "node",
|
LIST: "list", ITEM: "item", MENU: "menu", NODE: "node",
|
||||||
HIDE: "hide", SHOW: "show",
|
HIDE: "hide", SHOW: "show",
|
||||||
H1: "h1", H2: "h2", H3: "h3",
|
H1: "h1", H2: "h2", H3: "h3",
|
||||||
}
|
}
|
||||||
var lang = {
|
var lang = {
|
||||||
UNDEFINED: "undefined",
|
UNDEFINED: "undefined",
|
||||||
STRING: "string", NUMBER: "number",
|
STRING: "string", NUMBER: "number",
|
||||||
OBJECT: "object", FUNCTION: "function",
|
OBJECT: "object", FUNCTION: "function",
|
||||||
ESCAPE: "Escape", ENTER: "Enter", TAB: "Tab",
|
ESCAPE: "Escape", ENTER: "Enter", TAB: "Tab",
|
||||||
}
|
}
|
||||||
function shy(help, meta, list, cb) {
|
function shy(help, meta, list, cb) {
|
||||||
var index = 0, args = arguments; function next(type) {
|
var index = 0, args = arguments; function next(type) {
|
||||||
if (index < args.length && (!type || type == typeof args[index])) {
|
if (index < args.length && (!type || type == typeof args[index])) {
|
||||||
return args[index++]
|
return args[index++]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb = args[args.length-1]||function() {}
|
cb = args[args.length-1]||function() {}
|
||||||
cb.help = next(lang.STRING)||""
|
cb.help = next(lang.STRING)||""
|
||||||
cb.meta = next(lang.OBJECT)|| {}
|
cb.meta = next(lang.OBJECT)|| {}
|
||||||
cb.list = next(lang.OBJECT)||[]
|
cb.list = next(lang.OBJECT)||[]
|
||||||
return cb
|
return cb
|
||||||
}; var _can_name = "", _can_path = ""
|
}; var _can_name = "", _can_path = ""
|
||||||
var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args: {}, pack: {}, libs: [], cache: {}}, function(name, can, libs, cb) {
|
var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args: {}, pack: {}, libs: [], cache: {}}, function(name, can, libs, cb) {
|
||||||
var meta = arguments.callee.meta, list = arguments.callee.list
|
var meta = arguments.callee.meta, list = arguments.callee.list
|
||||||
if (typeof name == lang.OBJECT) { var Config = name; Config.plugin = Config.plugin||chat.plugin_list
|
if (typeof name == lang.OBJECT) { var Config = name; Config.plugin = Config.plugin||chat.plugin_list
|
||||||
Config.panels = Config.panels||chat.panel_list, Config.main = Config.main||{name: "Header"}
|
Config.panels = Config.panels||chat.panel_list, Config.main = Config.main||{name: "Header"}
|
||||||
meta.libs = chat.libs, meta.iceberg = Config.iceberg||meta.iceberg
|
meta.libs = chat.libs, meta.iceberg = Config.iceberg||meta.iceberg
|
||||||
|
|
||||||
// 预加载
|
// 预加载
|
||||||
libs = []; for (var i = 0; i < Config.panels.length; i++) { var panel = Config.panels[i]
|
libs = []; for (var i = 0; i < Config.panels.length; i++) { var panel = Config.panels[i]
|
||||||
panel && (libs = libs.concat(panel.list = panel.list||["/panel/"+panel.name+".css", "/panel/"+panel.name+".js"]))
|
panel && (libs = libs.concat(panel.list = panel.list||["/panel/"+panel.name+".css", "/panel/"+panel.name+".js"]))
|
||||||
}; libs = libs.concat(Config.plugin, Config.main.list)
|
}; libs = libs.concat(Config.plugin, Config.main.list)
|
||||||
|
|
||||||
// 根模块
|
// 根模块
|
||||||
_can_name = "", name = Config.name||"chat", cb = can||function(can) {
|
_can_name = "", name = Config.name||"chat", cb = can||function(can) {
|
||||||
can.onengine._init(can, can.Conf(Config), Config.panels, Config._init, can._target)
|
can.onengine._init(can, can.Conf(Config), Config.panels, Config._init, can._target)
|
||||||
}, can = {_follow: name, _target: Config.target||document.body}, can._root = can
|
}, can = {_follow: name, _target: Config.target||document.body}, can._root = can
|
||||||
for (var k in Config) { can[k] = Config[k] }
|
for (var k in Config) { can[k] = Config[k] }
|
||||||
}
|
}
|
||||||
|
|
||||||
can = can||{}
|
can = can||{}
|
||||||
var proto = {__proto__: meta, _path: _can_path, _name: name, _load: function(name, each) { // 加载缓存
|
var proto = {__proto__: meta, _path: _can_path, _name: name, _load: function(name, each) { // 加载缓存
|
||||||
var cache = meta.cache[name]||[]; for (list.reverse(); list.length > 0; list) {
|
var cache = meta.cache[name]||[]; for (list.reverse(); list.length > 0; list) {
|
||||||
var sub = list.pop(); sub != can && cache.push(sub)
|
var sub = list.pop(); sub != can && cache.push(sub)
|
||||||
}; meta.cache[name] = cache
|
}; meta.cache[name] = cache
|
||||||
|
|
||||||
// 加载模块
|
// 加载模块
|
||||||
for (var i = 0; i < cache.length; i++) { var sub = cache[i], name = sub._name
|
for (var i = 0; i < cache.length; i++) { var sub = cache[i], name = sub._name
|
||||||
if (typeof each == lang.FUNCTION && each(can, name, sub)) { continue }
|
if (typeof each == lang.FUNCTION && each(can, name, sub)) { continue }
|
||||||
!can[name] && (can[name] = {}); for (var k in sub) {
|
!can[name] && (can[name] = {}); for (var k in sub) {
|
||||||
can[name].hasOwnProperty(k) || (can[name][k] = sub[k])
|
can[name].hasOwnProperty(k) || (can[name][k] = sub[k])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
||||||
typeof cb == lang.FUNCTION && setTimeout(function() { cb(can) }, 10)
|
typeof cb == lang.FUNCTION && setTimeout(function() { cb(can) }, 10)
|
||||||
return // 加载完成
|
return // 加载完成
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!libs[0]) { return can.require(libs.slice(1), cb, each) }
|
if (!libs[0]) { return can.require(libs.slice(1), cb, each) }
|
||||||
libs[0] = libs[0].toLowerCase()
|
libs[0] = libs[0].toLowerCase()
|
||||||
|
|
||||||
if (libs[0] == "") {
|
if (libs[0] == "") {
|
||||||
libs[0] = can._name.replace(".js", ".css")
|
libs[0] = can._name.replace(".js", ".css")
|
||||||
} else if (libs[0][0] != ice.PS && libs[0].indexOf(ice.HTTP) != 0) {
|
} else if (libs[0][0] != ice.PS && libs[0].indexOf(ice.HTTP) != 0) {
|
||||||
libs[0] = can._name.slice(0, can._name.lastIndexOf(ice.PS)+1)+libs[0]
|
libs[0] = can._name.slice(0, can._name.lastIndexOf(ice.PS)+1)+libs[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求模块
|
// 请求模块
|
||||||
var name = libs[0].split("?")[0]
|
var name = libs[0].split("?")[0]
|
||||||
function next() { can._load(name, each), can.require(libs.slice(1), cb, each) }
|
function next() { can._load(name, each), can.require(libs.slice(1), cb, each) }
|
||||||
meta.cache[name]? next(): (_can_path = libs[0], meta._load(name, next))
|
meta.cache[name]? next(): (_can_path = libs[0], meta._load(name, next))
|
||||||
},
|
},
|
||||||
request: function(event, option) { event = event||{}
|
request: function(event, option) { event = event||{}
|
||||||
var msg = event._msg||can.misc.Message(event, can); event._msg = msg
|
var msg = event._msg||can.misc.Message(event, can); event._msg = msg
|
||||||
function set(key, value) { msg.Option(key) || value == "" || msg.Option(key, value) }
|
function set(key, value) { msg.Option(key) || value == "" || msg.Option(key, value) }
|
||||||
|
|
||||||
can.core.List(arguments, function(option, index) { if (!option || index == 0) { return }
|
can.core.List(arguments, function(option, index) { if (!option || index == 0) { return }
|
||||||
can.base.isFunc(option.Option)? can.core.List(option.Option(), function(key) {
|
can.base.isFunc(option.Option)? can.core.List(option.Option(), function(key) {
|
||||||
set(key, option.Option(key))
|
set(key, option.Option(key))
|
||||||
}): can.core.Item(can.base.isFunc(option)? option(): option, set)
|
}): can.core.Item(can.base.isFunc(option)? option(): option, set)
|
||||||
}); return msg
|
}); return msg
|
||||||
},
|
},
|
||||||
|
|
||||||
get: function(name, key, cb) {
|
get: function(name, key, cb) {
|
||||||
return can.search({}, [can.core.Keys(name, "onexport", key)], cb)
|
return can.search({}, [can.core.Keys(name, "onexport", key)], cb)
|
||||||
},
|
},
|
||||||
set: function(name, key, value) { var msg = can.request({}); msg.Option(key, value)
|
set: function(name, key, value) { var msg = can.request({}); msg.Option(key, value)
|
||||||
return can.search(msg._event, [can.core.Keys(name, "onimport", key)])
|
return can.search(msg._event, [can.core.Keys(name, "onimport", key)])
|
||||||
},
|
},
|
||||||
setHeaderMenu: function(list, cb) { can._menu && can.page.Remove(can, can._menu)
|
setHeaderMenu: function(list, cb) { can._menu && can.page.Remove(can, can._menu)
|
||||||
var msg = can.request({}, {trans: can.onaction._trans})
|
var msg = can.request({}, {trans: can.onaction._trans})
|
||||||
return can._menu = can.search(msg._event, ["Header.onimport.menu", can._name].concat(list), cb)
|
return can._menu = can.search(msg._event, ["Header.onimport.menu", can._name].concat(list), cb)
|
||||||
},
|
},
|
||||||
setHeader: function(key, value) { return can.set("Header", key, value) },
|
setHeader: function(key, value) { return can.set("Header", key, value) },
|
||||||
getHeader: function(key, cb) { return can.get("Header", key, cb) },
|
getHeader: function(key, cb) { return can.get("Header", key, cb) },
|
||||||
getAction: function(key, cb) { return can.get("Action", key, cb) },
|
getAction: function(key, cb) { return can.get("Action", key, cb) },
|
||||||
getActionSize: function(cb) { return can.get("Action", "size", cb) },
|
getActionSize: function(cb) { return can.get("Action", "size", cb) },
|
||||||
search: function(event, cmds, cb) { return can.run && can.run(event, ["_search"].concat(cmds), cb, true) },
|
search: function(event, cmds, cb) { return can.run && can.run(event, ["_search"].concat(cmds), cb, true) },
|
||||||
|
|
||||||
ConfHeight: function(value) { return can.Conf(html.HEIGHT, value) },
|
ConfHeight: function(value) { return can.Conf(html.HEIGHT, value) },
|
||||||
ConfWidth: function(value) { return can.Conf(html.WIDTH, value) },
|
ConfWidth: function(value) { return can.Conf(html.WIDTH, value) },
|
||||||
Conf: function(key, value) { var res = can._conf
|
Conf: function(key, value) { var res = can._conf
|
||||||
for (var i = 0; i < arguments.length; i += 2) {
|
for (var i = 0; i < arguments.length; i += 2) {
|
||||||
if (typeof key == lang.OBJECT) {
|
if (typeof key == lang.OBJECT) {
|
||||||
res = can.core.Value(can._conf, arguments[i])
|
res = can.core.Value(can._conf, arguments[i])
|
||||||
i--
|
i--
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res = can.core.Value(can._conf, arguments[i], arguments[i+1])
|
res = can.core.Value(can._conf, arguments[i], arguments[i+1])
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}, _conf: {},
|
}, _conf: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navigator.userAgent.indexOf("MSIE") > -1) {
|
if (navigator.userAgent.indexOf("MSIE") > -1) {
|
||||||
for (var k in proto) { can[k] = proto[k] }
|
for (var k in proto) { can[k] = proto[k] }
|
||||||
} else {
|
} else {
|
||||||
can.__proto__ = proto
|
can.__proto__ = proto
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_can_name) { // 加入缓存
|
if (_can_name) { // 加入缓存
|
||||||
meta.cache[_can_name] = meta.cache[_can_name]||[], meta.cache[_can_name].push(can)
|
meta.cache[_can_name] = meta.cache[_can_name]||[], meta.cache[_can_name].push(can)
|
||||||
} else { // 加入队列
|
} else { // 加入队列
|
||||||
list.push(can)
|
list.push(can)
|
||||||
}
|
}
|
||||||
if (can._follow) { libs = libs.concat(meta.libs, meta.volcano) }
|
if (can._follow) { libs = libs.concat(meta.libs, meta.volcano) }
|
||||||
if (libs && libs.length > 0) {
|
if (libs && libs.length > 0) {
|
||||||
for (var i = 0; i < libs.length; i++) {
|
for (var i = 0; i < libs.length; i++) {
|
||||||
if (libs[i] == undefined) {
|
if (libs[i] == undefined) {
|
||||||
|
|
||||||
} else if (libs[i] == "") {
|
} else if (libs[i] == "") {
|
||||||
libs[i] = _can_path.replace(".js", ".css")
|
libs[i] = _can_path.replace(".js", ".css")
|
||||||
} else if (libs[i][0] != ice.PS && libs[i].indexOf(ice.HTTP) != 0) {
|
} else if (libs[i][0] != ice.PS && libs[i].indexOf(ice.HTTP) != 0) {
|
||||||
libs[i] = _can_path.slice(0, _can_path.lastIndexOf(ice.PS)+1)+libs[i]
|
libs[i] = _can_path.slice(0, _can_path.lastIndexOf(ice.PS)+1)+libs[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return can.require(libs, cb), can
|
return can.require(libs, cb), can
|
||||||
})
|
})
|
||||||
Volcanos.meta._load = function(url, cb) {
|
Volcanos.meta._load = function(url, cb) {
|
||||||
switch (url.split("?")[0].split(ice.PT).pop().toLowerCase()) {
|
switch (url.split("?")[0].split(ice.PT).pop().toLowerCase()) {
|
||||||
case nfs.CSS:
|
case nfs.CSS:
|
||||||
var item = document.createElement(mdb.LINK)
|
var item = document.createElement(mdb.LINK)
|
||||||
item.rel = "stylesheet", item.type = "text/css"
|
item.rel = "stylesheet", item.type = "text/css"
|
||||||
item.onload = cb, item.href = url
|
item.onload = cb, item.href = url
|
||||||
return (document.head||document.body).appendChild(item), item
|
return (document.head||document.body).appendChild(item), item
|
||||||
case nfs.JS:
|
case nfs.JS:
|
||||||
var item = document.createElement(ssh.SCRIPT)
|
var item = document.createElement(ssh.SCRIPT)
|
||||||
item.onload = cb, item.onerror = cb, item.src = url
|
item.onload = cb, item.onerror = cb, item.src = url
|
||||||
return document.body.appendChild(item), item
|
return document.body.appendChild(item), item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function can(tool) {
|
function can(tool) {
|
||||||
Volcanos({name: "chat", panels: [
|
Volcanos({name: "chat", panels: [
|
||||||
{name: "Header", help: "标题栏", pos: "hide", state: ["time", "usernick", "avatar"]},
|
{name: "Header", help: "标题栏", pos: "hide", state: ["time", "usernick", "avatar"]},
|
||||||
{name: "Action", help: "工作台", pos: chat.MAIN, tool: tool},
|
{name: "Action", help: "工作台", pos: chat.MAIN, tool: tool},
|
||||||
{name: "Search", help: "搜索框", pos: "auto"},
|
{name: "Search", help: "搜索框", pos: "auto"},
|
||||||
]})
|
]})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user