;(function(factory){'use strict';if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else if(typeof module!=='undefined'&&module.exports){module.exports=factory(require('jquery'));}else{factory(jQuery);}})(function($){var _previousResizeWidth=-1,_updateTimeout=-1;var _parse=function(value){return parseFloat(value)||0;};var _rows=function(elements){var tolerance=1,$elements=$(elements),lastTop=null,rows=[];$elements.each(function(){var $that=$(this),top=$that.offset().top-_parse($that.css('margin-top')),lastRow=rows.length>0?rows[rows.length-1]:null;if(lastRow===null){rows.push($that);}else{if(Math.floor(Math.abs(lastTop-top))<=tolerance){rows[rows.length-1]=lastRow.add($that);}else{rows.push($that);}} lastTop=top;});return rows;};var _parseOptions=function(options){var opts={byRow:true,property:'height',target:null,remove:false};if(typeof options==='object'){return $.extend(opts,options);} if(typeof options==='boolean'){opts.byRow=options;}else if(options==='remove'){opts.remove=true;} return opts;};var matchHeight=$.fn.matchHeight=function(options){var opts=_parseOptions(options);if(opts.remove){var that=this;this.css(opts.property,'');$.each(matchHeight._groups,function(key,group){group.elements=group.elements.not(that);});return this;} if(this.length<=1&&!opts.target){return this;} matchHeight._groups.push({elements:this,options:opts});matchHeight._apply(this,opts);return this;};matchHeight.version='master';matchHeight._groups=[];matchHeight._throttle=80;matchHeight._maintainScroll=false;matchHeight._beforeUpdate=null;matchHeight._afterUpdate=null;matchHeight._rows=_rows;matchHeight._parse=_parse;matchHeight._parseOptions=_parseOptions;matchHeight._apply=function(elements,options){var opts=_parseOptions(options),$elements=$(elements),rows=[$elements];var scrollTop=$(window).scrollTop(),htmlHeight=$('html').outerHeight(true);var $hiddenParents=$elements.parents().filter(':hidden');$hiddenParents.each(function(){var $that=$(this);$that.data('style-cache',$that.attr('style'));});$hiddenParents.css('display','block');if(opts.byRow&&!opts.target){$elements.each(function(){var $that=$(this),display=$that.css('display');if(display!=='inline-block'&&display!=='flex'&&display!=='inline-flex'){display='block';} $that.data('style-cache',$that.attr('style'));$that.css({'display':display,'padding-top':'0','padding-bottom':'0','margin-top':'0','margin-bottom':'0','border-top-width':'0','border-bottom-width':'0','height':'100px','overflow':'hidden'});});rows=_rows($elements);$elements.each(function(){var $that=$(this);$that.attr('style',$that.data('style-cache')||'');});} $.each(rows,function(key,row){var $row=$(row),targetHeight=0;if(!opts.target){if(opts.byRow&&$row.length<=1){$row.css(opts.property,'');return;} $row.each(function(){var $that=$(this),style=$that.attr('style'),display=$that.css('display');if(display!=='inline-block'&&display!=='flex'&&display!=='inline-flex'){display='block';} var css={'display':display};css[opts.property]='';$that.css(css);if($that.outerHeight(false)>targetHeight){targetHeight=$that.outerHeight(false);} if(style){$that.attr('style',style);}else{$that.css('display','');}});}else{targetHeight=opts.target.outerHeight(false);} $row.each(function(){var $that=$(this),verticalPadding=0;if(opts.target&&$that.is(opts.target)){return;} if($that.css('box-sizing')!=='border-box'){verticalPadding+=_parse($that.css('border-top-width'))+_parse($that.css('border-bottom-width'));verticalPadding+=_parse($that.css('padding-top'))+_parse($that.css('padding-bottom'));} $that.css(opts.property,(targetHeight-verticalPadding)+'px');});});$hiddenParents.each(function(){var $that=$(this);$that.attr('style',$that.data('style-cache')||null);});if(matchHeight._maintainScroll){$(window).scrollTop((scrollTop/htmlHeight)*$('html').outerHeight(true));} return this;};matchHeight._applyDataApi=function(){var groups={};$('[data-match-height], [data-mh]').each(function(){var $this=$(this),groupId=$this.attr('data-mh')||$this.attr('data-match-height');if(groupId in groups){groups[groupId]=groups[groupId].add($this);}else{groups[groupId]=$this;}});$.each(groups,function(){this.matchHeight(true);});};var _update=function(event){if(matchHeight._beforeUpdate){matchHeight._beforeUpdate(event,matchHeight._groups);} $.each(matchHeight._groups,function(){matchHeight._apply(this.elements,this.options);});if(matchHeight._afterUpdate){matchHeight._afterUpdate(event,matchHeight._groups);}};matchHeight._update=function(throttle,event){if(event&&event.type==='resize'){var windowWidth=$(window).width();if(windowWidth===_previousResizeWidth){return;} _previousResizeWidth=windowWidth;} if(!throttle){_update(event);}else if(_updateTimeout===-1){_updateTimeout=setTimeout(function(){_update(event);_updateTimeout=-1;},matchHeight._throttle);}};$(matchHeight._applyDataApi);$(window).bind('load',function(event){matchHeight._update(false,event);});$(window).bind('resize orientationchange',function(event){matchHeight._update(true,event);});});var $=jQuery.noConflict();$(".wiki-embed iframe").wrap("
");$(".wiki-embed object").wrap("
");$(".wiki-embed .wikitable").css("width","100%");jQuery(document).ready(function($){$(".copyright-footer").insertAfter("#ubc7-unit-social-icons");});jQuery(function(){jQuery('.homeBox').matchHeight({byRow:true,property:'min-height',target:null,remove:false});});jQuery(document).ready(function($){$("#facet-sidebar-open a").on('click',function(){$('#facet-sidebar').addClass('show');});$('#facet-sidebar-close').on('click',function(){$('#facet-sidebar').removeClass('show');});});(function(){var LICS={"CC BY":{url:function(v){return"https://creativecommons.org/licenses/by/"+v+"/"},ver:true},"CC BY-SA":{url:function(v){return"https://creativecommons.org/licenses/by-sa/"+v+"/"},ver:true},"CC BY-ND":{url:function(v){return"https://creativecommons.org/licenses/by-nd/"+v+"/"},ver:true},"CC BY-NC":{url:function(v){return"https://creativecommons.org/licenses/by-nc/"+v+"/"},ver:true},"CC BY-NC-SA":{url:function(v){return"https://creativecommons.org/licenses/by-nc-sa/"+v+"/"},ver:true},"CC BY-NC-ND":{url:function(v){return"https://creativecommons.org/licenses/by-nc-nd/"+v+"/"},ver:true},"CC0":{url:function(){return"https://creativecommons.org/publicdomain/zero/1.0/"},ver:false},"Public Domain":{url:function(){return"https://creativecommons.org/publicdomain/mark/1.0/"},ver:false}};var LIC_MAP={"cc by 4.0":["CC BY","4.0"],"cc by 3.0":["CC BY","3.0"],"cc by 2.5":["CC BY","2.5"],"cc by 2.0":["CC BY","2.0"],"cc by 1.0":["CC BY","1.0"],"cc by-sa 4.0":["CC BY-SA","4.0"],"cc by-sa 3.0":["CC BY-SA","3.0"],"cc by-sa 2.5":["CC BY-SA","2.5"],"cc by-sa 2.0":["CC BY-SA","2.0"],"cc by-sa 1.0":["CC BY-SA","1.0"],"cc by-nd 4.0":["CC BY-ND","4.0"],"cc by-nd 3.0":["CC BY-ND","3.0"],"cc by-nc 4.0":["CC BY-NC","4.0"],"cc by-nc 3.0":["CC BY-NC","3.0"],"cc by-nc-sa 4.0":["CC BY-NC-SA","4.0"],"cc by-nc-sa 3.0":["CC BY-NC-SA","3.0"],"cc by-nc-sa 2.5":["CC BY-NC-SA","2.5"],"cc by-nc-sa 2.0":["CC BY-NC-SA","2.0"],"cc by-nc-nd 4.0":["CC BY-NC-ND","4.0"],"cc by-nc-nd 3.0":["CC BY-NC-ND","3.0"],"cc0":["CC0","1.0"],"cc0 1.0":["CC0","1.0"],"public domain mark 1.0":["Public Domain",""],"public domain":["Public Domain",""]};var activeLic=null;var activeTab="preview";function $i(id){return document.getElementById(id)} function strip(h){if(!h)return"";var d=document.createElement("div");d.innerHTML=h;d.querySelectorAll('[style*="display:none"],[style*="display: none"]').forEach(function(el){el.remove()});return d.textContent.trim()} function esc(s){return s.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")} function yr(s){var m=(s||"").match(/\b(19|20)\d{2}\b/);return m?m[0]:""} function absUrl(href,base){try{return new URL(href,base).href}catch(e){return href}} function setF(id,val,auto){var el=$i("tasl-"+id);if(!el)return;el.value=val||"";el.classList.toggle("t-af",auto&&!!val);var tag=$i("tasl-"+id+"-auto");if(tag)tag.style.display=(auto&&val)?"inline-block":"none";} function setStatus(type,icon,msg){var s=$i("tasl-status");s.className="t-status "+type;var ic=$i("tasl-sicon");if(type==="loading")ic.innerHTML='
';else ic.textContent=icon;$i("tasl-smsg").textContent=msg;} function setBusy(b){var btn=$i("tasl-gobtn");btn.disabled=b;btn.textContent=b?"Looking up…":"Look it up";} function loadImg(src){var img=$i("tasl-img");img.style.display="none";$i("tasl-imgph").style.display="flex";img.src=src;} function detectType(url){try{var u=new URL(url),h=u.hostname;if(h.includes("commons.wikimedia.org"))return"wm-commons";if(h.includes("upload.wikimedia.org"))return"wm-upload";if(/\.(jpe?g|png|gif|webp|svg|tiff?)(\?|$)/i.test(u.pathname))return"direct-img";return"webpage";}catch(e){return"invalid"}} function wmFilename(url){try{var u=new URL(url);var m1=u.pathname.match(/\/wiki\/(File:[^?#]+)/i);if(m1)return decodeURIComponent(m1[1]);var m2=u.pathname.match(/\/wikipedia\/commons(?:\/thumb)?\/[a-f0-9]\/[a-f0-9]+\/([^/]+?)(?:\/|$)/i);if(m2)return"File:"+decodeURIComponent(m2[1]);}catch(e){}return null;} function parseArtist(html){if(!html)return{name:"",url:""};var d=document.createElement("div");d.innerHTML=html;d.querySelectorAll('[style*="display:none"],[style*="display: none"]').forEach(function(el){el.remove()});var name="",url="";var links=d.querySelectorAll("a");if(links.length){name=links[0].textContent.trim();links.forEach(function(a){if(url)return;var h=a.getAttribute("href")||"";if(h.startsWith("https://")||h.startsWith("http://"))url=h;else if(h.startsWith("//"))url="https:"+h;});}else{name=d.textContent.trim();} return{name:name,url:url};} window.taslGo=function(){var raw=($i("tasl-url").value||"").trim();if(!raw){setStatus("error","⚠","Please paste a URL first.");return} var type=detectType(raw);if(type==="invalid"){setStatus("error","⚠","That doesn't look like a valid URL. Make sure it starts with https://");return} setBusy(true);if(type==="wm-commons"||type==="wm-upload")fetchWM(raw);else if(type==="direct-img"){loadImg(raw);setF("source",raw,false);setStatus("partial","ℹ️","This is a direct image link. The image has been loaded for preview. Please fill in the Title, Author, and License fields manually — they're usually listed on the page where you found the image.");setBusy(false);taslGen();}else fetchProxy(raw);};function fetchWM(url){var fname=wmFilename(url);if(!fname){setStatus("error","✗","Could not find a file name in this URL. Make sure it links to a File: page on Wikimedia Commons.");setBusy(false);return;} var api="https://commons.wikimedia.org/w/api.php?action=query&titles="+encodeURIComponent(fname)+"&prop=imageinfo&iiprop=url|user|extmetadata|size&iiextmetadatalanguage=en&format=json&origin=*";fetch(api).then(function(r){return r.json()}).then(function(data){var page=Object.values(data.query.pages)[0];if(!page||page.missing!==undefined){setStatus("error","✗","File not found on Wikimedia Commons. Check the URL.");setBusy(false);return} var info=page.imageinfo[0],m=info.extmetadata||{};var pageLink="https://commons.wikimedia.org/wiki/"+encodeURIComponent(fname);var title=strip(m.ObjectName&&m.ObjectName.value||m.Title&&m.Title.value||fname.replace(/^File:/,"").replace(/\.[^.]+$/,""));var artistParsed=parseArtist(m.Artist&&m.Artist.value||"");var author=artistParsed.name||strip(info.user||"");var authorUrl=artistParsed.url;var licShort=(m.LicenseShortName&&m.LicenseShortName.value||"").trim();var licUrl=m.LicenseUrl&&m.LicenseUrl.value||"";var year=yr(strip(m.DateTimeOriginal&&m.DateTimeOriginal.value||m.DateTime&&m.DateTime.value||""));setF("title",title,!!title);setF("author",author,!!author);setF("authorurl",authorUrl,!!authorUrl);setF("source",pageLink,true);loadImg(info.url);if(info.width&&info.height)$i("tasl-imgcap").textContent=info.width+" × "+info.height+" px";var licOk=applyLicKey(licShort.toLowerCase())||applyLicUrl(licUrl);if(year){$i("tasl-yr").checked=true;$i("tasl-yrwrap").style.display="inline";$i("tasl-yrval").value=year} var filled=[title,author,pageLink].filter(Boolean).length;setStatus("success","✓",filled+" of 3 TASL fields auto-filled."+(licOk?" License detected: "+licShort+".":' License "'+licShort+'" — please select it manually.')+" Always verify before publishing.");setBusy(false);taslGen();}).catch(function(e){setStatus("error","✗","Couldn't reach Wikimedia: "+e.message+". Check your connection and try again.");setBusy(false);});} function fetchProxy(pageUrl){setStatus("loading",null,"Fetching page… (a public CORS proxy is used — only the URL is sent, no personal data)");var proxyUrl="https://api.allorigins.win/get?url="+encodeURIComponent(pageUrl);fetch(proxyUrl).then(function(r){if(!r.ok)throw new Error("Proxy returned "+r.status);return r.json();}).then(function(json){if(!json.contents)throw new Error("Empty page.");var doc=new DOMParser().parseFromString(json.contents,"text/html");function getMeta(names){for(var i=0;i0?"partial":"partial","ℹ️",filled>0?"Found "+filled+" field(s) from page metadata."+(licOk?" License detected.":" Please select the license manually.")+" Review all fields carefully.":"Couldn't find metadata automatically on this page. Please fill in the fields manually — check the image's original page for author and license details.");setBusy(false);taslGen();}).catch(function(){setStatus("error","✗","Couldn't fetch this page automatically. Please fill in the fields manually — the information is usually listed near the image on its original website.");setBusy(false);});} function applyLicKey(key){key=(key||"").trim().toLowerCase();if(!LIC_MAP[key])return false;setLicUI(LIC_MAP[key][0],LIC_MAP[key][1],true);return true;} function applyLicUrl(url){if(!url)return false;var u=url.toLowerCase();if(u.includes("/zero/")){setLicUI("CC0","1.0",true);return true} if(u.includes("/publicdomain/mark")){setLicUI("Public Domain","",true);return true} var m=u.match(/\/licenses\/(by(?:-sa|-nd|-nc|-nc-sa|-nc-nd)?)\/([\d.]+)/i);if(m){var k="CC "+m[1].toUpperCase();if(LICS[k]){setLicUI(k,m[2],true);return true}} return false;} function setLicUI(lic,ver,auto){document.querySelectorAll("#tasl-app .t-lopt").forEach(function(o){o.classList.remove("sel","taf")});var el=document.querySelector("#tasl-app .t-lopt[data-lic='"+lic+"']");if(el){el.classList.add("sel");if(auto)el.classList.add("taf")} activeLic=lic;var vs=$i("tasl-ver"),note=$i("tasl-licnote");if(LICS[lic]&&LICS[lic].ver&&ver){vs.value=ver;vs.disabled=false} else{vs.disabled=!(LICS[lic]&&LICS[lic].ver)} note.style.display=auto?"inline":"none";} window.taslPickLic=function(el){document.querySelectorAll("#tasl-app .t-lopt").forEach(function(o){o.classList.remove("sel","taf")});el.classList.add("sel");activeLic=el.dataset.lic;var vs=$i("tasl-ver");vs.disabled=!(LICS[activeLic]&&LICS[activeLic].ver);vs.style.opacity=vs.disabled?"0.45":"1";$i("tasl-licnote").style.display="none";taslGen();};window.taslEx=function(url){$i("tasl-url").value=url;taslGo()};window.taslToggleYr=function(){$i("tasl-yrwrap").style.display=$i("tasl-yr").checked?"inline":"none";taslGen()};window.taslImgOk=function(){$i("tasl-img").style.display="block";$i("tasl-imgph").style.display="none"};window.taslImgErr=function(){$i("tasl-imgph").innerHTML='⚠️Image could
not be loaded'};window.taslReset=function(){["title","author","authorurl","source","yrval"].forEach(function(id){setF(id,"",false)});$i("tasl-url").value="";$i("tasl-img").src="";$i("tasl-img").style.display="none";$i("tasl-imgph").innerHTML='🖼Image preview
will appear here';$i("tasl-imgph").style.display="flex";$i("tasl-imgcap").textContent="";$i("tasl-status").className="t-status";$i("tasl-licnote").style.display="none";document.querySelectorAll("#tasl-app .t-lopt").forEach(function(o){o.classList.remove("sel","taf")});activeLic=null;$i("tasl-yr").checked=false;$i("tasl-modified").checked=false;$i("tasl-yrwrap").style.display="none";$i("tasl-ver").disabled=false;taslGen();};function getData(){var ver=$i("tasl-ver").value;return{title:$i("tasl-title").value.trim(),author:$i("tasl-author").value.trim(),authorUrl:$i("tasl-authorurl").value.trim(),source:$i("tasl-source").value.trim(),modified:$i("tasl-modified").checked,year:$i("tasl-yr").checked?$i("tasl-yrval").value.trim():"",licName:activeLic?(LICS[activeLic].ver?activeLic+" "+ver:activeLic):"",licUrl:activeLic?LICS[activeLic].url(ver):""};} function buildHtml(d){if(!d.licUrl)return"";var p=[];if(d.title)p.push(d.source?'"'+esc(d.title)+'"':'"'+esc(d.title)+'"');if(d.author){p.push((d.authorUrl?'by '+esc(d.author)+"":"by "+esc(d.author))+(d.year?" ("+d.year+")":""));}else if(d.year)p.push("("+d.year+")");p.push(d.modified?"is adapted and shared under":"is licensed under");p.push(''+esc(d.licName)+"");return p.join(" ");} function buildMd(d){if(!d.licUrl)return"";var p=[];if(d.title)p.push(d.source?'["'+d.title+'"]('+d.source+')':'"'+d.title+'"');if(d.author){p.push((d.authorUrl?"by ["+d.author+"]("+d.authorUrl+")":"by "+d.author)+(d.year?" ("+d.year+")":""));}else if(d.year)p.push("("+d.year+")");p.push(d.modified?"is adapted and shared under":"is licensed under");p.push("["+d.licName+"]("+d.licUrl+")");return p.join(" ");} function buildPlain(d){if(!d.licUrl)return"";var lines=[];if(d.title)lines.push("Title: "+d.title);if(d.author)lines.push("Author: "+d.author+(d.year?" ("+d.year+")":""));if(d.authorUrl)lines.push("Author profile: "+d.authorUrl);if(d.source)lines.push("Source: "+d.source);lines.push("License: "+d.licName);lines.push("License URL: "+d.licUrl);if(d.modified)lines.push("(This is an adaptation of the original work.)");return lines.join("\n");} window.taslGen=function(){var d=getData(),h=buildHtml(d),md=buildMd(d),pt=buildPlain(d);var pv=$i("tasl-out-preview");if(h){pv.innerHTML=h;pv.classList.remove("empty")} else{pv.textContent="Select a license above to generate your attribution.";pv.classList.add("empty")} $i("tasl-out-html").textContent=h;$i("tasl-out-markdown").textContent=md;$i("tasl-out-plain").textContent=pt;};window.taslTab=function(tab,btn){activeTab=tab;document.querySelectorAll("#tasl-app .t-tab").forEach(function(b){b.classList.remove("on")});document.querySelectorAll("#tasl-app .t-panel").forEach(function(p){p.classList.remove("on")});btn.classList.add("on");$i("tasl-panel-"+tab).classList.add("on");};window.taslCopy=function(){var map={preview:"tasl-out-preview",html:"tasl-out-html",markdown:"tasl-out-markdown",plain:"tasl-out-plain"};var text=($i(map[activeTab]).textContent||"").trim();if(!text||text==="Select a license above to generate your attribution.")return;function showToast(){var t=$i("tasl-toast");t.textContent="Copied!";t.classList.add("show");setTimeout(function(){t.classList.remove("show")},2200)} if(navigator.clipboard){navigator.clipboard.writeText(text).then(showToast).catch(function(){fb(text,showToast)})} else fb(text,showToast);function fb(t,cb){var ta=document.createElement("textarea");ta.value=t;ta.style.cssText="position:fixed;opacity:0";document.body.appendChild(ta);ta.select();document.execCommand("copy");document.body.removeChild(ta);cb()}};taslGen();})();