MediaWiki:Common.js: Unterschied zwischen den Versionen
Zeile 4: | Zeile 4: | ||
// remove empty p-Tags & hide p-Tags only containing br-Tags | // remove empty p-Tags & hide p-Tags only containing br-Tags | ||
− | $content = jQuery( '#content' ) | + | $content = jQuery('#content') |
− | $content.remove( 'p:empty' ) | + | $content.remove('p:empty') |
− | $content.find( 'p > br' ).each( function ( i, e ) { | + | $content.find('p > br').each(function (i, e) { |
− | + | $br = jQuery(e) | |
− | + | if ( | |
− | + | $br.siblings().length === 0 && | |
− | + | $br.parent().text().trim().length === 0 | |
− | + | ) { | |
− | + | $br.parent().hide() | |
− | + | } | |
− | } ) | + | }) |
// set language code | // set language code | ||
− | var languageCode = | + | var languageCode = 'de' |
− | var urlParameterDeEasy = | + | var urlParameterDeEasy = 'einfach' |
− | if ( window.location.href.indexOf( urlParameterDeEasy ) > -1 ) { | + | if (window.location.href.indexOf(urlParameterDeEasy) > -1) { |
− | + | languageCode = 'de-easy' | |
} | } | ||
− | jQuery( '#mw-content-text' ).attr( 'lang', languageCode ) | + | jQuery('#mw-content-text').attr('lang', languageCode) |
− | jQuery( 'body' ).attr( 'lang', languageCode ) | + | jQuery('body').attr('lang', languageCode) |
// increase body height to match sidebar height | // increase body height to match sidebar height | ||
− | var sidebarHeight = jQuery( '#mw-panel' ).outerHeight() | + | var sidebarHeight = jQuery('#mw-panel').outerHeight() |
− | var bodyHeight = jQuery( 'body.mediawiki' ).outerHeight() | + | var bodyHeight = jQuery('body.mediawiki').outerHeight() |
− | if ( sidebarHeight > bodyHeight ) { | + | if (sidebarHeight > bodyHeight) { |
− | + | jQuery('#footer').css('margin-bottom', sidebarHeight - bodyHeight) | |
} else { | } else { | ||
− | + | jQuery('#mw-panel').height(jQuery('body').height()) | |
} | } | ||
// replace registration link | // replace registration link | ||
− | jQuery( '#pt-createaccount' ) | + | jQuery('#pt-createaccount').attr('id', 'pt-gettingstarted') |
− | + | jQuery('#pt-gettingstarted a'). | |
− | jQuery( '#pt-gettingstarted a' ) | + | attr('href', '/index.php/Kiwithek:Getting_Started'). |
− | + | attr( | |
− | + | 'title', | |
− | + | 'Lies nach, wie du mit uns in Kontakt treten kannst um an der KiwiThek mitzuarbeiten.', | |
+ | ). | ||
+ | text('Getting Started') | ||
// insert Bildinformationen template into uploaded file page | // insert Bildinformationen template into uploaded file page | ||
var template = '{{Bildinformationen\n' + | var template = '{{Bildinformationen\n' + | ||
− | + | '| Beschreibung = Bitte bearbeite mich und fülle die Bildinfos aus!\n' + | |
− | + | '| Urheber =\n' + | |
− | + | '| Herausgeber =\n' + | |
− | + | '| QuelleText =\n' + | |
− | + | '| QuelleUrl =\n' + | |
− | + | '| LizenzText =\n' + | |
− | + | '| LizenzUrl =\n' + | |
− | + | '| Originaltitel =\n' + | |
− | + | '| Bearbeitung =\n' + | |
− | + | '| GeoLand =\n' + | |
− | + | '| GeoRegion =\n' + | |
− | + | '| GeoGPSNorth =\n' + | |
− | + | '| GeoGPSEast =\n' + | |
− | + | '| Sonstiges =\n' + | |
− | + | '}}' | |
− | jQuery( '#wpUploadDescription' ).val(template) | + | jQuery('#wpUploadDescription').val(template) |
+ | |||
+ | // Badge: Page created by children | ||
+ | var hasCreatedByChildrenCategory = jQuery('#catlinks'). | ||
+ | text(). | ||
+ | indexOf('Seiten von Kindern') >= 0 | ||
+ | if (hasCreatedByChildrenCategory) { | ||
+ | var $pageByChildrenNode = jQuery( | ||
+ | '<div class="badge--children">Diese Seite wurde von Kindern erstellt</div>', | ||
+ | ) | ||
+ | |||
+ | jQuery($pageByChildrenNode).insertAfter('#firstHeading') | ||
+ | } |
Version vom 2. Oktober 2020, 10:08 Uhr
/**
* MediaWiki:Common.js
*/
// remove empty p-Tags & hide p-Tags only containing br-Tags
$content = jQuery('#content')
$content.remove('p:empty')
$content.find('p > br').each(function (i, e) {
$br = jQuery(e)
if (
$br.siblings().length === 0 &&
$br.parent().text().trim().length === 0
) {
$br.parent().hide()
}
})
// set language code
var languageCode = 'de'
var urlParameterDeEasy = 'einfach'
if (window.location.href.indexOf(urlParameterDeEasy) > -1) {
languageCode = 'de-easy'
}
jQuery('#mw-content-text').attr('lang', languageCode)
jQuery('body').attr('lang', languageCode)
// increase body height to match sidebar height
var sidebarHeight = jQuery('#mw-panel').outerHeight()
var bodyHeight = jQuery('body.mediawiki').outerHeight()
if (sidebarHeight > bodyHeight) {
jQuery('#footer').css('margin-bottom', sidebarHeight - bodyHeight)
} else {
jQuery('#mw-panel').height(jQuery('body').height())
}
// replace registration link
jQuery('#pt-createaccount').attr('id', 'pt-gettingstarted')
jQuery('#pt-gettingstarted a').
attr('href', '/index.php/Kiwithek:Getting_Started').
attr(
'title',
'Lies nach, wie du mit uns in Kontakt treten kannst um an der KiwiThek mitzuarbeiten.',
).
text('Getting Started')
// insert Bildinformationen template into uploaded file page
var template = '{{Bildinformationen\n' +
'| Beschreibung = Bitte bearbeite mich und fülle die Bildinfos aus!\n' +
'| Urheber =\n' +
'| Herausgeber =\n' +
'| QuelleText =\n' +
'| QuelleUrl =\n' +
'| LizenzText =\n' +
'| LizenzUrl =\n' +
'| Originaltitel =\n' +
'| Bearbeitung =\n' +
'| GeoLand =\n' +
'| GeoRegion =\n' +
'| GeoGPSNorth =\n' +
'| GeoGPSEast =\n' +
'| Sonstiges =\n' +
'}}'
jQuery('#wpUploadDescription').val(template)
// Badge: Page created by children
var hasCreatedByChildrenCategory = jQuery('#catlinks').
text().
indexOf('Seiten von Kindern') >= 0
if (hasCreatedByChildrenCategory) {
var $pageByChildrenNode = jQuery(
'<div class="badge--children">Diese Seite wurde von Kindern erstellt</div>',
)
jQuery($pageByChildrenNode).insertAfter('#firstHeading')
}