From 0a8ee276c0cb681881bf80a11029d238cf5e05b1 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Thu, 17 Nov 2022 15:43:38 +0800 Subject: [PATCH] add chat/favor.go --- frame.js | 6 +++--- lib/user.js | 4 +++- page/index.css | 2 +- plugin/local/chat/iframe.js | 12 ++++-------- plugin/state.js | 11 ++++++----- proto.js | 2 +- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/frame.js b/frame.js index 4aa94e89..b126ad5e 100644 --- a/frame.js +++ b/frame.js @@ -201,7 +201,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, _status: function(can, list, status) { status = status||can._status, can.onmotion.clear(can, status) can.core.List(can.base.Obj(list, can.core.Value(can, [chat.ONEXPORT, mdb.LIST])), function(item) { item = can.base.isString(item)? {name: item}: item - if (can.base.beginWith(item.value, ice.PS, ice.HTTP)) { item.value = can.page.Format(html.A, item.value) } + if (can.base.beginWith(item.value, ice.PS, ice.HTTP)) { item.value = can.page.Format(html.A, item.value, item.value.split("?")[0]) } can.page.Append(can, status, [{view: can.base.join([html.ITEM, item.name]), title: item.name, list: [ {text: [item.name, html.LABEL]}, {text: [": ", html.LABEL]}, {text: [(item.value == undefined? "": item.value)+"", html.SPAN, item.name]}, ], onclick: function(event) { can.user.copy(event, can, item.value) }}]) @@ -234,7 +234,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { line = {}, can.core.List(array, function(item) { line[item.key] = item.value }) } function run(event, cmd, arg) { return can.run(can.request(event, line, can.Option()), [ctx.ACTION, cmd].concat(arg)) } return {text: [value, html.TD], onclick: function(event) { var target = event.target - if (can.page.tagis(target, html.INPUT) && target.type == html.BUTTON) { + if (can.page.tagis(target, html.INPUT) && target.type == html.BUTTON) { can.request(event, {height: can.ConfHeight()-4-table.offsetHeight, width: can.ConfWidth()}) meta && meta[target.name]? can.user.input(can.request(event, {action: target.name}), can, meta[target.name], function(args) { run(event, target.name, args) }): run(event, target.name) } else { can.sup.onimport.change(event, can.sup, key, event.target.innerText) || can.sup.onexport.record(can.sup, line) } }, ondblclick: function(event) { if ([mdb.KEY, mdb.HASH, mdb.ID].indexOf(key) > -1) { return } @@ -384,7 +384,7 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { if (target.value == target.name) { target.value = can.user.trans(can, target.name) } }) can.page.Select(can, target, html.IFRAME, function(item) { - can.page.style(can, item, html.HEIGHT, can.ConfHeight()-88, html.WIDTH, can.ConfWidth()-30) + // can.page.style(can, item, html.HEIGHT, can.ConfHeight()-88, html.WIDTH, can.ConfWidth()-30) }) }, }, diff --git a/lib/user.js b/lib/user.js index 9283eaaa..a7ee3569 100644 --- a/lib/user.js +++ b/lib/user.js @@ -4,7 +4,7 @@ Volcanos("user", {info: {}, agent: { getLocation: function(can, cb) { var call = arguments.callee; if (call._res) { return cb(call._res) } navigator.geolocation.getCurrentPosition(function(res) { cb(call._res = {latitude: parseInt(res.coords.latitude*100000), longitude: parseInt(res.coords.longitude*100000)}) - }, function(some) { can.base.isFunc(cb) && cb({type: "unknown", name: "unknown", latitude: 3998412, longitude: 11630748}) } ) + }, function(some) { can.base.isFunc(cb) && cb({type: "location", name: "北京市", text: "天安门", latitude: 3998412, longitude: 11630748}) } ) }, openLocation: function(can, msg) { window.open("https://map.baidu.com/search/"+encodeURIComponent(msg.Option(mdb.TEXT)) @@ -58,6 +58,8 @@ Volcanos("user", {info: {}, agent: { cli.OPEN, "打开", cli.CLOSE, "关闭", cli.START, "启动", cli.STOP, "停止", cli.BEGIN, "开始", cli.END, "结束", cli.EXEC, "执行", cli.DONE, "完成", web.CLEAR, "清空", web.REFRESH, "刷新", web.SUBMIT, "提交", web.CANCEL, "取消", web.UPLOAD, "上传", web.DOWNLOAD, "下载", web.TOIMAGE, "截图", web.SHARE, "共享", "Close", "关闭", "Close others", "关闭其它", "Close all", "关闭所有", + chat.IFRAME, "浏览", chat.LOCATION, "地图", + "full", "全屏", )[text]||text }, time: function(can, time, fmt) { var now = can.base.Date(time) diff --git a/page/index.css b/page/index.css index 136e5d95..ecf9f61a 100644 --- a/page/index.css +++ b/page/index.css @@ -303,7 +303,7 @@ body.simple fieldset.feel.float { top:0; } body.white.simple div.profile { background-color:whitesmoke; } body.white.simple div.profile { color:black; } body.white.simple div.display { background-color:whitesmoke; } -body.white.simple div.code { background-color:white; color:black; border:none; } +body.white.simple div.code { background-color:white; color:black; padding:0px; border:none; } body.white.simple fieldset.plugin div.status { border-top:1px solid lightgray; } body.white.simple>div.carte { background-color:white; border:solid 1px #e7e7e7; } body.white.simple>div.carte div.item { background-color:white; color:black; } diff --git a/plugin/local/chat/iframe.js b/plugin/local/chat/iframe.js index 4ac3f245..0194d4f9 100644 --- a/plugin/local/chat/iframe.js +++ b/plugin/local/chat/iframe.js @@ -1,10 +1,6 @@ -Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { - can.current = msg.TableDetail(), can.onimport.layout(can), can.base.isFunc(cb) && cb(msg) - }, - layout: function(can) { var item = can.current; can.onmotion.clear(can), can.onimport.title(can, item.name||item.link) - can.page.Append(can, can._output, [{type: html.IFRAME, src: item.link, height: can.ConfHeight(), width: can.ConfWidth(), style: {border: 0}}]) +Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.current = msg.TableDetail(), can.onimport.layout(can) }, + layout: function(can) { var item = can.current; can.onimport.title(can, item.name||item.link.split("?")[0]) + can.page.Appends(can, can._output, [{type: html.IFRAME, src: item.link, height: can.ConfHeight(), width: can.ConfWidth(), style: {border: 0}}]) }, }) -Volcanos(chat.ONACTION, { - open: function(can) { can.user.open(can.current.link) }, -}) +Volcanos(chat.ONACTION, {open: function(event, can) { can.user.open(can.current.link) }}) diff --git a/plugin/state.js b/plugin/state.js index 8bf08933..6277679a 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -23,16 +23,17 @@ Volcanos(chat.ONIMPORT, {_process: function(can, msg) { }, _field: function(can, msg) { var opts = {} can.page.SelectArgs(can, can._option, "", function(target) { var value = msg.Option(target.name); target.name && value && (opts[target.name] = value) }) - msg.Table(function(item) { can.onappend._plugin(can, item, {type: chat.STORY, index: item.index, args: can.base.Obj(item[ice.ARG], [])}, function(sub, meta) { + var height = can.ConfHeight()-2*html.ACTION_HEIGHT; can.page.Select(can, can._output, html.TABLE, function(target) { height -= target.offsetHeight+4 }) + msg.Table(function(item) { can.onappend._plugin(can, item, {index: item.index, args: can.base.Obj(item[ice.ARG], []), height: can.base.Min(height, 200)}, function(sub, meta) { sub.Conf(can.base.Obj(item.conf)); if (sub.isSimpleMode()) { (function() { sub.ConfHeight(can.ConfHeight()/2) var msg = can.request(); msg.Echo(sub.Conf(ice.MSG_RESULT)), can.onappend._output(sub, msg, sub.Conf("feature.display")) })(); return } - var opt = can.base.Obj(item[ice.OPT], []); sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) + var opt = can.base.Obj(item[ice.OPT], []); sub.ConfWidth(can.ConfWidth()) sub.run = function(event, cmds, cb) { var res = can.request(event, can.Option(), opts, {pid: msg.Option("pid")}) 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.Option("_index")==can._index? []: [ice.RUN, msg.Option("_index")]).concat(msg[ice.MSG_PREFIX]||[]).concat(cmds), cb, true) } }) }); return true }, @@ -69,7 +70,7 @@ Volcanos(chat.ONIMPORT, {_process: function(can, msg) { return can.page.style(can, div, html.MAX_HEIGHT, 400), can.page.Append(can, div, [{text: _arg}]), div.scrollBy(0, 10000), true }).length == 0) { can.onappend.board(can, _arg) } return true }, - _open: function(can, msg, _arg) { return can.user.open(_arg), can.Update() }, + _open: function(can, msg, _arg) { return can.user.open(_arg), true }, size: function(can, height, width, auto, mode) { if (auto) { @@ -205,7 +206,7 @@ Volcanos(chat.ONACTION, {list: [ getLocation: function(event, can, button) { can.user.agent.getLocation(can, function(data) { can.request(event, data) can.user.input(event, can, [mdb.TYPE, mdb.NAME, mdb.TEXT, "latitude", "longitude"], function(args) { - can.runAction(event, button, args) + can.runAction(event, button, args, function() { can.Update() }) }) }) }, diff --git a/proto.js b/proto.js index e77fe80c..350c7949 100644 --- a/proto.js +++ b/proto.js @@ -181,7 +181,7 @@ var chat = { _INIT: "_init", _TRANS: "_trans", _ENGINE: "_engine", _SEARCH: "_search", _OUTPUTS_CURRENT: "_outputs.-1", _NAMES: "_names", _TOAST: "_toast", - + IFRAME: "iframe", LOCATION: "location", } var team = { TASK: "task", PLAN: "plan",