MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Zenmi Wiki JavaScript. Any code here will be loaded for all users on every page load. */
/* Add JP button to editing toolbar
function customizeWikiEditorToolbar() {
$("#wpTextbox1").wikiEditor("addToToolbar", {
section: "main",
group: "insert",
tools: {
"lang-ja": {
label: "Designate text fragment as written in Japanese",
type: "button",
icon: "http://images.shoutwiki.com/zenmi/d/da/Lang_ja.png",
action: {
type: "encapsulate",
options: {
pre: "{{lang|ja|",
post: "}}",
peri: "\u93c8\u7e01"
}
}
}
}
})
}
mw.loader.using("mediawiki.toolbar", function() {
mw.user.options.get("usebetatoolbar") ? mw.loader.using("ext.wikiEditor.toolbar", function() {
$(document).ready(customizeWikiEditorToolbar)
}) : mw.toolbar.addButton("http://images.shoutwiki.com/zenmi/d/da/Lang_ja.png", "Designate text fragment as written in Japanese", "{{lang|ja|", "}}", "\u93c8\u7e01")
});*/
/* Check JSON pages for syntax validity before saving. Note that it's a "weak" check, just for the convenience and it can be easily circumvented */
/\.json$/.test(mw.config.get("wgTitle")) && $("#editform").submit(function(a) {
var b = $(this).find("#wpTextbox1").val();
if (void 0 !== b) try {
$.parseJSON(b)
} catch (c) {
window.confirm("The JSON data appears invalid. Are you sure you want to proceed?") || a.preventDefault()
}
});
/* Sitenotice autoscroll */
function AutoScroll(a) {
$(a).find("ul:first").animate({
marginTop:"-25px"
}, 500, function() {
$(this).css({marginTop:"0px"}).find("li:first").appendTo(this)
})
}
$(document).ready(function() {
setInterval('AutoScroll("#scrollDiv")', 5e3)
});
/* Implement song sources (still needs working on) */
(function(){
var config = {
song_info_url: mw.config.get('wgScript') + "?title=MediaWiki: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);
},
});
})();