MediaWiki:Common.js
Zur Navigation springen
Zur Suche springen
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Strg+F5
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Downloadlinks für <pre data-filename=Foo.txt> */
var downloadable = $('*[data-filename]');
if (downloadable.length == 1) {
var link = $('<a>Download</a>');
link.attr('href', 'data:text/plain;base64,' + btoa(
// hack to get UTF-8 encoding
unescape(encodeURIComponent(downloadable[0].textContent))
));
link.attr('download', $(downloadable[0]).attr('data-filename'))
$(downloadable[0]).prepend(link);
} else if (downloadable.length > 1) {
var btn = $('<a>Download ZIP</a>');
btn.click(function() {
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js', function(data, textStatus, jqxhr) {
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.js', function() {
var zip = new JSZip();
var dirname = wgPageName.split('/').pop();
downloadable.each(function() {
zip.file(dirname + '/' + $(this).attr('data-filename'), this.textContent);
});
zip.generateAsync({
type: "blob"
})
.then(function(content) {
saveAs(content, dirname + ".zip");
});
});
});
});
$('#mw-content-text').prepend(btn);
}
function encourageContributions(){
var username = mw.config.get('wgUserName');
if (username){
var month = new Date().getMonth(); // JavaScript months start with 0
var semesterStart = new Date(new Date().getFullYear() - (month < 2), month < 9 ? 2 : 9);
var api = new mw.Api();
api.get( {
action: 'query',
list: 'usercontribs',
ucuser: username,
uclimit: 1,
ucend: semesterStart.toISOString()
}).done( function ( data ) {
if (data.query.usercontribs.length > 0){
if (mw.config.get('wgUserLanguage') == 'de')
bubble.innerHTML = 'Danke für deine Beiträge! Weiter so!';
else
bubble.innerHTML = 'Thanks for your contributions! Keep it up!';
} else {
if (mw.config.get('wgUserLanguage') == 'de')
bubble.innerHTML = 'Hast du dieses Semester schon etwas beigetragen?';
else
bubble.innerHTML = 'Have you contributed something yet this semester?';
}
});
}
}
if (document.location.pathname == "/wiki/TU_Wien/Informatik"){
var bubble = document.getElementById('mascot-says-bubble');
var img = document.createElement('img');
img.width=0;
img.onerror = function (){
if (mw.config.get('wgUserLanguage') == 'de')
bubble.innerHTML = 'Bist du schon auf <a href="https://mm.fsinf.at/?vowi">Mattermost</a>?';
else
bubble.innerHTML = 'Are you already on <a href="https://mm.fsinf.at/?vowi">Mattermost</a>?';
}
img.onload = encourageContributions;
img.src = 'https://mattermost.fsinf.at/api/v4/teams/sswtb6oqciyyfmkibh6mjz479w/image';
} else if (document.location.pathname == '/wiki/Uni_Wien/Sprachwissenschaft'){
var bubble = document.getElementById('mascot-says-bubble');
encourageContributions();
}
/*
if (mw.config.get('wgNamespaceNumber') == mw.config.get('wgNamespaceIds').tu_wien){
$('#lecturers a').css('position', 'relative').removeAttr('title').hover( function(e){
var id = e.target.href.split('/').pop();
var css = 'position:absolute; left:0; top:2em; pointer-events: none; max-width: 120px; box-shadow: 5px 5px 5px gray;';
$(e.target).append($('<img src="https://toss.fsinf.at/api/persons/'+id+'/picture" style="'+css+'" onerror="this.style.display = \'none\'">'));
}, function (e){
$(e.target).find('img').remove();
});
}*/