Welcome to Assassin's Creed Wiki! Log in and join the community.
User:Vatsa1708/wikia.js: Difference between revisions
Jump to navigation
Jump to search
imported>Vatsa1708 m Trying features |
imported>Vatsa1708 mNo edit summary |
||
| Line 1: | Line 1: | ||
/* ######################################################################## */ | /* ######################################################################## */ | ||
/* ### DISABLE ARCHIVE EDIT ### */ | /* ### DISABLE ARCHIVE EDIT ### */ | ||
| Line 332: | Line 12: | ||
var config = $.extend(true, { | var config = $.extend(true, { | ||
archiveSubpage: 'Archive', | archiveSubpage: 'Archive', | ||
disableCompletely: | disableCompletely: true, | ||
textColor: '#D9D9D9', | textColor: '#D9D9D9', | ||
userLang: false, | userLang: false, | ||
Revision as of 15:16, 14 September 2011
/* ######################################################################## */
/* ### DISABLE ARCHIVE EDIT ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Remove section edit links and gray out main edit ### */
/* ### button on archived talk pages ### */
/* ### Credit: User:Porter21 ### */
/* ######################################################################## */
function disableArchiveEdit () {
// Configuration
var userconfig = (window.DisableArchiveEditConfig) ? window.DisableArchiveEditConfig : {};
var config = $.extend(true, {
archiveSubpage: 'Archive',
disableCompletely: true,
textColor: '#D9D9D9',
userLang: false,
// English
en: {
archived: "Archived",
archivedTooltip: "This page is an archive and should not be edited."
}
}, userconfig);
// Function for multi-language support (by Daniel Friesen aka User:Dantman)
function msg(name) {
if ( config.userLang && wgUserLanguage in config && name in config[wgUserLanguage] )
return config[wgUserLanguage][name];
if ( wgContentLanguage in config && name in config[wgContentLanguage] )
return config[wgContentLanguage][name];
return config.en[name];
}
// Check whether page is an archive
if ((new RegExp('\\/\[' + config.archiveSubpage.substr(0,1).toUpperCase()
+ config.archiveSubpage.substr(0,1).toLowerCase() + '\]' + config.archiveSubpage.substr(1)
+ '\\s\*\\d\*')).test(wgTitle)) {
// Remove "add new section" links and prepare altering "edit" page control
switch (skin) {
case 'monaco':
$('#control_addsection').remove();
$('#fe_newsection').remove();
editlink = $('#ca-edit');
break;
case 'monobook':
$('#ca-addsection').remove();
editlink = $('#ca-edit > a');
break;
case 'oasis':
case 'wikia':
var oasisButton = $(($('#WikiaUserPagesHeader').length ? '.UserProfileActionButton' : '#WikiaPageHeader') + ' > .wikia-menu-button');
oasisButton.children("a:first").prependTo($('ul:first', oasisButton)).wrap('<li />').children('img').remove();
oasisButton.prepend('<a />');
$('a[data-id="addtopic"]', oasisButton).parent().remove();
editlink = $('a:first', oasisButton);
break;
}
// Remove "edit section" links
$('span.editsection').remove();
// Alter "edit" page control
if (config.disableCompletely) {
editlink.remove();
} else {
editlink.attr('title', msg('archivedTooltip')).css('color', config.textColor).text(msg('archived'));
}
}
}
/* ######################################################################## */
/* ### DUPLICATE FILE LIST ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Finds duplicate files on the wiki. ### */
/* ### Credit: User:pcj (http://www.wowpedia.org) ### */
/* ######################################################################## */
function findDupFiles(gf) {
var fileDiv = $('#mw-dupfiles');
if (fileDiv.length) {
dil = new Array();
ajaxIndicator = stylepath + '/common/progress-wheel.gif';
output = '';
url = '/api.php?action=query&generator=allimages&prop=duplicatefiles&gailimit=500&format=json';
if (!($('#dupFilesProgress').length)) {
fileDiv.prepend('<span style="float: right;" id="dupFilesProgress" title="In progress..."><img src="' + ajaxIndicator + '" style="vertical-align: baseline;" border="0" alt="In progress..." /></span>');
}
if (gf) {
url += "&gaifrom=" + gf;
}
$.getJSON( url, function (data) {
if ( data.query ) {
pages = data.query.pages;
for (pageID in pages) {
dils = "," + dil.join();
if ( dils.indexOf("," + pages[pageID].title) == -1
&& pages[pageID].title.indexOf("File::") == -1 && pages[pageID].duplicatefiles ) {
output += "<h3><a href='/wiki/" + encodeURIComponent(pages[pageID].title).replace(/'/g, "%27") + "'>" + pages[pageID].title + "</a></h3>
<ul>
";
for ( x = 0; x < pages[pageID].duplicatefiles.length; x++ ) {
output += "<li><a href='/wiki/File:" + encodeURIComponent(pages[pageID].duplicatefiles[x].name).replace(/'/g, "%27") + "'>File:" + pages[pageID].duplicatefiles[x].name + "</a></li>
";
dil.push("File:" + pages[pageID].duplicatefiles[x].name.replace(/_/g, " "));
}
output += "</ul>
"
}
}
fileDiv.append(output);
if (data["query-continue"]) {
setTimeout("findDupFiles('" + encodeURIComponent(data["query-continue"].allimages.gaifrom).replace(/'/g, "%27") + "');", 5000);
} else {
$('#dupFilesProgress').hide();
}
}
} );
}
}