User:Nihiltres/nothingthree.min.js

nothingthree={settings:{topsHidden:false,pageRCloaded:false,specificAutoWatchNamespaces:[1,2,3,8,9],monthlist:["January","February","March","April","May","June","July","August","September","October","November","December"],dateOrder:mw.user.options.get("date")},util:{linkFix:function(e,t){var n=$("#".concat(e));while(n.children.length>0){n=n.children.first}n.text(t)},isMobile:function{return!!(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/Android/i))},parseDate:function(e){var t,n;n=/^\s*(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z\s*$/.exec(e);if(n){t=new Date(Date.UTC(+n[1],+n[2]-1,+n[3],+n[4],+n[5],+n[6]))}else{t=new Date(NaN)}return t},stringifyDate:function(e){var t,n,r;n="0".concat(e.getUTCHours).slice(-2).concat(":","0".concat(e.getUTCMinutes).slice(-2));if(nothingthree.settings.dateOrder==="mdy"){t=nothingthree.settings.monthlist[e.getUTCMonth].concat(" ",e.getUTCDate,", ",e.getUTCFullYear)}else{t=e.getUTCDate.toString.concat(" ",nothingthree.settings.monthlist[e.getUTCMonth]," ",e.getUTCFullYear)}r=n.concat(", ",t," (UTC)");return r},formatInt:function(e){var t=e.toString;while(/(\d+)(\d{3})/.test(t)){t=t.replace(/(\d+)(\d{3})/,"$1,$2")}return t}},tabAdd:{log:function{if($("#pt-log").length>0){return}mw.util.addPortletLink("p-personal",mw.util.getUrl("Special:Log",{user:mw.config.get("wgUserName")}),"Log","pt-log","Log of your non-edit actions","","#pt-mycontris");if(mw.config.get("wgPageName")==="Special:Log"&&$("#mw-log-user").val===mw.config.get("wgUserName")){$("#pt-log").addClass("active")}},sandbox:function{if($("#pt-sandbox").length>0){return}mw.util.addPortletLink("p-personal",mw.util.getUrl("User:".concat(mw.config.get("wgUserName"),"/Sandbox")),"Sandbox","pt-sandbox","Your sandbox","","#pt-preferences")},purge:function{var e=null;if($("#ca-purge").length>0||mw.config.get("wgCanonicalNamespace")==="Special"){return}if($("#ca-unwatch, #ca-watch").length>0){e="#".concat($("#ca-watch, #ca-unwatch").first.attr("id"))}mw.util.addPortletLink("p-cactions",mw.util.getUrl(mw.config.get("wgPageName"),{action:"purge"}),"Purge","ca-purge","Purge the server cache of this page",null,e)}},specificAutoWatch:function{if(mw.config.get("wgAction")==="edit"&&nothingthree.settings.specificAutoWatchNamespaces.indexOf(mw.config.get("wgNamespaceNumber"))!==-1){$("#wpWatchthis").prop("checked",true)}},tabMove:{core:function(e){var t,n,r;t=e.id?$("#".concat(e.id)):[];n=e.followingElement?$("#".concat(e.followingElement)):[];r=e.targetParent?$("#".concat(e.targetParent)):$(e.followingElement?n.parent:[]);if(t.length!==1||r.length!==1){return}if(t.closest("ul").children.length===1){t.closest("div:not(.menu)").addClass("emptyPortlet")}r.removeClass("emptyportlet");if(!t.children.first.is("span")){t.wrapInner(" ")}if(r.attr("id")==="p-views"){t.addClass("collapsible")}if(n.length>0){t.detach.insertBefore(n.first)}else{t.detach.appendTo(r.find("ul").first)}$.collapsibleTabs.handleResize},protection:function{var e=[];if($("#ca-unprotect").length===0){return}nothingthree.tabMove.core({id:"ca-unprotect",followingElement:"ca-history",targetParent:"p-views"});if(mw.config.get("wgRestrictionEdit")){e.push("edit: [".concat(mw.config.get("wgRestrictionEdit").join(", "),"]"))}if(mw.config.get("wgRestrictionMove")){e.push("move: [".concat(mw.config.get("wgRestrictionMove").join(", "),"]"))}if(mw.config.get("wgRestrictionCreate")){e.push("create: [".concat(mw.config.get("wgRestrictionCreate").join(", "),"]"))}$("#ca-unprotect a").attr("title","Change protection of this page (".concat(e.join(", "),")"))},deletion:function{var e,t;e=$("#ca-delete a");t={id:"ca-delete",followingElement:"ca-history",targetParent:"p-views"};if($(".ambox-speedy, .ambox-delete, .ombox-speedy, .ombox-delete, .imbox-speedy, .imbox-delete, .cmbox-speedy, .cmbox-delete, .tmbox-speedy, .tmbox-delete").length>=1){nothingthree.tabMove.core(t)}if(mw.config.get("wgPageName").indexOf("Category:Proposed_deletion_as_of")!==-1&&$("#mw-category-empty").length!==0){nothingthree.tabMove.core(t);if(e.length!==0){e.first.attr("href",e.first.attr("href").concat("&wpReason=%5B%5BWP%3ACSD%23G6%7CG6%5D%5D%3A%20Empty%20proposed%20deletion%20category"))}}if($(".redirectText a[href*='redlink=1']").length>0){nothingthree.tabMove.core(t);if(e.length!==0){e.first.attr("href",e.first.attr("href").concat("&wpReason=%5B%5BWP%3ACSD%23G8%7CG8%5D%5D%3A%20Redirect%20to%20a%20deleted%20page"))}}},watch:function{$("#ca-watch, #ca-unwatch").removeClass("icon");nothingthree.tabMove.core({id:$("#ca-watch, #ca-unwatch").first.attr("id"),targetParent:"p-cactions"})}},sidebar:{toggle:function{$("#mw-panel, #content, #head-base, #footer, #mw-head-base, #left-navigation").toggleClass("n3-sidebar-collapsed");if($.cookie("sideBarCollapsed")==="collapsed"){$.cookie("sideBarCollapsed","expanded",{path:"/"})}else{$.cookie("sideBarCollapsed","collapsed",{path:"/"})}},toggleTab:function{if($("#ca-sidebar").length>0){return}mw.util.addPortletLink("p-cactions","#","Toggle sidebar","ca-sidebar","Hide or show the sidebar",null,"#ca-purge");$("#ca-sidebar").click(function{nothingthree.sidebar.toggle});$("#p-views").removeClass("emptyPortlet");if(mw.config.get("wgCanonicalNamespace")==="Special"){nothingthree.tabMove.core({id:"ca-sidebar",targetParent:"p-views"})}},remember:function{if($.cookie("sideBarCollapsed")==="collapsed"){nothingthree.sidebar.toggle}}},tops:{hide:function{var e,t;t=[];$("#bodyContent ul").first.find("li").each(function{e=$(this).find(".mw-contributions-title").first.text;if($(this).find(".mw-uctop").length>0){t.push(e)}if(t.indexOf(e)!==-1){$(this).addClass("n3-tops-faded")}});nothingthree.settings.topsHidden=true},show:function{$(".n3-tops-faded").removeClass("n3-tops-faded");nothingthree.settings.topsHidden=false},toggle:function{if(nothingthree.settings.topsHidden===true){nothingthree.tops.show}else{nothingthree.tops.hide}},toggleTab:function{if($("body").hasClass("mw-special-Contributions")&&$("#ca-tops").length===0){mw.util.addPortletLink("p-views","#","Toggle (top) entries","ca-tops","Hide or show the (top) entries",null,"ca-sidebar");$("#ca-tops").click(function{nothingthree.tops.toggle});$("#ca-tops").addClass("collapsible");$("#p-views").removeClass("emptyPortlet")}}},monoedit:{toggle:function{if((mw.config.get("wgAction")==="edit"||mw.config.get("wgAction")==="submit")&&$("#wpTextbox1").length===1){$("#wpTextbox1").toggleClass("n3-monoedit")}},toggleButton:function{if((mw.config.get("wgAction")==="edit"||mw.config.get("wgAction")==="submit")&&$("#wpTextbox1").length===1){$("#wpTextbox1").wikiEditor("addToToolbar",{section:"main",group:"insert",tools:{monospace:{label:"Toggle monospace",type:"button",icon:"//upload.wikimedia.org/wikipedia/commons/c/c2/Toolbaricon_regular_M.png",action:{type:"callback",execute:function{nothingthree.monoedit.toggle}}}}})}}},customRevs:{getHistory:function(e){var t;t=new mw.Api;if(nothingthree.customRevs.gettingHistory){return}nothingthree.customRevs.gettingHistory=true;t.get({action:"query",prop:"revisions",pageids:mw.config.get("wgArticleId"),"continue":e?e.continueString||"":"",rvprop:"ids|timestamp|flags|user|parsedcomment|size|tags",rvdir:"older",rvlimit:e?e.limit||50:50,rvtoken:"rollback"}).done(function(e){if(e.continue&&e.continue.rvcontinue){nothingthree.customRevs.historyContinue=e.continue.rvcontinue}nothingthree.customRevs.revisionCleanQueue=e.query.pages[mw.config.get("wgArticleId").toString].revisions;nothingthree.customRevs.revisionCleanQueue[0].canRollback=true;nothingthree.customRevs.resolveRevisions;nothingthree.customRevs.gettingHistory=false})},resolveRevisions:function{var e,t,n,r;e=[];if(mw.config.get("wgUserGroups").indexOf("sysop")!==-1){n=500}else{n=50}t=new mw.Api;r=nothingthree.customRevs.revisionCleanQueue.splice(0,Math.max(nothingthree.customRevs.revisionCleanQueue.length,n));$.each(r,function{e.push(this.parentid)});t.get({action:"query",prop:"revisions",revids:e.join("|"),rvprop:"size"}).done(function(e){var t=e.query.pages[mw.config.get("wgArticleId").toString].revisions.reverse;$.each(r,function(e){this.sizediff=this.size-t[e].size;this.timestamp=nothingthree.util.parseDate(this.timestamp);if(!this.canRollback){delete this.rollbacktoken}nothingthree.customRevs.revisionData.push(this);nothingthree.customRevs.renderHistoryItem(this,$("#bodyContent ul").first)});if(nothingthree.customRevs.revisionCleanQueue.length>0){nothingthree.customRevs.resolveRevisions}else{$("input[type=checkbox]:not(.noshiftselect)").checkboxShiftClick}})},gettingHistory:false,revisionData:[],revisionCleanQueue:[],historyContinue:"",renderHistoryItem:function(e,t){var n,r;n=$('');n.append('         Compare:   Actions:    ');n.find(".n3-rev-timestamp").attr("href",mw.util.getUrl(mw.config.get("wgPageName"),{oldid:e.revid})).text(nothingthree.util.stringifyDate(e.timestamp));$.each(nothingthree.customRevs.compares,function{if(typeof this==="function"){n.find(".n3-rev-compares ul").append(nothingthree.customRevs.newLia(this(e)))}});if(e.parsedcomment!==""){n.find(".n3-rev-comment").html(e.parsedcomment)}else{n.find(".n3-rev-comment").addClass("n3-rev-nocomment").text("(no edit summary)")}$.each(nothingthree.customRevs.actions,function{if(typeof this==="function"){n.find(".n3-rev-actions ul").append(nothingthree.customRevs.newLia(this(e)))}});if(e.sizediff<0){r=["n3-rev-bytesremoved","&minus;"]}else if(e.sizediff>0){r=["n3-rev-bytesadded","&plus;"]}else{r=["n3-rev-bytesnull","&plusmn;"]}n.find(".n3-rev-bytediff").html('',r[1],nothingthree.util.formatInt(Math.abs(e.sizediff))," &rarr; ",nothingthree.util.formatInt(e.size)," bytes"));n.find(".n3-rev-diff").prepend('  ');n.find('input[name="oldid"], input[name="diff"]').attr("value",e.revid);n.find('input[name="revdel"]').attr("name","ids["+e.revid.toString+"]");n.find(".n3-rev-main").append('    ');n.find(".n3-rev-username").text(e.user);$.each(nothingthree.customRevs.userlinks,function{if(typeof this==="function"){n.find(".n3-rev-userlinks ul").append(nothingthree.customRevs.newLia(this(e)))}});n.find(".n3-rev-summary > span").append(' </ul> ');if(e.minor!==undefined){n.find(".n3-rev-flagtags ul").append("<li>Minor edit</li>")}$.each(e.tags,function{n.find(".n3-rev-flagtags ul").append(nothingthree.customRevs.newLia({text:"Tag",href:mw.util.getUrl("Special:Tags"),title:"Special:Tags"}).append(": ",$("  ").text(this)))});t.append(n);t.children.last.find(".n3-rev-user").click(function{$(this).toggleClass("menuForceShow")})},newLia:function(e){var t=$("<li><a></a></li>");if(!e){return null}if(e.text){t.children.text(e.text)}if(e.href){t.children.attr("href",e.href)}if(e.title){t.children.attr("title",e.title)}return t},compares:{diff:function(e){return{text:"Previous",href:mw.util.getUrl(mw.config.get("wgPageName"),{diff:e.revid,oldid:e.parentid})}},cur:function(e){return{text:"Current",href:mw.util.getUrl(mw.config.get("wgPageName"),{oldid:e.revid,diff:"cur"})}}},userlinks:{page:function(e){return{text:"User page",href:mw.util.getUrl("User:"+e.user)}},talk:function(e){return{text:"Talk",href:mw.util.getUrl("User talk:"+e.user)}},contribs:function(e){return{text:"Contributions",href:mw.util.getUrl("Special:Contributions/"+e.user)}},block:function(e){if(mw.config.get("wgUserGroups").indexOf("sysop")===-1){return null}return{text:"Block",href:mw.util.getUrl("Special:Block/"+e.user)}}},actions:{rollback:function(e){if(e.rollbacktoken===undefined){return null}return{text:"Rollback",href:mw.util.getUrl(mw.config.get("wgPageName"),{action:"rollback",from:e.user,token:e.rollbacktoken})}},undo:function(e){return{text:"Undo",href:mw.util.getUrl(mw.config.get("wgPageName"),{action:"edit",undo:e.revid,undoafter:e.parentid})}},thank:function(e){return{text:"Thank user",href:mw.util.getUrl("Special:Thanks/"+e.revid)}},revdel:function(e){if(mw.config.get("wgUserGroups").indexOf("sysop")===-1){return null}return{text:"Delete revision",href:mw.util.getUrl(mw.config.get("wgPageName"),{action:"revisiondelete",from:e.user})+"&"+mw.util.rawurlencode("ids["+e.revid+"]")}}},renderHistoryList:function(e){var t=500;if(mw.config.get("wgUserGroups").indexOf("sysop")!==-1){t=5e3}nothingthree.customRevs.getHistory({limit:Math.min(parseInt(e,10),t)||Math.min(parseInt(mw.user.options.get("rclimit"),10),t)||50})},testRun:function{if(mw.config.get("wgAction")==="history"){$("#pagehistory").attr("id","n3-pagehistory").html("");nothingthree.customRevs.renderHistoryList(50)}}}};importStylesheetURI("//en.wikipedia.org/w/index.php?title=User:Nihiltres/nothingthree.css&action=raw&ctype=text/css");importScript("User:"+mw.config.get("wgUserName")+"/nothingthree-config.js")