24/7 assistant: canned answers + OpenRouter AI, widget on every page
RM Circle pattern: nine canned answers for the questions everyone asks (pyramid, withdrawals, splits, qualification, joining, credits, safety), OpenRouter fallback with a facts-loaded system prompt and hard no-income- promise rules, graceful no-key fallback. Floating mint bubble widget with linkified replies; 10/min per-IP rate limit. Assets v=20260904i. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
// 24/7 assistant widget: floating bubble, slide-up panel, /api/chat.
|
||||
(function () {
|
||||
const root = document.createElement('div');
|
||||
root.id = 'iapChat';
|
||||
root.innerHTML = '<button id="iapChatBtn" aria-label="Chat with us" type="button">💬</button>'
|
||||
+ '<div id="iapChatPanel" hidden>'
|
||||
+ '<div class="ch-head"><b>Ask anything</b><span class="ch-sub">Real answers, around the clock</span>'
|
||||
+ '<button id="iapChatClose" aria-label="Close chat" type="button">×</button></div>'
|
||||
+ '<div class="ch-msgs" id="iapChatMsgs">'
|
||||
+ '<div class="ch-m bot">Hey. Ask me how the payments work, what the packages buy, or anything else. Straight answers only, no income hype.</div>'
|
||||
+ '</div>'
|
||||
+ '<div class="ch-input"><input id="iapChatIn" placeholder="Type your question…" maxlength="600">'
|
||||
+ '<button id="iapChatSend" type="button">Send</button></div>'
|
||||
+ '</div>';
|
||||
document.body.appendChild(root);
|
||||
|
||||
const $ = id => document.getElementById(id);
|
||||
const msgs = $('iapChatMsgs');
|
||||
const input = $('iapChatIn');
|
||||
let history = [];
|
||||
|
||||
const add = (text, who) => {
|
||||
const d = document.createElement('div');
|
||||
d.className = 'ch-m ' + who;
|
||||
// linkify plain URLs
|
||||
d.innerHTML = String(text).replace(/[&<>]/g, c => ({ '&': '&', '<': '<', '>': '>' }[c]))
|
||||
.replace(/(https?:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>');
|
||||
msgs.appendChild(d);
|
||||
msgs.scrollTop = msgs.scrollHeight;
|
||||
return d;
|
||||
};
|
||||
async function send() {
|
||||
const q = input.value.trim();
|
||||
if (!q) return;
|
||||
input.value = '';
|
||||
add(q, 'me');
|
||||
const wait = add('…', 'bot');
|
||||
try {
|
||||
const r = await (await fetch('/api/chat', { method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message: q, history: history.slice(-4).join(' | ') }) })).json();
|
||||
wait.remove();
|
||||
add(r.reply || r.error || 'No answer came back. Try again.', 'bot');
|
||||
history.push('Q: ' + q, 'A: ' + (r.reply || ''));
|
||||
} catch (e) {
|
||||
wait.remove();
|
||||
add('Connection hiccup. Try that again.', 'bot');
|
||||
}
|
||||
}
|
||||
$('iapChatBtn').addEventListener('click', () => {
|
||||
const p = $('iapChatPanel');
|
||||
p.hidden = !p.hidden;
|
||||
if (!p.hidden) input.focus();
|
||||
});
|
||||
$('iapChatClose').addEventListener('click', () => { $('iapChatPanel').hidden = true; });
|
||||
$('iapChatSend').addEventListener('click', send);
|
||||
input.addEventListener('keydown', e => { if (e.key === 'Enter') send(); });
|
||||
})();
|
||||
@@ -220,6 +220,27 @@ input[type=range]{padding:0;border:0;background:transparent;accent-color:var(--m
|
||||
input:focus,select:focus{border-color:var(--mint)}
|
||||
:focus-visible{outline:2px solid var(--mint);outline-offset:2px}
|
||||
.hero-note{font-family:var(--mono);font-size:12px;color:var(--muted);margin-top:26px}
|
||||
/* chat widget */
|
||||
#iapChatBtn{position:fixed;right:20px;bottom:20px;z-index:40;width:56px;height:56px;border-radius:50%;
|
||||
border:0;background:var(--mint);color:var(--mint-ink);font-size:24px;cursor:pointer;
|
||||
box-shadow:0 8px 30px rgba(67,232,195,.4)}
|
||||
#iapChatBtn:hover{transform:scale(1.06)}
|
||||
#iapChatPanel{position:fixed;right:20px;bottom:88px;z-index:40;width:min(360px,calc(100vw - 40px));
|
||||
background:var(--panel-solid);border:1px solid var(--line-strong);border-radius:18px;overflow:hidden;
|
||||
box-shadow:0 24px 70px rgba(0,0,0,.65);display:flex;flex-direction:column}
|
||||
.ch-head{padding:14px 16px;border-bottom:1px solid var(--line);font-family:var(--disp);position:relative}
|
||||
.ch-head .ch-sub{display:block;font-size:12px;color:var(--muted);font-family:"Segoe UI",system-ui,sans-serif}
|
||||
#iapChatClose{position:absolute;right:10px;top:10px;background:transparent;border:0;color:var(--muted);
|
||||
font-size:22px;cursor:pointer;line-height:1}
|
||||
.ch-msgs{padding:14px;overflow-y:auto;max-height:340px;display:flex;flex-direction:column;gap:10px}
|
||||
.ch-m{border-radius:12px;padding:9px 13px;font-size:13.5px;line-height:1.5;max-width:86%}
|
||||
.ch-m.bot{background:rgba(67,232,195,.08);border:1px solid rgba(67,232,195,.2);align-self:flex-start}
|
||||
.ch-m.me{background:rgba(130,148,196,.12);border:1px solid var(--line);align-self:flex-end}
|
||||
.ch-m a{word-break:break-all}
|
||||
.ch-input{display:flex;gap:8px;padding:11px;border-top:1px solid var(--line)}
|
||||
.ch-input input{flex:1;min-width:0}
|
||||
.ch-input button{background:var(--mint);color:var(--mint-ink);border:0;border-radius:10px;padding:0 16px;
|
||||
font-weight:700;cursor:pointer;font-family:var(--disp)}
|
||||
@media(prefers-reduced-motion:no-preference){
|
||||
.feed .row:first-child{animation:landed .9s ease}
|
||||
@keyframes landed{from{background:rgba(67,232,195,.3)}to{background:var(--mint-soft)}}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<title>The contract | InstantAdPay</title>
|
||||
<meta name="description" content="Plain-language review of the InstantAdPay settlement contract: what it does, what nobody can change, what the operator can and cannot touch, and how to verify all of it yourself.">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904h">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904i">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
@@ -129,7 +129,8 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260904h"></script>
|
||||
<script src="/assets/contract.js?v=20260904h"></script>
|
||||
<script src="/assets/common.js?v=20260904i"></script>
|
||||
<script src="/assets/contract.js?v=20260904i"></script>
|
||||
<script src="/assets/chat.js?v=20260904i"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+5
-4
@@ -5,7 +5,7 @@
|
||||
<title>InstantAdPay: advertise and earn, locked in code</title>
|
||||
<meta name="description" content="Real ad packages with instant on-chain settlement. Every purchase pays the sponsor line in the same transaction, verifiable by anyone on the live ledger.">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904h">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904i">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -398,8 +398,9 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script src="/assets/common.js?v=20260904h"></script>
|
||||
<script src="/assets/wallet.js?v=20260904h"></script>
|
||||
<script src="/assets/home.js?v=20260904h"></script>
|
||||
<script src="/assets/common.js?v=20260904i"></script>
|
||||
<script src="/assets/wallet.js?v=20260904i"></script>
|
||||
<script src="/assets/home.js?v=20260904i"></script>
|
||||
<script src="/assets/chat.js?v=20260904i"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+4
-3
@@ -5,7 +5,7 @@
|
||||
<title>Live ledger | InstantAdPay</title>
|
||||
<meta name="description" content="Every purchase, payout, and pass-up on InstantAdPay, streamed straight from the blockchain with a verify link on every line.">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904h">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904i">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
@@ -25,7 +25,8 @@
|
||||
<div>InstantAdPay · <a href="/">how it works</a> · <a id="contractLink" href="#" target="_blank" rel="noopener">contract source ↗</a></div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260904h"></script>
|
||||
<script src="/assets/ledger.js?v=20260904h"></script>
|
||||
<script src="/assets/common.js?v=20260904i"></script>
|
||||
<script src="/assets/ledger.js?v=20260904i"></script>
|
||||
<script src="/assets/chat.js?v=20260904i"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+5
-4
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>My account | InstantAdPay</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904h">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260904i">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
@@ -131,8 +131,9 @@
|
||||
|
||||
<footer><div>InstantAdPay · <a href="/ledger">live ledger</a></div></footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20260904h"></script>
|
||||
<script src="/assets/wallet.js?v=20260904h"></script>
|
||||
<script src="/assets/my.js?v=20260904h"></script>
|
||||
<script src="/assets/common.js?v=20260904i"></script>
|
||||
<script src="/assets/wallet.js?v=20260904i"></script>
|
||||
<script src="/assets/my.js?v=20260904i"></script>
|
||||
<script src="/assets/chat.js?v=20260904i"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user