- Willkommen im deutschen Touhou Wiki!
- Falls du selbst mithelfen möchtest, dann kontaktiere uns auch bitte auf den Discord-Servern an der linken Seitenleiste!
- Lese die Richtlinien!
- Touhou gibt es auch auf Deutsch!
MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
imported>Chloe Die Seite wurde neu angelegt: „→Das folgende JavaScript wird für alle Benutzer geladen.: //<source lang="javascript"> //Map jQuery over to $ //Will be done by ResourceLoader later on //No…“ |
imported>Yaroneko An Version aus dem englischen Wiki angeglichen |
||
| Zeile 1: | Zeile 1: | ||
/ | //<source lang="javascript"> | ||
mw.loader.load( '//platform-api.sharethis.com/js/sharethis.js#property=5c076081f30c5a001138ce35&product=inline-follow-buttons&action=raw&ctype=text/javascript'); | |||
$(function() { | |||
$(".showExtra").click(function() { | |||
$(this).closest("table").find(".extraRow").fadeIn("slow");$(this).closest("tr").remove(); | |||
}); | |||
filterTable(); | |||
tabContentCreate(); | |||
} | |||
); | |||
/* Import more specific scripts if necessary */ | /* Import more specific scripts if necessary */ | ||
function customizeWikiEditorToolbar() { | |||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
{ | 'section': 'main', | ||
'group': 'insert', | |||
'tools': { | |||
'lang-ja': { | |||
{ | label: 'Designate text fragment as written in Japanese', | ||
type: 'button', | |||
icon: '/images/7/79/WikiEd-lang-ja.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: "{{lang|ja|", | |||
/ | post: "}}", | ||
peri: "\u6771\u65b9" | |||
} | |||
} | } | ||
} | } | ||
} | } | ||
} | } ); | ||
} | }; | ||
mw.loader.using('mediawiki.action.edit', function () { | |||
/* add button for {{lang|ja|}} to editor toolbar */ | |||
/* check for WikiEditor first, then fall back on default */ | |||
if ( mw.user.options.get('usebetatoolbar') ) { | |||
mw.loader.using( 'ext.wikiEditor.toolbar', function () { | |||
$(document).ready( customizeWikiEditorToolbar ); | |||
}); | |||
function | |||
{ | |||
if ( | |||
} | |||
} else { | } else { | ||
mw.toolbar.addButton( | |||
"/images/d/da/Lang_ja.png", // imageFile | |||
"Designate text fragment as written in Japanese", // speedTip | |||
"{{lang|ja|", // tagOpen | |||
"}}", // tagClose | |||
"\u6771\u65b9" // sample text | |||
); | |||
} | } | ||
}); | |||
/* Sitenotice autoscroll */ | |||
function AutoScroll(obj){ | |||
$(obj).find("ul:first").animate({ | |||
marginTop:"-25px" | |||
},500,function(){ | |||
$(this).css({marginTop:"0px"}).find("li:first").appendTo(this); | |||
}); | |||
} | } | ||
$(document).ready(function(){ | |||
function | setInterval('AutoScroll("#scrollDiv")',5000); | ||
{ | }); | ||
(function(){ | |||
var config = { | |||
song_info_url: mw.config.get('wgScript') + "?title=Touhou_Wiki:SongSource.json&action=raw&ctype=application/json", | |||
source_regexp: /^\s*source:\s*(.*)/, | |||
original_title_regexp: /^\s*original title:\s*(.*)/, | |||
tracks_heading_regexp: /^\s*Tracks\s*$/, | |||
categories: ["Arrangement CDs", "Official CDs"], | |||
}; | |||
jQuery.ajax({ | |||
url: mw.config.get('wgScript') + '?title=MediaWiki:SongSource.js&action=raw&ctype=text/javascript', | |||
dataType: "script", | |||
cache: "true", | |||
success: function() { | |||
initSongSource(config); | |||
}, | |||
}); | |||
})(); | |||
importScript("MediaWiki:ToggleAll.js"); | |||
if ($(window).width() < 1025){ | |||
$("#mp-WorksColumns .mp-image").addClass("mp-smaller-image"); | |||
$("#mp-News .mp-image").addClass("mp-smaller-image"); | |||
} | } | ||
$(window).resize(function(){ | |||
if ($(this).width() < 1025){ | |||
$("#mp-WorksColumns .mp-image").addClass("mp-smaller-image"); | |||
$("#mp-News .mp-image").addClass("mp-smaller-image"); | |||
} else { | |||
$("#mp-WorksColumns .mp-image").removeClass("mp-smaller-image"); | |||
$("#mp-News .mp-image").removeClass("mp-smaller-image"); | |||
} | } | ||
}); | |||
} | |||
// check JSON pages for syntax validity before saving | |||
// note that it's "weak" check, just for the convenience | |||
// and it can be easily circumvented | |||
if (/\.json$/.test(wgTitle)) { | |||
// if there's no edit form, nothing bad will happen | |||
/ | $("#editform").submit(function(evt) { | ||
var data = $(this).find("#wpTextbox1").val(); | |||
if (data !== undefined) { | |||
try { | |||
$.parseJSON(data); | |||
// | } catch (e) { | ||
if (!window.confirm("The JSON data appears invalid. Are you sure you want to proceed?")) { | |||
evt.preventDefault(); | |||
// | |||
// if | |||
} | |||
{ | |||
} | } | ||
} | } | ||
} | |||
}); | |||
} | } | ||
// Filter Table Functions | |||
function filterTable(){ | |||
$("table.filterable").each(function(){ | |||
var i=0; | |||
var cols; | |||
$(this).find("tr:first-child th, tr:first-child td").each(function(){ | |||
if (!$(this).hasClass("unfilterable")){ | |||
cols=[]; | |||
$(this).closest("table").find("tr td:nth-child("+(i+1)+")").each(function(){ | |||
cols.push($(this).text()); | |||
}); | |||
cols = arrayUnique(cols); | |||
l=0; | |||
for (j=0; j<cols.length; j++){ | |||
t=charLength(cols[j]); | |||
if (l<t) l=t; | |||
} | |||
$(this).css("position","relative"); | |||
}); | $(this).html('<a href="javascript:void(0)" class="showFilterMenu">'+$(this).html()+'▼</a>'); | ||
$(this).append($('<div class="filterMenu hidden" style="position: absolute; top: '+$(this).height()+35+'px; left: 0; width: '+(50+l*7)+'px; text-align: left; padding: 5px; border: 1px #333333 solid; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; background: inherit; z-index: 1"></div>')); | |||
for (j=0; j<cols.length; j++){ | |||
$(this).find(".filterMenu").append('<div><input type="checkbox" value="'+cols[j]+'" col="'+(i+1)+'" class="filterOption" checked>'+cols[j]+'</div>'); | |||
} | |||
} | |||
i++; | |||
}); | |||
$(this).find("tr:nth-child(n+1)").attr("condition", 0); | |||
}); | |||
$(".showFilterMenu").click(function(){ | |||
if ($(this).parent().find(".filterMenu:visible").length){ | |||
$(".filterMenu").slideUp(150); | |||
}else{ | |||
$(".filterMenu").slideUp(150); | |||
$(this).parent().find(".filterMenu").slideDown(150); | |||
} | |||
function | }); | ||
$(document).mouseup(function(e){ | |||
var container = $(".filterMenu"); | |||
if (!container.is(e.target) && container.has(e.target).length === 0){ | |||
container.slideUp(150); | |||
} | |||
}); | |||
$(".filterOption").click(function(){ | |||
col=$(this).attr("col"); | |||
val=$(this).val(); | |||
if ($(this).is(":checked")) chg=1; else chg=-1; | |||
$(this).closest("table").find("tr:nth-child(n+1)").each(function(){ | |||
if ($(this).find("td:nth-child("+col+")").text()==val){ | |||
var cond=$(this).attr("condition"); | |||
cond=Number(cond)+chg; | |||
$(this).attr("condition", cond); | |||
if (cond==0) $(this).show(); | |||
else $(this).hide(); | |||
} | |||
}); | |||
}); | |||
} | } | ||
function arrayUnique(a) { | |||
return a.reduce(function(p, c) { | |||
if (p.indexOf(c) < 0) p.push(c); | |||
return p; | |||
}, []); | |||
function | |||
{ | |||
return; | |||
} | } | ||
function charLength(s){ | |||
return s.length+(encodeURI(s).split(/%..|./).length-1-s.length)/2; | |||
} | } | ||
function tabContentCreate () { | |||
var group1 = $('.tab_content_container'), group1l = group1.length; | |||
for(var i = 0; i < group1l; i++){ | |||
var group = group1.eq(i); | |||
var container = group.find('.tab_content_button_container').eq(0); | |||
var | var default_div = group.find('.tab_content_default').eq(0); | ||
var | var width = default_div.attr('data-width'); | ||
var group2 = group.find('.tab_content_button'), group2l = group2.length; | |||
for(var j = 0; j < group2l; j++){ | |||
group2.eq(j).appendTo(container); | |||
} | |||
var group2 = group.find('.tab_content_button'), group2l = group2.length; | |||
for(var j = 0; j < group2l; j++){ | |||
group2.eq(j).css('width', width); | |||
group2.eq(j).on('click', function(){ | |||
var a = $(this); | |||
var key = a.attr('data-index'); | |||
var tab = a.parents('.tab_content_container').find('.tab_content_content[data-index="' + key + '"]'); | |||
a.parents('.tab_content_container').find('.tab_content_content').css('display', 'none'); | |||
a.parents('.tab_content_button_container').find('.tab_content_button').css({ | |||
'cursor' : 'pointer', | |||
'background-color' : '#eee', | |||
'box-shadow' : '0 0 3px 0 #000' | |||
}); | |||
tab.css('display', 'block'); | |||
a.css({ | |||
'cursor' : 'default', | |||
'background-color' : '#fff', | |||
'box-shadow' : '0 0 2px 0 #000 inset, 0 0 2px 0 #000 inset' | |||
}) | |||
}); | |||
} | |||
var default_value = default_div.attr('data-value'); | |||
if(default_value === '0'){ | |||
group.find('.tab_content_button').eq(0).trigger('click'); | |||
} else { | |||
group.find('.tab_content_button[data-index="' + default_value + '"]').eq(0).trigger('click'); | |||
} | |||
} | |||
} | } | ||
Version vom 2. September 2019, 20:55 Uhr
//<source lang="javascript">
mw.loader.load( '//platform-api.sharethis.com/js/sharethis.js#property=5c076081f30c5a001138ce35&product=inline-follow-buttons&action=raw&ctype=text/javascript');
$(function() {
$(".showExtra").click(function() {
$(this).closest("table").find(".extraRow").fadeIn("slow");$(this).closest("tr").remove();
});
filterTable();
tabContentCreate();
}
);
/* Import more specific scripts if necessary */
function customizeWikiEditorToolbar() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'lang-ja': {
label: 'Designate text fragment as written in Japanese',
type: 'button',
icon: '/images/7/79/WikiEd-lang-ja.png',
action: {
type: 'encapsulate',
options: {
pre: "{{lang|ja|",
post: "}}",
peri: "\u6771\u65b9"
}
}
}
}
} );
};
mw.loader.using('mediawiki.action.edit', function () {
/* add button for {{lang|ja|}} to editor toolbar */
/* check for WikiEditor first, then fall back on default */
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
$(document).ready( customizeWikiEditorToolbar );
});
} else {
mw.toolbar.addButton(
"/images/d/da/Lang_ja.png", // imageFile
"Designate text fragment as written in Japanese", // speedTip
"{{lang|ja|", // tagOpen
"}}", // tagClose
"\u6771\u65b9" // sample text
);
}
});
/* Sitenotice autoscroll */
function AutoScroll(obj){
$(obj).find("ul:first").animate({
marginTop:"-25px"
},500,function(){
$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
});
}
$(document).ready(function(){
setInterval('AutoScroll("#scrollDiv")',5000);
});
(function(){
var config = {
song_info_url: mw.config.get('wgScript') + "?title=Touhou_Wiki:SongSource.json&action=raw&ctype=application/json",
source_regexp: /^\s*source:\s*(.*)/,
original_title_regexp: /^\s*original title:\s*(.*)/,
tracks_heading_regexp: /^\s*Tracks\s*$/,
categories: ["Arrangement CDs", "Official CDs"],
};
jQuery.ajax({
url: mw.config.get('wgScript') + '?title=MediaWiki:SongSource.js&action=raw&ctype=text/javascript',
dataType: "script",
cache: "true",
success: function() {
initSongSource(config);
},
});
})();
importScript("MediaWiki:ToggleAll.js");
if ($(window).width() < 1025){
$("#mp-WorksColumns .mp-image").addClass("mp-smaller-image");
$("#mp-News .mp-image").addClass("mp-smaller-image");
}
$(window).resize(function(){
if ($(this).width() < 1025){
$("#mp-WorksColumns .mp-image").addClass("mp-smaller-image");
$("#mp-News .mp-image").addClass("mp-smaller-image");
} else {
$("#mp-WorksColumns .mp-image").removeClass("mp-smaller-image");
$("#mp-News .mp-image").removeClass("mp-smaller-image");
}
});
// check JSON pages for syntax validity before saving
// note that it's "weak" check, just for the convenience
// and it can be easily circumvented
if (/\.json$/.test(wgTitle)) {
// if there's no edit form, nothing bad will happen
$("#editform").submit(function(evt) {
var data = $(this).find("#wpTextbox1").val();
if (data !== undefined) {
try {
$.parseJSON(data);
} catch (e) {
if (!window.confirm("The JSON data appears invalid. Are you sure you want to proceed?")) {
evt.preventDefault();
}
}
}
});
}
// Filter Table Functions
function filterTable(){
$("table.filterable").each(function(){
var i=0;
var cols;
$(this).find("tr:first-child th, tr:first-child td").each(function(){
if (!$(this).hasClass("unfilterable")){
cols=[];
$(this).closest("table").find("tr td:nth-child("+(i+1)+")").each(function(){
cols.push($(this).text());
});
cols = arrayUnique(cols);
l=0;
for (j=0; j<cols.length; j++){
t=charLength(cols[j]);
if (l<t) l=t;
}
$(this).css("position","relative");
$(this).html('<a href="javascript:void(0)" class="showFilterMenu">'+$(this).html()+'▼</a>');
$(this).append($('<div class="filterMenu hidden" style="position: absolute; top: '+$(this).height()+35+'px; left: 0; width: '+(50+l*7)+'px; text-align: left; padding: 5px; border: 1px #333333 solid; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; background: inherit; z-index: 1"></div>'));
for (j=0; j<cols.length; j++){
$(this).find(".filterMenu").append('<div><input type="checkbox" value="'+cols[j]+'" col="'+(i+1)+'" class="filterOption" checked>'+cols[j]+'</div>');
}
}
i++;
});
$(this).find("tr:nth-child(n+1)").attr("condition", 0);
});
$(".showFilterMenu").click(function(){
if ($(this).parent().find(".filterMenu:visible").length){
$(".filterMenu").slideUp(150);
}else{
$(".filterMenu").slideUp(150);
$(this).parent().find(".filterMenu").slideDown(150);
}
});
$(document).mouseup(function(e){
var container = $(".filterMenu");
if (!container.is(e.target) && container.has(e.target).length === 0){
container.slideUp(150);
}
});
$(".filterOption").click(function(){
col=$(this).attr("col");
val=$(this).val();
if ($(this).is(":checked")) chg=1; else chg=-1;
$(this).closest("table").find("tr:nth-child(n+1)").each(function(){
if ($(this).find("td:nth-child("+col+")").text()==val){
var cond=$(this).attr("condition");
cond=Number(cond)+chg;
$(this).attr("condition", cond);
if (cond==0) $(this).show();
else $(this).hide();
}
});
});
}
function arrayUnique(a) {
return a.reduce(function(p, c) {
if (p.indexOf(c) < 0) p.push(c);
return p;
}, []);
}
function charLength(s){
return s.length+(encodeURI(s).split(/%..|./).length-1-s.length)/2;
}
function tabContentCreate () {
var group1 = $('.tab_content_container'), group1l = group1.length;
for(var i = 0; i < group1l; i++){
var group = group1.eq(i);
var container = group.find('.tab_content_button_container').eq(0);
var default_div = group.find('.tab_content_default').eq(0);
var width = default_div.attr('data-width');
var group2 = group.find('.tab_content_button'), group2l = group2.length;
for(var j = 0; j < group2l; j++){
group2.eq(j).appendTo(container);
}
var group2 = group.find('.tab_content_button'), group2l = group2.length;
for(var j = 0; j < group2l; j++){
group2.eq(j).css('width', width);
group2.eq(j).on('click', function(){
var a = $(this);
var key = a.attr('data-index');
var tab = a.parents('.tab_content_container').find('.tab_content_content[data-index="' + key + '"]');
a.parents('.tab_content_container').find('.tab_content_content').css('display', 'none');
a.parents('.tab_content_button_container').find('.tab_content_button').css({
'cursor' : 'pointer',
'background-color' : '#eee',
'box-shadow' : '0 0 3px 0 #000'
});
tab.css('display', 'block');
a.css({
'cursor' : 'default',
'background-color' : '#fff',
'box-shadow' : '0 0 2px 0 #000 inset, 0 0 2px 0 #000 inset'
})
});
}
var default_value = default_div.attr('data-value');
if(default_value === '0'){
group.find('.tab_content_button').eq(0).trigger('click');
} else {
group.find('.tab_content_button[data-index="' + default_value + '"]').eq(0).trigger('click');
}
}
}