MediaWiki:EventForm.js: Difference between revisions
Created page with "$(document).ready(function () { if (mw.config.get("wgPageName") === "Form:EventForm") { $("#pf-form").on("submit", function (event) { event.preventDefault(); // Stop default form submission var webhookUrl = "https://script.google.com/macros/s/EXAMPLE1234567890/exec"; // Replace with your Webhook URL var eventData = { eventDate: $("input[name='event_date']").val(), eventTime: $("input[name='..." |
(No difference)
|
Revision as of 11:44, 9 March 2025
$(document).ready(function () {
if (mw.config.get("wgPageName") === "Form:EventForm") {
$("#pf-form").on("submit", function (event) {
event.preventDefault(); // Stop default form submission
var webhookUrl = "https://script.google.com/macros/s/EXAMPLE1234567890/exec"; // Replace with your Webhook URL
var eventData = {
eventDate: $("input[name='event_date']").val(),
eventTime: $("input[name='event_time']").val(),
eventLocation: $("input[name='event_location']").val(),
eventDescription: $("textarea[name='event_description']").val(),
submittedBy: mw.config.get("wgUserName") // Get the logged-in user's wiki username
};
fetch(webhookUrl, {
method: "POST",
body: JSON.stringify(eventData),
headers: { "Content-Type": "application/json" }
})
.then(response => response.text())
.then(data => {
console.log("Google Sheets Response:", data);
$("#pf-form").unbind("submit").submit(); // Allow form submission after webhook
})
.catch(error => {
console.error("Error:", error);
alert("Error submitting event. Please try again.");
});
});
}
});