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
...
imported>Vatsa1708
mNo edit summary
 
(69 intermediate revisions by 2 users not shown)
Line 1: Line 1:
/*
/* ######################################################################## */
* ADVANCED AJAX AUTO-REFRESHING ARTICLES
/* ### AJAX RC                                                          ### */
  */
/* ### ---------------------------------------------------------------- ### */
var ajaxIndicator = 'http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif',
/* ### Description: Automatically refresh "Recent changes" via AJAX    ### */
ajaxTimer,
/* ### Credit:      User:pcj (http://www.wowpedia.org)                  ### */
ajaxRefresh = 60000,
/* ###              User:Porter21 (fallout.wikia.com)                  ### */
refreshText = 'Auto-Refresh',
/* ######################################################################## */
refreshHover = 'Enable auto-refreshing of this page' ,
  /*
doRefresh = true;
var indicator = 'http://images1.wikia.nocookie.net/assassinscreed/images/d/de/Ajax-loader.gif';
var ajaxPages = new Array('Special:RecentChanges', 'Special:WikiActivity', 'Special:NewFiles');
if ( !window.ajaxPages ) {
var ajaxTimer;
var ajaxPages = new Array( 'Special:RecentChanges', 'Special:WikiActivity' );
var ajaxRefresh = 30000;
}
var refreshText = 'Auto-refresh';
if ( !window.ajaxCallAgain ) {
ajaxCallAgain = [];
}
if( typeof AjaxRCRefreshText == "string" ) {
if( typeof AjaxRCRefreshText == "string" ) {
refreshText = AjaxRCRefreshText;
refreshText = AjaxRCRefreshText;
}
}
var refreshHover = 'Enable auto-refreshing page loads';
if( typeof AjaxRCRefreshHoverText == "string" ) {
if( typeof AjaxRCRefreshHoverText == "string" ) {
refreshHover = AjaxRCRefreshHoverText;
refreshHover = AjaxRCRefreshHoverText;
}
}
var doRefresh = true;
   
   
/**
function setCookie(c_name,value,expiredays) {
* Sets the cookie
  var exdate=new Date()
* @param c_name string Name of the cookie
  exdate.setDate(exdate.getDate()+expiredays)
* @param value string 'on' or 'off'
  document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
* @param expiredays integer Expiry time of the cookie in days
*/
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) {
* Gets the cookie
  if (document.cookie.length>0) {
* @param c_name string Cookie name
      c_start=document.cookie.indexOf(c_name + "=")
* @return The cookie name or empty string
      if (c_start!=-1) {  
*/
        c_start=c_start + c_name.length+1  
function getCookie( c_name ) {
        c_end=document.cookie.indexOf(";",c_start)
if ( document.cookie.length > 0 ) {
        if (c_end==-1) c_end=document.cookie.length
var c_start = document.cookie.indexOf( c_name + "=" )
        return unescape(document.cookie.substring(c_start,c_end))
if ( c_start !== -1 ) {
      }  
c_start = c_start + c_name.length + 1;
  }
var c_end = document.cookie.indexOf( ";", c_start );
  return ""
if ( c_end === -1 ) {
c_end = document.cookie.length;
}
return unescape( document.cookie.substring( c_start, c_end ) );
}  
}
return "";
}
}
   
   
/**
* Main function to start the Auto-refresh process
*/
function preloadAJAXRL() {
function preloadAJAXRL() {
var ajaxRLCookie = ( getCookie( "ajaxload-" + wgPageName ) == "on" ) ? true : false,
  ajaxRLCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false;
appTo = ( $( '#WikiaPageHeader' ).length ) ? $( '#WikiaPageHeader' ) : ( $( '#AdminDashboardHeader' ).length ? $( '#AdminDashboardHeader > h1' ) : $( '.firstHeading' ) );
  appTo = ($("#WikiaPageHeader").length)?$("#WikiaPageHeader > h1" ) : ( $( "#AdminDashboardHeader" ).length ? $( "#AdminDashboardHeader > h1" ):$(".firstHeading") );
appTo.append( '&nbsp;<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="' + ajaxIndicator + '" style="vertical-align: baseline;" border="0" alt="Refreshing page" /></span></span>' );
  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 ) {
  $("#ajaxLoadProgress").ajaxSend(function (event, xhr, settings){
if ( location.href == settings.url ) {
      if (location.href == settings.url) $(this).show();
$( this ).show();
  }).ajaxComplete (function (event, xhr, settings){
}
      if (location.href == settings.url) $(this).hide();
} ).ajaxComplete ( function ( event, xhr, settings ) {
  });
if ( location.href == settings.url ) {
  $("#ajaxToggle").click(toggleAjaxReload);
$( this ).hide();
  $("#ajaxToggle").attr("checked", ajaxRLCookie);
for( i in ajaxCallAgain ) {
  if (getCookie("ajaxload-"+wgPageName)=="on") loadPageData();
ajaxCallAgain[i]();
}
}
} );
$( '#ajaxToggle' ).click( toggleAjaxReload );
$( '#ajaxToggle' ).attr( 'checked', ajaxRLCookie);
if ( getCookie( "ajaxload-" + wgPageName ) == "on" ) {
loadPageData();
}
}
}
   
   
/**
* Turn refresh on and off by toggling the checkbox
*/
function toggleAjaxReload() {
function toggleAjaxReload() {
if ( $( '#ajaxToggle' ).prop( 'checked' ) == true ) {
  if ($("#ajaxToggle").prop("checked") == true) {
setCookie( "ajaxload-" + wgPageName, "on", 30 );
      setCookie("ajaxload-"+wgPageName, "on", 30);
doRefresh = true;
      doRefresh = true;
loadPageData();
      loadPageData();
} else {
  } else {
setCookie( "ajaxload-" + wgPageName, "off", 30 );
      setCookie("ajaxload-"+wgPageName, "off", 30);
doRefresh = false;
      doRefresh = false;
clearTimeout( ajaxTimer );
      clearTimeout(ajaxTimer);
}
  }
}
}
   
   
/**
* Does the actual refresh
*/
function loadPageData() {
function loadPageData() {
var cC = ( $( '#WikiaArticle' ).length ) ? '#WikiaArticle' : '#bodyContent';
  cC = ($("#WikiaArticle").length)?"#WikiaArticle":"#bodyContent";
$( cC ).load( location.href + " " + cC + " > *", function ( data ) {
  $(cC).load(location.href + " " + cC + " > *", function (data) {  
if ( doRefresh ) {
      if (doRefresh) ajaxTimer = setTimeout("loadPageData();", ajaxRefresh);
ajaxTimer = setTimeout( "loadPageData();", ajaxRefresh );
  });
}
} );
}
}
addOnloadHook(function(){ for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) preloadAJAXRL() } } );
/**
*/
* Load the script on specific pages
*/
$( function () {  
for ( x in ajaxPages ) {
if ( wgPageName == ajaxPages[x] && $( '#ajaxToggle' ).length === 0 ) {
preloadAJAXRL();
}
}
} );


 
//**Duplicate images**//
/** remove admin link on toolbar **/
importScriptPage('MediaWiki:Common.js/dupimage.js‎‎', 'prototype');
$().ready( function() {
$('li > a[data-tracking="admindashboard/toolbar/admin"]').remove();
} );
 
function urlQuery(quer) {
for(i in location.href.split('?')) {
for(j in location.href.split('?')[i].split('&')) {
if(location.href.split('?')[i].split('&')[j].split('=')[0] == quer) {
return location.href.split('?')[i].split('&')[j].split('=')[1];
}
}
}
return '';
}

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');