diff --git a/frame.js b/frame.js index f08dbac4..1331b502 100644 --- a/frame.js +++ b/frame.js @@ -115,8 +115,8 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, Clone: function() { meta.args = sub.page.SelectArgs(sub, option, "") can.onappend._init(can, meta, list, function(sub) { - can.core.Timer(10, function() { for (var k in sub._inputs) { sub._inputs[k]._target.focus(); break } }) - can.base.isFunc(cb) && cb(sub) + can.core.Timer(10, function() { for (var k in sub._inputs) { can.onmotion.focus(can, sub._inputs[k]._target); break } }) + can.base.isFunc(cb) && cb(sub, true) }, target) }, }, list, function(sub) { sub.Conf(meta), meta.feature = sub.base.Obj(meta.feature, {}) @@ -133,11 +133,11 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, }, _option: function(can, meta, option) { var index = -1, args = can.base.Obj(meta.args||meta.arg, []), opts = can.base.Obj(meta.opts, {}) function add(item, next) { item.type != html.BUTTON && index++ - Volcanos(item.name, {_follow: can.core.Keys(can._follow, item.name), + return Volcanos(item.name, {_follow: can.core.Keys(can._follow, item.name), _target: can.onappend.input(can, item, args[index]||opts[item.name], option), _option: can._option, _action: can._action, _output: can._output, _status: can._status, Option: can.Option, Action: can.Action, Status: can.Status, - CloneInput: function() { add(item)._target.focus() }, CloneField: function() { can.Clone() }, + CloneInput: function() { can.onmotion.focus(can, add(item)._target) }, CloneField: function() { can.Clone() }, }, [item.display||"/plugin/input.js"], function(input) { input.Conf(item) input.run = function(event, cmds, cb, silent) { var msg = can.request(event) if (msg.RunAction(event, input, cmds)) { return } @@ -338,8 +338,8 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, meta.help = value.help||meta.help||html.STORY meta.type = meta.type||html.STORY - can.onappend._init(can, meta, ["/plugin/state.js"], function(sub) { - sub.base.isFunc(cb) && cb(sub, meta) + can.onappend._init(can, meta, ["/plugin/state.js"], function(sub, skip) { + sub.base.isFunc(cb) && cb(sub, meta, skip) }, target||can._output) }, @@ -419,7 +419,7 @@ Volcanos("onlayout", {help: "页面布局", list: [], _init: function(can, targe can.onengine.signal(can, chat.ONSIZE, can.request({}, {width: width, height: height})) }, topic: function(can, topic) { topic && (can._topic = topic) - can.user.topic(can, can._topic || can.user.Search(can, chat.TOPIC) || ((can.user.Search(can, cli.POD)||can.base.isNight())? chat.BLACK: chat.WHITE)) + can.user.topic(can, can._topic || can.user.Search(can, chat.TOPIC) || ((can.base.isNight()||can.user.mod.isPod)? chat.BLACK: chat.WHITE)) can.page.ClassList.add(can, document.body, can.user.language(can)) }, background: function(can, url, target) { diff --git a/lib/user.js b/lib/user.js index 9f26bead..dcf682da 100644 --- a/lib/user.js +++ b/lib/user.js @@ -21,14 +21,15 @@ Volcanos("user", {help: "用户操作", agent: { }, isLandscape: window.innerWidth > window.innerHeight, isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1, - isMobile: navigator.userAgent.indexOf("Mobile") > -1, isIPhone: navigator.userAgent.indexOf("iPhone") > -1, + isMobile: navigator.userAgent.indexOf("Mobile") > -1, isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1, isWindows: navigator.userAgent.indexOf("Windows") > -1, - isLocalFile: location && location.protocol && location.protocol == "file:", isExtension: location && location.protocol && location.protocol == "chrome-extension:", + isLocalFile: location && location.protocol && location.protocol == "file:", mod: { - isCmd: location && location.pathname && (location.pathname.indexOf("/cmd/") > -1 || location.pathname.indexOf("/help/") == 0), + isPod: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0), + isCmd: location && location.pathname && (location.pathname.indexOf("/chat/cmd/") == 0 || location.pathname.indexOf("/help/") == 0), }, alert: function(text) { alert(JSON.stringify(text)) }, @@ -58,13 +59,14 @@ Volcanos("user", {help: "用户操作", agent: { if (typeof text == "function") { text = text.name || "" } return can._trans&&can._trans[text] || can.Conf("trans."+text) || can.Conf("feature._trans."+text) || { + "clear": "清空", "refresh": "刷新", "submit": "提交", "cancel": "取消", - "open": "打开", "close": "关闭", - "begin": "启动", "end": "结束", + "create": "创建", "share": "共享", "list": "查看", "back": "返回", - "run": "执行", "refresh": "刷新", - "share": "共享", "clear": "清空", - "done": "完成", + "begin": "开始", "end": "结束", + "start": "启动", "stop": "停止", + "open": "打开", "close": "关闭", + "run": "执行", "done": "完成", }[text] || text }, toast: function(can, content, title, duration, progress) { @@ -194,7 +196,7 @@ Volcanos("user", {help: "用户操作", agent: { var ui = can.page.Append(can, document.body, [{view: ["input"], style: {left: 0, top: 0}, list: [ {view: ["option", "table"], list: can.core.List(form, function(item) { item = typeof item == "string"? {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: html.TEXT) + item.type = item.type||(item.values? html.SELECT: item.name == "text"? html.TEXTAREA: html.TEXT) item._init = function(target) { item.run = function(event, cmds, cb) { diff --git a/panel/action.js b/panel/action.js index 70e7b930..c505291a 100644 --- a/panel/action.js +++ b/panel/action.js @@ -5,8 +5,8 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg) item.feature = can.base.Obj(item.feature||item.meta) item.inputs = can.base.Obj(item.inputs||item.list) - can.onappend.plugin(can, item, function(sub, meta) { - can.onimport._plugin(can, river, storm, sub, meta), next() + can.onappend.plugin(can, item, function(sub, meta, skip) { + can.onimport._plugin(can, river, storm, sub, meta), skip || next() }) }, function() { can.onaction.layout(can, can.user.Search(can, chat.LAYOUT)||can.Conf(chat.LAYOUT)) @@ -35,7 +35,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg) sub._target.Meta = meta }, _menu: function(can, msg) { - if (can.user.isMobile || can.user.Search(can, cli.POD)) { return } + if (can.user.mod.isPod||can.user.isMobile) { return } can._menu && can.page.Remove(can, can._menu) can._menu = can.search({}, ["Header.onimport.menu", ctx.ACTION].concat( @@ -95,7 +95,7 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, can.base.isFunc(cb) && cb() }, onmain: function(can, msg) { - var cmds = location.pathname.split("/").slice(1); if (cmds[0] == cli.CMD) { + var cmds = location.pathname.split("/").slice(1); if (cmds[0] == ice.CMD) { can.onappend.plugin(can, {index: cmds[1]}, function(sub) { sub.run = function(event, cmds, cb) {} }) } can.onimport._share(can, can.user.Search(can, web.SHARE)) diff --git a/panel/cmd.js b/panel/cmd.js index 5449d168..bc3ae8b3 100644 --- a/panel/cmd.js +++ b/panel/cmd.js @@ -1,10 +1,10 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, list, cb, target) { - can.onmotion.float.auto(can, can._output, "carte") - can.base.isFunc(cb) && cb() - }, + can.onmotion.float.auto(can, can._output, chat.CARTE) + can.base.isFunc(cb) && cb() +}, onmain: function(can) { can._names = location.pathname var msg = can.request({}, {_names: location.pathname}) - can.Conf("tool")? can.core.Next(can.Conf("tool"), function(line, next) { + can.Conf(chat.TOOL)? can.core.Next(can.Conf(chat.TOOL), function(line, next) { can.onaction._plugin(can, line.index, can.base.Obj(line.args, []), next) }): can.run(msg._event, [ctx.ACTION, ctx.COMMAND], function(msg) { @@ -15,13 +15,9 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, can.page.ClassList.add(can, can._target, "Action") }, _plugin: function(can, index, args, next) { - can.onappend.plugin(can, {type: "plugin", index: index, args: args, opts: can.user.Search(), height: window.innerHeight, width: window.innerWidth}, function(sub, meta) { - sub.run = function(event, cmds, cb) { - can.run(event, can.misc.Concat([ctx.ACTION, "run", index], cmds), cb) - } - // can.onmotion.hidden(can, sub._legend) - can.user.title(meta.name) - next() + can.onappend.plugin(can, {type: chat.PLUGIN, index: index, args: args, opts: can.user.Search(), height: window.innerHeight, width: window.innerWidth}, function(sub, meta) { + sub.run = function(event, cmds, cb) { can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN, index], cmds), cb) } + can.user.title(meta.name), next() }) }, }) diff --git a/panel/header.js b/panel/header.js index d91d4e2d..3fd1be30 100644 --- a/panel/header.js +++ b/panel/header.js @@ -15,14 +15,14 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.base.isFunc(cb) && cb(msg) }, _agent: function(can, msg, target) { - if (can.user.isMobile) { + if (can.user.mod.isPod) { + can.onaction.River(can) + can.onaction.Footer(can) + } else if (can.user.isMobile) { can.onaction.River(can) can.onaction.Footer(can) } else if (can.user.isExtension) { can.onaction.River(can) - } else if (can.user.Search(can, ice.POD)) { - can.onaction.River(can) - can.onaction.Footer(can) } can.user.isWeiXin && can.onimport._weixin(can) }, @@ -35,7 +35,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, } }, _title: function(can, msg, target) { - can.user.title(can.user.Search(can, chat.TITLE)||can.user.Search(can, cli.POD)) + can.user.title(can.user.Search(can, chat.TITLE)||can.user.Search(can, ice.POD)) !can.user.isMobile && can.core.List(msg.result||["shylinux.com/x/contexts"], function(item) { can.page.Append(can, target, [{view: [chat.TITLE, html.DIV, item], title: "返回主页", onclick: function(event) { can.onaction.title(event, can) @@ -79,7 +79,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, }, _menus: function(can, msg, target) { var menus = can.base.Obj(msg.Option(chat.MENUS)||can.Conf(chat.MENUS), [chat.HEADER, ["setting", chat.BLACK, chat.WHITE, chat.PRINT]]) - can.onimport.menu(can, can.user.isMobile||can.user.isExtension||can.user.Search(can, cli.POD)? [chat.HEADER, chat.RIVER]: menus, function(event, item) { + can.onimport.menu(can, can.user.mod.isPod||can.user.isMobile||can.user.isExtension? [chat.HEADER, chat.RIVER]: menus, function(event, item) { can.core.CallFunc(can.onaction[item]||function(event, can) { can.run(event, [item], function(msg) { can.user.toast(can, "执行成功", can.user.trans(can, item)) }) }, {event: event, can: can, button: item}) diff --git a/panel/river.js b/panel/river.js index 075cbd3a..0c1a4830 100644 --- a/panel/river.js +++ b/panel/river.js @@ -9,23 +9,22 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, }) })), 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) { can._main_river = "product", can._main_storm = "chrome" } if (can.user.isMobile) { can._main_river = "product", can._main_storm = "office" } if (can.user.isWeiXin) { can._main_river = "service", can._main_storm = "wx" } - can._main_title = can.user.Search(can, chat.TITLE) || msg.Option(ice.MSG_TITLE) || Volcanos.meta.args.title || can.user.Search(can, cli.POD) || can._main_title - can._main_river = can.user.Search(can, chat.RIVER) || msg.Option(ice.MSG_RIVER) || Volcanos.meta.args.river || can._main_river - can._main_storm = can.user.Search(can, chat.STORM) || msg.Option(ice.MSG_STORM) || Volcanos.meta.args.storm || can._main_storm + can._main_title = can.user.Search(can, chat.TITLE)||msg.Option(ice.MSG_TITLE)||Volcanos.meta.args.title||can.user.mod.isPod||can._main_title + can._main_river = can.user.Search(can, chat.RIVER)||msg.Option(ice.MSG_RIVER)||Volcanos.meta.args.river||can._main_river + can._main_storm = can.user.Search(can, chat.STORM)||msg.Option(ice.MSG_STORM)||Volcanos.meta.args.storm||can._main_storm }, - _menu: function(can, msg) { - can.user.Search(can, cli.POD) || can.search({}, ["Header.onimport.menu"].concat(can.base.Obj(msg.Option(chat.MENUS), can.ondetail.menus)), function(event, item) { - can.core.CallFunc([can.ondetail, item], [event, can, item, can.Conf(chat.RIVER), can.Conf(chat.STORM)]) + _menu: function(can, msg) { if (can.user.mod.isPod) { return } + can.search({}, ["Header.onimport.menu"].concat(can.base.Obj(msg.Option(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)]) }) }, - _carte: function(can, list, river, storm) { - (!can.user.isMobile && !can.user.Search(can, cli.POD)) && can.onaction.carte(event, can, list, function(event, button, module) { + _carte: function(can, list, river, storm) { if (can.user.mod.isPod||can.user.isMobile) { return } + can.onaction.carte(event, can, list, function(event, button, module) { module[button](event, can, button, river, storm) }) }, @@ -35,6 +34,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, }, onmouseenter: function(event) { can.onimport._carte(can, can.ondetail.list, meta.hash) + }, _init: function(target) { cb(target) can.river_list[meta.hash] = target }} @@ -42,10 +42,11 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, _storm: function(can, meta, river) { return {text: [meta.name, html.DIV, html.ITEM], onclick: function(event) { 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) { can.onimport._carte(can, can.ondetail.sublist, river, meta.hash) + }, _init: function(target) { can.storm_list[can.core.Keys(river, meta.hash)] = target }} @@ -66,16 +67,15 @@ Volcanos("onengine", {help: "解析引擎", list: [], _engine: function(event, c Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg, list, cb, target) { can.base.isFunc(cb) && cb() }, - _trans: {create: "创建", refresh: "刷新"}, onlogin: function(can, msg) { - can.onappend._action(can, can.Conf("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) }) }, onsearch: function(can, msg, word) { if (word[0] == "*" || word[0] == chat.STORM) { can.onexport.storm(can, msg, word) } }, onaction_touch: function(can, msg) { - can.onmotion.float.del(can, "carte") + can.onmotion.float.del(can, chat.CARTE) can.user.isMobile && can.onmotion.hidden(can) }, onaction_notool: function(can, msg, river, storm) { @@ -94,7 +94,7 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg, var list = can.sublist[river]; if (list) { return can.onmotion.toggle(can, list) } can.run({}, [river, chat.TOOL], function(msg) { - var select = 0; list = can.page.Append(can, can._output, [{view: "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) return can.onimport._storm(can, item, river) }) }]).first, list.children.length > 0 && list.children[select].click() @@ -104,7 +104,7 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg, }) }, action: function(event, can, river, storm) { - can.page.Modify(can, can.sublist[river], {style: {display: "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.list div.item", can.storm_list[can.core.Keys(river, storm)]) @@ -116,8 +116,8 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg, create: function(event, can) { can.user.trans(can, {"public": "公开群", "protected": "内部群", "private": "私有群"}) can.user.input(event, can, [ - {name: "type", values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"}, - {name: "name", value: "hi", _trans: "群名"}, {type: html.TEXTAREA, name: "text", value: "hello", _trans: "简介"}, + {name: kit.MDB_TYPE, values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"}, + {name: kit.MDB_NAME, value: "hi", _trans: "群名"}, {name: kit.MDB_TEXT, value: "hello", _trans: "简介"}, ], function(event, button, meta, list, args) { can.run(event, [ctx.ACTION, mdb.CREATE].concat(args), function(msg) { can.user.Search(can, {river: msg.Result()}) @@ -132,40 +132,45 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg, }) }, }) -Volcanos("ondetail", {help: "菜单交互", list: ["共享群组", "添加应用", "添加设备", "重命名群组", "删除群组"], +Volcanos("ondetail", {help: "菜单交互", + list: ["共享群组", "添加应用", "添加设备", "添加用户", "重命名群组", "删除群组"], sublist: ["共享应用", "添加工具", "保存参数", "重命名应用", "删除应用"], menus: [chat.RIVER, - ["create", "创建群组", "添加应用", "添加工具", "添加用户", "添加设备", "创建空间"], + ["create", "创建群组", "添加应用", "添加工具", "添加设备", "创建空间"], ["share", "共享群组", "共享应用", "共享工具", "共享主机", "访问空间"], ], "创建群组": function(event, can) { can.onaction.create(event, can) }, - "共享群组": function(event, can, button, river) { - can.user.input(event, can, [ - {name: "name", value: river, _trans: "标题"}, - ], function(event, button, meta, list) { - can.user.share(can, can.request(event), [river, ctx.ACTION, chat.SHARE, kit.MDB_TYPE, chat.RIVER, kit.MDB_NAME, meta.name]) + can.user.input(event, can, [{name: chat.TILTE, value: river, _trans: "标题"}], function(event, button, meta, list) { + can.user.share(can, can.request(event), [river, ctx.ACTION, chat.SHARE, kit.MDB_TYPE, chat.RIVER, kit.MDB_NAME, list[0]]) }) }, - "添加用户": function(event, can, button, river) { - 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) { + "添加应用": function(event, can, button, river) { can.ondetail.create(event, can, button, river) }, + "共享应用": function(event, can, button, river, storm) { + can.user.input(event, can, [{name: chat.TILTE, value: storm, _trans: "标题"}], function(event, button, meta, list) { + can.user.share(can, can.request(event), [river, ctx.ACTION, chat.SHARE, kit.MDB_TYPE, chat.STORM, kit.MDB_NAME, list[0], + chat.STORM, storm, chat.RIVER, river, + ]) + }) + }, + "添加工具": function(event, can, button, river, storm) { + can.user.select(event, can, ctx.COMMAND, "context,command", function(item, next) { + can.run({}, [river, chat.TOOL, ctx.ACTION, mdb.INSERT, kit.MDB_HASH, storm].concat([ice.POD, "", ice.CTX, item[0], ice.CMD, item[1]]), function(msg) { next() }) + }, function() { + can.user.Search(can, {river: river, storm: storm}) }) }, - "添加应用": function(event, can, button, river) { - can.user.trans(can, {"public": "公开应用", "protected": "群组应用", "private": "个人应用"}) - can.user.input(event, can, [ - {name: "type", values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"}, - {name: "name", value: "hi", _trans: "名称"}, {type: html.TEXTAREA, name: "text", value: "hello", _trans: "简介"}, - ], function(event, button, meta, list, args) { - can.run({}, [river, chat.TOOL, ctx.ACTION, mdb.CREATE].concat(args), function(msg) { - can.user.Search(can, {river: river, storm: msg.Result()}) - }) + "共享工具": function(event, can, button, river, storm) { + 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, kit.MDB_TYPE, chat.FIELD, + kit.MDB_NAME, item[0], kit.MDB_TEXT, item[3], chat.RIVER, item[1], chat.STORM, item[2], + ]) }) }, + "添加设备": function(event, can, button, river) { can.user.select(event, can, web.SPACE, "type,name,text", function(item, next) { can.run({}, [river, chat.NODE, ctx.ACTION, mdb.INSERT, kit.MDB_TYPE, item[0], kit.MDB_NAME, item[1]], function(msg) { @@ -173,88 +178,6 @@ Volcanos("ondetail", {help: "菜单交互", list: ["共享群组", "添加应用 }) }) }, - "重命名群组": function(event, can, button, river) { - can.user.input(event, can, [kit.MDB_NAME], function(event, button, meta, list) { - var msg = can.request(event, {hash: river}) - can.run(event, [ctx.ACTION, mdb.MODIFY, kit.MDB_NAME, meta.name], function(msg) { - can.user.Search(can, {river: river}) - }) - }) - }, - "删除群组": function(event, can, button, river) { - var msg = can.request(event, {hash: river}) - can.run(event, [ctx.ACTION, mdb.REMOVE], function(msg) { - can.user.Search(can, {}) - }) - }, - - "共享应用": function(event, can, button, river, storm) { - can.user.input(event, can, [ - {name: "name", value: storm, _trans: "标题"}, - ], function(event, button, meta, list) { - var msg = can.request(event) - can.user.share(can, msg, [river, ctx.ACTION, chat.SHARE, - kit.MDB_TYPE, chat.STORM, kit.MDB_NAME, meta.name, - chat.STORM, storm, chat.RIVER, river, - ]) - }) - }, - "添加工具": function(event, can, button, river, storm) { - can.user.select(event, can, ctx.COMMAND, "context,command", function(item, next) { - can.run({}, [river, chat.TOOL, ctx.ACTION, mdb.INSERT, kit.MDB_HASH, storm].concat([cli.POD, "", cli.CTX, item[0], cli.CMD, item[1]]), function(msg) { - next() - }) - }, function() { - can.user.Search(can, {river: river, storm: storm}) - }) - }, - "保存参数": function(event, can, button, river, storm) { - can.search(event, ["Action.onexport.args"], function(item, next, index, array) { - var msg = can.request({}, {hash: storm, id: item.dataset.id}) - var toast = can.user.toast(can, (index+1)+"/"+array.length, "保存参数", 10000, (index+1)/array.length) - can.run(msg._event, [river, chat.TOOL, ctx.ACTION, mdb.MODIFY, cli.ARG, item.dataset.args], function(msg) { - toast.close(), next() - }) - }) - }, - "重命名应用": function(event, can, button, river, storm) { - var msg = can.request(event, {hash: storm}) - can.user.input(event, can, [kit.MDB_NAME], function(ev, button, meta, list, args) { - can.run(event, [river, chat.TOOL, ctx.ACTION, mdb.MODIFY].concat(args), function(msg) { - can.user.Search(can, {river: river, storm: storm}) - }) - }) - }, - "删除应用": function(event, can, button, river, storm) { - var msg = can.request(event, {hash: storm}) - can.run(event, [river, chat.TOOL, ctx.ACTION, mdb.REMOVE], function(msg) { - can.user.Search(can, {river: river}) - }) - }, - - "内部系统": function(event, can, button, river, storm) { - can.user.select(event, can, "github", "time,type,name,text") - }, - "访问应用": function(event, can, button, river, storm) { - var msg = can.request(event, {sort: ","}) - can.user.select(event, can, chat.STORM, "type,name,text") - }, - "访问工具": function(event, can, button, river, storm) { - var msg = can.request(event, {sort: ","}) - can.user.select(event, can, mdb.PLUGIN, "type,name,text") - }, - "访问用户": function(event, can, button, river, storm) { - can.user.select(event, can, chat.USER, "time,type,name,text") - }, - "访问空间": function(event, can, button, river, storm) { - var msg = can.request(event, {river: river}) - can.user.select(event, can, web.SPACE, "time,type,name,text") - }, - "工作任务": function(event, can, button, river, storm) { - var msg = can.request(event, {index: "web.team.task"}) - can.user.select(event, can, team.TASK, "time,zone,id,type,name,text") - }, - "共享主机": function(event, can, button, river, storm) { can.run(event, [ctx.ACTION, aaa.INVITE], function(msg) { can.user.toast(can, { @@ -263,27 +186,68 @@ Volcanos("ondetail", {help: "菜单交互", list: ["共享群组", "添加应用 }) }) }, - "共享工具": function(event, can, button, river, storm) { - 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, kit.MDB_TYPE, chat.FIELD, - chat.RIVER, item[1], chat.STORM, item[2], - kit.MDB_NAME, item[0], kit.MDB_TEXT, item[3], - ]) + "创建空间": function(event, can, button, river, storm) { + 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) { + var link = can.user.MergeURL(can, {_path: "/chat/pod/"+can.core.Keys(can.user.Search(can, ice.POD), msg.Option(kit.MDB_NAME))}) + can.user.toast(can, link), can.user.open(link) + }) + }) + }, + "访问空间": function(event, can, button, river, storm) { + can.user.select({river: river}, can, web.SPACE, "time,type,name,text") + }, + + + "添加用户": function(event, can, button, river) { + 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) { + next() + }) + }) + }, + "重命名群组": function(event, can, button, river) { + can.user.input(event, can, [kit.MDB_NAME], function(event, button, meta, list) { + can.run(can.request(event, {hash: river})._event, [ctx.ACTION, mdb.MODIFY, kit.MDB_NAME, meta.name], function(msg) { + can.user.Search(can, {river: river}) + }) + }) + }, + "删除群组": function(event, can, button, river) { + can.run(can.request(event, {hash: river})._event, [ctx.ACTION, mdb.REMOVE], function(msg) { can.user.Search(can, {}) }) + }, + + "保存参数": function(event, can, button, river, storm) { + can.search(event, ["Action.onexport.args"], function(item, next, index, array) { + var msg = can.request({}, {hash: storm, id: item.dataset.id}) + var toast = can.user.toast(can, (index+1)+"/"+array.length, "保存参数", 10000, (index+1)/array.length) + can.run(msg._event, [river, chat.TOOL, ctx.ACTION, mdb.MODIFY, ice.ARG, item.dataset.args], function(msg) { + toast.close(), next() + }) + }) + }, + "重命名应用": function(event, can, button, river, storm) { + can.user.input(event, can, [kit.MDB_NAME], function(ev, button, meta, list, args) { + can.run(can.request(event, {hash: storm})._event, [river, chat.TOOL, ctx.ACTION, mdb.MODIFY].concat(args), function(msg) { + can.user.Search(can, {river: river, storm: storm}) + }) + }) + }, + "删除应用": function(event, can, button, river, storm) { + can.run(can.request(event, {hash: storm})._event, [river, chat.TOOL, ctx.ACTION, mdb.REMOVE], function(msg) { + can.user.Search(can, {river: river}) }) }, - "创建空间": function(event, can, button, river, storm) { - can.user.input(event, {__proto__: can, run: function(event, cmds, cb, silent) { - var msg = can.request(event, {action: cli.START}) - can.run(event, cmds, cb, silent) - }}, [ - {name: "name", value: "hi", action: "key"}, - {name: "repos", action: "key"}, - {name: "template", action: "key"}, - ], function(event, button, data, list, args) { - can.run(event, [ctx.ACTION, cli.START].concat(args, chat.RIVER, river), function(msg) { - var link = can.user.MergeURL(can, {_path: "/chat/pod/"+can.core.Keys(can.user.Search(can, cli.POD), msg.Option(kit.MDB_NAME))}) - can.user.toast(can, link), can.user.open(link) + + create: function(event, can, button, river) { + can.user.trans(can, {"public": "公开应用", "protected": "群组应用", "private": "个人应用"}) + can.user.input(event, can, [ + {name: kit.MDB_TYPE, values: [chat.PUBLIC, chat.PROTECTED, chat.PRIVATE], _trans: "类型"}, + {name: kit.MDB_NAME, value: "hi", _trans: "名称"}, {name: kit.MDB_TEXT, value: "hello", _trans: "简介"}, + ], function(event, button, meta, list, args) { + can.run({}, [river, chat.TOOL, ctx.ACTION, mdb.CREATE].concat(args), function(msg) { + can.user.Search(can, {river: river, storm: msg.Result()}) }) }) }, diff --git a/plugin/input.js b/plugin/input.js index d36d234c..a13e85ab 100644 --- a/plugin/input.js +++ b/plugin/input.js @@ -32,7 +32,7 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, meta, case html.TEXT: event.target.setSelectionRange(0, -1); break }; can.run(event), event.stopPropagation(), event.preventDefault(); break case "b": if (event.ctrlKey) { can.CloneInput() } break - case "m": if (event.ctrlKey) { can.CloneField() } break + case "m": if (event.ctrlKey) { can.CloneField(), event.stopPropagation(), event.preventDefault() } break } }, }) diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 1f591769..052c31a9 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -123,7 +123,7 @@ Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], switch (can.parse) { case "png": case "jpg": - can.page.Append(can, can.ui.content, [{img: can.base.Path("/share/local", can.file)+"?"+can.user.Search(can, "pod")}]) + can.page.Append(can, can.ui.content, [{img: can.base.Path("/share/local", can.file)+"?"+can.user.Search(can, ice.POD)}]) return } diff --git a/plugin/state.js b/plugin/state.js index e7595d11..8ee54dea 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -1,18 +1,11 @@ -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) { 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]) }, - _location: function(can, msg) { - // can.user.open(msg._arg[0]) - location.href = msg._arg[0] - }, - _rewrite: function(can, msg) { can.Option(msg._arg[0], msg._arg[1]) - can.Update() - return true - }, + _location: function(can, msg) { location.href = msg._arg[0] }, + _rewrite: function(can, msg) { can.Option(msg._arg[0], msg._arg[1]), can.Update(); return true }, _refresh: function(can, msg) { can.core.Timer(parseInt(msg.Option("_delay")||"500"), function() { var sub = can.request({}, {_count: parseInt(msg.Option("_count"))-1}) @@ -21,7 +14,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, return true }, _display: function(can, msg) { - Volcanos("some", {}, [msg.Option("_display")].concat(Volcanos.meta.volcano, Volcanos.meta.libs), 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._option = can._option sub._action = can._action @@ -30,13 +23,12 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, return true }, _field: function(can, msg) { - msg.Table(function(item) { can.onappend._plugin(can, item, {arg: can.base.Obj(item["arg"], [])}, function(sub, meta) { - var opt = can.base.Obj(item["opt"], []) + 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], []) sub.run = function(event, cmds, cb, silent) { - var res = can.request(event); can.core.Item(can.Option(), function(key, value) { - res.Option(key) || res.Option(key, value) - }); for (var i = 0; i < opt.length; i += 2) { res.Option(opt[i], opt[i+1]) } - can.run(event, (msg["_prefix"]||[]).concat(cmds), cb, true) + var res = can.request(event, can.Option()) + 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) } }) }) return true @@ -45,16 +37,16 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, can.onappend.table(can, msg) can.onappend.board(can, msg) can.onmotion.story.auto(can) - can.page.Modify(can, can._output, {style: {display: "block"}}) + can.page.Modify(can, can._output, {style: {display: html.BLOCK}}) return true }, + + _open: function(can, msg) { can.user.open(msg.Option("_arg")); return true }, _hold: function(can, msg) { return true }, _back: function(can) { can._history.pop(); for (var his = can._history.pop(); his; his = can._history.pop()) { if (his[0] == ctx.ACTION) { continue } - can.page.Select(can, can._option, "textarea.args,input.args,select.args", 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 } !his && can.Update() @@ -73,63 +65,46 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, // can.onmotion.story.auto(can, can._output) }, - _open: function(can, msg) { - can.user.open(msg.Option("_arg")) - return true - }, }) Volcanos("onaction", {help: "交互操作", list: [ "共享工具", "生成链接", "保存参数", "清空参数", "刷新数据", [ "其它 ->", "复制数据", "下载数据", "清空数据", "删除工具", "摄像头", ], - ], _init: function(can, msg, list, cb, target) { - }, + ], _init: function(can, msg, list, cb, target) {}, _engine: function(event, can, button) { can.Update(event, [ctx.ACTION, button].concat(can.Input([], true))) }, "共享工具": function(event, can) { var meta = can.Conf() - var ui = can.user.input(event, can, [{name: "name", value: meta.name}], function(event, button, data, list, args) { - var msg = can.request(event, {arg: [ - kit.MDB_TYPE, "field", - kit.MDB_NAME, list[0], kit.MDB_TEXT, JSON.stringify(can.Input([], true)), - // "river", meta.ctx||meta.key||"", "storm", meta.index||meta.cmd||meta.name, - "storm", meta.index, + var ui = can.user.input(event, can, [{name: chat.TITLE, value: meta.name}], function(ev, button, data, list) { + var msg = can.request(event, {arg: [kit.MDB_TYPE, chat.FIELD, + kit.MDB_NAME, meta.index, kit.MDB_TEXT, JSON.stringify(can.Input([], true)), + chat.RIVER, can.Conf(chat.RIVER), chat.STORM, can.Conf(chat.STORM), chat.TITLE, list[0], ]}) can.search(event, ["Header.onaction.share"]) - }) - can.onlayout.figure(event, can, ui._target, true) + }); can.onlayout.figure(event, can, ui._target, true) }, - "保存参数": function(event, can) { var meta = can.Conf() - var msg = can.request(event, {river: can.Conf("river"), storm: can.Conf("storm"), id: meta.id}) - can.search(event, ["River.ondetail.保存参数"], function(msg) { - can.user.toast(can, "保存成功") - }, true) - }, - "清空参数": function(event, can) { - can.page.Select(can, can._option, '.args', function(item) { return item.value = "" }) - }, - "刷新数据": function(event, can) { - can.Update({}, can.Input([], true)) - }, - "全屏": function(event, can) { - if (can.page.ClassList.neg(can, can._target, "fixed")) { - - } - }, - "生成链接": function(event, can) { var meta = can.Conf() - var pre = "/chat/cmd/"; if (can.user.Search(can, "pod")) { pre = "/chat/pod/"+can.user.Search(can, "pod")+"/cmd/" } + var pre = "/chat/cmd/"; if (can.user.mod.isPod) { pre = "/chat/pod/"+can.user.Search(can, ice.POD)+"/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}) var msg = can.request(event, {link: can.user.MergeURL(can, args)}) can.search(event, ["Header.onaction.share"]) }, + "保存参数": function(event, can) { var meta = can.Conf() + var msg = can.request(event, {river: can.Conf(chat.RIVER), storm: can.Conf(chat.STORM), id: meta.id}) + can.search(event, ["River.ondetail.保存参数"], function(msg) { can.user.toast(can, "保存成功") }, true) + }, + "清空参数": function(event, can) { + can.page.SelectArgs(can, can._option, "", function(item) { return item.value = "" }) + }, + "刷新数据": function(event, can) { can.Update({}, can.Input([], true)) }, + "复制数据": function(event, can) { var meta = can.Conf(), msg = can._msg 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.length > 1 && can.user.copy(event, can, res.join("\n")) + res.length > 1 && can.user.copy(event, can, res.join(ice.SP)) msg.result && can.user.copy(event, can, msg.Result()) }, "下载数据": function(event, can) { var meta = can.Conf(), msg = can._msg @@ -140,12 +115,9 @@ Volcanos("onaction", {help: "交互操作", list: [ res.length > 1 && can.user.downloads(can, res.join("\n"), meta.name+".csv") msg.result && can.user.downloads(can, msg.Result(), meta.name+".txt") }, - "清空数据": function(event, can) { - can.onmotion.clear(can, can._output) - }, - "删除工具": function(event, can) { - can.page.Remove(can, can._target) - }, + "清空数据": function(event, can) { can.onmotion.clear(can, can._output) }, + "删除工具": function(event, can) { can.page.Remove(can, can._target) }, + "摄像头": function(event, can) { 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) { @@ -172,23 +144,25 @@ Volcanos("onaction", {help: "交互操作", list: [ }) }, + "参数": function(event, can) { can.onmotion.toggle(can, can._action) }, + clear: function(event, can, name) { can.onmotion.clear(can, can._output) }, + close: function(event, can) { can.page.Remove(can, can._target) }, + upload: function(event, can) { can.user.upload(event, can) }, + change: function(event, can, name, value, cb) { + return can.page.SelectArgs(can, can._option, "", function(input) { + if (input.name == name && value != input.value) { input.value = value + var data = input.dataset||{}; can.Update(event, can.Input(), cb) + return input + } + }) + }, + next: function(event, can) { can.Update(event, [ctx.ACTION, "next", can.Status("total")||0, can.Option("limit"), can.Option("offend")]) }, prev: function(event, can) { can.Update(event, [ctx.ACTION, "prev", can.Status("total")||0, can.Option("limit"), can.Option("offend")]) }, - change: function(event, can, name, value, cb) { - return can.page.Select(can, can._option, "input.args", function(input) { - if (input.name == name && value != input.value) { input.value = value - var data = input.dataset || {}; can.Update(event, can.Input(), cb) - return input - } - }) - }, - upload: function(event, can) { - can.user.upload(event, can) - }, scanQRCode: function(event, can, cmd) { can.user.agent.scanQRCode(function(text) { var cmds = [ctx.ACTION, cmd] @@ -196,7 +170,7 @@ Volcanos("onaction", {help: "交互操作", list: [ can.core.Item(data, function(key, value) { cmds.push(key, value) }) if (data["auth"]) { if (can.user.confirm("auth "+data["auth"])) { - can.run(event, [ctx.ACTION, "auth", "space", data["auth"]]) + can.run(event, [ctx.ACTION, "auth", web.SPACE, data["auth"]]) } return } @@ -231,9 +205,6 @@ Volcanos("onaction", {help: "交互操作", list: [ }, openLocation: function(event, can) { can.user.agent.openLocation(can.request(event)) }, - "参数": function(event, can) { can.onmotion.toggle(can, can._action) }, - clear: function(event, can, name) { can.onmotion.clear(can, can._output) }, - close: function(event, can) { can.page.Remove(can, can._target) }, }) Volcanos("onexport", {help: "导出数据", list: []}) diff --git a/proto.js b/proto.js index 498c9806..dc8e63a2 100644 --- a/proto.js +++ b/proto.js @@ -40,6 +40,7 @@ const ice = { MSG_STATUS: "_status", MSG_DISPLAY: "_display", MSG_PROCESS: "_process", + MSG_PREFIX: "_prefix", PROCESS_AGAIN: "_again", @@ -51,11 +52,10 @@ const ctx = { ACTION: "action", } const cli = { - RUN: "run", - POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg", OPT: "opt", - OPEN: "open", CLOSE: "close", START: "start", STOP: "stop", - CLEAR: "clear", - DONE: "done", + RUN: "run", DONE: "done", + OPEN: "open", CLOSE: "close", + START: "start", STOP: "stop", + CLEAR: "clear", REFRESH: "refresh", } const web = { SHARE: "share", @@ -63,17 +63,13 @@ const web = { } const aaa = { USERNAME: "username", USERNICK: "usernick", BACKGROUND: "background", AVATAR: "avatar", - LANGUAGE: "language", ENGLISH: "english", CHINESE: "chinese", - LOGIN: "login", LOGOUT: "logout", INVITE: "invite", } const mdb = { + PLUGIN: "plugin", RENDER: "render", SEARCH: "search", INPUTS: "inputs", CREATE: "create", REMOVE: "remove", INSERT: "insert", DELETE: "delete", MODIFY: "modify", SELECT: "select", - PLUGIN: "plugin", - SEARCH: "search", - INPUTS: "inputs", META: "meta", HASH: "hash", LIST: "list", }