MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus smw-dev03
(Die Seite wurde neu angelegt: „→Das folgende JavaScript wird für alle Benutzer geladen.: document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("form[action*='Special:FormEdit']"); const input = form.querySelector("input[type='text']"); const warning = document.getElementById("gutachten-warning"); form.addEventListener("submit", function(e) { e.preventDefault(); const pageName = input.value.trim(); if (!pageName) retur…“) |
Keine Bearbeitungszusammenfassung |
||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
$(document).ready(function() { | |||
if (mw.config.get('wgCanonicalSpecialPageName') === 'FormEdit') { | |||
const urlParts = window.location.pathname.split('/'); | |||
const formName = urlParts[urlParts.length - 2]; | |||
const pageName = decodeURIComponent(urlParts[urlParts.length - 1]); | |||
// | if (formName === 'GutachtenAuspragungForm') { | ||
} | const apiUrl = mw.util.wikiScript('api') + '?action=query&titles=' + encodeURIComponent(pageName) + '&format=json'; | ||
}) | |||
. | $.getJSON(apiUrl, function(data) { | ||
const pages = data.query.pages; | |||
const exists = !pages.hasOwnProperty('-1'); | |||
} | if (!exists) { | ||
} | // Directly redirect with a query parameter indicating the issue | ||
const redirectUrl = mw.util.getUrl('Spezial:Mit_Formular_bearbeiten', { | |||
form: 'GutachtenAuspragungForm', | |||
warning: 'notexist' | |||
}); | |||
window.location.replace(redirectUrl); | |||
} | |||
}); | |||
} | |||
// Check for warning parameter and display message if redirected here | |||
const urlParams = new URLSearchParams(window.location.search); | |||
if (urlParams.get('warning') === 'notexist') { | |||
mw.loader.using('mediawiki.notification', function(){ | |||
mw.notify('Das angeforderte Gutachten existiert nicht. Bitte nutzen Sie dieses Formular, um ein neues Gutachten anzulegen.', { | |||
title: 'Hinweis', | |||
type: 'warn', | |||
autoHideSeconds: 7 | |||
}); | |||
}); | |||
} | |||
} | |||
}); | }); | ||
Aktuelle Version vom 5. Mai 2025, 12:58 Uhr
$(document).ready(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'FormEdit') {
const urlParts = window.location.pathname.split('/');
const formName = urlParts[urlParts.length - 2];
const pageName = decodeURIComponent(urlParts[urlParts.length - 1]);
if (formName === 'GutachtenAuspragungForm') {
const apiUrl = mw.util.wikiScript('api') + '?action=query&titles=' + encodeURIComponent(pageName) + '&format=json';
$.getJSON(apiUrl, function(data) {
const pages = data.query.pages;
const exists = !pages.hasOwnProperty('-1');
if (!exists) {
// Directly redirect with a query parameter indicating the issue
const redirectUrl = mw.util.getUrl('Spezial:Mit_Formular_bearbeiten', {
form: 'GutachtenAuspragungForm',
warning: 'notexist'
});
window.location.replace(redirectUrl);
}
});
}
// Check for warning parameter and display message if redirected here
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('warning') === 'notexist') {
mw.loader.using('mediawiki.notification', function(){
mw.notify('Das angeforderte Gutachten existiert nicht. Bitte nutzen Sie dieses Formular, um ein neues Gutachten anzulegen.', {
title: 'Hinweis',
type: 'warn',
autoHideSeconds: 7
});
});
}
}
});