From 99e03c3faab941fcb30fa86927352bc8b1846d0c Mon Sep 17 00:00:00 2001 From: shylinux Date: Fri, 14 Jul 2023 12:58:38 +0800 Subject: [PATCH] opt some --- lib/misc.js | 7 +++++-- plugin/local/wiki/feel.js | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/misc.js b/lib/misc.js index fa4b7c76..87452bee 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -164,11 +164,14 @@ Volcanos("misc", { }, 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) }, - Cookie: function(can, key, value, path) { function set(k, v) { document.cookie = k+mdb.EQ+v+";path="+(path||nfs.PS) } + 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() + } if (can.base.isObject(key)) { for (var k in key) { set(k, key[k]) } key = undefined } if (can.base.isUndefined(key)) { var cs = {}; if (!document.cookie) { return } return document.cookie.split("; ").forEach(function(item) { var ls = item.split(mdb.EQ); cs[ls[0]] = ls[1] }), cs } if (value === "") { var expires = new Date(); expires.setTime(expires.getTime() - 10) - return document.cookie = key+mdb.EQ+value+";path="+(path||nfs.PS)+";expires=" + expires.toGMTString(); + return document.cookie = key+mdb.EQ+value+";path="+(path||nfs.PS)+";expires="+expires.toGMTString() } can.base.isUndefined(value) || set(key, value) var val = (new RegExp(key+"=([^;]*);?")).exec(document.cookie); return val && val.length > 1? val[1]: "" }, diff --git a/plugin/local/wiki/feel.js b/plugin/local/wiki/feel.js index 7598fad0..40ce9929 100644 --- a/plugin/local/wiki/feel.js +++ b/plugin/local/wiki/feel.js @@ -5,14 +5,20 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.onmotion.clear(can) can.base.endWith(item.path, nfs.PS)? can.onimport.item(can, item, function(event) { can.Option(nfs.PATH, item.path) && can.Update(event) }): can.list.push(item) }) can.core.List(can.list, function(item, index) { item.nick = (can.misc.localStorage(can, can.onexport.key(can, "p", can.onimport._file(can, item.path)))||"")+" "+item.name; var target = can.onimport.item(can, item, function(_event) { - can.cb = function(event) { var target = _event.target, next = _event.target.nextSibling + var target = _event.target + can.cb = function(event) { var next = _event.target.nextSibling can.misc.localStorage(can, can.onexport.key(can, "last"), item.path) can.video = event.target, can.Status(item), target.innerHTML = parseInt(event.target.currentTime*100/event.target.duration)+"% "+item.name if (event.type == "ended" && next) { can.onmotion.delay(can, function() { next.click() }, 3000), can.user.toast(can, "3s 后即将播放下一个", "", 3000) } } can.onmotion.clear(can, can.ui.content) can.onimport.file(can, item.path, item, index, can.ui.content, can.ConfHeight()-can.onexport.height(can)-1, true).focus() - }, function() {}, can.ui.project); item.path == can.misc.localStorage(can, can.onexport.key(can, "last")) && target.click() }) + can.onmotion.delay(can, function() { target.scrollIntoView(), can.onimport.layout(can, can.ConfHeight(), can.ConfWidth()) }) + }, function() {}, can.ui.project); + if (item.path == can.misc.localStorage(can, can.onexport.key(can, "last"))) { + target.click(), can.isCmdMode() && can.onmotion.delay(can, function() { can.onaction.full({}, can) }) + } + }) can.onimport.page(can, can.list, can.begin = parseInt(msg.Option(cli.BEGIN)||"0")) }, _file: function(can, path) { var p = location.href.indexOf(ice.HTTP) == 0? "": "http://localhost:9020" @@ -32,6 +38,11 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { can.onmotion.clear(can) can.page.style(can, can.ui.display, html.WIDTH, can.ConfWidth()-can.ui.project.offsetWidth) can.list.length > 0 && can.page.style(can, can.ui.project, html.HEIGHT, can.base.Min(can.ui.display.offsetHeight, can.Action(html.HEIGHT), can.ConfHeight())) can.isCmdMode() && can.page.style(can, can.ui.project, html.HEIGHT, can.ConfHeight()) + can.isCmdMode() && can.page.Select(can, can.ui.content, "video", function(target) { + can.page.isDisplay(can.ui.project)? + can.page.style(can, target, html.HEIGHT, can.ui.content.offsetHeight, html.MAX_WIDTH, can.ui.content.offsetWidth): + can.page.style(can, target, html.HEIGHT, can.page.height(), html.MAX_WIDTH, can.page.width()) + }) }, }, [""]) Volcanos(chat.ONFIGURE, {