MediaWiki:Common.js/ajaxRC.js

/* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * * Original by pcj of Wowpedia * Maintenance, cleanup, style and bug fixes by: *  Grunny (http://c.wikia.com/wiki/User:Grunny) *  Kangaroopower (http://c.wikia.com/wiki/User:Kangaroopower) *  Cqm (http://c.wikia.com/wiki/User:Cqm) */ !function(a,b,c,d){"use strict";function e(a){return null===localStorage.getItem("AjaxRC-refresh")&&localStorage.setItem("AjaxRC-refresh",!0),a===!1?localStorage.setItem("AjaxRC-refresh",!1):a===!0&&localStorage.setItem("AjaxRC-refresh",!0),JSON.parse(localStorage.getItem("AjaxRC-refresh"))}function f{var d,f=b(".firstHeading").length?b(".firstHeading"):b("#WikiaPageHeader").length?b("#WikiaPageHeader > h1"):b("#AdminDashboardHeader").length?b("#AdminDashboardHeader > h1"):!1,i=b(' ').css({"font-size":"x-small","line-height":"100%","margin-top":"-24px","margin-right":-1*(parseInt(f.parent.css("padding-right"))-16)+"px","float":"right"}).append(b(' ').css({"border-bottom":"1px dotted",cursor:"help"}).attr("title",o).text(m+":"),b('').css({"margin-bottom":0,top:"12px",position:"relative"}),b(' ').css("display","none").append(b(" ").css({"vertical-align":"baseline","float":"none",border:0,position:"absolute","margin-top":"22px"}).attr("src",l).attr("alt","Refreshing page")));f===!1?b("#WikiaArticle").prepend(i):f.append(i),d=f.find("#ajaxLoadProgress"),b(document).ajaxSend(function(a,b,c){location.href===c.url&&d.show}).ajaxComplete(function(e,f,g){var h,i=b("#mw-content-text").find(".mw-collapsible"),l=a.ajaxCallAgain||[];if(location.href===g.url)for(d.hide,i.length&&i.makeCollapsible,"Recentchanges"===k.wgCanonicalSpecialPageName&&(c.special.recentchanges.init,b(".mw-recentchanges-table").find(".WikiaDropdown").length&&j.init),"WikiActivity"===k.wgCanonicalSpecialPageName&&a.WikiActivity.init,h=0;h<l.length;h++)l[h]}),b("#ajaxToggle").click(g),b("#ajaxToggle").attr("checked",e),e&&h}function g{b("#ajaxToggle").prop("checked")===!0?(e(!0),h):(e(!1),clearTimeout(i))}function h{var a=b(" ");a.load(location.href+" #mw-content-text",function{var c=a.children("#mw-content-text");c.length&&b("#mw-content-text").replaceWith(c),i=setTimeout(h,n)}),a.remove}var i,j,k=c.config.get(["stylepath","wgAction","wgCanonicalSpecialPageName","wgPageName"]),l=a.ajaxIndicator||k.stylepath+"/common/images/ajax.gif",m="string"==typeof a.AjaxRCRefreshText?a.AjaxRCRefreshText:"AJAX",n=a.ajaxRefresh||1e4,o="string"==typeof a.AjaxRCRefreshHoverText?a.AjaxRCRefreshHoverText:"Automatically refresh the page every "+n/1e3+" seconds",p=a.ajaxPages||["Special:RecentChanges","Special:WikiActivity","Special:NewPages"],q=["delete","edit","protect","revisiondelete"];b(function{-1!==b.inArray(k.wgPageName,p)&&0===b("#ajaxToggle").length&&-1===b.inArray(k.wgAction,q)&&f}),j={init:function{this.$table=b(".mw-recentchanges-table"),this.$dropdown=this.$table.find(".WikiaDropdown"),this.$submit=this.$table.find('input[type="submit"]'),this.$submit.on("click.RecentChangesDropdown",b.proxy(this.saveFilters,this)),this.$submit.removeAttr("disabled"),this.dropdown=new d.MultiSelectDropdown(this.$dropdown),this.dropdown.on("change",b.proxy(this.onChange,this))},saveFilters:function(c){var d=this;c.preventDefault,d.dropdown.disable,d.$submit.attr("disabled","disabled"),0===d.dropdown.getSelectedValues.length&&d.dropdown.doSelectAll(!0),b.nirvana.sendRequest({controller:"RecentChangesController",method:"saveFilters",data:{filters:d.dropdown.getSelectedValues},type:"POST",format:"json",callback:function{a.location.reload}})}}}(this,jQuery,mediaWiki,Wikia);