update(chat): update ui chat

This commit is contained in:
Admin 2026-05-20 10:19:09 +07:00
parent 6e60415341
commit a1794db11c
1 changed files with 18 additions and 12 deletions

View File

@ -12,7 +12,6 @@
if (w.__MSW_LOADED__) return; if (w.__MSW_LOADED__) return;
w.__MSW_LOADED__ = true; w.__MSW_LOADED__ = true;
var P = w.PROLOGY_CONFIG || {};
var CFG = { var CFG = {
apiEndpoint: apiEndpoint:
P.CHAT_API_URL || P.CHAT_API_URL ||
@ -24,7 +23,9 @@
rateLimit: { rateLimit: {
max: P.CHAT_RATE_LIMIT_MAX != null ? P.CHAT_RATE_LIMIT_MAX : 3, max: P.CHAT_RATE_LIMIT_MAX != null ? P.CHAT_RATE_LIMIT_MAX : 3,
windowMin: windowMin:
P.CHAT_RATE_LIMIT_WINDOW_MIN != null ? P.CHAT_RATE_LIMIT_WINDOW_MIN : 10, P.CHAT_RATE_LIMIT_WINDOW_MIN != null
? P.CHAT_RATE_LIMIT_WINDOW_MIN
: 10,
}, },
minFillMs: P.CHAT_MIN_FILL_MS != null ? P.CHAT_MIN_FILL_MS : 3000, minFillMs: P.CHAT_MIN_FILL_MS != null ? P.CHAT_MIN_FILL_MS : 3000,
fabImageUrl: fabImageUrl:
@ -97,11 +98,7 @@
var phone = (f.phone || "").trim(); var phone = (f.phone || "").trim();
var message = (f.message || "").trim(); var message = (f.message || "").trim();
if (!name || !/^[\p{L}\p{M}'\-\s]{2,80}$/u.test(name)) e.push("sms-name"); if (!name || !/^[\p{L}\p{M}'\-\s]{2,80}$/u.test(name)) e.push("sms-name");
if ( if (!phone || !/^04\s?\d{2}\s?\d{3}\s?\d{3}$/.test(phone))
!phone ||
!/^[\d\s\+\-\(\)]{7,15}$/.test(phone) ||
!/\d{5,}/.test(phone)
)
e.push("sms-phone"); e.push("sms-phone");
if (!message || message.length < 10) e.push("sms-msg"); if (!message || message.length < 10) e.push("sms-msg");
return e; return e;
@ -146,7 +143,7 @@
/* FAB — no transition on background/box-shadow to kill flicker; only transform transitions */ /* FAB — no transition on background/box-shadow to kill flicker; only transform transitions */
"#fab{position:fixed;bottom:24px;" + pos + "z-index:99998;", "#fab{position:fixed;bottom:24px;" + pos + "z-index:99998;",
"width:60px;height:60px;border-radius:50%;", "width:60px;height:60px;border-radius:50%;",
"background-image:url(" + CFG.fabImageUrl + ");", "background-image:url(https://prology.nswteam.net/media/wysiwyg/image_2026-04-02_15-43-14.png);",
"background-size:cover;background-position:center;background-repeat:no-repeat;", "background-size:cover;background-position:center;background-repeat:no-repeat;",
"border:none;cursor:pointer;outline:none;", "border:none;cursor:pointer;outline:none;",
"box-shadow:0 6px 20px rgba(79,70,229,.4);", "box-shadow:0 6px 20px rgba(79,70,229,.4);",
@ -241,7 +238,7 @@
/* SMS */ /* SMS */
'<div class="pane active" id="pane-sms">', '<div class="pane active" id="pane-sms">',
'<div class="field"><input id="sms-name" type="text" maxlength="80" autocomplete="name" placeholder="Your Name"><div class="hint" id="h-sms-name">Please enter your full name</div></div>', '<div class="field"><input id="sms-name" type="text" maxlength="80" autocomplete="name" placeholder="Your Name"><div class="hint" id="h-sms-name">Please enter your full name</div></div>',
'<div class="field"><input id="sms-phone" type="tel" maxlength="15" autocomplete="tel" placeholder="Mobile Number (Australia)"><div class="hint" id="h-sms-phone">Enter a valid AU mobile number</div></div>', '<div class="field"><input id="sms-phone" type="tel" inputmode="numeric" maxlength="13" autocomplete="tel-national" placeholder="Mobile Phone (AU): 04 XX XXX XXX"><div class="hint" id="h-sms-phone">Enter AU mobile in format: 04 XX XXX XXX</div></div>',
'<div class="field"><textarea id="sms-msg" maxlength="1000" placeholder="How can we help?"></textarea><div class="hint" id="h-sms-msg">Please provide more details (min 10 chars)</div></div>', '<div class="field"><textarea id="sms-msg" maxlength="1000" placeholder="How can we help?"></textarea><div class="hint" id="h-sms-msg">Please provide more details (min 10 chars)</div></div>',
'<div class="hp"><input type="text" id="hp-sms" tabindex="-1" autocomplete="off"></div>', '<div class="hp"><input type="text" id="hp-sms" tabindex="-1" autocomplete="off"></div>',
'<button class="btn-submit" id="btn-sms">Send SMS ' + '<button class="btn-submit" id="btn-sms">Send SMS ' +
@ -275,7 +272,7 @@
'<div class="success-icon">' + SVG_CHECK + "</div>", '<div class="success-icon">' + SVG_CHECK + "</div>",
"<h3>Message Received!</h3>", "<h3>Message Received!</h3>",
"<p>Thanks for reaching out.<br>We'll get back to you shortly.</p>", "<p>Thanks for reaching out.<br>We'll get back to you shortly.</p>",
'<button class="btn-new" id="btn-new">Send another message</button>', '<button class="btn-submit" id="btn-new">Send another message</button>',
"</div>", "</div>",
"</div>", "</div>",
].join(""); ].join("");
@ -424,8 +421,17 @@
bumpRl(); bumpRl();
showSuccess(); showSuccess();
} else if (xhr.status === 429) } else if (xhr.status === 429)
setStatus(prefix, "Server busy. Please try again later.", "warn"); setStatus(
else setStatus(prefix, "Failed to send. Please try again.", "fail"); prefix,
"Too many requests. Please try again later.",
"warn",
);
else
setStatus(
prefix,
"Too many requests. Please try again later.",
"fail",
);
}; };
xhr.ontimeout = function () { xhr.ontimeout = function () {
$btn.disabled = false; $btn.disabled = false;