User:Phette23/Scripts/FindDPLA-DEV.js

!function(t,e,i){var n={title:$("#firstHeading").text,categories:[],otherTitles:[],redirects:[],getCategories:function{$("#mw-normal-catlinks li").each(function(t,e){n.categories.push($(e).text)})},getOtherTitles:function{$(".hatnote").each(function(t,e){var i=$(e).text.match('"(.*)" redirects here');i&&n.otherTitles.push(i[1])})}},o={},r=[],a=function(t){var e="e4c036f3302aad8d8c188683967b9619",i="http://api.dp.la/v2/items";return i+"?api_key="+e+"&q="+encodeURIComponent(t)+"&callback=_handleResponse"},s=function(t){$("body").append(' ')},l=function(t){o=t;var e=o.docs.length;e>0?h(u):n.otherTitles.length>0?s(n.otherTitles.pop):n.categories.length>0&&s(n.categories.pop)},c=function(t,e){var i=parseInt(e,10)||60,n=t.replace(/(\s\/)$/,"");return n.length>i?n.substr(0,i).replace(/\s$/,"")+"&hellip;":n},h=function(t){var e=o.docs,i={};$.each(e,function(t,e){var n=e.sourceResource;i.title=$.isArray(n.title)?n.title[0]:n.title,i.title=c(i.title),i.uri=e.isShownAt,i.isImage=d(n),r.push(i),i={}}),"function"==typeof t&&t},p=function(t){return t.replace("<","&lt;").replace(">","&gt;")},f=function(e){var i=$("#firstHeading").add(".hatnote"),n=function(e){i.visible(!0)&&($("#wikipedpla").show("slow"),$(t).off("scroll",n))};$("#mw-content-text").prepend(e),$("#wikipedpla").css("display","hidden"),i.visible(!0)?$("#wikipedpla").show("slow"):$(t).on("scroll",n)},u=function{var t=' .dp-img:after { content: " "; background: url(https://upload.wikimedia.org/wikipedia/commons/a/a3/VisualEditor_-_Icon_-_Picture.svg); width: 12px; height: 12px; display: inline-block; background-size: 12px 12px;} } DPLA ',e=!1,i=r.length;t+=1===i?"item:":"items:",$.each(r,function(n,o){n+1===i&&1!==i&&(e=!0),e&&(t+=" & "),t+=' "+p(o.title),t+=e?".":","}),t+=" ",f(t)},d=function(t){var e=t.type;if($.isArray(e)){for(var i in e)if(e.hasOwnProperty(i)&&"image"===i.toLowerCase)return!0;return!1}return e&&"image"===e.toLowerCase?!0:!1},g=function{var e=$('li[id^="ca-nstab-"]'),i=e.attr("id"),o="Main Page"===e.text;t._handleResponse||(t._handleResponse=l),"undefined"!=typeof unsafeWindow&&(unsafeWindow._handleResponse=l),"main"!==i.substr(-4)||o||(n.getCategories,n.getOtherTitles,s(n.title))};!function(e){var i=e(t);e.fn.visible=function(t,e,n){if(!(this.length<1)){var o=this.length>1?this.eq(0):this,r=o.get(0),a=i.width,s=i.height,n=n?n:"both",l=e===!0?r.offsetWidth*r.offsetHeight:!0;if("function"==typeof r.getBoundingClientRect){var c=r.getBoundingClientRect,h=c.top>=0&&c.top0&&c.bottom<=s,f=c.left>=0&&c.left0&&c.right<=a,d=t?h||p:h&&p,g=t?f||f:f&&u;if("both"===n)return l&&d&&g;if("vertical"===n)return l&&d;if("horizontal"===n)return l&&g}else{var v=i.scrollTop,w=v+s,m=i.scrollLeft,$=m+a,b=o.offset,y=b.top,k=y+o.height,x=b.left,_=x+o.width,R=t===!0?k:y,C=t===!0?y:k,T=t===!0?_:x,I=t===!0?x:_;if("both"===n)return!!l&&w>=C&&R>=v&&$>=I&&T>=m;if("vertical"===n)return!!l&&w>=C&&R>=v;if("horizontal"===n)return!!l&&$>=I&&T>=m}}}}(jQuery),g}(window,document);