diff --git a/guangchang/ceshi/index.html b/guangchang/ceshi/index.html index 7c24b1a..37ea46f 100644 --- a/guangchang/ceshi/index.html +++ b/guangchang/ceshi/index.html @@ -320,8 +320,8 @@ mark{background:linear-gradient(transparent 62%,var(--c20) 0);color:inherit;padd
- - + + - - - + + + + + @@ -2570,17 +2570,17 @@ - + - - + + - + diff --git a/js/app.js b/js/app.js index 26b3f6c..566af85 100644 --- a/js/app.js +++ b/js/app.js @@ -3,7 +3,7 @@ (function () { 'use strict'; /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ - var VER = '26110286'; + var VER = '26110287'; const $ = (s, c) => (c || document).querySelector(s); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); diff --git a/js/gch/v4.js b/js/gch/v4.js index ea9fcfb..5eed656 100644 --- a/js/gch/v4.js +++ b/js/gch/v4.js @@ -231,5 +231,5 @@ } /* feed.js 首页默认不加载(index.html 只引了 topics.js),这里按需拉一次 */ if (window.GC_FEED) init(); - else { var fs = document.createElement('script'); fs.src = 'guangchang/feed.js?v=26110286'; fs.onload = fs.onerror = init; document.body.appendChild(fs); } + else { var fs = document.createElement('script'); fs.src = 'guangchang/feed.js?v=26110287'; fs.onload = fs.onerror = init; document.body.appendChild(fs); } })(); diff --git a/js/gch/v6.js b/js/gch/v6.js index d9dbe22..8b64003 100644 --- a/js/gch/v6.js +++ b/js/gch/v6.js @@ -6,9 +6,9 @@ (function () { var sec = document.getElementById('gcHome'); if (!sec) return; - var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/gch/v4.css?v=26110286'; + var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/gch/v4.css?v=26110287'; document.head.appendChild(l); - var s = document.createElement('script'); s.src = 'js/gch/v4.js?v=26110286'; + var s = document.createElement('script'); s.src = 'js/gch/v4.js?v=26110287'; s.onload = function () { if (sec.querySelector('.g4-foot')) merge(); else sec.addEventListener('gc4-ready', merge, { once: true }); }; /* v4 要先拉 feed.js 才渲染 */ document.body.appendChild(s); diff --git a/js/kit.css b/js/kit.css index e63ac7e..9b4305a 100644 --- a/js/kit.css +++ b/js/kit.css @@ -93,3 +93,14 @@ html.night .kit-pn .kit-rows .kr{border-bottom-color:rgba(255,255,255,.1)} .kr .lv-i{overflow:hidden;text-overflow:ellipsis} html.night .lv-i em{color:#F1E6EE} @media (prefers-reduced-motion:reduce){.lv-i{transition:none}} +/* 11-04 三改:每条叠放「静态行 / 滚动行」,.kr.live 时显示滚动(kit.js lvShuffle 随机 2~3 条) */ +.kr-sw{position:relative;display:block;height:18px} +.kr-sw>.kr-n,.kr-sw>.kr-lv{position:absolute;left:0;right:0;top:0;transition:opacity .35s ease} +.kr-sw>.kr-lv{opacity:0;pointer-events:none} +.kr.live .kr-sw>.kr-lv{opacity:1} +.kr.live .kr-sw>.kr-n{opacity:0} +.kr.t-qa .lv-i{color:#2E9B78} +/* 生娃计算器固定第一条,图标块左上角小火苗 */ +.kr-ic{position:relative} +.kr-hot{position:absolute;right:-6px;top:-6px;display:grid;place-items:center;width:17px;height:17px;border-radius:50%;background:linear-gradient(135deg,#F0453A,#FF8A3D);border:1.5px solid #fff;box-sizing:content-box} +.kr-hot svg{width:11px;height:11px;color:#fff} diff --git a/js/kit.js b/js/kit.js index e174832..d276df7 100644 --- a/js/kit.js +++ b/js/kit.js @@ -9,7 +9,7 @@ if (/[?&]kit=0(?:&|$)/.test(location.search)) return; var box = document.getElementById('kit'), sec = document.getElementById('kitHome'); if (!box || !sec) return; - var V = '26110286'; + var V = '26110287'; var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/kit.css?v=' + V; document.head.appendChild(l); document.documentElement.classList.add('has-kit'); @@ -88,9 +88,12 @@ } var cl = CALC.filter(function (x) { return !(x.gate && wk && wk < x.gate); }); if (b >= 5) cl = [cl[cl.length - 1]].concat(cl.slice(0, -1)); /* 孕 29 周起产假排前 */ + /* 11-04 用户:「生娃计算器放第一个,标个火」→ 计算器两条里 huafei 必在,排到 6 条最前(hot) */ + var hf = CALC[0]; cl = [hf].concat(cl.filter(function (x) { return x !== hf; })); cl.slice(0, 2).forEach(function (x) { out.js.push({ q: x.q, href: x.h + (x.cm ? (location.search ? location.search + '&' : '?') + 'calc=1' : location.search) + location.hash, n: total() * x.heat, u: '人算过' }); }); var r = []; - for (var k = 0; k < 2; k++) ['qz', 'qa', 'js'].forEach(function (c) { if (out[c][k]) r.push(Object.assign({ c: c }, out[c][k])); }); + if (out.js[0]) r.push(Object.assign({ c: 'js', hot: 1 }, out.js[0])); + [['qz', 0], ['qa', 0], ['js', 1], ['qz', 1], ['qa', 1]].forEach(function (p) { if (out[p[0]][p[1]]) r.push(Object.assign({ c: p[0] }, out[p[0]][p[1]])); }); return { r: r, wk: wk }; } var TAG = { qz: '测试', qa: '百问', js: '计算器' }; @@ -108,16 +111,16 @@ /* 11-03 用户:「这 6 条跟下面孕妈广场那 6 条太像,换个形式」→(便签墙试过,用户要回到一行一条的排列,只换样式) 一行一条,但不用名次数字和配图:左边按类型的彩色图标块(测试紫 / 百问绿 / 计算器橙),中间问题 + 类型·人数,右边 ›(11-03 用户嫌乱,样式收成一张白卡,见 kit.css)。 */ L.className = 'kit-list kit-rows'; - var can = d.r.map(function (x, i) { return lvList(x) ? i : -1; }).filter(function (i) { return i >= 0; }); - if (!LV_PICK || LV_PICK.some(function (i) { return can.indexOf(i) < 0; })) { - LV_PICK = can.slice().sort(function () { return Math.random() - .5; }).slice(0, 2); - } - L.innerHTML = d.r.map(function (x, i) { - var lv = LV_PICK.indexOf(i) >= 0 && lvList(x); - return '' + KR_CH[x.c] + '' + - '' + esc(x.q) + '' + (lv ? lvHTML(lv) : '' + TAG[x.c] + '' + FIRE + '' + wan(x.n) + '' + x.u + '') + '' + + /* 11-04 二改:「不用固定两个,6 条里随机 2~3 条在滚,一会儿换别的」→ 每条都备好静态行 + 滚动行(.kr-sw 叠放), + lvShuffle 每 5~7 秒随机定 2~3 条显示滚动(每次至少换 1 条),其余显示「类型 · 人数」 */ + L.innerHTML = d.r.map(function (x) { + var lv = lvList(x); + return '' + KR_CH[x.c] + + (x.hot ? '' + FIRE + '' : '') + '' + + '' + esc(x.q) + '' + TAG[x.c] + '' + FIRE + '' + wan(x.n) + '' + x.u + '' + (lv ? lvHTML(lv) : '') + '' + '' + KR_GO[x.c] + ''; }).join(''); + lvShuffle(); lvRun(); } /* ---------- 6 条里随机 2 条:类型·人数 那一行换成「谁测出了什么 / 谁算出了多少」滚动 ---------- @@ -133,12 +136,13 @@ '/taier-guzhong/': ['估出宝宝约 1.6 斤', '估出宝宝约 2.3 斤', '估出宝宝约 3.1 斤'], 'topic/zhichang/': ['算出产假能休 178 天(广东)', '算出产假能休 158 天(上海)', '算出产假能休 188 天(河南)', '算出产假能休 180 天(吉林)'] }; - var LV_PICK = null, lvT = 0, lvN = Math.floor(Math.random() * LV_NM.length); + var lvT = 0, lvN = Math.floor(Math.random() * LV_NM.length); function lvList(x) { if (x.c === 'qz') { var id = (x.href.match(/[?&]id=(t\d+)/) || [])[1], r = (window.GC_RES || {})[id]; return r && r.length ? r.map(function (t) { return '测出「' + esc(t) + '」'; }) : null; } + if (x.c === 'qa') return ['刚看完这条', '正在看', '收藏了这条', '把这条转给了老公']; var k = Object.keys(LV_JS).filter(function (h) { return x.href.indexOf(h) === 0; })[0]; return k ? LV_JS[k] : null; } @@ -148,13 +152,26 @@ return '' + LV_NM[j] + '' + t + ''; }).join('') + ''; } + var lvS = 0, LV_ON = []; + function lvShuffle() { + var rs = [].slice.call(box.querySelectorAll('.kit-rows .kr')).filter(function (r) { return r.querySelector('.kr-lv'); }); + if (!rs.length) return; + var n = Math.min(rs.length, Math.random() < .5 ? 2 : 3), nx, t = 0; + do { /* 随机挑 n 条;和上一轮完全一样就重挑,保证每次都有变化 */ + nx = rs.map(function (r, i) { return i; }).sort(function () { return Math.random() - .5; }).slice(0, n).sort(); + } while (nx.join() === LV_ON.join() && ++t < 9); + LV_ON = nx; + rs.forEach(function (r, i) { r.classList.toggle('live', LV_ON.indexOf(i) >= 0); }); + clearTimeout(lvS); + lvS = setTimeout(lvShuffle, 5000 + Math.random() * 2000); + } function lvRun() { clearInterval(lvT); lvT = setInterval(function () { if (document.hidden) return; box.querySelectorAll('.kr-lv').forEach(function (w) { var a = w.querySelector('.lv-i.on'), b = (a && a.nextElementSibling) || w.firstElementChild; - if (!a || a === b) return; + if (!a || a === b || !w.closest('.kr.live')) return; a.classList.remove('on'); a.classList.add('up'); setTimeout(function () { a.classList.remove('up'); }, 450); b.classList.add('on'); }); diff --git a/topic/_shared/tools.js b/topic/_shared/tools.js index 4119403..5cb33b3 100644 --- a/topic/_shared/tools.js +++ b/topic/_shared/tools.js @@ -68,7 +68,7 @@ function getJSON(u) { return fetch(u, { cache: 'no-cache' }).then(function (r) { if (!r.ok) throw r.status; return r.json(); }); } function related(box) { - getJSON('../_shared/idx.json?v=26110286').then(function (idx) { + getJSON('../_shared/idx.json?v=26110287').then(function (idx) { var me = null; idx.forEach(function (x) { if (x[0] === SLUG) me = x; }); var tag = me ? me[2] : '', h = 0; for (var i = 0; i < SLUG.length; i++) h = (h * 31 + SLUG.charCodeAt(i)) >>> 0; var rest = idx.filter(function (x) { return x[0] !== SLUG; }); @@ -175,7 +175,7 @@ } fetch(API + '/comments?kind=topic&target=' + encodeURIComponent(SLUG) + (OID ? '&openid=' + encodeURIComponent(OID) : '')) .then(function (r) { return r.json(); }).then(function (j) { if (j && j.code === 200) { RC = j.result; paint(); } }).catch(function () {}); - getJSON('../_shared/cm/' + SLUG + '.json?v=26110286').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); }); + getJSON('../_shared/cm/' + SLUG + '.json?v=26110287').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); }); } function extras(el) {