Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
24 lines
1.6 KiB
JavaScript
24 lines
1.6 KiB
JavaScript
'use strict';
|
|
/* ============================================================================
|
|
* 비밀번호 규칙 안내 (v1.3.17)
|
|
* 화면의 "비밀번호(6자 이상)" 같은 안내 문구를 관리자 콘솔에서 정한 지금 규칙으로 바꿔 보인다.
|
|
* 대상: data-pw-rule 속성이 있는 입력칸(placeholder 의 괄호 안 규칙)과 라벨. 규칙 검사는 서버가 한다.
|
|
* data-pw-rule="placeholder" — placeholder 를 "<원래 앞말> (<규칙>)" 으로
|
|
* data-pw-rule="label" — 라벨 글자의 "(…)" 부분을 규칙으로
|
|
* 전역: window.pwRuleText (규칙 문장, 불러오기 전에는 null), window.applyPwRule(root)
|
|
* ========================================================================== */
|
|
(function () {
|
|
window.pwRuleText = null;
|
|
var tr = function (s) { return typeof window.T === 'function' ? window.T(s) : s; };
|
|
function apply(root) {
|
|
if (!window.pwRuleText) return;
|
|
(root || document).querySelectorAll('[data-pw-rule]').forEach(function (el) {
|
|
var mode = el.getAttribute('data-pw-rule');
|
|
if (mode === 'placeholder') { var head = (el.getAttribute('data-pw-head') || ''); el.placeholder = head ? head + ' (' + window.pwRuleText + ')' : window.pwRuleText; }
|
|
else if (mode === 'label') { var n = el.firstChild; if (n && n.nodeType === 3) n.nodeValue = n.nodeValue.replace(/\([^)]*\)/, '(' + window.pwRuleText + ')'); }
|
|
});
|
|
}
|
|
window.applyPwRule = apply;
|
|
fetch('/api/auth/password-policy', { credentials: 'same-origin' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (d) { if (d && d.text) { window.pwRuleText = d.text; apply(); } }).catch(function () {});
|
|
})();
|