MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus smw-dev03
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
if (mw.config.get('wgCanonicalSpecialPageName') === 'FormEdit') { | if (mw.config.get('wgCanonicalSpecialPageName') === 'FormEdit') { | ||
| Zeile 8: | Zeile 7: | ||
const pageName = decodeURIComponent(urlParts[urlParts.length - 1]); | const pageName = decodeURIComponent(urlParts[urlParts.length - 1]); | ||
if (formName === 'GutachtenAuspragungForm') { | if (formName === 'GutachtenAuspragungForm') { | ||
| Zeile 18: | Zeile 16: | ||
if (!exists) { | 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
});
});
}
}
});