Welcome to Assassin's Creed Wiki! Log in and join the community.

User:Vatsa1708/wikia.js: Difference between revisions

From the Assassin's Creed Wiki
Jump to navigation Jump to search
imported>Vatsa1708
mNo edit summary
imported>Vatsa1708
mNo edit summary
 
(56 intermediate revisions by 2 users not shown)
Line 1: Line 1:
/* ######################################################################## */
/* ######################################################################## */
/* ### DISABLE ARCHIVE EDIT                                            ### */
/* ### AJAX RC                                                          ### */
/* ### ---------------------------------------------------------------- ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Remove section edit links and gray out main edit    ### */
/* ### Description: Automatically refresh "Recent changes" via AJAX    ### */
/* ###             button on archived talk pages                      ### */
/* ### Credit:      User:pcj (http://www.wowpedia.org)                  ### */
/* ### Credit:      User:Porter21                                       ### */
/* ###             User:Porter21 (fallout.wikia.com)                  ### */
/* ######################################################################## */
/* ######################################################################## */
/*
var indicator = 'http://images1.wikia.nocookie.net/assassinscreed/images/d/de/Ajax-loader.gif';
var ajaxPages = new Array('Special:RecentChanges', 'Special:WikiActivity', 'Special:NewFiles');
var ajaxTimer;
var ajaxRefresh = 30000;
var refreshText = 'Auto-refresh';
if( typeof AjaxRCRefreshText == "string" ) {
refreshText = AjaxRCRefreshText;
}
var refreshHover = 'Enable auto-refreshing page loads';
if( typeof AjaxRCRefreshHoverText == "string" ) {
refreshHover = AjaxRCRefreshHoverText;
}
var doRefresh = true;
   
   
function disableArchiveEdit () {
function setCookie(c_name,value,expiredays) {
   // Configuration
   var exdate=new Date()
   var userconfig = (window.DisableArchiveEditConfig) ? window.DisableArchiveEditConfig : {};
   exdate.setDate(exdate.getDate()+expiredays)
   var config = $.extend(true, {
   document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
      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 getCookie(c_name) {
   function msg(name) {
   if (document.cookie.length>0) {
       if ( config.userLang && wgUserLanguage in config && name in config[wgUserLanguage] )
      c_start=document.cookie.indexOf(c_name + "=")
         return config[wgUserLanguage][name];
       if (c_start!=-1) {
      if ( wgContentLanguage in config && name in config[wgContentLanguage] )
        c_start=c_start + c_name.length+1
         return config[wgContentLanguage][name];
         c_end=document.cookie.indexOf(";",c_start)
       return config.en[name];
        if (c_end==-1) c_end=document.cookie.length
         return unescape(document.cookie.substring(c_start,c_end))
       }
   }
   }
  return ""
}
   
   
  // Check whether page is an archive
function preloadAJAXRL() {
   if ((new RegExp('\\/\[' + config.archiveSubpage.substr(0,1).toUpperCase()
   ajaxRLCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false;
      + config.archiveSubpage.substr(0,1).toLowerCase() + '\]' + config.archiveSubpage.substr(1)
  appTo = ($("#WikiaPageHeader").length)?$("#WikiaPageHeader > h1" ) : ( $( "#AdminDashboardHeader" ).length ? $( "#AdminDashboardHeader > h1" ):$(".firstHeading") );
      + '\\s\*\\d\*')).test(wgTitle)) {
  appTo.append('&#160;<span style="font-size: xx-small; line-height: 100%;" id="ajaxRefresh"><span style="border-bottom: 1px dotted; cursor: help;" id="ajaxToggleText" title="' + refreshHover + '">' + refreshText + ':</span><input type="checkbox" style="margin-bottom: 0;" id="ajaxToggle"><span style="display: none;" id="ajaxLoadProgress"><img src="' + indicator + '" style="vertical-align: baseline;" border="0" alt="Refreshing page" /></span></span>');
      // Remove "add new section" links and prepare altering "edit" page control
  $("#ajaxLoadProgress").ajaxSend(function (event, xhr, settings){
      switch (skin) {
      if (location.href == settings.url) $(this).show();
        case 'monaco':
  }).ajaxComplete (function (event, xhr, settings){
            $('#control_addsection').remove();
      if (location.href == settings.url) $(this).hide();
            $('#fe_newsection').remove();
  });
  $("#ajaxToggle").click(toggleAjaxReload);
            editlink = $('#ca-edit');
  $("#ajaxToggle").attr("checked", ajaxRLCookie);
            break;
  if (getCookie("ajaxload-"+wgPageName)=="on") loadPageData();
        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
function toggleAjaxReload() {
      $('span.editsection').remove();
  if ($("#ajaxToggle").prop("checked") == true) {
       setCookie("ajaxload-"+wgPageName, "on", 30);
       // Alter "edit" page control
       doRefresh = true;
       if (config.disableCompletely) {
      loadPageData();
        editlink.remove();
  } else {
      } else {
      setCookie("ajaxload-"+wgPageName, "off", 30);
        editlink.attr('title', msg('archivedTooltip')).css('color', config.textColor).text(msg('archived'));
      doRefresh = false;
      }
      clearTimeout(ajaxTimer);
   }
   }
}
}
/* ######################################################################## */
/* ### DUPLICATE FILE LIST                                              ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Finds duplicate files on the wiki.                  ### */
/* ### Credit:      User:pcj (http://www.wowpedia.org)                  ### */
/* ######################################################################## */
   
   
function findDupFiles(gf) {
function loadPageData() {
   var fileDiv = $('#mw-dupfiles');
   cC = ($("#WikiaArticle").length)?"#WikiaArticle":"#bodyContent";
  $(cC).load(location.href + " " + cC + " > *", function (data) {
  if (fileDiv.length) {
       if (doRefresh) ajaxTimer = setTimeout("loadPageData();", ajaxRefresh);
      dil = new Array();
  });
      ajaxIndicator = stylepath + '/common/progress-wheel.gif';
}
      output = '';
addOnloadHook(function(){ for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) preloadAJAXRL() } } );
      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>


