ChatGPT's update to harden software and run db updates.

This commit is contained in:
2026-10-21 06:53:45 -04:00
parent 1e63076123
commit acc8cb70f5
171 changed files with 9325 additions and 404 deletions
+3 -43
View File
@@ -5,53 +5,13 @@
$(document).ready(function () {
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"), $CKEditor;
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
// ----------------------
// Initialize the Editor.
// ----------------------
ClassicEditor
.create(document.querySelector('#alert_message'), {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'underline',
'link',
'bulletedList',
'numberedList',
'|',
'fontColor',
'fontSize',
'fontFamily',
'|',
'indent',
'outdent',
'alignment',
'|',
'horizontalLine',
'insertTable',
'|',
'undo',
'redo',
'|'
]},
link: {
addTargetToExternalLinks: true,
defaultProtocol: "http://"
}
})
.then(editor => {
$CKEditor = editor;
})
.catch(error => {
console.error('CK-Editor error...');
console.error(error);
});
HcrRichText.create(document.querySelector('#alert_message'));
// ------------
@@ -210,7 +170,7 @@ $(document).ready(function () {
e.preventDefault();
$CKEditor.updateSourceElement();
if (!HcrRichText.sync(document.querySelector('#alert_message'))) return;
$.post("./", $(this).serialize())
+3 -44
View File
@@ -6,54 +6,13 @@
$(document).ready(function () {
var $application = $("#APPLICATION_MNEMONIC").val(),
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"),
$CKEditor;
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
// ----------------------
// Initialize the Editor.
// ----------------------
ClassicEditor
.create(document.querySelector('#popover_text'), {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'underline',
'link',
'bulletedList',
'numberedList',
'|',
'fontColor',
'fontSize',
'fontFamily',
'|',
'indent',
'outdent',
'alignment',
'|',
'horizontalLine',
'insertTable',
'|',
'undo',
'redo',
'|'
]},
link: {
addTargetToExternalLinks: true,
defaultProtocol: "http://"
}
})
.then(editor => {
$CKEditor = editor;
})
.catch(error => {
console.error('CK-Editor error...');
console.error(error);
});
HcrRichText.create(document.querySelector('#popover_text'));
// -----------
// Save Button
@@ -114,7 +73,7 @@ $(document).ready(function () {
e.preventDefault();
$CKEditor.updateSourceElement();
if (!HcrRichText.sync(document.querySelector('#popover_text'))) return;
$.post("./", $(this).serialize())
-6
View File
File diff suppressed because one or more lines are too long
+41
View File
@@ -0,0 +1,41 @@
document.querySelectorAll('.club-action-modal').forEach(modal => {
const form = modal.querySelector('form');
if (!form) return;
let saving = false;
modal.addEventListener('shown.bs.modal', () => {
form.querySelector('input:not([type="hidden"]),select,textarea')?.focus();
});
modal.addEventListener('hide.bs.modal', event => {
if (saving) event.preventDefault();
});
form.addEventListener('submit', async event => {
event.preventDefault();
if (saving || !form.reportValidity()) return;
const error = modal.querySelector('.club-modal-error');
error.hidden = true;
const data = new FormData(form);
const buttons = Array.from(modal.querySelectorAll('button'));
const disabled = buttons.map(button => button.disabled);
saving = true;
buttons.forEach(button => button.disabled = true);
try {
// The existing hidden field named "action" shadows form.action.
const response = await fetch(form.getAttribute('action') || 'main.php', {
method: 'POST', credentials: 'same-origin', body: data,
headers: {'X-Requested-With': 'XMLHttpRequest', 'X-HCR-Modal': '1'}
});
const result = await response.json();
if (!response.ok || !result.ok) throw new Error(result.error || 'Your change could not be saved.');
window.location.assign(result.redirect);
} catch (failure) {
error.textContent = failure instanceof SyntaxError || failure instanceof TypeError
? 'Your change could not be confirmed. Reload the club page before retrying.'
: failure.message;
error.hidden = false;
error.focus();
} finally {
saving = false;
buttons.forEach((button, index) => button.disabled = disabled[index]);
}
});
});
+3 -43
View File
@@ -5,53 +5,13 @@
$(document).ready(function () {
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"), $CKEditor;
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
// ----------------------
// Initialize the Editor.
// ----------------------
ClassicEditor
.create(document.querySelector('#alert_message'), {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'underline',
'link',
'bulletedList',
'numberedList',
'|',
'fontColor',
'fontSize',
'fontFamily',
'|',
'indent',
'outdent',
'alignment',
'|',
'horizontalLine',
'insertTable',
'|',
'undo',
'redo',
'|'
]},
link: {
addTargetToExternalLinks: true,
defaultProtocol: "http://"
}
})
.then(editor => {
$CKEditor = editor;
})
.catch(error => {
console.error('CK-Editor error...');
console.error(error);
});
HcrRichText.create(document.querySelector('#alert_message'));
// ------------
@@ -210,7 +170,7 @@ $(document).ready(function () {
e.preventDefault();
$CKEditor.updateSourceElement();
if (!HcrRichText.sync(document.querySelector('#alert_message'))) return;
$.post("./", $(this).serialize())
+3 -44
View File
@@ -6,54 +6,13 @@
$(document).ready(function () {
var $application = $("#APPLICATION_MNEMONIC").val(),
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}"),
$CKEditor;
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
// ----------------------
// Initialize the Editor.
// ----------------------
ClassicEditor
.create(document.querySelector('#popover_text'), {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'underline',
'link',
'bulletedList',
'numberedList',
'|',
'fontColor',
'fontSize',
'fontFamily',
'|',
'indent',
'outdent',
'alignment',
'|',
'horizontalLine',
'insertTable',
'|',
'undo',
'redo',
'|'
]},
link: {
addTargetToExternalLinks: true,
defaultProtocol: "http://"
}
})
.then(editor => {
$CKEditor = editor;
})
.catch(error => {
console.error('CK-Editor error...');
console.error(error);
});
HcrRichText.create(document.querySelector('#popover_text'));
// -----------
// Save Button
@@ -144,7 +103,7 @@ $(document).ready(function () {
e.preventDefault();
$CKEditor.updateSourceElement();
if (!HcrRichText.sync(document.querySelector('#popover_text'))) return;
$.post("./", $(this).serialize())
+47
View File
@@ -0,0 +1,47 @@
/* Shared adapter for the locally hosted SunEditor build. */
window.HcrRichText = (function () {
'use strict';
const editors = new WeakMap();
function create(element) {
const buttons = element.closest('.card-body').querySelectorAll('.btnSave');
buttons.forEach(button => button.disabled = true);
const failure = function () {
const message = document.createElement('p');
message.setAttribute('role', 'alert');
message.textContent = 'The text editor could not load. Reload this page before saving.';
element.parentNode.appendChild(message);
};
let timer;
try {
timer = setTimeout(failure, 10000);
const editor = SUNEDITOR.create(element, {
height: '240px',
plugins: ['blockStyle', 'link', 'list_bulleted', 'list_numbered', 'font', 'fontSize', 'fontColor', 'align', 'hr', 'table'].map(name => SUNEDITOR.plugins[name]),
buttonList: [
['undo', 'redo'], ['blockStyle', 'bold', 'italic', 'underline'],
['link', 'list_bulleted', 'list_numbered'],
['font', 'fontSize', 'fontColor'], ['indent', 'outdent', 'align'],
['hr', 'table']
]
});
editor.$.eventManager.events.onload = function () {
clearTimeout(timer);
editors.set(element, editor);
element.hcrEditor = editor;
buttons.forEach(button => button.disabled = false);
};
} catch (error) {
console.error('Text editor initialization failed.', error);
clearTimeout(timer);
failure();
}
}
function sync(element) {
const editor = editors.get(element);
if (!editor)
return false;
element.value = editor.isEmpty() ? '' : editor.$.html.get();
return true;
}
return {create: create, sync: sync};
}());
+1
View File
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
/* HTML maxlength counts UTF-16 units; the server counts Unicode code points. */
(function () {
'use strict';
function initialize() {
document.querySelectorAll('[data-character-limit]').forEach(function (field) {
const limit = Number(field.dataset.characterLimit);
function validate() {
const tooLong = Array.from(field.value.replace(/^[ \t\n\r\0\v]+|[ \t\n\r\0\v]+$/g, '')).length > limit;
field.setCustomValidity(tooLong ? 'Please enter ' + limit + ' characters or fewer.' : '');
}
field.addEventListener('input', validate);
validate();
});
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initialize);
else initialize();
}());