make blockbypass modal look+sound better, check for success and auto close and make post when completed successfully

merge-requests/208/head
fatchan 4 years ago
parent 4745d6d7a6
commit 0df78e0a7f
  1. 25
      gulp/res/js/forms.js
  2. 8
      gulp/res/js/settings.js
  3. 2
      helpers/checks/blockbypass.js
  4. 6
      package-lock.json
  5. 2
      views/mixins/modal.pug

@ -3,11 +3,26 @@ function removeModal() {
modalClasses.forEach(c => document.getElementsByClassName(c)[0].remove());
}
function doModal(data) {
function doModal(data, postcallback) {
const modalHtml = modal({ modal: data });
let checkInterval;
document.body.insertAdjacentHTML('afterbegin', modalHtml);
document.getElementById('modalclose').onclick = removeModal;
document.getElementsByClassName('modal-bg')[0].onclick = removeModal;
document.getElementById('modalclose').onclick = () => {
removeModal();
clearInterval(checkInterval);
};
document.getElementsByClassName('modal-bg')[0].onclick = () => {
removeModal();
clearInterval(checkInterval);
};
const modalframe = document.getElementById('modalframe');
checkInterval = setInterval(() => {
if (modalframe && modalframe.contentDocument.title == 'Success') {
clearInterval(checkInterval);
removeModal();
postcallback();
}
}, 100);
}
const checkTypes = ['checkbox', 'radio'];
@ -140,7 +155,9 @@ class formHandler {
}
//not 200 status, so some error/failed post, wrong captcha, etc
if (json) {
doModal(json);
doModal(json, () => {
this.form.dispatchEvent(new Event('submit'));
});
} else {
//for bans, post form to show TODO: make modal support bans json and send dynamicresponse from it
this.clearFiles(); //dont resubmit files

@ -13,8 +13,6 @@ window.addEventListener('DOMContentLoaded', (event) => {
settingsBg.style.display = 'unset';
}
const settings = document.getElementById('settings');
const modalHtml = modal({
modal: {
title: 'Settings',
@ -32,7 +30,11 @@ window.addEventListener('DOMContentLoaded', (event) => {
settingsBg.onclick = hideSettings;
settingsModal.getElementsByClassName('close')[0].onclick = hideSettings;
settings.onclick = openSettings;
const settings = document.getElementById('settings');
if (settings) { //can be false if we are in minimal view
settings.onclick = openSettings;
}
window.dispatchEvent(new CustomEvent('settingsReady'));

@ -17,7 +17,7 @@ module.exports = async (req, res, next) => {
if (!res.locals.solvedCaptcha && (!bypassId || bypassId.length !== 24)) {
return dynamicResponse(req, res, 403, 'message', {
'title': 'Forbidden',
'message': 'Missing or invalid block bypass',
'message': 'Please complete a block bypass to post',
'frame': '/bypass_minimal.html',
'link': {
'href': '/bypass.html',

6
package-lock.json generated

@ -227,7 +227,7 @@
},
"@tohru/gm": {
"version": "github:fatchan/gm#c2ffb2ce0db3f64fbf4082462601429985b6dca6",
"from": "github:fatchan/gm#c2ffb2ce0db3f64fbf4082462601429985b6dca6",
"from": "github:fatchan/gm",
"requires": {
"array-parallel": "^0.1.3",
"array-series": "^0.1.5",
@ -2401,7 +2401,7 @@
}
},
"express-fileupload": {
"version": "github:fatchan/express-fileupload#9aada2ecdef8a6617ccf82746e5faa2aece77239",
"version": "github:fatchan/express-fileupload#fd713ae7a3c7f381638d6479faa142d366304329",
"from": "github:fatchan/express-fileupload",
"requires": {
"busboy": "^0.3.1"
@ -3605,7 +3605,7 @@
},
"gm": {
"version": "github:fatchan/gm#c2ffb2ce0db3f64fbf4082462601429985b6dca6",
"from": "github:fatchan/gm#c2ffb2ce0db3f64fbf4082462601429985b6dca6",
"from": "github:fatchan/gm",
"requires": {
"array-parallel": "^0.1.3",
"array-series": "^0.1.5",

@ -19,7 +19,7 @@ mixin modal(data)
li #{error}
if data.frame
.row
iframe.bypass(src=data.frame frameborder='0' scrolling='no')
iframe.bypass#modalframe(src=data.frame frameborder='0' scrolling='no')
else if data.link
.row
a.button.mv-0(href=data.link.href target='_blank') #{data.link.text}

Loading…
Cancel
Save