"
//**Duplicate images**//
              }
importScriptPage('MediaWiki:Common.js/dupimage.js‎‎', 'prototype');
            }
            fileDiv.append(output);
            if (data["query-continue"]) {
              setTimeout("findDupFiles('" + encodeURIComponent(data["query-continue"].allimages.gaifrom).replace(/'/g, "%27") + "');", 5000);
            } else {
              $('#dupFilesProgress').hide();
            }
        }
      } );
  }
}

Latest revision as of 10:30, 21 February 2016

/* ######################################################################## */
/* ### AJAX RC                                                          ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: Automatically refresh "Recent changes" via AJAX     ### */
/* ### Credit:      User:pcj (http://www.wowpedia.org)                  ### */
/* ###              User:Porter21 (fallout.wikia.com)                   ### */
/* ######################################################################## */
 /*
var indicator = 'http://images1.wikia.nocookie.net/assassinscreed/images/d/de/Ajax-loader.gif';
var ajaxPages = new Array('Special:RecentChanges', 'Special:WikiActivity', 'Special:NewFiles');
var ajaxTimer;
var ajaxRefresh = 30000;
var refreshText = 'Auto-refresh';
if( typeof AjaxRCRefreshText == "string" ) {
	refreshText = AjaxRCRefreshText;
}
var refreshHover = 'Enable auto-refreshing page loads';
if( typeof AjaxRCRefreshHoverText == "string" ) {
	refreshHover = AjaxRCRefreshHoverText;
}
var doRefresh = true;
 
function setCookie(c_name,value,expiredays) {
   var exdate=new Date()
   exdate.setDate(exdate.getDate()+expiredays)
   document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
 
function getCookie(c_name) {
   if (document.cookie.length>0) {
      c_start=document.cookie.indexOf(c_name + "=")
      if (c_start!=-1) { 
         c_start=c_start + c_name.length+1 
         c_end=document.cookie.indexOf(";",c_start)
         if (c_end==-1) c_end=document.cookie.length
         return unescape(document.cookie.substring(c_start,c_end))
      } 
   }
   return ""
}
 
function preloadAJAXRL() {
   ajaxRLCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false;
   appTo = ($("#WikiaPageHeader").length)?$("#WikiaPageHeader > h1" ) : ( $( "#AdminDashboardHeader" ).length ? $( "#AdminDashboardHeader > h1" ):$(".firstHeading") );
   appTo.append('&#160;<span style="font-size: xx-small; line-height: 100%;" id="ajaxRefresh"><span style="border-bottom: 1px dotted; cursor: help;" id="ajaxToggleText" title="' + refreshHover + '">' + refreshText + ':</span><input type="checkbox" style="margin-bottom: 0;" id="ajaxToggle"><span style="display: none;" id="ajaxLoadProgress"><img src="' + indicator + '" style="vertical-align: baseline;" border="0" alt="Refreshing page" /></span></span>');
   $("#ajaxLoadProgress").ajaxSend(function (event, xhr, settings){
      if (location.href == settings.url) $(this).show();
   }).ajaxComplete (function (event, xhr, settings){
      if (location.href == settings.url) $(this).hide();
   });
   $("#ajaxToggle").click(toggleAjaxReload);
   $("#ajaxToggle").attr("checked", ajaxRLCookie);
   if (getCookie("ajaxload-"+wgPageName)=="on") loadPageData();
}
 
function toggleAjaxReload() {
   if ($("#ajaxToggle").prop("checked") == true) {
      setCookie("ajaxload-"+wgPageName, "on", 30);
      doRefresh = true;
      loadPageData();
   } else {
      setCookie("ajaxload-"+wgPageName, "off", 30);
      doRefresh = false;
      clearTimeout(ajaxTimer);
   }
}
 
function loadPageData() {
   cC = ($("#WikiaArticle").length)?"#WikiaArticle":"#bodyContent";
   $(cC).load(location.href + " " + cC + " > *", function (data) { 
      if (doRefresh) ajaxTimer = setTimeout("loadPageData();", ajaxRefresh);
   });
}
addOnloadHook(function(){ for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) preloadAJAXRL() } } );
*/

//**Duplicate images**//
importScriptPage('MediaWiki:Common.js/dupimage.js‎‎', 'prototype');