diff --git a/publish/chrome/contexts.js b/publish/chrome/contexts.js index 662e6fe7..fd63a187 100644 --- a/publish/chrome/contexts.js +++ b/publish/chrome/contexts.js @@ -56,30 +56,20 @@ setTimeout(function() { Volcanos({ can.onappend.plugin(can, {type: chat.CONTEXTS, index: arg[0], args: can.base.Obj(arg[1])}, function(sub, meta) { sub.run = function(event, cmds, cb) { msg.RunAction(event, can, cmds) || can.runActionCommand(event, meta.index, cmds, function(msg) { can.onmotion.toggle(can, sub._option, true), can.onmotion.toggle(can, sub._action, true), can.onmotion.toggle(can, sub._output, true), can.onmotion.toggle(can, sub._status, true) - can.base.isFunc(cb) && cb(msg) + can.base.isFunc(cb) && cb(msg) }) } can.onmotion.move(can, sub._target, {left: msg.Option(html.LEFT), top: msg.Option(html.TOP), right: msg.Option(html.RIGHT), bottom: msg.Option(html.BOTTOM)}, function(target) { can.page.style(can, sub._output, html.MAX_HEIGHT, window.innerHeight-target.offsetTop-80, html.MAX_WIDTH, window.innerWidth-target.offsetLeft-20) }) - sub._legend.onclick = function(event) { - can.onmotion.toggle(can, sub._option), can.onmotion.toggle(can, sub._action), can.onmotion.toggle(can, sub._output), can.onmotion.toggle(can, sub._status) - } + sub._legend.onclick = function(event) { can.onmotion.toggle(can, sub._option), can.onmotion.toggle(can, sub._action), can.onmotion.toggle(can, sub._output), can.onmotion.toggle(can, sub._status) } msg.Option("selection")? can.onengine.listen(can, "onselection", function() { sub.Option(msg.Option("selection"), window.getSelection()), sub.Update() }): sub._legend.onclick() sub.onaction["保存参数"] = function(event) { can.run(can.request(event, {domain: location.host, id: msg.Option(mdb.ID)}), [chat.FIELD, mdb.MODIFY, html.TOP, sub._target.offsetTop, html.LEFT, sub._target.offsetLeft, ctx.ARGS, JSON.stringify(sub.Input([], true))]) } }, document.body) }, - change: function(can, msg, arg) { - arg.length > 1 && can.page.Modify(can, arg[0], can.base.Obj(arg[1])) - arg.length > 0 && can.page.Select(can, document.body, arg[0], function(item) { - msg.Push(mdb.TEXT, item.outerHTML) - }) - }, order: function(can, msg, arg) { var ui = can.user.input(event, can, [ctx.INDEX, ctx.ARGS, "selection", html.LEFT, html.TOP], function(args) { - can.run(event, [chat.FIELD, mdb.INSERT, mdb.ZONE, location.host].concat(args), function(res) { - can.user.toastSuccess(can) - }) + can.run(event, [chat.FIELD, mdb.INSERT, web.DOMAIN, location.host].concat(args), function(res) { can.user.toastSuccess(can) }) }); can.page.style(can, ui._target, {left: 200, top: 200}) can.page.ClassList.add(can, ui._target, chat.CONTEXTS) }, diff --git a/publish/chrome/daemon.js b/publish/chrome/daemon.js index 5f8cc562..bbb9e941 100644 --- a/publish/chrome/daemon.js +++ b/publish/chrome/daemon.js @@ -1,45 +1,40 @@ Volcanos({ - chrome: function(can, msg, arg, cb) { msg.detail = msg.detail.slice(3) - if (arg.length == 0 || arg[0] == "") { - chrome.windows.getAll(function(wins) { - can.core.List(wins, function(win) { win.wid = win.id - msg.Push(win, ["type", "state", "wid", "focused", html.LEFT||"0", html.TOP||"0", html.WIDTH, html.HEIGHT]) - }), can.base.isFunc(cb) && cb(msg) - }) - } else if (arg.length == 1 || arg[1] == "") { - chrome.tabs.getAllInWindow(parseInt(arg[0]), function(tabs) { - can.core.Next(tabs, function(tab, next) { var _msg = can.request(); _msg.detail = ["info"] - can._tabsend(can, _msg, function(res) { tab.tid = tab.id - msg.Push(tab, ["index", "tid", "active", html.WIDTH, html.HEIGHT]) - msg.Push("title", res && res["title"][0] || "") - msg.Push("url", res && res["url"][0] || "") - next() - }, tab.id) - }, function() { can.base.isFunc(cb) && cb(msg) }) - }) - } else if (arg[1] == "current") { - chrome.tabs.query({currentWindow: true, active: true}, function(tabs) { arg[1] = tabs[0].id + chrome: function(can, msg, arg, cb) { msg.detail = msg.detail.slice(3) + if (arg.length == 0 || arg[0] == "") { + chrome.windows.getAll(function(win) { can.core.List(win, function(win) { win.wid = win.id + msg.Push(win, ["type", "state", "wid", "focused", html.LEFT, html.TOP, html.WIDTH, html.HEIGHT]) + }), can.base.isFunc(cb) && cb(msg) }) + } else if (arg.length == 1 || arg[1] == "") { + chrome.tabs.getAllInWindow(parseInt(arg[0]), function(tab) { can.core.Next(tab, function(tab, next) { var _msg = can.request(); _msg.detail = ["info"] + can._tabsend(can, _msg, function(res) { tab.tid = tab.id + msg.Push(tab, ["index", "tid", "active", html.WIDTH, html.HEIGHT]) + msg.Push("title", res&&res["title"][0]||"").Push("url", res&&res["url"][0]||"") + next() + }, tab.id) + }, function() { can.base.isFunc(cb) && cb(msg) }) }) + } else if (arg[1] == "current") { + chrome.tabs.query({currentWindow: true, active: true}, function(tabs) { arg[1] = tabs[0].id can._tabsend(can, msg, null, arg[1]) - }) - } else { + }) + } else { can._tabsend(can, msg, null, arg[1]) - } - }, + } + }, _tabsend: function(can, msg, cb, target) { chrome.tabs.sendMessage(parseInt(target||msg.Option(ice.MSG_TARGET)), msg, cb||function(res) { msg.Copy(res), msg.Reply() }) }, - _daemon: function(can) { - can.misc.WSS(can, {type: html.CHROME, name: html.CHROME}, function(event, msg, cmd, arg, cb) { - msg.Option(ice.MSG_TARGET)? can._tabsend(can, msg): can.core.CallFunc([can, cmd], {can: can, msg: msg, arg: arg, cb: cb}) - }) - chrome.runtime.onMessage.addListener(function(req, sender, cb) { - var msg = can.request({}, {tid: sender.tab.id, url: sender.url}); can.core.List(req.option, function(key) { msg.Option(key, req[key][0]) }) + _daemon: function(can) { + can.misc.WSS(can, {type: html.CHROME, name: html.CHROME}, function(event, msg, cmd, arg, cb) { + msg.Option(ice.MSG_TARGET)? can._tabsend(can, msg): can.core.CallFunc([can, cmd], {can: can, msg: msg, arg: arg, cb: cb}) + }) + chrome.runtime.onMessage.addListener(function(req, sender, cb) { + var msg = can.request({}, {tid: sender.tab.id, url: sender.url}); can.core.List(req.option, function(key) { msg.Option(key, req[key][0]) }) return msg._source = [sender.tab.id], can.run(msg, req.detail||[], cb), true - }) + }) chrome.history && chrome.history.onVisited.addListener(function(item) { - can.run({}, ["sync", mdb.TYPE, mdb.LINK, mdb.NAME, item.title, mdb.LINK, item.url, "tid", item.id]) - }) - }, + can.run({}, ["sync", mdb.TYPE, mdb.LINK, mdb.NAME, item.title, mdb.LINK, item.url, "tid", item.id]) + }) + }, _motion: function(can) { can.user.toast = function(can, message, title) { chrome.notifications.create(null, { message: message, title: title||can._name, iconUrl: "/favicon.ico", type: "basic", diff --git a/publish/chrome/popup.html b/publish/chrome/popup.html index dd34ed34..6a2d6af0 100644 --- a/publish/chrome/popup.html +++ b/publish/chrome/popup.html @@ -3,7 +3,7 @@ - + diff --git a/publish/chrome/popup.js b/publish/chrome/popup.js index f921fbf5..91e834c5 100644 --- a/publish/chrome/popup.js +++ b/publish/chrome/popup.js @@ -1,61 +1,82 @@ Volcanos({name: "popup", iceberg: "http://localhost:9020/chat/", river: { - product: {name: "产品群", storm: { - office: {name: "办公 office", list: [ - {name: "feel", help: "影音媒体", index: "web.wiki.feel"}, - {name: "draw", help: "思维导图", index: "web.wiki.draw"}, - {name: "data", help: "数据表格", index: "web.wiki.data"}, - {name: "plan", help: "计划任务", index: "web.team.plan"}, - {name: "think", help: "智库", index: "web.wiki.word", args: ["usr/learning/"]}, - {name: "index", help: "索引", index: "web.wiki.word", args: ["usr/learning/index.shy"]}, - {name: "context", help: "编程", index: "web.wiki.word", args: ["src/main.shy"]}, - ]}, - chrome: {name: "爬虫 chrome", list: [ - {name: "feel", help: "网页爬虫", index: "web.wiki.feel", args: ["spide/"], feature: { - display: "/plugin/local/wiki/feel.js", - height: 200, limit: 3, - }}, - {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"]}, - ]}, - }}, - project: {name: "研发群", storm: { - studio: {name: "研发 studio", list: [ - {name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"]}, - {name: "repos", help: "代码库", index: "web.code.git.status"}, - {name: "plan", help: "任务表", index: "web.team.plan"}, - {name: "ctx", help: "上下文", index: "web.wiki.word", args: ["src/main.shy"]}, - ]}, - web: {name: "网页 web", list: [ - {name: "HTML5", help: "浏览器", index: "web.wiki.word", args: ["usr/icebergs/misc/chrome/chrome.shy"]}, - ]}, - }}, - profile: {name: "测试群", storm: { - release: {name: "发布 release", index: [ - "web.code.publish", "web.code.compile", "web.code.autogen", - ]}, - research: {name: "测试 research", index: [ - "web.code.favor", "web.code.bench", "web.code.pprof", - "web.code.case", - ]}, - }}, - operate: {name: "运维群", storm: { - aaa: {name: "权限 aaa", index: [ - "user", "sess", "role", "totp", - ]}, - web: {name: "应用 web", index: [ - "spide", "route", "share", "dream", - ]}, - cli: {name: "系统 cli", index: [ - "qrcode", "daemon", "system", "runtime", - ]}, - nfs: {name: "文件 nfs", index: [ - "cat", "dir", "tail", "trash", - ]}, - ssh: {name: "脚本 ssh", index: [ - "connect", "session", "service", "channel", - "source", "screen", - ]}, - }}, - }, -}) + product: {name: "产品群", storm: { + office: {name: "办公 office", list: [ + {name: "feel", help: "影音媒体", index: "web.wiki.feel"}, + {name: "draw", help: "思维导图", index: "web.wiki.draw"}, + {name: "data", help: "数据表格", index: "web.wiki.data"}, + {name: "plan", help: "计划任务", index: "web.team.plan"}, + {name: "think", help: "智库", index: "web.wiki.word", args: ["usr/learning/"]}, + {name: "index", help: "索引", index: "web.wiki.word", args: ["usr/learning/index.shy"]}, + {name: "context", help: "编程", index: "web.wiki.word", args: ["src/main.shy"]}, + ]}, + chrome: {name: "爬虫 chrome", list: [ + {name: "feel", help: "网页爬虫", index: "web.wiki.feel", args: ["spide/"], feature: { + display: "/plugin/local/wiki/feel.js", + height: 200, limit: 3, + }}, + {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"]}, + ]}, + }}, + project: {name: "研发群", storm: { + studio: {name: "研发 studio", list: [ + {name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/,usr/volcanos/,usr/icebergs/,usr/toolkits/", "main.go"]}, + {name: "repos", help: "代码库", index: "web.code.git.status"}, + {name: "favor", help: "收藏夹", index: "web.chat.favor"}, + {name: "plan", help: "任务表", index: "web.team.plan"}, + {name: "ctx", help: "上下文", index: "web.wiki.word"}, + ]}, + chrome: {name: "网页 chrome", index: [ + "web.code.chrome.chrome", + "web.code.chrome.daemon", + "web.code.chrome.spide", + "web.code.chrome.cache", + "web.code.chrome.style", + "web.code.chrome.field", + ]}, + }}, + profile: {name: "测试群", storm: { + release: {name: "发布 release", index: [ + "web.code.webpack", + "web.code.compile", + "web.code.publish", + "web.code.docker.client", + "web.space", + "web.dream", + "web.code.git.server", + "web.code.git.status", + ]}, + toolkit: {name: "工具 toolkit", index: [ + "web.code.favor", + "web.code.xterm", + "web.code.inner", + "web.code.vimer", + "web.code.bench", + "web.code.pprof", + "web.code.oauth", + ]}, + language: {name: "语言 language", index: [ + "web.code.c", + "web.code.sh", + "web.code.py", + "web.code.shy", + "web.code.js", + "web.code.go", + ]}, + }}, + operate: {name: "运维群", storm: { + aaa: {name: "权限 aaa", index: [ + "offer", "email", "user", "totp", "sess", "role", + ]}, + web: {name: "应用 web", index: [ + "broad", "serve", "space", "dream", "share", "cache", "spide", + ]}, + cli: {name: "系统 cli", index: [ + "qrcode", "daemon", "system", "runtime", "mirrors", "forever", "host", "port", + ]}, + nfs: {name: "文件 nfs", index: [ + "cat", "dir", "pack", "tail", "trash", + ]}, + }}, +}})