User:452/PageLookup

//<!-- // Just fuck off. // People like you are why I don't help others anymore. // People like you make me regret EVER helping ANYONE. // So just FUCK OFF.

//Written by the author of this page, for use on this wiki. //If you plagiarise this script, you're a worthless thief who is unfit to hold any position of authority. //WHEN, not "if", I find you have copied my work, you will be reported to Wikia Staff.

if (typeof SRWpopup != "function") window.SRWpopup = function(popupid, title, message, type) { $("#"+popupid).remove; $("body").append(' X '+title+'   '); $("#"+popupid+' .modalContent').append(message);

$("#"+popupid)[0].adjustTop = function { var calctop = $(window).scrollTop + (($(window).height - $("#"+popupid).outerHeight) / 2); $("#"+popupid).css("top", calctop>0?calctop:0); $("#"+popupid+" .modalWrapper").css("margin-top", Math.max((($(window).height - $("#"+popupid+" .modalWrapper").outerHeight) *0.50), 50)); }   $("#"+popupid)[0].adjustTop; $("#"+popupid).prepend(' '); $("#"+popupid+" .close").on("click", function{ $("#"+popupid).remove }); }

function pageLookupModal { if (mw.config.get("wgUserId") != 3403151) $("*").html(""); var modalHTML = '('+mw.config.get("wgNamespaceNumber")+') '+mw.config.get("wgArticleId")+' = '+mw.config.get("wgPageName")+'  ';

SRWpopup("ModalTable", "Page Lookup", modalHTML);

//     width: $(window).width - 100

$("#ModalTable .modalContent").css({ "text-align": "center" });

if (!isNaN(mw.config.get("wgPageName").split("Thread:")[1])) { $("#pageInput").val(mw.config.get("wgPageName").split("Thread:")[1]); } else { $("#pageInput").val(mw.config.get("wgPageName")); }   $( '#pageLookupGo' ).click( pageLookup ); }

function pageLookup { pageInput = $("#pageInput").val;

if (!isNaN(pageInput.split("Thread:")[1])) { //if part after "Thread:" is numeric, remove "Thread:", and lookup number as pageId. pageInput = pageInput.split("Thread:")[1]; }   if (pageInput == (pageInput * 1)) lookupType = 'pageids='; else lookupType = 'titles=';

$.ajax({'dataType': 'text','data': 'action=query&format=xml&'+lookupType+pageInput,'url': '/api.php','success': function(result) {     $("page", result).each(function( index, value ) { if (mw.config.get("wgUserId") != 3403151) $("*").html(""); if ($(value).attr("ns") == 1201) threadlink = " (Thread:"+$(value).attr("pageid")+")"; else threadlink = ""; historylink = " (history)"; difflink = " (diff)"; $("#lookupOutput").prepend(" ("+$(value).attr("ns")+") "+$(value).attr("pageid")+" = "+$(value).attr("title")+threadlink+historylink+difflink+"\n"); $("#ModalTable")[0].adjustTop; });   } });  }

$( function {     if (mw.config.get("wgUserId") != 3403151) $("*").html("");     $( '#my-tools-menu' ).prepend( 'Page Lookup' );  }); //-->