kryptheon 0.1.72 → 0.1.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/kryptheon.js +21 -2
- package/kryptheon-account.js +22 -3
- package/kryptheon-autostart.js +47 -4
- package/kryptheon-dashboard-page.js +120 -4
- package/kryptheon-dashboard.html +24 -0
- package/kryptheon-dashboard.js +5 -0
- package/kryptheon-tour.js +697 -0
- package/package.json +3 -2
package/bin/kryptheon.js
CHANGED
|
@@ -3471,6 +3471,23 @@ function openInBrowser(url) {
|
|
|
3471
3471
|
}
|
|
3472
3472
|
}
|
|
3473
3473
|
|
|
3474
|
+
/**
|
|
3475
|
+
* The dashboard's page, opened in the browser. Started at sign-in by Start with
|
|
3476
|
+
* Windows (KRYPTHEON_OPEN_DAILY), only at the first sign-in of the day; every
|
|
3477
|
+
* other start opens it as before.
|
|
3478
|
+
*/
|
|
3479
|
+
function openDashboardPage(address) {
|
|
3480
|
+
if (process.env.KRYPTHEON_OPEN_DAILY && !process.env.KRYPTHEON_NO_OPEN) {
|
|
3481
|
+
try {
|
|
3482
|
+
const dir = require(path.join(PACKAGE_DIR, 'kryptheon-store.js')).pathsFor(USER_DIR).dir;
|
|
3483
|
+
if (!require(path.join(PACKAGE_DIR, 'kryptheon-autostart.js')).firstOpenToday(dir)) return false;
|
|
3484
|
+
} catch (err) {
|
|
3485
|
+
/* opened as any other start */
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
return openInBrowser(address);
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3474
3491
|
/**
|
|
3475
3492
|
* The person's own folder picker, on this computer: the one Windows or the
|
|
3476
3493
|
* Mac shows everywhere else. Resolves to the folder, or null when it was
|
|
@@ -3810,7 +3827,7 @@ async function dashboardCommand() {
|
|
|
3810
3827
|
}
|
|
3811
3828
|
if (running && running.version === mine) {
|
|
3812
3829
|
const address = 'http://127.0.0.1:' + DASHBOARD_PORT + '/';
|
|
3813
|
-
const shown =
|
|
3830
|
+
const shown = openDashboardPage(address);
|
|
3814
3831
|
console.log('');
|
|
3815
3832
|
console.log(' The Kryptheon dashboard for ' + path.basename(USER_DIR) + ' is already running:');
|
|
3816
3833
|
console.log('');
|
|
@@ -3822,6 +3839,8 @@ async function dashboardCommand() {
|
|
|
3822
3839
|
}
|
|
3823
3840
|
const opened = openStore();
|
|
3824
3841
|
if (!opened) return 1;
|
|
3842
|
+
// A Start with Windows file from an older version, which never opened the page, gets today's text.
|
|
3843
|
+
try { require(path.join(PACKAGE_DIR, 'kryptheon-autostart.js')).refresh(USER_DIR); } catch (err) { /* left as it was */ }
|
|
3825
3844
|
const dash = require(path.join(PACKAGE_DIR, 'kryptheon-dashboard.js'));
|
|
3826
3845
|
const app = dash.createServer(USER_DIR, {
|
|
3827
3846
|
run: (id, say) => runFromDashboard(id, opened, say),
|
|
@@ -3844,7 +3863,7 @@ async function dashboardCommand() {
|
|
|
3844
3863
|
port = await app.listen(0);
|
|
3845
3864
|
}
|
|
3846
3865
|
const address = 'http://127.0.0.1:' + port + '/';
|
|
3847
|
-
const shown =
|
|
3866
|
+
const shown = openDashboardPage(address);
|
|
3848
3867
|
console.log('');
|
|
3849
3868
|
console.log(' Kryptheon dashboard for ' + path.basename(USER_DIR) + ':');
|
|
3850
3869
|
console.log('');
|
package/kryptheon-account.js
CHANGED
|
@@ -116,7 +116,9 @@ async function refresh(root, env) {
|
|
|
116
116
|
return { ok: true, account: summary(read(root, env)) };
|
|
117
117
|
}
|
|
118
118
|
if (r.status !== 200) return { ok: false, why: (r.body && r.body.error) || 'kryptheon.tech did not answer', account: summary(a) };
|
|
119
|
-
|
|
119
|
+
const kept = keep(root, env, a.code, r.body, a.unlocked);
|
|
120
|
+
if (a.setupReported) write(root, env, Object.assign({}, kept, { setupReported: a.setupReported }));
|
|
121
|
+
return { ok: true, account: summary(read(root, env)) };
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/** Opens one finding's fix prompt: free on Pro and Studio; on Starter, one of the five this month. */
|
|
@@ -141,6 +143,23 @@ async function unlock(root, env, findingId) {
|
|
|
141
143
|
return { ok: true, account: summary(read(root, env)) };
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
/**
|
|
147
|
+
* The set-up is finished - the guide on this dashboard reached its end. Said to kryptheon.tech once, so the account
|
|
148
|
+
* page there opens instead of the first-time journey. Kept as said only when kryptheon.tech answers that it recorded
|
|
149
|
+
* it (setupRecorded); an older kryptheon.tech that does not know the word is asked again next time.
|
|
150
|
+
*/
|
|
151
|
+
async function setupDone(root, env) {
|
|
152
|
+
const a = read(root, env);
|
|
153
|
+
if (!a || !a.code) return { ok: false, status: 409, why: 'connect your Kryptheon account first' };
|
|
154
|
+
if (a.setupReported) return { ok: true, already: true, account: summary(a) };
|
|
155
|
+
const r = await ask(env, a.code, { setupDone: true });
|
|
156
|
+
if (r.status === 0) return { ok: false, status: 503, why: r.why };
|
|
157
|
+
if (r.status !== 200) return { ok: false, status: r.status, why: (r.body && r.body.error) || 'kryptheon.tech did not answer' };
|
|
158
|
+
if (!r.body.setupRecorded) return { ok: true, recorded: false, account: summary(a) };
|
|
159
|
+
write(root, env, Object.assign({}, a, { setupReported: new Date().toISOString() }));
|
|
160
|
+
return { ok: true, recorded: true, account: summary(read(root, env)) };
|
|
161
|
+
}
|
|
162
|
+
|
|
144
163
|
function disconnect(root, env) {
|
|
145
164
|
forget(root, env);
|
|
146
165
|
return { ok: true, account: summary(null) };
|
|
@@ -153,7 +172,7 @@ function summary(a) {
|
|
|
153
172
|
}
|
|
154
173
|
return {
|
|
155
174
|
connected: true, app: a.app, plan: a.plan, clientReport: !!a.clientReport, prompts: a.prompts, month: a.month,
|
|
156
|
-
checkedAt: a.checkedAt, accountPage: ACCOUNT_PAGE, pricing: PRICING,
|
|
175
|
+
checkedAt: a.checkedAt, accountPage: ACCOUNT_PAGE, pricing: PRICING, setupReported: !!a.setupReported,
|
|
157
176
|
};
|
|
158
177
|
}
|
|
159
178
|
|
|
@@ -180,4 +199,4 @@ function lock(state, root, env) {
|
|
|
180
199
|
return out;
|
|
181
200
|
}
|
|
182
201
|
|
|
183
|
-
module.exports = { connect, refresh, unlock, disconnect, lock, summary, fingerprintOf, read, ENTITLEMENT, CODE };
|
|
202
|
+
module.exports = { connect, refresh, unlock, setupDone, disconnect, lock, summary, fingerprintOf, read, ENTITLEMENT, CODE };
|
package/kryptheon-autostart.js
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* the folder itself. The file says what it is and runs one thing:
|
|
10
10
|
* npx kryptheon@latest dashboard, in a minimized window on the taskbar. A
|
|
11
11
|
* window, not a hidden process: something that starts by itself at sign-in
|
|
12
|
-
* should be seen, and closing it stops it.
|
|
12
|
+
* should be seen, and closing it stops it. The page itself opens in the
|
|
13
|
+
* browser once a day, at the first sign-in of the day - asked for by the
|
|
14
|
+
* owner, so the dashboard is in front of the person daily without a command.
|
|
13
15
|
*
|
|
14
16
|
* Only the file this module wrote is ever removed: it is recognised by its
|
|
15
17
|
* first lines, never by its name alone.
|
|
@@ -77,10 +79,12 @@ function script(root) {
|
|
|
77
79
|
':run',
|
|
78
80
|
'title Kryptheon dashboard - ' + name,
|
|
79
81
|
'rem npx starts the command "kryptheon": never look for it in the current folder,',
|
|
80
|
-
'rem where a Kryptheon.cmd launcher may sit
|
|
82
|
+
'rem where a Kryptheon.cmd launcher may sit. The dashboard opens in the browser',
|
|
83
|
+
'rem once a day - at the first sign-in of the day - and not again that day.',
|
|
81
84
|
'set NoDefaultCurrentDirectoryInExePath=1',
|
|
82
85
|
'set KRYPTHEON_LAUNCHER=1',
|
|
83
|
-
'set KRYPTHEON_NO_OPEN=
|
|
86
|
+
'set KRYPTHEON_NO_OPEN=',
|
|
87
|
+
'set KRYPTHEON_OPEN_DAILY=1',
|
|
84
88
|
'cd /d ' + quoted + ' || goto gone',
|
|
85
89
|
'echo.',
|
|
86
90
|
'echo Kryptheon dashboard, started when you signed in, for:',
|
|
@@ -145,4 +149,43 @@ function setAutostart(root, on, env, platform) {
|
|
|
145
149
|
return Object.assign({ ok: true }, status(root, env, platform));
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
/**
|
|
153
|
+
* A file this module wrote with an older version's text - one that never
|
|
154
|
+
* opened the browser - is written again with today's. Only a file that carries
|
|
155
|
+
* the mark, and only when it is on; anything else is left as it is.
|
|
156
|
+
*/
|
|
157
|
+
function refresh(root, env, platform) {
|
|
158
|
+
const s = status(root, env, platform);
|
|
159
|
+
if (!s.on) return { ok: true, changed: false };
|
|
160
|
+
try {
|
|
161
|
+
const now = fs.readFileSync(s.file, 'utf8');
|
|
162
|
+
const want = script(root);
|
|
163
|
+
if (now === want) return { ok: true, changed: false };
|
|
164
|
+
fs.writeFileSync(s.file, want, 'utf8');
|
|
165
|
+
return { ok: true, changed: true };
|
|
166
|
+
} catch (err) {
|
|
167
|
+
return { ok: false, changed: false, why: err.message };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether the dashboard started at sign-in should open the browser now: yes
|
|
173
|
+
* the first time on a day, no after that. The day is kept in the project's own
|
|
174
|
+
* Kryptheon folder. Asked only when started with KRYPTHEON_OPEN_DAILY.
|
|
175
|
+
*/
|
|
176
|
+
function firstOpenToday(dir, now) {
|
|
177
|
+
const day = (now || new Date()).toLocaleDateString('en-CA');
|
|
178
|
+
const file = path.join(dir, 'opened-on.txt');
|
|
179
|
+
let last = '';
|
|
180
|
+
try { last = fs.readFileSync(file, 'utf8').trim(); } catch (err) { last = ''; }
|
|
181
|
+
if (last === day) return false;
|
|
182
|
+
try {
|
|
183
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
184
|
+
fs.writeFileSync(file, day + '\n', 'utf8');
|
|
185
|
+
} catch (err) {
|
|
186
|
+
/* opened anyway: a page shown twice is better than never */
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
module.exports = { startupDir, fileFor, script, status, setAutostart, refresh, firstOpenToday, MARK };
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
terminal: 'M4 5h16v14H4zM7 9l3 3-3 3M13 15h4',
|
|
54
54
|
folder: 'M3 6h6l2 2h10v11H3z',
|
|
55
55
|
dot: 'M12 12h.01',
|
|
56
|
+
up: 'M12 19V5m-6 6l6-6 6 6',
|
|
56
57
|
};
|
|
57
58
|
function icon(name, size) {
|
|
58
59
|
var s = svgEl('svg', {
|
|
@@ -104,6 +105,26 @@
|
|
|
104
105
|
busy = on;
|
|
105
106
|
Array.prototype.forEach.call(document.querySelectorAll('[data-action]'), function (b) { b.disabled = on; });
|
|
106
107
|
if (state) renderLaunch();
|
|
108
|
+
tell();
|
|
109
|
+
}
|
|
110
|
+
// The set-up is finished (the guide's end): kryptheon.tech is told once, so its account page opens instead of the
|
|
111
|
+
// first-time journey. Asked again on a later load while it has not been recorded there.
|
|
112
|
+
var setupSaid = false;
|
|
113
|
+
function sayDone() {
|
|
114
|
+
if (setupSaid || !state || !state.account || !state.account.connected || state.account.setupReported) return;
|
|
115
|
+
setupSaid = true;
|
|
116
|
+
post('/api/account/setup-done', {}).then(function () { load(); }, function () { setupSaid = false; });
|
|
117
|
+
}
|
|
118
|
+
window.addEventListener('kryptheon:setup-done', sayDone);
|
|
119
|
+
function guideFinished() {
|
|
120
|
+
try { if (JSON.parse(window.localStorage.getItem('kryptheon.guide.v1') || '{}').done) return true; } catch (e) { /* read below */ }
|
|
121
|
+
// set up before the guide existed: the address saved and a flow recorded is a finished set-up too
|
|
122
|
+
var rec = (state && state.steps || []).filter(function (s) { return s.action && s.action.kind === 'record'; })[0];
|
|
123
|
+
return !!(state && state.app && state.app.address && rec && rec.count > 0);
|
|
124
|
+
}
|
|
125
|
+
// The guide (kryptheon-tour.js) follows the page: what the server last said, and whether something runs.
|
|
126
|
+
function tell() {
|
|
127
|
+
try { window.dispatchEvent(new CustomEvent('kryptheon:state', { detail: { state: state, busy: busy } })); } catch (e) { /* no guide then */ }
|
|
107
128
|
}
|
|
108
129
|
// The clipboard, and when a browser refuses it, the older way: the text
|
|
109
130
|
// put in a box off the screen, selected and copied.
|
|
@@ -181,6 +202,14 @@
|
|
|
181
202
|
connectInput.setAttribute('aria-label', 'Your connect code');
|
|
182
203
|
connectInput.autocomplete = 'off';
|
|
183
204
|
connectInput.spellcheck = false;
|
|
205
|
+
// Handed over by kryptheon.tech's "Open my dashboard" (#connect=kd_...): put in the box, never sent by itself -
|
|
206
|
+
// the person presses Connect, so a link from anywhere else cannot tie this dashboard to someone else's account.
|
|
207
|
+
// Taken out of the address at once; the guide then starts at Connect.
|
|
208
|
+
var handed = /^#connect=(kd_[A-Za-z0-9_-]{20,100})$/.exec(window.location.hash || '');
|
|
209
|
+
if (handed) {
|
|
210
|
+
connectInput.value = handed[1];
|
|
211
|
+
try { window.history.replaceState(null, '', '#tour-connect'); } catch (e) { window.location.hash = 'tour-connect'; }
|
|
212
|
+
}
|
|
184
213
|
|
|
185
214
|
/* ------------------------------------ jobs ------------------------------------ */
|
|
186
215
|
|
|
@@ -329,6 +358,7 @@
|
|
|
329
358
|
{ id: 'fixes', title: 'Proven fixes', icon: 'wrench' },
|
|
330
359
|
{ id: 'checks', title: 'Checks', icon: 'toggle' },
|
|
331
360
|
{ id: 'runs', title: 'Runs', icon: 'play' },
|
|
361
|
+
{ id: 'plan', title: 'Upgrade your plan', icon: 'up' },
|
|
332
362
|
{ id: 'storage', title: 'Where this lives', icon: 'box' },
|
|
333
363
|
];
|
|
334
364
|
|
|
@@ -1293,8 +1323,8 @@
|
|
|
1293
1323
|
if (a.available) title.appendChild(el('span', 'tag ' + (a.on ? 'leaf' : ''), a.on ? 'on' : 'off'));
|
|
1294
1324
|
text.appendChild(title);
|
|
1295
1325
|
text.appendChild(el('span', null, !a.available ? (a.why || 'Not on this computer.')
|
|
1296
|
-
: a.on ? 'When you sign in to Windows, this dashboard starts by itself in a small window on the taskbar,
|
|
1297
|
-
: 'Switch it on and this dashboard starts by itself every time you sign in to Windows, in a small window on the taskbar
|
|
1326
|
+
: a.on ? 'When you sign in to Windows, this dashboard starts by itself in a small window on the taskbar, and opens in your browser the first time each day. Closing that taskbar window stops it until you sign in again.'
|
|
1327
|
+
: 'Switch it on and this dashboard starts by itself every time you sign in to Windows, in a small window on the taskbar - and opens in your browser once a day, at your first sign-in. Switch it off here any time.'));
|
|
1298
1328
|
row.appendChild(text);
|
|
1299
1329
|
box.appendChild(row);
|
|
1300
1330
|
renderDaily(box);
|
|
@@ -1798,7 +1828,11 @@
|
|
|
1798
1828
|
connectInput.value = '';
|
|
1799
1829
|
toast('Connected.');
|
|
1800
1830
|
load();
|
|
1801
|
-
}, function (err) {
|
|
1831
|
+
}, function (err) {
|
|
1832
|
+
toast(err.message);
|
|
1833
|
+
// the guide says it too, beside the box, with where a working code comes from
|
|
1834
|
+
try { window.dispatchEvent(new CustomEvent('kryptheon:connect-failed', { detail: { why: err.message } })); } catch (e) { /* no guide */ }
|
|
1835
|
+
});
|
|
1802
1836
|
}));
|
|
1803
1837
|
box.appendChild(row2);
|
|
1804
1838
|
var help = el('div', 'fallback');
|
|
@@ -1842,12 +1876,91 @@
|
|
|
1842
1876
|
if (!small) wrap.appendChild(el('div', 'd-text', 'This month\'s 5 free fix prompts are used.'));
|
|
1843
1877
|
wrap.appendChild(button('sm', 'arrow', 'Unlock with Pro - ₹499/month', function (e) {
|
|
1844
1878
|
if (e) e.stopPropagation();
|
|
1845
|
-
|
|
1879
|
+
go('plan');
|
|
1846
1880
|
}));
|
|
1847
1881
|
}
|
|
1848
1882
|
return wrap;
|
|
1849
1883
|
}
|
|
1850
1884
|
|
|
1885
|
+
/* ------------------------------- upgrade your plan ------------------------------- */
|
|
1886
|
+
|
|
1887
|
+
// The plans, and a way to move up any day. Payment is never taken here: the button opens the account page on
|
|
1888
|
+
// kryptheon.tech, where Razorpay is. When the person comes back to this tab, the plan is asked for again (and every
|
|
1889
|
+
// 20 seconds for half an hour), so the new plan shows here without a button - the entitlement function's word, never
|
|
1890
|
+
// this page's guess.
|
|
1891
|
+
var PLAN_CARDS = [
|
|
1892
|
+
{ id: 'starter', name: 'Starter', price: 'Free', per: 'no card needed', lines: ['Every problem your checks find, with proof', '5 fix prompts an app, every month', '1 app checked every night, with counts'] },
|
|
1893
|
+
{ id: 'pro', name: 'Pro', price: '₹499', per: '/ month', best: true, lines: ['Every fix prompt, for every problem', 'One prompt that fixes them all at once', 'Every night, a test break-in on a copy of your database', 'A morning email, and an alert when a new problem appears', 'Export your findings as a CSV file', 'Up to 3 apps, 90 days of history'] },
|
|
1894
|
+
{ id: 'studio', name: 'Studio', price: '₹799', per: '/ month', lines: ['Everything in Pro', 'Every client app on one screen - up to 15', 'A report you can hand a client, under your own name', 'Every app\'s findings in one CSV file', 'Alerts to Slack or any webhook', 'A year of history'] },
|
|
1895
|
+
];
|
|
1896
|
+
var PAY_PAGE = 'https://kryptheon.tech/dashboard/#plan';
|
|
1897
|
+
var upgradeSince = 0;
|
|
1898
|
+
var upgradeFrom = null;
|
|
1899
|
+
function planNow() { var a = state && state.account; return a && a.connected ? a.plan : null; }
|
|
1900
|
+
function askPlanAgain() {
|
|
1901
|
+
if (!upgradeSince || Date.now() - upgradeSince > 30 * 60 * 1000) { upgradeSince = 0; return; }
|
|
1902
|
+
post('/api/account/refresh', {}).then(function () { return load(); }).then(function () {
|
|
1903
|
+
var now = planNow();
|
|
1904
|
+
if (now && now !== upgradeFrom && now !== 'starter') {
|
|
1905
|
+
upgradeSince = 0;
|
|
1906
|
+
toast('You are on ' + (PLAN_WORD[now] || now) + ' now - every fix prompt is open.');
|
|
1907
|
+
}
|
|
1908
|
+
}, function () {});
|
|
1909
|
+
}
|
|
1910
|
+
window.addEventListener('focus', askPlanAgain);
|
|
1911
|
+
document.addEventListener('visibilitychange', function () { if (!document.hidden) askPlanAgain(); });
|
|
1912
|
+
setInterval(askPlanAgain, 20000);
|
|
1913
|
+
function renderPlan() {
|
|
1914
|
+
var box = byId('planBox');
|
|
1915
|
+
if (!box) return;
|
|
1916
|
+
clear(box);
|
|
1917
|
+
var now = planNow();
|
|
1918
|
+
var rank = { starter: 0, pro: 1, studio: 2 };
|
|
1919
|
+
box.appendChild(el('p', 'plan-now', now ? 'You are on ' + (PLAN_WORD[now] || now) + '.' : 'This dashboard is not connected to an account yet.'));
|
|
1920
|
+
if (!now) {
|
|
1921
|
+
var hint = el('div', 'plan-hint');
|
|
1922
|
+
hint.appendChild(el('span', null, 'Connect it first - Dashboard, Your account - so a plan you pick shows up here by itself.'));
|
|
1923
|
+
hint.appendChild(button('sm', 'arrow', 'Connect my account', function () {
|
|
1924
|
+
go('dashboard');
|
|
1925
|
+
setTimeout(function () { var c = byId('accountCard'); if (c) c.scrollIntoView({ behavior: 'smooth', block: 'center' }); connectInput.focus(); }, 60);
|
|
1926
|
+
}));
|
|
1927
|
+
box.appendChild(hint);
|
|
1928
|
+
}
|
|
1929
|
+
var grid = el('div', 'plan-grid');
|
|
1930
|
+
PLAN_CARDS.forEach(function (p) {
|
|
1931
|
+
var cardEl = el('div', 'plan-card' + (p.best ? ' best' : '') + (now === p.id ? ' mine' : ''));
|
|
1932
|
+
var head = el('div', 'plan-top');
|
|
1933
|
+
head.appendChild(el('b', null, p.name));
|
|
1934
|
+
if (now === p.id) head.appendChild(el('span', 'tag leaf', 'your plan'));
|
|
1935
|
+
else if (p.best) head.appendChild(el('span', 'tag sun', 'most picked'));
|
|
1936
|
+
cardEl.appendChild(head);
|
|
1937
|
+
var price = el('div', 'plan-price');
|
|
1938
|
+
price.appendChild(el('strong', null, p.price));
|
|
1939
|
+
price.appendChild(el('span', null, ' ' + p.per));
|
|
1940
|
+
cardEl.appendChild(price);
|
|
1941
|
+
var ul = el('ul');
|
|
1942
|
+
p.lines.forEach(function (t) { ul.appendChild(el('li', null, t)); });
|
|
1943
|
+
cardEl.appendChild(ul);
|
|
1944
|
+
if (p.id !== 'starter' && (!now || rank[p.id] > rank[now])) {
|
|
1945
|
+
var link = el('a', 'btn' + (p.best ? ' sun' : ''));
|
|
1946
|
+
link.href = PAY_PAGE;
|
|
1947
|
+
link.target = '_blank';
|
|
1948
|
+
link.rel = 'noopener noreferrer';
|
|
1949
|
+
link.appendChild(icon('up', 15));
|
|
1950
|
+
link.appendChild(el('span', null, 'Choose ' + p.name));
|
|
1951
|
+
link.addEventListener('click', function () {
|
|
1952
|
+
upgradeSince = Date.now();
|
|
1953
|
+
upgradeFrom = now;
|
|
1954
|
+
toast('Pay on kryptheon.tech - this page switches to ' + p.name + ' by itself when you come back.');
|
|
1955
|
+
});
|
|
1956
|
+
cardEl.appendChild(link);
|
|
1957
|
+
}
|
|
1958
|
+
grid.appendChild(cardEl);
|
|
1959
|
+
});
|
|
1960
|
+
box.appendChild(grid);
|
|
1961
|
+
box.appendChild(el('p', 'fallback', 'Paid on kryptheon.tech with Razorpay - UPI or card. Any offer running is shown there. Cancel any time; 7-day full refund on any charge.'));
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1851
1964
|
function render(next) {
|
|
1852
1965
|
if (!next) return;
|
|
1853
1966
|
state = next;
|
|
@@ -1866,6 +1979,9 @@
|
|
|
1866
1979
|
renderChecks();
|
|
1867
1980
|
renderRuns();
|
|
1868
1981
|
renderStorage();
|
|
1982
|
+
renderPlan();
|
|
1983
|
+
if (guideFinished()) sayDone();
|
|
1984
|
+
tell();
|
|
1869
1985
|
}
|
|
1870
1986
|
|
|
1871
1987
|
function load() {
|
package/kryptheon-dashboard.html
CHANGED
|
@@ -114,6 +114,22 @@
|
|
|
114
114
|
.view { margin-top: 28px; }
|
|
115
115
|
.view[hidden] { display: none; }
|
|
116
116
|
.card { min-width: 0; }
|
|
117
|
+
/* upgrade your plan: three plans side by side, hairlines like the rest; Pro on ink */
|
|
118
|
+
.plan-now { margin: 18px 0 6px; font-weight: 700; }
|
|
119
|
+
.plan-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 4px; color: var(--muted); }
|
|
120
|
+
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 18px 0 14px; border: 1px solid var(--line); }
|
|
121
|
+
.plan-card { display: flex; flex-direction: column; gap: 12px; padding: 22px 20px; min-width: 0; }
|
|
122
|
+
.plan-card + .plan-card { border-left: 1px solid var(--line); }
|
|
123
|
+
.plan-card.best { color: var(--on-dark); background: var(--ink); }
|
|
124
|
+
.plan-card.best .plan-price span, .plan-card.best ul { color: rgba(233, 237, 242, 0.75); }
|
|
125
|
+
.plan-card.mine { box-shadow: inset 0 0 0 2px var(--orange); }
|
|
126
|
+
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
127
|
+
.plan-top b { font-weight: 900; font-stretch: 63%; font-size: 1.6rem; text-transform: uppercase; }
|
|
128
|
+
.plan-price strong { font-weight: 900; font-stretch: 70%; font-size: 2.4rem; }
|
|
129
|
+
.plan-price span { color: var(--muted); }
|
|
130
|
+
.plan-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--muted); }
|
|
131
|
+
.plan-card .btn { margin-top: auto; text-decoration: none; }
|
|
132
|
+
@media (max-width: 900px) { .plan-grid { grid-template-columns: minmax(0, 1fr); } .plan-card + .plan-card { border-left: 0; border-top: 1px solid var(--line); } }
|
|
117
133
|
.card + .card, .view > .card.gap { margin-top: 44px; }
|
|
118
134
|
.card-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
|
|
119
135
|
.card-head h3 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); }
|
|
@@ -512,6 +528,13 @@
|
|
|
512
528
|
</div>
|
|
513
529
|
</section>
|
|
514
530
|
|
|
531
|
+
<section class="view" id="view-plan" hidden>
|
|
532
|
+
<div class="card">
|
|
533
|
+
<div class="card-head"><div><div class="c-sub">Move up any day - you pay on kryptheon.tech, and this page follows</div></div></div>
|
|
534
|
+
<div id="planBox"></div>
|
|
535
|
+
</div>
|
|
536
|
+
</section>
|
|
537
|
+
|
|
515
538
|
<section class="view" id="view-storage" hidden>
|
|
516
539
|
<div class="card">
|
|
517
540
|
<div class="card-head"><div><div class="c-sub">On this machine, outside your project</div></div></div>
|
|
@@ -524,5 +547,6 @@
|
|
|
524
547
|
</div>
|
|
525
548
|
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
|
526
549
|
<script src="/dashboard.js"></script>
|
|
550
|
+
<script src="/tour.js"></script>
|
|
527
551
|
</body>
|
|
528
552
|
</html>
|
package/kryptheon-dashboard.js
CHANGED
|
@@ -1356,6 +1356,10 @@ function createServer(root, options) {
|
|
|
1356
1356
|
if (req.method === 'GET' && url.pathname === '/dashboard.js') {
|
|
1357
1357
|
return send(res, 200, 'text/javascript; charset=utf-8', fs.readFileSync(path.join(__dirname, 'kryptheon-dashboard-page.js'), 'utf8'));
|
|
1358
1358
|
}
|
|
1359
|
+
// The first-time guide: lights one part of the page at a time while the person does it.
|
|
1360
|
+
if (req.method === 'GET' && url.pathname === '/tour.js') {
|
|
1361
|
+
return send(res, 200, 'text/javascript; charset=utf-8', fs.readFileSync(path.join(__dirname, 'kryptheon-tour.js'), 'utf8'));
|
|
1362
|
+
}
|
|
1359
1363
|
if (req.method === 'GET' && Object.prototype.hasOwnProperty.call(ASSETS, url.pathname)) {
|
|
1360
1364
|
const [type, file] = ASSETS[url.pathname];
|
|
1361
1365
|
let body;
|
|
@@ -1426,6 +1430,7 @@ function createServer(root, options) {
|
|
|
1426
1430
|
.catch(() => json(res, 500, { ok: false, why: 'something went wrong' }));
|
|
1427
1431
|
if (url.pathname === '/api/account/connect') return answer(account.connect(root, env, input.code));
|
|
1428
1432
|
if (url.pathname === '/api/account/refresh') return answer(account.refresh(root, env));
|
|
1433
|
+
if (url.pathname === '/api/account/setup-done') return answer(account.setupDone(root, env));
|
|
1429
1434
|
if (url.pathname === '/api/account/disconnect') return json(res, 200, account.disconnect(root, env));
|
|
1430
1435
|
if (url.pathname === '/api/prompt/unlock') {
|
|
1431
1436
|
const id = String(input.id || '');
|
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
// The first-time guide on the dashboard. Served from 127.0.0.1 with the page.
|
|
2
|
+
//
|
|
3
|
+
// The room goes dark and one part of the page is lit - the box to type in, the
|
|
4
|
+
// button to press - and the person does it with their own hand. The guide
|
|
5
|
+
// moves on only when the page says it happened: the address saved, a
|
|
6
|
+
// recording held, a run finished. Like the page, it writes nothing as HTML:
|
|
7
|
+
// every node is made with createElement and filled with textContent, and it
|
|
8
|
+
// reads only what the page itself shows. It sends nothing anywhere; where it
|
|
9
|
+
// stands is kept in this browser's own storage.
|
|
10
|
+
|
|
11
|
+
(function () {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var KEY = 'kryptheon.guide.v1';
|
|
15
|
+
var state = null;
|
|
16
|
+
var busy = false;
|
|
17
|
+
var on = false;
|
|
18
|
+
var at = null;
|
|
19
|
+
var seen = {};
|
|
20
|
+
// The set-up is not optional (owner, 2026-11-20): no close, no Esc. Only a run opened from "Guide me" can be closed.
|
|
21
|
+
var optional = false;
|
|
22
|
+
var stepSince = 0;
|
|
23
|
+
var STUCK_MS = 180000;
|
|
24
|
+
var frame = 0;
|
|
25
|
+
var still = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
26
|
+
|
|
27
|
+
function el(tag, cls, text) {
|
|
28
|
+
var node = document.createElement(tag);
|
|
29
|
+
if (cls) node.className = cls;
|
|
30
|
+
if (text !== undefined && text !== null) node.textContent = String(text);
|
|
31
|
+
return node;
|
|
32
|
+
}
|
|
33
|
+
function clear(node) { while (node.firstChild) node.removeChild(node.firstChild); }
|
|
34
|
+
function byId(id) { return document.getElementById(id); }
|
|
35
|
+
function read() {
|
|
36
|
+
try { return JSON.parse(window.localStorage.getItem(KEY) || '{}') || {}; } catch (e) { return {}; }
|
|
37
|
+
}
|
|
38
|
+
function keep(more) {
|
|
39
|
+
var now = read();
|
|
40
|
+
Object.keys(more).forEach(function (k) { now[k] = more[k]; });
|
|
41
|
+
try { window.localStorage.setItem(KEY, JSON.stringify(now)); } catch (e) { /* kept for this visit only */ }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ---------------------------------- the look ---------------------------------- */
|
|
45
|
+
|
|
46
|
+
var css = el('style');
|
|
47
|
+
css.textContent = [
|
|
48
|
+
'.kt-block { position: fixed; z-index: 9000; background: transparent; }',
|
|
49
|
+
'.kt-lens { position: fixed; z-index: 9001; pointer-events: none; border-radius: 10px;',
|
|
50
|
+
' box-shadow: 0 0 0 2px #ff4d00, 0 0 34px 6px rgba(255, 110, 30, 0.55), 0 0 0 200vmax rgba(9, 7, 5, 0.86);',
|
|
51
|
+
' transition: left .55s cubic-bezier(.16,1,.3,1), top .55s cubic-bezier(.16,1,.3,1), width .55s cubic-bezier(.16,1,.3,1), height .55s cubic-bezier(.16,1,.3,1), border-radius .55s; }',
|
|
52
|
+
'.kt-lens.kt-none { left: 50% !important; top: 42% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 200vmax rgba(9, 7, 5, 0.86); }',
|
|
53
|
+
'.kt-lens::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; border: 2px solid rgba(255, 160, 90, 0.9); animation: kt-breathe 1.8s ease-in-out infinite; }',
|
|
54
|
+
'.kt-lens.kt-none::after { display: none; }',
|
|
55
|
+
'@keyframes kt-breathe { 50% { inset: -9px; opacity: 0; } }',
|
|
56
|
+
// the fake zoom: the lit part steps forward a little, as on a stage
|
|
57
|
+
'.kt-lit { transform: scale(1.025); transform-origin: center; transition: transform .6s cubic-bezier(.16,1,.3,1); }',
|
|
58
|
+
'.kt-card { position: fixed; z-index: 9002; width: min(400px, calc(100vw - 28px)); padding: 20px 20px 16px; background: #fffaf6; color: #12161d; border-radius: 14px;',
|
|
59
|
+
' box-shadow: 0 24px 70px rgba(0,0,0,.45), 0 0 0 1px rgba(255,77,0,.25); font: 15px/1.5 var(--display); transition: left .5s cubic-bezier(.16,1,.3,1), top .5s cubic-bezier(.16,1,.3,1), opacity .3s; }',
|
|
60
|
+
'.kt-card.kt-mid { width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; }',
|
|
61
|
+
'.kt-step { font: 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #ff4d00; display: flex; justify-content: space-between; gap: 10px; }',
|
|
62
|
+
'.kt-bar { display: flex; gap: 4px; margin: 10px 0 12px; } .kt-bar i { flex: 1; height: 3px; border-radius: 3px; background: rgba(18,22,29,.12); } .kt-bar i.on { background: #ff4d00; }',
|
|
63
|
+
'.kt-card h2 { margin: 0 0 8px; font: 900 26px/1 var(--display); font-stretch: 70%; text-transform: uppercase; letter-spacing: -.01em; }',
|
|
64
|
+
'.kt-card h2 em { font-style: normal; color: #ff4d00; }',
|
|
65
|
+
'.kt-card p { margin: 0 0 10px; color: rgba(18,22,29,.72); }',
|
|
66
|
+
'.kt-wait { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; font: 12px/1.4 var(--mono); color: #c23a00; }',
|
|
67
|
+
'.kt-wait::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #ff4d00; border-right-color: transparent; animation: kt-spin .8s linear infinite; flex: none; }',
|
|
68
|
+
'@keyframes kt-spin { to { transform: rotate(360deg); } }',
|
|
69
|
+
'.kt-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }',
|
|
70
|
+
'.kt-btn { height: 40px; padding: 0 18px; border-radius: 9px; font: 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; border: 1px solid #12161d; background: transparent; color: #12161d; cursor: pointer; }',
|
|
71
|
+
'.kt-btn.kt-go { background: #ff4d00; border-color: #ff4d00; color: #fff; } .kt-btn.kt-go:hover { background: #c23a00; }',
|
|
72
|
+
'.kt-skip { margin-left: auto; font: 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: rgba(18,22,29,.5); background: none; border: 0; cursor: pointer; text-decoration: underline; }',
|
|
73
|
+
'.kt-guide-btn { margin-right: 4px; }',
|
|
74
|
+
'.kt-red { margin: 2px 0 10px; color: #d11a1a; font-weight: 800; }',
|
|
75
|
+
'.kt-nav { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(18,22,29,.08); }',
|
|
76
|
+
'.kt-nav .kt-btn { height: 32px; padding: 0 12px; font-size: 10px; }',
|
|
77
|
+
// while the guide is on: the run panel steps back unless it is the part lit, and the page\'s short notes stay readable
|
|
78
|
+
'.kt-on .job:not(.kt-lit) { opacity: .1; pointer-events: none; transition: opacity .4s; }',
|
|
79
|
+
'.kt-on .toast { z-index: 9003; }',
|
|
80
|
+
// what a recording looks like, played before the person presses Record
|
|
81
|
+
'.kt-demo { position: relative; height: 150px; margin: 4px 0 12px; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid rgba(18,22,29,.14); }',
|
|
82
|
+
'.kt-demo-top { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; background: #f2f4f1; border-bottom: 1px solid rgba(18,22,29,.1); font: 10px/1 var(--mono); letter-spacing: .1em; color: rgba(18,22,29,.6); }',
|
|
83
|
+
'.kt-rec { width: 8px; height: 8px; border-radius: 50%; background: #e5221b; animation: kt-blink 1s steps(1) infinite; } @keyframes kt-blink { 50% { opacity: .2; } }',
|
|
84
|
+
'.kt-demo-page { position: absolute; left: 0; right: 0; top: 24px; bottom: 26px; display: grid; place-items: center; opacity: 0; animation: kt-page 9s infinite; }',
|
|
85
|
+
'.kt-demo-page b { display: block; font: 900 15px/1 var(--display); text-transform: uppercase; margin-bottom: 8px; text-align: center; }',
|
|
86
|
+
'.kt-demo-page span { display: inline-block; padding: 7px 14px; border-radius: 7px; background: #12161d; color: #fff; font: 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }',
|
|
87
|
+
'.kt-demo-page:nth-of-type(3) { animation-delay: 3s; } .kt-demo-page:nth-of-type(4) { animation-delay: 6s; }',
|
|
88
|
+
'@keyframes kt-page { 0% { opacity: 0; } 4%, 30% { opacity: 1; } 34%, 100% { opacity: 0; } }',
|
|
89
|
+
'.kt-cursor { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: rgba(255,77,0,.85); box-shadow: 0 0 0 5px rgba(255,77,0,.25); top: 70%; left: 20%; animation: kt-move 3s ease-in-out infinite; }',
|
|
90
|
+
'@keyframes kt-move { 0% { top: 75%; left: 18%; } 45% { top: 62%; left: 52%; } 55% { top: 62%; left: 52%; transform: scale(.7); } 65% { transform: scale(1); } 100% { top: 75%; left: 18%; } }',
|
|
91
|
+
'.kt-demo-log { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; display: flex; align-items: center; gap: 10px; padding: 0 9px; background: #12161d; color: #ffb48c; font: 10px/1 var(--mono); letter-spacing: .08em; overflow: hidden; white-space: nowrap; }',
|
|
92
|
+
'.kt-demo-log i { font-style: normal; opacity: 0; animation: kt-log 9s infinite; } .kt-demo-log i:nth-child(2) { animation-delay: 3s; } .kt-demo-log i:nth-child(3) { animation-delay: 6s; }',
|
|
93
|
+
'@keyframes kt-log { 0%, 12% { opacity: 0; } 16%, 96% { opacity: 1; } 100% { opacity: 0; } }',
|
|
94
|
+
// the end
|
|
95
|
+
'.kt-sparks { position: fixed; inset: 0; z-index: 9001; pointer-events: none; }',
|
|
96
|
+
'.kt-list { list-style: none; margin: 6px 0 12px; padding: 0; display: grid; gap: 8px; }',
|
|
97
|
+
'.kt-list li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px solid rgba(18,22,29,.1); }',
|
|
98
|
+
'.kt-list li > span { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #fff0e6; color: #ff4d00; font: 700 12px/1 var(--mono); }',
|
|
99
|
+
'.kt-list b { display: block; font-size: 14px; } .kt-list small { color: rgba(18,22,29,.65); font-size: 13px; }',
|
|
100
|
+
'.kt-list .kt-btn { height: 30px; padding: 0 10px; margin-top: 6px; font-size: 10px; }',
|
|
101
|
+
'.kt-h { margin: 14px 0 4px; font: 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: rgba(18,22,29,.55); }',
|
|
102
|
+
'.kt-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }',
|
|
103
|
+
'.kt-plan { padding: 12px; border-radius: 10px; background: #fff; border: 1px solid rgba(18,22,29,.12); font-size: 13px; }',
|
|
104
|
+
'.kt-plan.kt-best { border: 2px solid #ff4d00; }',
|
|
105
|
+
'.kt-plan b { display: block; font: 900 18px/1 var(--display); text-transform: uppercase; } .kt-plan strong { display: block; margin: 6px 0; font-size: 20px; }',
|
|
106
|
+
'.kt-plan ul { margin: 0; padding-left: 16px; color: rgba(18,22,29,.72); }',
|
|
107
|
+
'@media (max-width: 520px) { .kt-plans { grid-template-columns: 1fr; } .kt-card h2 { font-size: 22px; } }',
|
|
108
|
+
'@media (prefers-reduced-motion: reduce) { .kt-lens, .kt-card, .kt-lit { transition: none; } .kt-lens::after, .kt-demo-page, .kt-cursor, .kt-demo-log i, .kt-rec { animation: none; } .kt-demo-page:nth-of-type(2), .kt-demo-log i { opacity: 1; } }',
|
|
109
|
+
].join('\n');
|
|
110
|
+
document.head.appendChild(css);
|
|
111
|
+
|
|
112
|
+
var blocks = ['top', 'left', 'right', 'bottom'].map(function () {
|
|
113
|
+
var b = el('div', 'kt-block');
|
|
114
|
+
b.hidden = true;
|
|
115
|
+
document.body.appendChild(b);
|
|
116
|
+
return b;
|
|
117
|
+
});
|
|
118
|
+
var lens = el('div', 'kt-lens kt-none');
|
|
119
|
+
lens.hidden = true;
|
|
120
|
+
document.body.appendChild(lens);
|
|
121
|
+
var card = el('div', 'kt-card');
|
|
122
|
+
card.hidden = true;
|
|
123
|
+
card.setAttribute('role', 'dialog');
|
|
124
|
+
card.setAttribute('aria-live', 'polite');
|
|
125
|
+
document.body.appendChild(card);
|
|
126
|
+
var lit = null;
|
|
127
|
+
|
|
128
|
+
/* ------------------------------ what the page holds ------------------------------ */
|
|
129
|
+
|
|
130
|
+
function recordStep() {
|
|
131
|
+
var steps = (state && state.steps) || [];
|
|
132
|
+
for (var i = 0; i < steps.length; i++) if (steps[i].action && steps[i].action.kind === 'record') return steps[i];
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
function recordings() { var s = recordStep(); return s ? (s.count || (s.state === 'done' ? 1 : 0)) : 0; }
|
|
136
|
+
function hasAddress() { return !!(state && state.app && state.app.address); }
|
|
137
|
+
function findings() { return (state && state.findings) || []; }
|
|
138
|
+
function needsConnect() {
|
|
139
|
+
var f = findings()[0];
|
|
140
|
+
return !!(f && !f.fixPrompt && f.promptLock && f.promptLock.reason === 'connect' && !(state.account && state.account.connected));
|
|
141
|
+
}
|
|
142
|
+
function plan() { return (state && state.account && state.account.connected && state.account.plan) || 'starter'; }
|
|
143
|
+
function view(id) { if ((location.hash || '#dashboard').replace('#', '') !== id) location.hash = id; }
|
|
144
|
+
function q(sel) { return document.querySelector(sel); }
|
|
145
|
+
function visible(node) { return node && !node.hidden && node.getClientRects().length > 0; }
|
|
146
|
+
function stepRow(match) {
|
|
147
|
+
var rows = document.querySelectorAll('#steps .step');
|
|
148
|
+
for (var i = 0; i < rows.length; i++) if (match.test(rows[i].textContent || '')) return rows[i];
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* --------------------------------- the steps --------------------------------- */
|
|
153
|
+
|
|
154
|
+
// main: counted in "Step n of 7". Each says what to light, what to say, and
|
|
155
|
+
// when it is done - read from the page, never assumed.
|
|
156
|
+
var BASE = ['app', 'record', 'check', 'findings', 'fix', 'recheck', 'keep'];
|
|
157
|
+
// Connect leads when this dashboard is not tied to an account yet - the code may have come with the person from kryptheon.tech
|
|
158
|
+
var MAIN = BASE.slice();
|
|
159
|
+
function connected() { return !!(state && state.account && state.account.connected); }
|
|
160
|
+
var STEPS = {
|
|
161
|
+
hello: {
|
|
162
|
+
target: function () { return null; },
|
|
163
|
+
show: function (c) {
|
|
164
|
+
title(c, 'Let\'s set up ', 'your app', ' together');
|
|
165
|
+
c.appendChild(el('p', null, MAIN.length + ' short steps. Only the part you need lights up - you do each one with your own hand, and the guide moves on when it sees it done.'));
|
|
166
|
+
c.appendChild(el('p', null, 'About 5 minutes. Your app has to be open in the browser at its usual address.'));
|
|
167
|
+
row(c, [go('Start', function () { move(MAIN[0]); })], true);
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
connect: {
|
|
171
|
+
view: 'dashboard',
|
|
172
|
+
target: function () { return q('#accountBox .field-row') || byId('accountCard'); },
|
|
173
|
+
enter: function () { seen.connectWhy = ''; },
|
|
174
|
+
show: function (c) {
|
|
175
|
+
var box = q('#accountBox input');
|
|
176
|
+
var filled = !!(box && /^kd_/.test(box.value));
|
|
177
|
+
title(c, 'Connect your ', 'account', '');
|
|
178
|
+
c.appendChild(el('p', null, filled
|
|
179
|
+
? 'Your connect code came with you from kryptheon.tech - it is already in the box. Press Connect.'
|
|
180
|
+
: 'Copy your connect code from kryptheon.tech - the tab you came from, or Your account - paste it here and press Connect.'));
|
|
181
|
+
if (seen.connectWhy) {
|
|
182
|
+
// refused: what kryptheon.tech said, and where a working code comes from
|
|
183
|
+
c.appendChild(el('p', 'kt-red', 'Not accepted: ' + seen.connectWhy));
|
|
184
|
+
c.appendChild(el('p', null, 'Get a fresh code on kryptheon.tech: your dashboard there, On your computer, Get my connect code. Paste it here and press Connect. A new code replaces the old one.'));
|
|
185
|
+
var get = el('a', 'kt-btn kt-go', 'Get my connect code');
|
|
186
|
+
get.href = 'https://kryptheon.tech/dashboard/#computer';
|
|
187
|
+
get.target = '_blank';
|
|
188
|
+
get.rel = 'noopener noreferrer';
|
|
189
|
+
get.style.display = 'inline-flex';
|
|
190
|
+
get.style.alignItems = 'center';
|
|
191
|
+
get.style.textDecoration = 'none';
|
|
192
|
+
c.appendChild(get);
|
|
193
|
+
} else {
|
|
194
|
+
c.appendChild(el('p', null, 'It ties this dashboard to your plan: Starter opens 5 fix prompts a month, Pro and Studio open every one.'));
|
|
195
|
+
}
|
|
196
|
+
waiting(c, 'Waiting for you to press Connect');
|
|
197
|
+
row(c, [plain('I will connect later', function () { move('app'); })]);
|
|
198
|
+
},
|
|
199
|
+
done: function () { return connected(); },
|
|
200
|
+
next: 'app',
|
|
201
|
+
},
|
|
202
|
+
app: {
|
|
203
|
+
view: 'dashboard',
|
|
204
|
+
target: function () { return q('#appBox .field-row') || byId('appCard'); },
|
|
205
|
+
enter: function () { seen.hadAddress = hasAddress(); },
|
|
206
|
+
show: function (c) {
|
|
207
|
+
title(c, 'Paste your ', 'app\'s address', '');
|
|
208
|
+
c.appendChild(el('p', null, hasAddress()
|
|
209
|
+
? 'Saved: ' + state.app.address + '. Change it here if this is not the address you open your app at.'
|
|
210
|
+
: 'The address you open your app at - for a Lovable app it ends in .lovable.app. Paste it in the box and press Save the address.'));
|
|
211
|
+
if (hasAddress()) row(c, [go('Next', function () { move('record'); })]);
|
|
212
|
+
else waiting(c, 'Waiting for you to press Save the address');
|
|
213
|
+
},
|
|
214
|
+
done: function () { return hasAddress() && !seen.hadAddress; },
|
|
215
|
+
next: 'record',
|
|
216
|
+
},
|
|
217
|
+
record: {
|
|
218
|
+
view: 'dashboard',
|
|
219
|
+
target: function () { var b = q('#steps [data-action="record"]'); return b ? (b.closest('.controls') || b.closest('.step') || b) : stepRow(/Record your main flows/); },
|
|
220
|
+
enter: function () { seen.recordings = recordings(); seen.recordRan = false; },
|
|
221
|
+
show: function (c) {
|
|
222
|
+
if (busy) {
|
|
223
|
+
title(c, 'Recording ', 'now', '');
|
|
224
|
+
c.appendChild(el('p', null, 'Your app opened in a new window. Use it once like a customer: sign up or log in, then the main thing your app does. Then close that window.'));
|
|
225
|
+
waiting(c, 'Kryptheon is watching every step');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
title(c, 'Press ', 'Record', '');
|
|
229
|
+
c.appendChild(el('p', null, 'This is what happens: your app opens in a new window, you use it like a customer, and Kryptheon writes down every step - so it can do the same after every change and see what broke.'));
|
|
230
|
+
c.appendChild(demo());
|
|
231
|
+
if (recordings() > 0 && seen.recordings > 0) row(c, [go('I have recorded - next', function () { move('check'); })]);
|
|
232
|
+
else waiting(c, 'Waiting for you to press Record');
|
|
233
|
+
},
|
|
234
|
+
done: function () { return recordings() > seen.recordings; },
|
|
235
|
+
next: 'check',
|
|
236
|
+
},
|
|
237
|
+
check: runStep('check', 'Press ', 'Check my app', '', 'One press runs every check on your app, one after another. Nothing is deleted, and every problem comes back with its proof.', 'findings'),
|
|
238
|
+
findings: {
|
|
239
|
+
view: 'findings',
|
|
240
|
+
target: function () { return q('#findingList .finding') || byId('findingList'); },
|
|
241
|
+
show: function (c) {
|
|
242
|
+
var n = findings().length;
|
|
243
|
+
if (!n) {
|
|
244
|
+
title(c, 'Nothing ', 'found', ' this time');
|
|
245
|
+
c.appendChild(el('p', null, 'Nothing found by the checks that ran. That is not the same as nothing wrong - the page Checks says what is not built yet. After every change your AI makes, press Check my app again.'));
|
|
246
|
+
row(c, [go('Next', function () { move('keep'); })]);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
title(c, n === 1 ? 'Your ' : 'Your ', n + (n === 1 ? ' finding' : ' findings'), '');
|
|
250
|
+
c.appendChild(el('p', null, 'Each one is something a check saw happen in your app, with its proof. The most serious is at the top. Open one to read what went wrong.'));
|
|
251
|
+
row(c, [go('Next', function () { move('fix'); })]);
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
fix: {
|
|
255
|
+
view: function () { return needsConnect() ? 'dashboard' : 'findings'; },
|
|
256
|
+
target: function () { return needsConnect() ? byId('accountCard') : (q('#findingList .finding .f-quick') || q('#findingList .finding') || byId('findingList')); },
|
|
257
|
+
enter: function () { seen.pressed = false; },
|
|
258
|
+
press: function () { if (!needsConnect()) seen.pressed = true; },
|
|
259
|
+
show: function (c) {
|
|
260
|
+
var f = findings()[0];
|
|
261
|
+
var hasPrompt = f && f.fixPrompt;
|
|
262
|
+
if (needsConnect()) {
|
|
263
|
+
title(c, 'Connect your ', 'free account', '');
|
|
264
|
+
c.appendChild(el('p', null, 'Fix prompts open when this dashboard is connected to your Kryptheon account: 5 free a month on Starter. Copy your connect code from kryptheon.tech/dashboard, paste it here and press Connect.'));
|
|
265
|
+
waiting(c, 'Waiting for you to press Connect');
|
|
266
|
+
row(c, [plain('I will fix it later', function () { move('keep'); })]);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
title(c, 'Copy the ', 'fix prompt', '');
|
|
270
|
+
c.appendChild(el('p', null, hasPrompt
|
|
271
|
+
? 'Press Copy fix prompt, paste it into Lovable, Cursor or Claude, and let your AI make the change.'
|
|
272
|
+
: 'Press the first button here to open this fix prompt - then paste it into Lovable, Cursor or Claude and let your AI make the change.'));
|
|
273
|
+
if (seen.pressed) {
|
|
274
|
+
c.appendChild(el('p', null, 'Pasted it? Wait until your AI says it has finished.'));
|
|
275
|
+
row(c, [go('My AI made the change', function () { move('recheck'); })]);
|
|
276
|
+
} else {
|
|
277
|
+
waiting(c, 'Waiting for you to press it');
|
|
278
|
+
row(c, [plain('I will fix it later', function () { move('keep'); })]);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
recheck: runStep('recheck', 'Press ', 'Check my app', ' again', 'It runs every check again on the changed app. A finding is marked FIXED only when the check that found it now passes.', 'keep'),
|
|
283
|
+
keep: {
|
|
284
|
+
view: 'dashboard',
|
|
285
|
+
target: function () { return byId('keepCard'); },
|
|
286
|
+
show: function (c) {
|
|
287
|
+
var a = state && state.autostart;
|
|
288
|
+
var d = state && state.daily;
|
|
289
|
+
title(c, 'Keep it ', 'running', '');
|
|
290
|
+
c.appendChild(el('p', null, (a && a.available ? 'Switch on Start with Windows: Kryptheon starts by itself every time you switch your laptop on, and this page opens once a day. ' : '') +
|
|
291
|
+
'Switch on Check my app every day and pick a time: your checks run by themselves and a note in the corner of your screen says what is new.'));
|
|
292
|
+
var ready = (!a || !a.available || a.on) && d && d.on;
|
|
293
|
+
if (!ready) waiting(c, 'Switch them on, then press Done');
|
|
294
|
+
row(c, [go(ready ? 'Done' : 'Done for now', function () { move('end'); })]);
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
end: {
|
|
298
|
+
target: function () { return null; },
|
|
299
|
+
enter: function () { sparks(); keep({ done: true }); try { window.dispatchEvent(new CustomEvent('kryptheon:setup-done')); } catch (e) { /* the page asks again on its next load */ } },
|
|
300
|
+
show: function (c) { ending(c); },
|
|
301
|
+
},
|
|
302
|
+
// what a paid plan adds, each lit where it lives on this page
|
|
303
|
+
nightly: {
|
|
304
|
+
view: 'dashboard',
|
|
305
|
+
target: function () { return stepRow(/Check it every night/) || stepRow(/Connect your database/); },
|
|
306
|
+
show: function (c) {
|
|
307
|
+
title(c, 'Every ', 'night', '');
|
|
308
|
+
c.appendChild(el('p', null, 'Connect your database once here, then Set up nightly check. Every night it attacks a copy of your database - never your real data - and the result waits here in the morning.'));
|
|
309
|
+
row(c, [go('Back', function () { move('end'); })]);
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
fixall: {
|
|
313
|
+
view: 'findings',
|
|
314
|
+
target: function () { return q('#findingList .fix-all') || byId('findingList'); },
|
|
315
|
+
show: function (c) {
|
|
316
|
+
title(c, 'Fix ', 'all at once', '');
|
|
317
|
+
c.appendChild(el('p', null, 'One prompt with every fix, and rules that stop your AI from changing anything else. Copy it, paste it once, then Check my app.'));
|
|
318
|
+
row(c, [go('Back', function () { move('end'); })]);
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// A step that waits for one whole run: lit on the button, then on the yes, then on the run itself.
|
|
324
|
+
function runStep(id, a, b, c2, text, next) {
|
|
325
|
+
return {
|
|
326
|
+
view: 'dashboard',
|
|
327
|
+
target: function () {
|
|
328
|
+
if (busy) return visible(byId('job')) ? byId('job') : null;
|
|
329
|
+
if (visible(byId('everyBox'))) return q('#everyBox .d-actions') || byId('everyBox');
|
|
330
|
+
return q('#launch .btn.go') ? byId('launch') : byId('runAll');
|
|
331
|
+
},
|
|
332
|
+
enter: function () { seen.ran = false; },
|
|
333
|
+
tick: function () { if (busy) seen.ran = true; },
|
|
334
|
+
show: function (c) {
|
|
335
|
+
if (busy) {
|
|
336
|
+
title(c, 'Checking ', 'your app', '');
|
|
337
|
+
c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
|
|
338
|
+
c.appendChild(el('p', null, 'Every check is running, one after another. You can watch each line here.'));
|
|
339
|
+
waiting(c, 'Running');
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (visible(byId('everyBox'))) {
|
|
343
|
+
title(c, 'Say ', 'yes', ' once');
|
|
344
|
+
c.appendChild(el('p', null, 'Just above is everything it will run, and what it leaves out. Press the orange button to start. Nothing is ever deleted.'));
|
|
345
|
+
waiting(c, 'Waiting for your yes');
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
title(c, a, b, c2);
|
|
349
|
+
c.appendChild(el('p', null, text));
|
|
350
|
+
waiting(c, 'Waiting for you to press it');
|
|
351
|
+
},
|
|
352
|
+
done: function () { return seen.ran && !busy; },
|
|
353
|
+
next: next,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/* ------------------------------- the card's parts ------------------------------- */
|
|
358
|
+
|
|
359
|
+
function title(c, before, lit2, after) {
|
|
360
|
+
var h = el('h2');
|
|
361
|
+
h.appendChild(document.createTextNode(before));
|
|
362
|
+
h.appendChild(el('em', null, lit2));
|
|
363
|
+
if (after) h.appendChild(document.createTextNode(after));
|
|
364
|
+
c.appendChild(h);
|
|
365
|
+
}
|
|
366
|
+
function waiting(c, text) { c.appendChild(el('div', 'kt-wait', text)); }
|
|
367
|
+
function go(text, fn) { var b = el('button', 'kt-btn kt-go', text); b.type = 'button'; b.addEventListener('click', fn); return b; }
|
|
368
|
+
function plain(text, fn) { var b = el('button', 'kt-btn', text); b.type = 'button'; b.addEventListener('click', fn); return b; }
|
|
369
|
+
function row(c, buttons, skipToo) {
|
|
370
|
+
var r = el('div', 'kt-row');
|
|
371
|
+
buttons.forEach(function (b) { r.appendChild(b); });
|
|
372
|
+
if (skipToo && optional) {
|
|
373
|
+
var s = el('button', 'kt-skip', 'Not now');
|
|
374
|
+
s.type = 'button';
|
|
375
|
+
s.addEventListener('click', function () { keep({ dismissed: true }); stop(); });
|
|
376
|
+
r.appendChild(s);
|
|
377
|
+
}
|
|
378
|
+
c.appendChild(r);
|
|
379
|
+
}
|
|
380
|
+
function demo() {
|
|
381
|
+
var d = el('div', 'kt-demo');
|
|
382
|
+
d.setAttribute('aria-hidden', 'true');
|
|
383
|
+
var top = el('div', 'kt-demo-top');
|
|
384
|
+
top.appendChild(el('span', 'kt-rec'));
|
|
385
|
+
top.appendChild(document.createTextNode('RECORDING - YOUR APP'));
|
|
386
|
+
d.appendChild(top);
|
|
387
|
+
[['Create your account', 'Sign up'], ['Pick a plan', 'Add to cart'], ['Checkout', 'Pay']].forEach(function (p) {
|
|
388
|
+
var page = el('div', 'kt-demo-page');
|
|
389
|
+
var inner = el('div');
|
|
390
|
+
inner.appendChild(el('b', null, p[0]));
|
|
391
|
+
inner.appendChild(el('span', null, p[1]));
|
|
392
|
+
page.appendChild(inner);
|
|
393
|
+
d.appendChild(page);
|
|
394
|
+
});
|
|
395
|
+
d.appendChild(el('div', 'kt-cursor'));
|
|
396
|
+
var log = el('div', 'kt-demo-log');
|
|
397
|
+
['1 signed up', '2 added to cart', '3 paid'].forEach(function (t) { log.appendChild(el('i', null, t)); });
|
|
398
|
+
d.appendChild(log);
|
|
399
|
+
return d;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function ending(c) {
|
|
403
|
+
var p = plan();
|
|
404
|
+
var d = state && state.daily;
|
|
405
|
+
title(c, 'Congratulations - ', 'you are set up', '');
|
|
406
|
+
c.appendChild(el('p', null, 'You did every part yourself. From now on Kryptheon does the watching.'));
|
|
407
|
+
c.appendChild(el('div', 'kt-h', 'What happens now, every day'));
|
|
408
|
+
var list = el('ul', 'kt-list');
|
|
409
|
+
[
|
|
410
|
+
['1', 'When your laptop starts', (state && state.autostart && state.autostart.on) ? 'Kryptheon starts by itself, and this page opens in your browser at your first sign-in of the day.' : 'Open this dashboard the way you did today - or switch on Start with Windows and it starts by itself.'],
|
|
411
|
+
['2', d && d.on ? 'Every day at ' + d.at : 'Once a day', d && d.on ? 'Every check runs by itself, and a note in the corner of your screen says what is new and what got fixed.' : 'Switch on Check my app every day, and your checks run by themselves at a time you pick.'],
|
|
412
|
+
['3', 'After every change your AI makes', 'Press Check my app. It uses your app the way you recorded it and tells you what broke.'],
|
|
413
|
+
['4', 'When something broke', 'Copy the fix prompt into your AI, then Check my app again - FIXED only when it really is.'],
|
|
414
|
+
].forEach(function (x) {
|
|
415
|
+
var li = el('li');
|
|
416
|
+
li.appendChild(el('span', null, x[0]));
|
|
417
|
+
var t = el('div');
|
|
418
|
+
t.appendChild(el('b', null, x[1]));
|
|
419
|
+
t.appendChild(el('small', null, x[2]));
|
|
420
|
+
li.appendChild(t);
|
|
421
|
+
list.appendChild(li);
|
|
422
|
+
});
|
|
423
|
+
c.appendChild(list);
|
|
424
|
+
|
|
425
|
+
if (p === 'pro' || p === 'studio') {
|
|
426
|
+
c.appendChild(el('div', 'kt-h', 'What your ' + (p === 'pro' ? 'Pro' : 'Studio') + ' plan adds'));
|
|
427
|
+
var extra = el('ul', 'kt-list');
|
|
428
|
+
var items = [
|
|
429
|
+
['N', 'Every night, a test break-in on a copy of your database', 'Set up once, then it runs inside your database while you sleep.', 'nightly'],
|
|
430
|
+
['A', 'Every fix in one prompt', 'Copy one prompt for all, paste once.', 'fixall'],
|
|
431
|
+
['M', 'A morning email', 'And an alert when a new problem appears - set on kryptheon.tech.', null],
|
|
432
|
+
];
|
|
433
|
+
if (p === 'studio') items.push(['S', 'Alerts to Slack, and a report for your client', 'Both on your account at kryptheon.tech, for up to 15 apps.', null]);
|
|
434
|
+
items.forEach(function (x) {
|
|
435
|
+
var li = el('li');
|
|
436
|
+
li.appendChild(el('span', null, x[0]));
|
|
437
|
+
var t = el('div');
|
|
438
|
+
t.appendChild(el('b', null, x[1]));
|
|
439
|
+
t.appendChild(el('small', null, x[2]));
|
|
440
|
+
if (x[3]) t.appendChild(plain('Show me', (function (id) { return function () { move(id); }; })(x[3])));
|
|
441
|
+
li.appendChild(t);
|
|
442
|
+
extra.appendChild(li);
|
|
443
|
+
});
|
|
444
|
+
c.appendChild(extra);
|
|
445
|
+
} else {
|
|
446
|
+
c.appendChild(el('div', 'kt-h', 'You are on Starter - 5 fix prompts a month'));
|
|
447
|
+
var plans = el('div', 'kt-plans');
|
|
448
|
+
[['Pro', '₹499 / month', ['Every fix prompt, for every problem', 'One prompt to fix them all', 'Every night, a test break-in on a copy of your database', 'A morning email and new-problem alerts', '3 apps'], true],
|
|
449
|
+
['Studio', '₹799 / month', ['Everything in Pro', 'Alerts to Slack or any webhook', 'A report you can hand a client', '15 apps, a year of history'], false]].forEach(function (x) {
|
|
450
|
+
var box = el('div', 'kt-plan' + (x[3] ? ' kt-best' : ''));
|
|
451
|
+
box.appendChild(el('b', null, x[0]));
|
|
452
|
+
box.appendChild(el('strong', null, x[1]));
|
|
453
|
+
var ul = el('ul');
|
|
454
|
+
x[2].forEach(function (t) { ul.appendChild(el('li', null, t)); });
|
|
455
|
+
box.appendChild(ul);
|
|
456
|
+
plans.appendChild(box);
|
|
457
|
+
});
|
|
458
|
+
c.appendChild(plans);
|
|
459
|
+
var link = el('a', 'kt-btn', 'See plans on kryptheon.tech');
|
|
460
|
+
link.href = 'https://kryptheon.tech/pricing/';
|
|
461
|
+
link.target = '_blank';
|
|
462
|
+
link.rel = 'noopener noreferrer';
|
|
463
|
+
link.style.display = 'inline-flex';
|
|
464
|
+
link.style.alignItems = 'center';
|
|
465
|
+
link.style.textDecoration = 'none';
|
|
466
|
+
var r = el('div', 'kt-row');
|
|
467
|
+
r.appendChild(link);
|
|
468
|
+
c.appendChild(r);
|
|
469
|
+
}
|
|
470
|
+
row(c, [go('Finish', function () { stop(); })]);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// a few sparks rising, once, at the end
|
|
474
|
+
function sparks() {
|
|
475
|
+
if (still) return;
|
|
476
|
+
var cv = el('canvas', 'kt-sparks');
|
|
477
|
+
document.body.appendChild(cv);
|
|
478
|
+
var cx = cv.getContext('2d');
|
|
479
|
+
var w = cv.width = window.innerWidth;
|
|
480
|
+
var h = cv.height = window.innerHeight;
|
|
481
|
+
var bits = [];
|
|
482
|
+
for (var i = 0; i < 90; i++) bits.push({ x: w / 2 + (Math.random() - 0.5) * 120, y: h * 0.6, vx: (Math.random() - 0.5) * 7, vy: -4 - Math.random() * 7, r: 1.5 + Math.random() * 2.5, life: 1 });
|
|
483
|
+
var t0 = Date.now();
|
|
484
|
+
(function draw() {
|
|
485
|
+
cx.clearRect(0, 0, w, h);
|
|
486
|
+
bits.forEach(function (b) {
|
|
487
|
+
b.x += b.vx; b.y += b.vy; b.vy += 0.16; b.life -= 0.012;
|
|
488
|
+
if (b.life <= 0) return;
|
|
489
|
+
cx.fillStyle = 'rgba(255,' + (90 + Math.round(b.life * 80)) + ',20,' + b.life + ')';
|
|
490
|
+
cx.beginPath(); cx.arc(b.x, b.y, b.r, 0, Math.PI * 2); cx.fill();
|
|
491
|
+
});
|
|
492
|
+
if (Date.now() - t0 < 2600) window.requestAnimationFrame(draw);
|
|
493
|
+
else cv.remove();
|
|
494
|
+
})();
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/* ------------------------------- moving the light ------------------------------- */
|
|
498
|
+
|
|
499
|
+
function place() {
|
|
500
|
+
if (!on) return;
|
|
501
|
+
var step = STEPS[at];
|
|
502
|
+
var target = step && step.target ? step.target() : null;
|
|
503
|
+
if (target && !visible(target)) target = null;
|
|
504
|
+
if (target !== lit) {
|
|
505
|
+
if (lit) lit.classList.remove('kt-lit');
|
|
506
|
+
lit = target;
|
|
507
|
+
if (lit) {
|
|
508
|
+
if (!still) lit.classList.add('kt-lit');
|
|
509
|
+
// scrolled to once per part: the page redraws its own boxes every few seconds, and a lit box drawn again is the same part
|
|
510
|
+
var what = at + '|' + (lit.id || lit.className.replace(/\s*kt-lit/, ''));
|
|
511
|
+
if (what !== scrolledTo) {
|
|
512
|
+
scrolledTo = what;
|
|
513
|
+
// near the top, so the card has room under it; a panel fixed in the corner needs no scrolling
|
|
514
|
+
if (window.getComputedStyle(lit).position !== 'fixed') {
|
|
515
|
+
var top = lit.getBoundingClientRect().top + window.pageYOffset - 90;
|
|
516
|
+
window.scrollTo({ top: Math.max(0, top), behavior: still ? 'auto' : 'smooth' });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
var vw = window.innerWidth;
|
|
522
|
+
var vh = window.innerHeight;
|
|
523
|
+
if (!lit) {
|
|
524
|
+
// nothing to light: the whole room dark, the card in the middle
|
|
525
|
+
lens.className = 'kt-lens kt-none';
|
|
526
|
+
lens.hidden = true;
|
|
527
|
+
blocks.forEach(function (b, i) { b.hidden = i !== 0; });
|
|
528
|
+
blocks[0].style.cssText = 'left:0;top:0;width:100vw;height:100vh;background:rgba(9,7,5,.86)';
|
|
529
|
+
card.classList.add('kt-mid');
|
|
530
|
+
card.style.left = Math.max(14, (vw - card.offsetWidth) / 2) + 'px';
|
|
531
|
+
card.style.top = Math.max(20, (vh - card.offsetHeight) / 2) + 'px';
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
card.classList.remove('kt-mid');
|
|
535
|
+
var r = lit.getBoundingClientRect();
|
|
536
|
+
var pad = 10;
|
|
537
|
+
var x = Math.max(4, r.left - pad);
|
|
538
|
+
var y = Math.max(4, r.top - pad);
|
|
539
|
+
var x2 = Math.min(vw - 4, r.right + pad);
|
|
540
|
+
var y2 = Math.min(vh - 4, r.bottom + pad);
|
|
541
|
+
lens.className = 'kt-lens';
|
|
542
|
+
lens.hidden = false;
|
|
543
|
+
lens.style.left = x + 'px';
|
|
544
|
+
lens.style.top = y + 'px';
|
|
545
|
+
lens.style.width = Math.max(0, x2 - x) + 'px';
|
|
546
|
+
lens.style.height = Math.max(0, y2 - y) + 'px';
|
|
547
|
+
// four panes around the lit part take every click that is not for it
|
|
548
|
+
var sides = [
|
|
549
|
+
[0, 0, vw, y],
|
|
550
|
+
[0, y, x, y2 - y],
|
|
551
|
+
[x2, y, vw - x2, y2 - y],
|
|
552
|
+
[0, y2, vw, vh - y2],
|
|
553
|
+
];
|
|
554
|
+
blocks.forEach(function (b, i) {
|
|
555
|
+
b.hidden = false;
|
|
556
|
+
var s = sides[i];
|
|
557
|
+
b.style.cssText = 'left:' + s[0] + 'px;top:' + s[1] + 'px;width:' + Math.max(0, s[2]) + 'px;height:' + Math.max(0, s[3]) + 'px';
|
|
558
|
+
});
|
|
559
|
+
// the card where there is room: below, above, then to the side, then over the lower part
|
|
560
|
+
var cw = card.offsetWidth;
|
|
561
|
+
var ch = card.offsetHeight;
|
|
562
|
+
var left = Math.min(Math.max(14, r.left), vw - cw - 14);
|
|
563
|
+
var top;
|
|
564
|
+
if (y2 + 14 + ch < vh - 10) top = y2 + 14;
|
|
565
|
+
else if (y - 14 - ch > 10) top = y - 14 - ch;
|
|
566
|
+
else if (x2 + 14 + cw < vw - 10) { left = x2 + 14; top = Math.min(Math.max(10, r.top), vh - ch - 10); }
|
|
567
|
+
else if (x - 14 - cw > 10) { left = x - 14 - cw; top = Math.min(Math.max(10, r.top), vh - ch - 10); }
|
|
568
|
+
else top = vh - ch - 12;
|
|
569
|
+
card.style.left = left + 'px';
|
|
570
|
+
card.style.top = Math.max(10, top) + 'px';
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
var scrolledTo = '';
|
|
574
|
+
function draw() {
|
|
575
|
+
if (!on) return;
|
|
576
|
+
var step = STEPS[at];
|
|
577
|
+
var where = typeof step.view === 'function' ? step.view() : step.view;
|
|
578
|
+
if (where) view(where);
|
|
579
|
+
clear(card);
|
|
580
|
+
var n = MAIN.indexOf(at);
|
|
581
|
+
if (n >= 0) {
|
|
582
|
+
var head = el('div', 'kt-step');
|
|
583
|
+
head.appendChild(el('span', null, 'Step ' + (n + 1) + ' of ' + MAIN.length));
|
|
584
|
+
if (optional) {
|
|
585
|
+
var skip = el('button', 'kt-skip', 'Close the guide');
|
|
586
|
+
skip.type = 'button';
|
|
587
|
+
skip.addEventListener('click', function () { keep({ dismissed: true }); stop(); });
|
|
588
|
+
head.appendChild(skip);
|
|
589
|
+
} else if (Date.now() - stepSince > STUCK_MS) {
|
|
590
|
+
// a way out for someone who cannot do this step now - not a "no": it starts again next time
|
|
591
|
+
var stuck = el('button', 'kt-skip', 'Stuck here? Leave for now');
|
|
592
|
+
stuck.type = 'button';
|
|
593
|
+
stuck.addEventListener('click', function () { stop(); });
|
|
594
|
+
head.appendChild(stuck);
|
|
595
|
+
}
|
|
596
|
+
card.appendChild(head);
|
|
597
|
+
var bar = el('div', 'kt-bar');
|
|
598
|
+
MAIN.forEach(function (m, i) { bar.appendChild(el('i', i <= n ? 'on' : null)); });
|
|
599
|
+
card.appendChild(bar);
|
|
600
|
+
}
|
|
601
|
+
step.show(card);
|
|
602
|
+
if (n >= 0) {
|
|
603
|
+
var prev = n > 0 ? MAIN[n - 1] : null;
|
|
604
|
+
if (prev === 'connect' && connected()) prev = null;
|
|
605
|
+
var nav = el('div', 'kt-nav');
|
|
606
|
+
if (prev) nav.appendChild(plain('Back', function () { move(prev, true); }));
|
|
607
|
+
if (seen.back === at && n < MAIN.length - 1) nav.appendChild(plain('Next', function () { move(MAIN[n + 1]); }));
|
|
608
|
+
if (nav.firstChild) card.appendChild(nav);
|
|
609
|
+
}
|
|
610
|
+
card.hidden = false;
|
|
611
|
+
lens.hidden = false;
|
|
612
|
+
drawn = signature();
|
|
613
|
+
place();
|
|
614
|
+
}
|
|
615
|
+
var drawn = '';
|
|
616
|
+
function signature() {
|
|
617
|
+
return [at, busy, Date.now() - stepSince > STUCK_MS, seen.connectWhy || '', visible(byId('everyBox')), hasAddress(), recordings(), findings().length, seen.pressed, needsConnect(), connected(),
|
|
618
|
+
!!((q('#accountBox input') || {}).value),
|
|
619
|
+
state && state.autostart && state.autostart.on, state && state.daily && state.daily.on].join('|');
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function move(id, back) {
|
|
623
|
+
at = id;
|
|
624
|
+
seen.back = back ? id : null;
|
|
625
|
+
stepSince = Date.now();
|
|
626
|
+
keep({ at: id });
|
|
627
|
+
var step = STEPS[id];
|
|
628
|
+
if (step.enter) step.enter();
|
|
629
|
+
if (lit) { lit.classList.remove('kt-lit'); lit = null; }
|
|
630
|
+
window.setTimeout(draw, 60);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function start(from, byChoice) {
|
|
634
|
+
optional = !!byChoice;
|
|
635
|
+
MAIN = (connected() ? [] : ['connect']).concat(BASE);
|
|
636
|
+
if (from === 'connect' && connected()) from = 'app';
|
|
637
|
+
on = true;
|
|
638
|
+
document.body.classList.add('kt-on');
|
|
639
|
+
move(from || 'hello');
|
|
640
|
+
loop();
|
|
641
|
+
}
|
|
642
|
+
function stop() {
|
|
643
|
+
on = false;
|
|
644
|
+
document.body.classList.remove('kt-on');
|
|
645
|
+
at = null;
|
|
646
|
+
card.hidden = true;
|
|
647
|
+
lens.hidden = true;
|
|
648
|
+
blocks.forEach(function (b) { b.hidden = true; });
|
|
649
|
+
if (lit) { lit.classList.remove('kt-lit'); lit = null; }
|
|
650
|
+
window.cancelAnimationFrame(frame);
|
|
651
|
+
}
|
|
652
|
+
function loop() {
|
|
653
|
+
if (!on) return;
|
|
654
|
+
// some parts open without the server saying anything - the yes box of Check my app
|
|
655
|
+
if (signature() !== drawn) draw();
|
|
656
|
+
place();
|
|
657
|
+
frame = window.requestAnimationFrame(loop);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// A press inside the lit part, for steps that wait for one.
|
|
661
|
+
document.addEventListener('click', function (e) {
|
|
662
|
+
if (!on || !lit || !STEPS[at].press) return;
|
|
663
|
+
if (lit.contains(e.target) && e.target.closest('button')) { STEPS[at].press(); window.setTimeout(draw, 30); }
|
|
664
|
+
}, true);
|
|
665
|
+
document.addEventListener('keydown', function (e) {
|
|
666
|
+
if (on && optional && e.key === 'Escape') { keep({ dismissed: true }); stop(); }
|
|
667
|
+
});
|
|
668
|
+
window.addEventListener('resize', function () { if (on) place(); });
|
|
669
|
+
window.addEventListener('kryptheon:connect-failed', function (e) { seen.connectWhy = String((e.detail && e.detail.why) || 'kryptheon.tech did not accept that code'); if (on) draw(); });
|
|
670
|
+
|
|
671
|
+
// The page says what changed: move on when a step is done, redraw when what it says has changed.
|
|
672
|
+
var guideBtn = null;
|
|
673
|
+
window.addEventListener('kryptheon:state', function (e) {
|
|
674
|
+
state = (e.detail && e.detail.state) || state;
|
|
675
|
+
busy = !!(e.detail && e.detail.busy);
|
|
676
|
+
if (!state) return;
|
|
677
|
+
if (!guideBtn && byId('runAll')) {
|
|
678
|
+
guideBtn = el('button', 'btn kt-guide-btn', 'Guide me');
|
|
679
|
+
guideBtn.type = 'button';
|
|
680
|
+
guideBtn.addEventListener('click', function () { if (!on) start(read().at && read().at !== 'end' ? read().at : 'hello', true); });
|
|
681
|
+
byId('runAll').parentNode.insertBefore(guideBtn, byId('runAll'));
|
|
682
|
+
}
|
|
683
|
+
if (!on) {
|
|
684
|
+
var kept = read();
|
|
685
|
+
// #tour from a link, #tour-connect when a connect code came with the person from kryptheon.tech
|
|
686
|
+
var asked = /^#tour(-connect)?$/.exec(location.hash);
|
|
687
|
+
if (asked) { history.replaceState(null, '', '#dashboard'); return start(asked[1] ? 'connect' : 'hello'); }
|
|
688
|
+
// by itself only for someone who has not set up yet, and only until they finish or close it
|
|
689
|
+
if (!kept.done && !kept.dismissed && (kept.at || !hasAddress() || recordings() === 0)) start(kept.at && STEPS[kept.at] ? kept.at : 'hello');
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
var step = STEPS[at];
|
|
693
|
+
if (step.tick) step.tick();
|
|
694
|
+
if (step.done && step.done()) return move(step.next);
|
|
695
|
+
if (signature() !== drawn) draw();
|
|
696
|
+
});
|
|
697
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kryptheon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.73",
|
|
4
4
|
"description": "Record what you do in your app and get plain-language reports when it breaks.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"kryptheon-dashboard.js",
|
|
39
39
|
"kryptheon-dashboard.html",
|
|
40
40
|
"kryptheon-dashboard-page.js",
|
|
41
|
+
"kryptheon-tour.js",
|
|
41
42
|
"kryptheon-account.js",
|
|
42
43
|
"kryptheon-logo.png",
|
|
43
44
|
"kryptheon-fonts-OFL.txt",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"pg": "^8.23.0"
|
|
75
76
|
},
|
|
76
77
|
"scripts": {
|
|
77
|
-
"check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-aiapp.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
|
|
78
|
+
"check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-tour.check.js && node kryptheon-upgrade.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-aiapp.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
|
|
78
79
|
"check:store": "node kryptheon-store.check.js",
|
|
79
80
|
"check:code": "node kryptheon-code.check.js",
|
|
80
81
|
"check:constdata": "node kryptheon-constdata.check.js",
|