lazy init edit submit btn and update demo link

This commit is contained in:
realaravinth 2021-07-26 11:49:07 +05:30
parent 8830961e04
commit 9bc11f3518
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
4 changed files with 51 additions and 49 deletions

View file

@ -27,7 +27,7 @@ Proof of work based, privacy respecting CAPTCHA system with a kickass UX.
system with a kickass UX. Your users no longer have to interact with
ridiculous image-based CAPTCHA system, wasting precious mental
bandwidth. Instead, your computer will do the work for you, [see for
yourself!](https://demo.mcaptcha.org/widget?sitekey=RnR9SvkkB2s1W9yrQSBBViJHLvuiXKo4)
yourself!](https://demo.mcaptcha.org/widget/?sitekey=6o3p1Fx94hJRFm8g8IHBB7sv8D0em20k)
## How does it work?
@ -80,7 +80,7 @@ easier. One click and you are on your way.
To observe mCaptcha in action, open dev tools and
monitor console and network activity.
1. [Link to widget](https://demo.mcaptcha.org/widget?sitekey=RnR9SvkkB2s1W9yrQSBBViJHLvuiXKo4)
1. [Link to widget](https://demo.mcaptcha.org/widget/?sitekey=6o3p1Fx94hJRFm8g8IHBB7sv8D0em20k)
2. [Video](https://github.com/mCaptcha/mCaptcha/blob/master/docs/res/widget-in-action.mp4?raw=true):

View file

@ -40,6 +40,26 @@
]
}
},
"174457087e02e07bfe52618cc8b5525067fa1722684f37a30004074a499774ee": {
"query": "SELECT time FROM mcaptcha_pow_confirmed_stats WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where key = $1)",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "time",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false
]
}
},
"1be6274d5cc6d16f38285b8a62c9f66e8c3014cd403bc599598e911023bfeedb": {
"query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id) VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1))",
"describe": {
@ -229,26 +249,6 @@
]
}
},
"4dc1b6d8ae3b92ebff45f683951c087244f9614ed0e95b75578f0d1346887224": {
"query": "SELECT fetched_at FROM mcaptcha_pow_fetched_stats WHERE config_id = \n (SELECT config_id FROM mcaptcha_config where key = $1)",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "fetched_at",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false
]
}
},
"507bea10c7f8417c5b1430211d0137299cd561333bf47f7b4887d0ef801d1ea4": {
"query": "UPDATE mcaptcha_config SET key = $1 \n WHERE key = $2 AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = $3)",
"describe": {
@ -404,6 +404,26 @@
"nullable": []
}
},
"85a3482fc65dab99cd01f51411f0567d303018bbb6483a0020db33180ce12cfb": {
"query": "SELECT time FROM mcaptcha_pow_solved_stats WHERE config_id = \n (SELECT config_id FROM mcaptcha_config where key = $1)",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "time",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false
]
}
},
"90608e874ec931db397dc7b357b60bc794fffec5e2eb59c0556808ea8dfef9e9": {
"query": "SELECT ID, password FROM mcaptcha_users WHERE name = ($1)",
"describe": {
@ -600,26 +620,6 @@
"nullable": []
}
},
"daebbef26cf04fdc46226304d028528e121a9847c07139d7d3a56a0e7c165879": {
"query": "SELECT solved_at FROM mcaptcha_pow_solved_stats WHERE config_id = \n (SELECT config_id FROM mcaptcha_config where key = $1)",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "solved_at",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false
]
}
},
"dcf0d4f9d803dcb1d6f775899f79595f9c78d46633e0ec822303284430df7a3d": {
"query": "-- gets all unread notifications a user has\nSELECT \n mcaptcha_notifications.id,\n mcaptcha_notifications.heading,\n mcaptcha_notifications.message,\n mcaptcha_notifications.received,\n mcaptcha_users.name\nFROM\n mcaptcha_notifications \nINNER JOIN \n mcaptcha_users \nON \n mcaptcha_notifications.tx = mcaptcha_users.id\nWHERE \n mcaptcha_notifications.rx = (\n SELECT \n id \n FROM \n mcaptcha_users\n WHERE\n name = $1\n )\nAND \n mcaptcha_notifications.read IS NULL;\n",
"describe": {
@ -712,13 +712,13 @@
"nullable": []
}
},
"fb15883459af48b0f6f1eee5d47641db8fa0875f7f21665dbc40800869e5e353": {
"query": "SELECT confirmed_at FROM mcaptcha_pow_confirmed_stats WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where key = $1)",
"fc6b52054ea35458f597bcd3bd9a99029fca816f1e65a9e12cfd7ea4acc33838": {
"query": "SELECT time FROM mcaptcha_pow_fetched_stats WHERE config_id = \n (SELECT config_id FROM mcaptcha_config where key = $1)",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "confirmed_at",
"name": "time",
"type_info": "Timestamptz"
}
],

View file

@ -6,7 +6,8 @@
<. } .>
<. let level = levels.len() + 1; .>
<. include!("../add/add-level.html"); .>
<button data-sitekey="<.= key .>" class="sitekey-form__submit" type="submit">
<button data-sitekey="<.= key .>"
id="sitekey-form__submit" class="sitekey-form__submit" type="submit">
Submit
</button>
<. include!("../view/__form-bottom.html"); .>

View file

@ -27,10 +27,12 @@ import {LEVELS} from '../add/ts/levels';
import getFormUrl from '../../../utils/getFormUrl';
import genJsonPayload from '../../../utils/genJsonPayload';
import createError from '../../../components/error';
import LazyElement from '../../../utils/lazyElement';
import VIEWS from '../../../views/v1/routes';
const BTN_CLASS = document.querySelector('sitekey-form__submit');
const BTN_ID = 'sitekey-form__submit';
const BTN = new LazyElement(BTN_ID);
const submit = async (e: Event) => {
e.preventDefault();
@ -43,8 +45,7 @@ const submit = async (e: Event) => {
const levels = LEVELS.getLevels();
console.debug(`[form submition]: levels: ${levels}`);
const btn = <HTMLElement>document.querySelector(`${BTN_CLASS}`);
const key = btn.dataset.sitekey;
const key = BTN.get().dataset.sitekey;
const payload = {
levels,