From 68edc8fa543fd41aa01d8707be828c1b061c0452 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 28 Jul 2024 23:22:04 +0800 Subject: [PATCH] opt portal --- frame.js | 29 +++++++++++++++++++++++++++++ lib/misc.js | 4 +++- lib/user.js | 11 +++++++++-- panel/header.js | 2 +- plugin/input/key.js | 2 ++ plugin/state.js | 9 +++------ 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/frame.js b/frame.js index b8084fda..64b8a187 100644 --- a/frame.js +++ b/frame.js @@ -1249,6 +1249,35 @@ Volcanos(chat.ONMOTION, { can.page.style(can, target, html.HEIGHT, begin += height/list.length) }, function() { can.page.style(can, target, html.HEIGHT, "") }) }, + slideAction: function(can, target) { + var action = can.page.Select(can, target.parentNode, html.DIV_ACTION)[0] + var beginY, beginX, beginLeft, max = can.base.Max(action.offsetWidth, 120, 60) + target.addEventListener("touchstart", function(event) { max = can.base.Max(action.offsetWidth, 120, 60) + beginY = event.touches[0].clientY, beginX = event.touches[0].clientX, beginLeft = parseFloat(target.style.left)||0 + }) + target.addEventListener("touchmove", function(event) { + if (Math.abs(event.touches[0].clientY - beginY) > Math.abs(event.touches[0].clientX - beginX)) { return } + var left = event.touches[0].clientX - beginX + beginLeft + target._left = left + if (left < 0 && left > -max) { can.page.style(can, event.currentTarget, {left: left}) } + can.onmotion.select(can, target.parentNode.parentNode, html.DIV_ITEM, target.parentNode) + can.onkeymap.prevent(event) + }) + target.addEventListener("touchend", function(event) { + var left = target._left + if (left < -max/2) { + can.page.style(can, event.currentTarget, {left: -max}) + } else { + can.page.style(can, event.currentTarget, {left: 0}) + } + can.page.Select(can, target.parentNode.parentNode, html.DIV_ITEM+">div.output", function(_target) { + if (_target != target) { + can.page.style(can, _target, {left: 0}) + _target._left = 0 + } + }) + }) + }, }) Volcanos(chat.ONKEYMAP, { _init: function(can, target) { target = target||document.body, can.onkeymap._build(can) diff --git a/lib/misc.js b/lib/misc.js index eb310667..a1489898 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -329,7 +329,9 @@ Volcanos("misc", { return can.core.List(can.core.Split(can.base.trimPrefix(location.hash, "#"), nfs.DF)||[], function(item) { return decodeURIComponent(item) }) }, SearchOrConf: function(can, key, def) { return can.misc.Search(can, key)||Volcanos.meta.args[key]||can.misc.sessionStorage(can, "can."+key)||can.misc.localStorage(can, "can."+key)||can.Conf(key)||def }, - CookieSessid: function(can, value, path) { return can.misc.Cookie(can, ice.MSG_SESSID+"_"+(location.port||(location.protocol == "https:"? "443": "80")), value, path) }, + CookieSessid: function(can, value, path) { + return can.misc.Cookie(can, ice.MSG_SESSID+"_"+(location.port||(location.protocol == "https:"? "443": "80")), value, path)||can.misc.Cookie(can, ice.MSG_SESSID, value, path) + }, Cookie: function(can, key, value, path) { function set(k, v) { var expires = new Date(); expires.setTime(expires.getTime() + 30*24*3600000) document.cookie = k+mdb.EQ+v+";path="+(path||nfs.PS)+";expires="+expires.toGMTString() diff --git a/lib/user.js b/lib/user.js index d261cd13..896b7c52 100644 --- a/lib/user.js +++ b/lib/user.js @@ -92,7 +92,13 @@ Volcanos("user", { }, toastProcess: function(can, content, title, progress) { return can.user.toast(can, {content: "🕑 "+(content||ice.PROCESS), title: title, duration: -1, progress: progress}) }, toastFailure: function(can, content, title) { return can.user.toast(can, {content: "❌ "+(content||ice.FAILURE), title: title, duration: -1}) }, - toastSuccess: function(can, content, title, duration) { return can.user.toast(can, {content: "✅ "+(content||ice.SUCCESS), title: title, duration: duration||1000}) }, + toastSuccess: function(can, content, title, duration) { + if (!can.user.isEnglish(can)) { + content && (content += " success"); var list = can.core.Split(content, " ", " ") + content = can.core.List(list, function(text) { return can.user.trans(can, text) }).join("") + } + return can.user.toast(can, {content: "✅ "+content, title: title, duration: duration||1000}) + }, toast: function(can, content, title, duration, progress, hash) { can = can._fields? can.sup: can if (title == can.ConfIndex()) { title = can.user.trans(can, title, can.Conf("help")) } var meta = can.base.isObject(content)? content: {content: content, title: title, duration: duration, progress: progress, hash: hash} @@ -297,7 +303,8 @@ Volcanos("user", { }), resize: html.IMG, }) }, login: function(can, _cb, _msg) { - can.misc.CookieSessid(can, ""), can.page.ClassList.add(can, document.body.parentNode, aaa.LOGIN), can.onimport.theme(can) + can.misc.CookieSessid(can, ""), can.misc.Cookie(can, "sessid", "") + can.page.ClassList.add(can, document.body.parentNode, aaa.LOGIN), can.onimport.theme(can) function check() { if (can.misc.CookieSessid(can) || can.user.info.sessid) { can.page.ClassList.del(can, document.body.parentNode, aaa.LOGIN), can.onimport.theme(can) can.onmotion.clearFloat(can), can.onmotion.delay(can, function() { socket._close = true, socket.close() }) diff --git a/panel/header.js b/panel/header.js index d71f24d0..c34fc928 100644 --- a/panel/header.js +++ b/panel/header.js @@ -107,7 +107,7 @@ Volcanos(chat.ONACTION, {_init: function(can) {}, can.require(can.core.List(msg["theme.list"], function(item) { return nfs.SRC_TEMPLATE+web.CHAT_HEADER+"/theme/"+item }), function() { if (can.base.beginWith(location.pathname, nfs.WIKI_PORTAL, web.CHAT_CMD+web.WIKI_PORTAL, web.CHAT_CMD+web.CHAT_OAUTH_CLIENT)) { return show(msg) } if (location.pathname == nfs.PS && can.base.beginWith(msg.Option(ice.MAIN)||"", nfs.WIKI_PORTAL, web.CHAT_CMD+web.WIKI_PORTAL)) { return show(msg) } - msg.Option(mdb.PLUGIN) && can.onappend.plugin(can, {index: msg.Option(mdb.PLUGIN)}, function(sub) { can.onmotion.hidden(can, sub._target) }, document.body) + msg.Option(mdb.PLUGIN) && can.onappend.plugin(can, {space: msg.plugin[1], index: msg.Option(mdb.PLUGIN)}, function(sub) { can.onmotion.hidden(can, sub._target) }, document.body) msg.Option(nfs.SCRIPT) && can.require(can.base.Obj(msg.Option(nfs.SCRIPT)), function(can) { can.onaction.source(can, msg) }) var tool = can._root.Action._conf.tool if (can.Conf(aaa.USERNICK, (msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME)).slice(0, 8)) diff --git a/plugin/input/key.js b/plugin/input/key.js index 46e1c54e..cc203c02 100644 --- a/plugin/input/key.js +++ b/plugin/input/key.js @@ -62,6 +62,8 @@ Volcanos(chat.ONFIGURE, {key: { meta.msg && meta.msg.Length() > 0? sub._show(sub, meta.msg, cb, target, meta.name): sub._load(event, sub, cb, target, meta.name, target.value) }) }, onblur: function(event, can, sub, cb, target) { if (target._hold) { return } + return + debugger can.onengine.signal(can, "onevent", can.request(event, {query: can.page.getquery(can, target)+","+target.value})) sub && can.onmotion.delay(can, sub.close, 300) }, diff --git a/plugin/state.js b/plugin/state.js index 344e6449..389b7f17 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -15,12 +15,9 @@ Volcanos(chat.ONIMPORT, { _display: function(can, msg) { can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY)) }, _clear: function(can, msg) { can.onmotion.clear(can) }, _inner: function(can, sub, msg) { sub = sub||can, can.onmotion.scrollIntoView(can, can.onappend.table(sub, msg)), can.onmotion.scrollIntoView(can, can.onappend.board(sub, msg)), can.onmotion.story.auto(sub) }, - _cookie: function(can, msg) { - // can.user.toast(can, stringify.JSON(msg._arg)) - can.misc.Cookie(can, msg._arg[0], msg._arg[1]) - debugger - if (msg._arg[2]) { - history.go(msg._arg[2]) + _cookie: function(can, msg) { can.misc.Cookie(can, msg._arg[0], msg._arg[1]) + if (msg._arg[2]) { history.go(msg._arg[2]) + can.onmotion.delay(can, function() { history.back() }, 300) } else { can.Update() }