diff --git a/js/login-gate.js b/js/login-gate.js index 8a4621b..26fe004 100644 --- a/js/login-gate.js +++ b/js/login-gate.js @@ -105,17 +105,23 @@ function page() { if (document.getElementById('homeBody')) return 'home'; if (document.getElementById('wf')) return 'plaza'; - return 'topic'; + if (/\/topic\//.test(location.pathname)) return 'topic'; + return 'other'; } + /* 其他应用(数胎动、体重……)引本文件时自己指定: + window.MB_GATE_SEL = '.save-btn,.add-record'; 点了要拦的按钮(CSS 选择器) + window.MB_GATE_IN = '.note-input'; 一聚焦就提示的输入框 + 或在自己的提交函数里:if (window.mbGate && mbGate.need()) return; */ + function selFor(map, cus) { return window[cus] || map[page()] || ''; } document.addEventListener('click', function (e) { if (!G.out || !e.target.closest) return; - var s = SEL[page()]; + var s = selFor(SEL, 'MB_GATE_SEL'); if (s && e.target.closest(s)) G.need(e); }, true); /* 评论输入框:一点进去就提示(别让人打完一段字才发现发不出去) */ document.addEventListener('focusin', function (e) { if (!G.out || !e.target.matches) return; - var s = IN[page()]; + var s = selFor(IN, 'MB_GATE_IN'); if (s && e.target.matches(s)) { e.target.blur(); prompt(); } }, true); })();