v26110233 广场普通卡去话题;图上文字 30% 放顶部/中间;回复里「作者」拉开间距;自己的评论带孕周;我的收藏(首页「我的」入口 + 广场收藏层)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,13 +51,15 @@
|
||||
var SK = 'mmbox.tp.v1', UK = (function () { var m = ((location.hash || '') + '&' + (location.search || '')).match(/[#?&]openid=([^&]*)/); return m ? decodeURIComponent(m[1]) : '_guest'; })();
|
||||
function loadMe() { try { var a = JSON.parse(localStorage.getItem(SK) || '{}') || {}; var m = a[UK] || {}; m.cm = m.cm || {}; m.lk = m.lk || {}; return { a: a, m: m }; } catch (e) { return { a: {}, m: { cm: {}, lk: {} } }; } }
|
||||
function saveMe(st) { try { st.a[UK] = st.m; localStorage.setItem(SK, JSON.stringify(st.a)); } catch (e) {} }
|
||||
/* 11-02 用户:自己发的评论带上孕周(首页写进 mmbox.gcwk.v1) */
|
||||
function myStage() { try { var g = JSON.parse(localStorage.getItem('mmbox.gcwk.v1') || 'null'); return !g ? '' : g.pp ? '宝妈' : g.w ? '孕 ' + g.w + ' 周' : ''; } catch (e) { return ''; } }
|
||||
function avP(a) { return typeof a === 'number' ? '../../guangchang/av/' + ('000' + a).slice(-4) + '.webp' : '../../assets/img/mom/' + a + '.jpg'; }
|
||||
function wan(n) { return n >= 1e4 ? (Math.round(n / 1e3) / 10) + '万' : String(n); }
|
||||
var HEART = '<svg viewBox="0 0 24 24"><path d="M12 20s-7-4.4-7-10a4 4 0 017-2.6A4 4 0 0119 10c0 5.6-7 10-7 10z"/></svg>';
|
||||
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=26110232').then(function (idx) {
|
||||
getJSON('../_shared/idx.json?v=26110233').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; });
|
||||
@@ -79,7 +81,7 @@
|
||||
function item(c, key) {
|
||||
var lk = !!st.m.lk[key];
|
||||
return '<div class="tc-it">' + (c.me ? '<span class="tc-av tc-me">我</span>' : '<img class="tc-av" src="' + esc(avP(c[1])) + '" alt="" loading="lazy">') +
|
||||
'<div class="tc-b"><div class="tc-n"><b>' + esc(c.me ? '我' : c[0]) + '</b>' + (c.me ? '<i>刚刚</i>' : (c[2] ? '<i>' + esc(c[2]) + '</i>' : '')) + '</div>' +
|
||||
'<div class="tc-b"><div class="tc-n"><b>' + esc(c.me ? '我' : c[0]) + '</b>' + (c.me ? '<i>' + esc(c.s || myStage() || '刚刚') + '</i>' : (c[2] ? '<i>' + esc(c[2]) + '</i>' : '')) + '</div>' +
|
||||
'<div class="tc-t">' + esc(c.me ? c.t : c[3]) + '</div>' +
|
||||
(!c.me && c[5] && c[5].length ? '<div class="tc-r">' + c[5].map(function (r) { return '<p><b>' + esc(r[0]) + ':</b>' + esc(r[3]) + '</p>'; }).join('') + '</div>' : '') +
|
||||
'<div class="tc-f"><button type="button" class="tc-lk' + (lk ? ' on' : '') + '" data-k="' + esc(key) + '">' + HEART + '<span>' + ((c.me ? 0 : c[4]) + (lk ? 1 : 0) || '赞') + '</span></button></div></div></div>';
|
||||
@@ -88,21 +90,21 @@
|
||||
var my = mine().slice().reverse(), n = L.length + my.length, show = open ? L : L.slice(0, 5);
|
||||
box.innerHTML = '<div class="tt-h"><b>大家怎么说</b><span>' + n + ' 条评论</span></div>' +
|
||||
'<div class="tc-in"><textarea rows="1" maxlength="200" placeholder="说说你的情况,和其他妈妈聊聊…"></textarea><button type="button" disabled>发布</button></div>' +
|
||||
'<div class="tc-list">' + my.map(function (c, i) { return item({ me: 1, t: c.t }, 'me' + c.ts); }).join('') +
|
||||
'<div class="tc-list">' + my.map(function (c, i) { return item({ me: 1, t: c.t, s: c.s }, 'me' + c.ts); }).join('') +
|
||||
show.map(function (c, i) { return item(c, SLUG + '#' + i); }).join('') + '</div>' +
|
||||
(!open && L.length > 5 ? '<button type="button" class="tc-more">展开全部 ' + n + ' 条评论</button>' : '');
|
||||
var ta = box.querySelector('textarea'), bt = box.querySelector('.tc-in button');
|
||||
ta.addEventListener('input', function () { bt.disabled = !ta.value.trim(); ta.style.height = '24px'; ta.style.height = Math.min(96, ta.scrollHeight) + 'px'; });
|
||||
bt.addEventListener('click', function () {
|
||||
var v = ta.value.trim(); if (!v) return;
|
||||
(st.m.cm[SLUG] = mine()).push({ t: v.slice(0, 200), ts: Date.now() }); saveMe(st); paint();
|
||||
(st.m.cm[SLUG] = mine()).push({ t: v.slice(0, 200), ts: Date.now(), s: myStage() }); saveMe(st); paint();
|
||||
});
|
||||
var mo = box.querySelector('.tc-more'); if (mo) mo.addEventListener('click', function () { open = true; paint(); });
|
||||
[].forEach.call(box.querySelectorAll('.tc-lk'), function (b) {
|
||||
b.addEventListener('click', function () { var k = b.dataset.k; if (st.m.lk[k]) delete st.m.lk[k]; else st.m.lk[k] = 1; saveMe(st); paint(); });
|
||||
});
|
||||
}
|
||||
getJSON('../_shared/cm/' + SLUG + '.json?v=26110232').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
|
||||
getJSON('../_shared/cm/' + SLUG + '.json?v=26110233').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
|
||||
}
|
||||
|
||||
function extras(el) {
|
||||
|
||||
Reference in New Issue
Block a user