1"use strict";(self.webpackChunkuniversity_of_glasgow=self.webpackChunkuniversity_of_glasgow||[]).push([[9354],{85645:function(e,t,s){s.r(t),s.d(t,{default:function(){return SearchBanner}});var r=s(67193),n=s(14309);function pageArea(){return window.location.pathname.split("/")[1]||"home"}function viewport(){return n.A.currentmediaquery()||"unknown"}class BannerAnalytics{constructor(e){this.banner=e,this.openedAt=0,this.typed=!1,this.renderTimer=null,this.renderSignature="",this.lastState="ok"}get verbose(){return!!window.__searchBannerDebug}get active(){return r.A.analyticsenabled()&&"function"==typeof window.gtag}markSession(){if(!window.searchBandUsed){window.searchBandUsed=!0;try{window.sessionStorage.setItem("gu_search_band_used","true")}catch(e){}}}send(e,t){if(!this.active)return void(this.verbose&&console.debug("[searchband:skipped]",e,t));this.markSession();const s={...t,send_to:"G-BH0Z4FTSKF",banner_env:"searchband"};this.verbose&&(s.debug_mode=1,console.debug("[searchband]",e,s)),window.gtag("event",e,s)}open(e){this.openedAt=Date.now(),this.typed=!1,this.renderSignature="",this.send("search_banner_open",{open_source:e,scope:this.banner.filterKey,page_area:pageArea(),page_type:this.banner.internal?"myglasgow":"public",viewport:viewport()})}close(e){this.send("search_banner_close",{close_source:e,scope:this.banner.filterKey,typed:this.typed?1:0,dwell_ms:this.openedAt?Date.now()-this.openedAt:0,viewport:viewport()}),this.openedAt=0,this.typed=!1,this.clearRenderTimer()}scopeChange(e,t,s){this.send("search_banner_scope_change",{from_scope:e,to_scope:t,input_method:s,typed:this.typed?1:0,page_area:pageArea()})}quicklink(e){const t=e.closest(".searchbanner-group, .searchbanner-subgroup"),s=t&&t.querySelector(".searchbanner-group-title"),r=(t?[...t.querySelectorAll("a.searchbanner-link")]:[]).indexOf(e);this.send("search_banner_quicklink_click",{link_label:e.textContent.trim().slice(0,100),link_group:s?s.textContent.trim().slice(0,100):"unknown",link_href:e.getAttribute("href")||"",link_kind:e.classList.contains("searchbanner-group-title-link")?"group_heading":"link",link_position:r>=0?r+1:0,scope:this.banner.filterKey,page_type:this.banner.internal?"myglasgow":"public"})}example(e){const t=(e.parentElement?[...e.parentElement.querySelectorAll(".searchbanner-example")]:[]).indexOf(e);this.send("search_banner_example_click",{example_label:e.textContent.trim().slice(0,100),example_position:t>=0?t+1:0,scope:this.banner.filterKey})}suggestion(e,t){const s=this.banner.results[e];s&&this.send("search_banner_suggestion_click",{suggestion_kind:this.suggestionKind(s),result_position:e+1,result_count:this.banner.results.length,scope:this.banner.filterKey,input_method:t,typed:this.typed?1:0})}suggestionKind(e){return"page"===e.type?"people"===this.banner.filterKey?"staff_result":"curated_page":"query"===e.type?"study"===this.banner.filterKey?"course_suggestion":"people"===this.banner.filterKey?"staff_suggestion":"site_suggestion":"search_term_row"}submit(e){this.send("search_banner_submit",{submit_source:e,scope:this.banner.filterKey,page_count:this.banner.lastPages.length,suggestion_count:this.banner.lastQueries.length,empty_results:this.banner.lastPages.length||this.banner.lastQueries.length?0:1,typed:this.typed?1:0,viewport:viewport()})}noteTyping(){this.typed=!0}results(e,t){"pending"!==e&&(this.lastState=e,this.clearRenderTimer(),this.renderTimer=window.setTimeout((()=>{this.renderTimer=null;const s=this.banner.lastPages.length,r=this.banner.lastQueries.length,n=[e,s,r,this.banner.filterKey].join(":");n!==this.renderSignature&&(this.renderSignature=n,this.send("search_banner_results_shown",{page_count:"people"===this.banner.filterKey?0:s,people_count:"people"===this.banner.filterKey?s:0,suggestion_count:r,result_count:s+r,zero_results:s||r?0:1,suggest_state:e,trigger:t,scope:this.banner.filterKey,viewport:viewport()}))}),600))}clearRenderTimer(){this.renderTimer&&(window.clearTimeout(this.renderTimer),this.renderTimer=null)}resetRender(){this.clearRenderTimer(),this.renderSignature="",this.lastState="ok"}}const i=[{title:"Study",href:"/study/",scopes:["courses"],links:[{label:"Subjects A-Z",href:"/subjects/"},{label:"Undergraduate",href:"/undergraduate/"},{label:"Postgraduate",href:"/postgraduate/"},{label:"Online study",href:"/study/online/"}
1,{label:"Short courses",href:"/study/short/"},{label:"International students",href:"/international/"},{label:"Student life",href:"/study/studentlife/"},{label:"Scholarships and funding",href:"/scholarships/"},{label:"Visit us / Open Days",href:"/explore/visit/"}]},{title:"Research",href:"/research/",links:[{label:"Research units A-Z",href:"/research/az/"},{label:"Research opportunities A-Z",href:"/postgraduate/research/",scopes:["courses"]},{label:"Glasgow Research Beacons",href:"/research/beacons/"},{label:"Research strategy & policies",href:"/research/strategy/"},{label:"Research excellence",href:"/research/excellence/"},{label:"Our research environment",href:"/research/ourresearchenvironment/"}]},{title:"Explore",href:"/explore/",links:[{label:"Meet World Changing Glasgow",href:"/explore/abouttheuniversity/"},{label:"City of Glasgow",href:"/study/studentlife/glasgow/"},{label:"Visit us",href:"/explore/visit/"},{label:"Accessibility",href:"/explore/accessibility/"},{label:"Maps and travel",href:"/explore/maps/"},{label:"News",href:"/news/"},{label:"Events",href:"/events/"},{label:"Schools",href:"/schools/",scopes:["people"]},{label:"Colleges",href:"/colleges/",scopes:["people"]},{label:"Services",href:"/myglasgow/services/",scopes:["myglasgow"]},{label:"Library",href:"/myglasgow/library/",scopes:["myglasgow"]},{label:"University strategies",href:"/explore/strategies/"}]},{title:"Connect",href:"/connect/",links:[{label:"Staff A-Z",href:"/stafflist/",scopes:["people"]},{label:"Information for our alumni",href:"/alumni/"},{label:"Support us",href:"/connect/supportus/"},{label:"Business & innovation",href:"/connect/businessandinnovation/"},{label:"Community and public engagement",href:"/connect/publicengagement/"},{label:"Ask a student",href:"/study/studentlife/askastudent/"}],subheadings:[{title:"Jobs at Glasgow",href:"https://jobs.gla.ac.uk/",links:[{label:"Current vacancies",href:"https://jobs.gla.ac.uk/"}]}]}],a=[{title:"Students",href:"/myglasgow/students/",scopes:["myglasgow"],links:[{label:"MyGlasgow Students",href:"/myglasgow/students/"},{label:"Student Services A-Z",href:"/myglasgow/students/azsearch/"},{label:"Services and support",href:"/myglasgow/students/supportservices/"},{label:"Information for new students",href:"/myglasgow/students/new/"},{label:"Registry (enrolment & exams)",href:"/myglasgow/registry/",keywords:["registry","enrolment","exams","graduation"]},{label:"Student wellbeing",href:"/myglasgow/students/wellbeing/"},{label:"Student news",href:"/myglasgow/students/news/"}]},{title:"Staff",href:"/myglasgow/staff/",scopes:["myglasgow"],links:[{label:"MyGlasgow Staff",href:"/myglasgow/staff/"},{label:"Policy and strategy",href:"/myglasgow/staff/policy/"},{label:"HR policies and forms",href:"/myglasgow/pod/a-z/",keywords:["hr","human","resources","policies","forms","pod"]},{label:"Training, upskilling and CPD",href:"/myglasgow/training/",keywords:["training","cpd","development","upskilling"]},{label:"Staff benefits",href:"/myglasgow/staff/benefits/"},{label:"Learning and teaching",href:"/myglasgow/learningandteaching/"},{label:"Research and impact support",href:"/myglasgow/research/",keywords:["research","impact","support"]}]},{title:"Services & IT",href:"/myglasgow/services/",scopes:["myglasgow"],links:[{label:"Services",href:"/myglasgow/services/"},{label:"Library",href:"/myglasgow/library/"},{label:"IT Helpdesk",href:"/myglasgow/it/helpdesk/"},{label:"IT Services for staff",href:"/myglasgow/it/forstaff/",keywords:["it","services","staff","computing"]},{label:"IT Services for students",href:"/myglasgow/it/forstudents/",keywords:["it","services","students","computing"]},{label:"Moodle",href:"/myglasgow/moodle/"},{label:"Campus Cards",href:"/myglasgow/students/sset/campuscards/"}]},{title:"Support & wellbeing",scopes:["myglasgow"],links:[{label:"Emergency and crisis support",href:"/myglasgow/staff/emergencyandcrisissupport/"},{label:"Counselling & Psychological Services",href:"/myglasgow/counselling/",keywords:["counselling","mental","health"]},{label:"Disability Service",href:"/myglasgow/disability/"},{label:"Equality & Diversity",href:"/myglasgow/equalitydiversity/"},{label:"Accommodation Services",href:"/myglasgow/accommodation/"},{label:"Careers Service",href:"/myglasgow/careers/"}]}],l=new Set(["a","an","the","and","or","for","of","at","to","in","on"]);function deriveKeywords(e,t){const s=new Set;
1return e.toLowerCase().split(/[^a-z0-9]+/).forEach((e=>{e&&e.length>1&&!l.has(e)&&s.add(e)})),(t||"").toLowerCase().split("/").forEach((e=>{const t=e.replace(/[^a-z0-9]+/g,"");t&&t.length>3&&!l.has(t)&&s.add(t)})),[...s]}const o=/^\/myglasgow\//,h=/^\/myglasgow\/sport(\/|$)/;const c=new Set("mr mrs ms miss mx dr prof professor sir dame lord lady".split(" "));function scorePerson(e,t){const s=String(e.staffSurname||e.surname||"").toLowerCase().trim(),r=t[t.length-1],n=`${e.forename||""} ${s}`.toLowerCase().split(/[^\p{L}\p{N}'-]+/u).filter(Boolean);let i=0,a=0;return t.forEach((e=>{if(s===e)return i+=1,void(a+=e===r?10:6);n.some((t=>t===e||t.startsWith(e)||e.length>=4&&function withinOneEdit(e,t){if(Math.abs(e.length-t.length)>1)return!1;let s=0,r=0,n=0;for(;s<e.length&&r<t.length;)if(e[s]!==t[r]){if(n+=1,n>1)return!1;e.length>t.length?s+=1:(t.length>e.length||(s+=1),r+=1)}else s+=1,r+=1;return n+(e.length-s)+(t.length-r)<=1}(t,e)))&&(i+=1,a+=4)})),{matched:i,score:a}}function personName(e){return[e.title,e.forename,e.staffSurname||e.surname].filter((e=>e&&String(e).trim())).join(" ").trim()}function personJob(e){const t=(e.appointment||[])[0];return t&&t.jobTitle||"People"}function personSortKey(e){return`${e.staffSurname||e.surname||""} ${e.forename||""}`}const u={title:"For students & staff",links:[{label:"MyGlasgow Students",href:"/myglasgow/students/",scopes:["myglasgow"],keywords:["myglasgow","students","portal","student"]},{label:"MyGlasgow Staff",href:"/myglasgow/staff/",scopes:["myglasgow"],keywords:["myglasgow","staff","portal","employee"]}]},p="//www.gla.ac.uk/search",g={everything:"glasgow~sp-staff-and-website-meta",courses:"glasgow~sp-courses",myglasgow:"glasgow~sp-staff-and-website-meta"},d=[{key:"ug",label:"Undergraduate",aliases:["undergraduate","ug"]},{key:"pgt",label:"Postgraduate taught",aliases:["postgraduate taught","postgraduate","pg","pgt"]},{key:"pgr",label:"Postgraduate research",aliases:["postgraduate research","pgr"]},{key:"sc",label:"Short courses",aliases:["short courses","short course","sc"]},{key:"cpd",label:"Continuing professional development",aliases:["continuing professional development","cpd","upskilling"]}];const b=new Set("a about an and any are as at be been but by can could did do does find for from get give help how i if in into is it its long look looking me much my need no not of on or please show so some take tell than that the their them there these they this to up us want was we were what when where which who why will with would you your".split(" ")),f=new Set("apply complete connect contact courses date deadline details email information list number open page pages phone service services study struggling submitting time times".split(" ")),m=[{key:"everything",label:"Everything",placeholder:"Search everything",svg:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256" aria-hidden="true"><path fill="currentColor" d="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path></svg>'},{key:"courses",label:"Study",placeholder:"Search study",emptyState:{hint:"Study searches programmes and courses.",examples:["Computing Science","Medicine","Law"]},svg:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256" aria-hidden="true"><path fill="currentColor" d="M224,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H32A16,16,0,0,0,16,64V192a16,16,0,0,0,16,16H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h64a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z"></path></svg>'},{key:"people",label:"People",placeholder:"Search people",emptyState:{hint:"People searches the staff directory – surnames work best.",examples:["Smith","Campbell"]},svg:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256" aria-hidden="true"><path fill="currentColor" d="M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8c18.84-32.56,52.14-52,89.07-52s70.23,19.44,89.07,52a8,8,0,1,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z"></path></svg>'},{key:"myglasgow",label:"MyGlasgow",placeholder:"Search MyGlasgow",emptyState:{hint:"MyGlasgow searches information for current students and staff."},svg:'<svg xmlns="http://www.w3.org/2000/svg" width="13.5" height="20" viewBox="0 0 14.1 21" fill="none" aria-hidden="true"><path d="M7.05,18.17h0c-2.4-.13-6.53-3.68-6.53-7.08V.5h13.08s0,.16,0,.16c0,.06.02,6.09,0,10.43,0,3.41-4.13,6.95-6.53,7.08h0ZM.84.83v10.26c0,3.18,3.98,6.62,6.21,6.75,2.23-.13,6.21-3.57,6.21-6.75.01-3.93,0-9.26,0-10.26H.84Z" style="fill:none;stroke:currentColor;stroke-miterlimit:10"></path><path d="M2.45,16.83c-.26.35-.66.52-1.02.67,0,0-.17.08-.17.08,0,0-.16.07-.16.07,0,0-.06.03-.06.03h0s-.09.05-.09.05c-.27.14-.44.33-.44.79v.13s0,.23,0,.23v1.06c0,.12.05.24.15.33.15.14.39.22.66.22h11.46c.27,0,.51-.
107.66-.22.1-.09.15-.21.15-.34v-1.07s0-.23,0-.23c0,0,0-.16,0-.16,0-.4-.12-.55-.33-.67,0,0-.21-.13-.21-.13,0,0-.24-.11-.24-.11,0,0-.02-.01-.02-.01,0,0-.14-.06-.14-.06-.36-.15-.76-.32-1.02-.67,0,0-.01-.02-.03-.04,0,.02-.01.05-.01.05-.02.08-.03.16-.03.25,0,.15.04.29.08.45.05.18.11.39.12.67v.04s-9.44,0-9.44,0v-.04c.01-.28.07-.49.12-.66.04-.16.08-.31.08-.46,0-.08-.01-.16-.03-.25,0,0,0-.02-.01-.05-.01.02-.03.04-.03.04ZM1.09,18.21h-.04s.02-.06.02-.06c.03-.08.11-.17.23-.24,0,0,.08-.04.08-.04,0,0,.21-.09.21-.09.16-.06.35-.13.51-.28l.09-.08-.02.15v.04c-.02.06-.04.14-.04.23,0,.11.03.22.08.36l.03.06h-.74c-.16,0-.29-.02-.4-.05ZM11.88,18.2c.06-.14.09-.26.09-.36,0-.08-.02-.15-.03-.22,0-.01,0-.05,0-.05l-.02-.14.09.08c.16.14.35.22.51.28,0,0,.17.07.17.07,0,0,.17.09.17.09.08.06.15.13.17.19l.02.04-.04.02c-.07.03-.2.06-.4.06h-.74l.02-.06ZM12.59,18.58c.25,0,.46-.05.62-.14l.07-.04v.25s-.01,1.3-.01,1.3c0,.04-.02.08-.05.11-.08.08-.25.13-.43.13H1.31c-.19,0-.36-.04-.44-.13-.03-.03-.05-.07-.05-.11v-1.06s0-.24,0-.24c0,0,0-.14,0-.14v-.07s.06.03.06.03c.16.07.36.11.62.11h11.09Z" style="fill:none;stroke:currentColor;stroke-miterlimit:10"></path></svg>'}];class SearchBanner{constructor(){this.originals=[document.querySelector("#ssKeywords")].filter(Boolean),this.originals.length&&(this.extraActivators=[document.querySelector("#open-search-mobile"),document.querySelector("#searchrevealwrapper")].filter(Boolean),this.open=!1,this.pointerDownOnFocusedTrigger=!1,this.filterPressIsTouch=!1,this.submitViaButton=!1,this.submitViaEnter=!1,this.suppressFocusClose=!1,this.activeIndex=-1,this.results=[],this.fetchSeq=0,this.internal=function isMyGlasgowArea(e){const t=e||window.location.pathname;return o.test(t)&&!h.test(t)}(),this.linkGroups=this.internal?a:i,this.quicklinkItems=this.flattenQuicklinks(),this.filterKey=this.internal?"myglasgow":"everything",this.lastTerm="",this.lastPages=[],this.lastQueries=[],this.ga=new BannerAnalytics(this),this.createDom(),this.bindEvents())}flattenQuicklinks(){const mergeScopes=(e,t)=>[...new Set([...e||[],...t||[]])],e=[],push=t=>e.push(t),collect=(t,s)=>{const r=s?new Set(e.map((e=>e.href))):null,n=s?t=>{r.has(t.href)||e.push(t)}:push;t.forEach((e=>{e.links.forEach((t=>n({group:e.title,...t,scopes:mergeScopes(e.scopes,t.scopes),keywords:t.keywords||deriveKeywords(t.label,t.href)}))),(e.subheadings||[]).forEach((t=>{n({group:e.title,label:t.title,href:t.href,scopes:mergeScopes(e.scopes,t.scopes),keywords:t.keywords||deriveKeywords(t.title,t.href)}),t.links.forEach((s=>n({group:t.title,...s,scopes:mergeScopes(e.scopes,t.scopes,s.scopes),keywords:s.keywords||deriveKeywords(s.label,s.href)})))}))}))};return collect(this.linkGroups,!1),this.internal&&collect(i,!0),this.internal||u.links.forEach((e=>push({group:u.title,...e,scopes:mergeScopes(u.scopes,e.scopes),keywords:e.keywords||deriveKeywords(e.label,e.href)}))),e}createQuicklinkGroupsHtml(){let e="";return this.linkGroups.forEach((t=>{const s=t.href?`<a class="searchbanner-group-title-link" href="${t.href}">${t.title}</a>`:t.title;e+=`<div class="searchbanner-group">\n <h3 class="searchbanner-group-title">${s}</h3>\n <ul class="searchbanner-grouplinks">`,t.links.forEach((t=>{e+=`<li><a class="searchbanner-link" href="${t.href}">${t.label}</a></li>`})),e+="</ul>",(t.subheadings||[]).forEach((t=>{const s=t.href?`<a class="searchbanner-group-title-link" href="${t.href}">${t.title}</a>`:t.title;e+=`<div class="searchbanner-subgroup">\n <h4 class="searchbanner-group-title searchbanner-subgroup-title">${s}</h4>\n <ul class="searchbanner-grouplinks">`,t.links.forEach((t=>{e+=`<li><a class="searchbanner-link" href="${t.href}">${t.label}</a></li>`})),e+="</ul></div>"})),e+="</div>"})),e}createReminderHtml(){return this.internal?"":`<div class="searchbanner-group searchbanner-reminder">\n <h3 class="searchbanner-group-title">${u.title}</h3>\n <ul class="searchbanner-grouplinks">\n ${u.links.map((e=>`<li><a class="searchbanner-link" href="${e.href}">${e.label}</a></li>`)).join("")}\n </ul>\n </div>`}createFiltersHtml(){return`<div class="searchbanner-filters" role="group" aria-labelledby="searchbanner-filterlabel">
1\n <span class="searchbanner-filterlabel" id="searchbanner-filterlabel">Filter by</span>\n <ul class="searchbanner-filterlist">\n ${m.map((e=>{const t=e.key===this.filterKey;return`<li><button type="button" class="searchbanner-filter${t?" searchbanner-filter--active":""}" data-filter="${e.key}" aria-label="${e.label}"${t?' aria-pressed="true"':""}>${e.svg}<span class="searchbanner-filter-label">${e.label}</span></button></li>`})).join("")}\n </ul>\n </div>`}placeholderFor(e){const t=m.find((t=>t.key===e));return t?t.placeholder:"Search the site"}createDom(){const e=document.createElement("div");e.id="searchbanner",e.className=this.internal?"searchbanner searchbanner--internal":"searchbanner",e.setAttribute("role","dialog"),e.setAttribute("aria-label","Search the University of Glasgow website"),e.setAttribute("aria-hidden","true"),e.innerHTML=`\n <div class="searchbanner-inner">\n <div class="searchbanner-toolbar">\n <form action="${this.formAction()}" method="get" role="search" class="searchbanner-form">\n <label for="ssKeywordsBand" class="searchbanner-label">Search</label>\n <div class="searchbanner-inputwrap">\n <span class="searchbanner-glyph" aria-hidden="true">${this.searchGlyph()}</span>\n <input type="text" id="ssKeywordsBand" name="query" class="searchbanner-input"\n placeholder="${this.placeholderFor(this.filterKey)}" autocomplete="off" aria-autocomplete="list" />\n <button type="submit" class="searchbanner-submit" aria-describedby="searchbanner-submithint">Search</button>\n </div>\n </form>\n <button type="button" class="searchbanner-close" aria-label="Close search">\n <span class="searchbanner-close-icon" aria-hidden="true">Ã</span>\n <span class="searchbanner-close-text">Close</span>\n </button>\n </div>\n <div id="searchbanner-submithint" class="searchbanner-submithint" role="status"></div>\n ${this.createFiltersHtml()}\n <div id="searchbanner-suggestions" class="searchbanner-suggestions" aria-live="polite"></div>\n <div id="searchbanner-scopehint" class="searchbanner-scopehint"></div>\n <div id="searchbanner-quicklinks" class="searchbanner-quicklinks" role="navigation"\n aria-labelledby="searchbanner-quicklinks-title">\n <h2 class="searchbanner-quicklinks-title" id="searchbanner-quicklinks-title">Browse the site</h2>\n ${this.createQuicklinkGroupsHtml()}\n ${this.createReminderHtml()}\n </div>\n </div>`,document.body.appendChild(e),document.documentElement.classList.add("searchbanner-live"),this.host=e,this.form=e.querySelector(".searchbanner-form"),this.input=e.querySelector("#ssKeywordsBand"),this.closeBtn=e.querySelector(".searchbanner-close"),this.submitBtn=e.querySelector(".searchbanner-submit"),this.inputwrap=e.querySelector(".searchbanner-inputwrap"),this.submitHint=e.querySelector("#searchbanner-submithint"),this.suggestions=e.querySelector("#searchbanner-suggestions"),this.quicklinks=e.querySelector("#searchbanner-quicklinks"),this.scopehint=e.querySelector("#searchbanner-scopehint"),this.filterBtns=[...e.querySelectorAll(".searchbanner-filter")],this.syncSubmitState()}searchGlyph(){return'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20.39 20.24" aria-hidden="true"><path fill="currentColor" d="M17.72,20.14l-4.79-4.79a8.36,8.36,0,1,1,2.54-2.61l4.82,4.82a1.17,1.17,0,0,1-.47,1.38l-0.72.72A1.19,1.19,0,0,1,17.72,20.14ZM13.93,8.35a5.58,5.58,0,1,0-5.58,5.58A5.57,5.57,0,0,0,13.93,8.35Z"></path></svg>'}bindEvents(){this.originals.forEach((e=>{const visibleNow=()=>this.isVisible(e);e.addEventListener("mousedown",(()=>{visibleNow()&&(this.pointerDownOnFocusedTrigger=document.activeElement===e)})),e.addEventListener("focus",(()=>{visibleNow()&&(this.returningFocus?this.returningFocus=!1:this.open?this.closeBanner(!0,"nav_field_toggle"):this.openBanner("nav_field"))})),e.addEventListener("click",(()=>{visibleNow()&&this.pointerDownOnFocusedTrigger&&(this.open?this.closeBanner(!0,"nav_field_toggle"):this.openBanner("nav_field"))}))})),this.input.addEventListener("input",(()=>this.onInput())),this.input.addEventListener("keydown",(e=>this.onKeydown(e))),this.form.addEventListener("keydown",(e=>{"Enter"===e.key&&(this.submitViaEnter=!0)})),this.form.addEventListener("submit",(e=>{e.preventDefault();const t=this.input.value.trim();if(t){let e="enter";!this.submitViaEnter&&this.submitViaButton&&(e="search_button"),this.ga.submit(e),this.submitViaButton=!1,this.submitViaEnter=!1,window.location.href=this.siteSearchUrl(t)}else this.submitViaButton=!1,this.submitViaEnter=!1,this.showEmptySubmitHint()})),this.closeBtn.addEventListener("click",(()=>this.closeBanner(!0,"close_button"))),this.submitBtn.addEventListener("click",(()=>{this.submitViaButton=!0})),this.quicklinks.addEventListener("click",(e=>{const t=e.target.closest("a.searchbanner-link, a.searchbanner-group-title-link");t&&this.ga.quicklink(t)}),!0),this.suggestions.addEventListener("click",(e=>{const t=e.target.closest(".searchbanner-result[data-index]");t&&this.ga.suggestion(Number(t.getAttribute("data-index")),"pointer")}),!0),this.filterBtns.forEach((e=>{e.addEventListener("pointerdown",(e=>{this.filterPressIsTouch="touch"===e.pointerType})),e.addEventListener("click",(t=>this.setFilter(e.getAttribute("data-filter"),this.filterPressIsTouch?"touch":0===t.detail?"keyboard":"pointer")))})),this.scopehint.addEventListener("click",(e=>{const t=e.target.closest(".searchbanner-example");t&&(this.input.value=t.getAttribute("data-term"),this.input.focus(),this.ga.example(t),this.onInput())}));document.addEventListener("click",(e=>{if(!this.isActivator(e.target))return;e.preventDefault(),e.stopPropagation();const t=this.activatorSource(e.target);this.open?this.closeBanner(!0,"mobile_icon"===t?"mobile_icon_toggle":"nav_field_toggle"):this.openBanner(t)}),!0),document.addEventListener("keydown",(e=>{if("Enter"!==e.key&&" "!==e.key)return;if(!this.isActivator(e.target))return;e.preventDefault(),e.stopPropagation();const t=this.activatorSource(e.target);this.open?this.closeBanner(!0,"mobile_icon"===t?"mobile_icon_toggle":"nav_field_toggle"):this.openBanner(t)}),!0),document.addEventListener("keyup",(e=>{"Enter"===e.key&&this.isActivator(e.target)&&(e.preventDefault(),e.stopPropagation())}),!0),document.addEventListener("focusin",(e=>{this.open&&(this.suppressFocusClose?this.suppressFocusClose=!1:this.isInside(e.target)||this.closeBanner(!1,"focu
1s_left"))}));document.addEventListener("pointerdown",(e=>{this.open&&(this.isInside(e.target)||this.closeBanner(!1,"outside_press"))}),!0);let e=!1;document.addEventListener("touchstart",(t=>{e=!!(t.target&&t.target.closest&&t.target.closest(".searchbanner-inputwrap"))}),{capture:!0,passive:!0}),document.addEventListener("touchmove",(()=>{this.open&&document.activeElement===this.input&&(e||(this.suppressFocusClose=!0,this.input.blur()))}),{capture:!0,passive:!0})}syncSubmitState(){const e=!this.input.value.trim();this.form.classList.toggle("searchbanner-form--idle",e),e||this.clearSubmitHint()}showEmptySubmitHint(){this.input.focus(),this.submitHint.textContent="Type a word to search the site, or choose a link below.",this.submitHint.classList.add("searchbanner-submithint--show"),this.inputwrap.classList.remove("searchbanner-inputwrap--nudge"),this.inputwrap.getBoundingClientRect(),this.inputwrap.classList.add("searchbanner-inputwrap--nudge")}clearSubmitHint(){this.submitHint.classList.contains("searchbanner-submithint--show")&&(this.submitHint.classList.remove("searchbanner-submithint--show"),this.submitHint.textContent="",this.inputwrap.classList.remove("searchbanner-inputwrap--nudge"))}openBanner(e="unknown"){this.open||(this.open=!0,this.ga.open(e),this.host.classList.add("searchbanner--open"),this.host.setAttribute("aria-hidden","false"),this.fetchSeq+=1,this.suggestTimer&&(clearTimeout(this.suggestTimer),this.suggestTimer=null),this.input.value="",this.activeIndex=-1,this.results=[],this.lastTerm="",this.lastPages=[],this.lastQueries=[],this.clearSubmitHint(),this.syncSubmitState(),this.showQuicklinks(),window.setTimeout((()=>this.input.focus()),0))}closeBanner(e,t="unknown"){this.open&&(this.open=!1,this.ga.close(t),this.host.classList.remove("searchbanner--open"),this.host.setAttribute("aria-hidden","true"),this.fetchSeq+=1,this.suggestTimer&&(clearTimeout(this.suggestTimer),this.suggestTimer=null),this.input.value="",this.activeIndex=-1,this.results=[],this.clearSuggestions(),this.clearSubmitHint(),this.syncSubmitState(),e&&this.focusOriginal())}isInside(e){return this.host.contains(e)||this.originals.some((t=>t&&t.contains(e)))||this.extraActivators.some((t=>t&&t.contains(e)))}isActivator(e){return!!(e&&1===e.nodeType&&e.closest&&e.closest("#open-search-mobile, #searchrevealwrapper"))}activatorSource(e){return e&&e.closest&&e.closest("#open-search-mobile")?"mobile_icon":"scrolled_reveal"}isVisible(e){if(!e||!e.isConnected)return!1;const t=window.getComputedStyle(e);if("none"===t.display||"hidden"===t.visibility||"0"===t.opacity)return!1;const s=e.getBoundingClientRect();return s.width>0&&s.height>0}focusOriginal(){const e=document.activeElement,visible=e=>{if(!e)return!1;const t=e.getBoundingClientRect();return t.width>0&&t.height>0},t=this.originals.find(visible)||this.extraActivators.find(visible);
1t&&e!==t&&(this.returningFocus=!0,t.focus(),window.setTimeout((()=>{this.returningFocus=!1}),300))}onInput(){const e=++this.fetchSeq,t=this.input.value.trim();if(this.syncSubmitState(),!t)return this.suggestTimer&&(clearTimeout(this.suggestTimer),this.suggestTimer=null),this.lastTerm="",this.lastPages=[],this.lastQueries=[],this.ga.resetRender(),void this.showQuicklinks();this.ga.noteTyping();const s=this.matchPages(t);this.lastTerm=t,this.lastPages=s,this.lastQueries=[],this.activeIndex=-1,this.renderResults(s,[],t,t.length>=2?"pending":"ok"),this.ga.results(t.length>=2?"pending":"ok","typing"),t.length>=2?(this.suggestTimer&&clearTimeout(this.suggestTimer),this.suggestTimer=setTimeout((()=>{this.fetchSuggestions(t).then((r=>{e===this.fetchSeq&&(this.lastQueries=r||[],this.activeIndex=-1,this.renderResults(s,r,t,null===r?"error":"ok"),this.ga.results(null===r?"error":"ok","typing"))}))}),150)):this.suggestTimer&&clearTimeout(this.suggestTimer)}matchPages(e){const t=this.deriveSuggestTerm(e).toLowerCase(),s=this.filterKey,r=[];return this.quicklinkItems.forEach((e=>{const n=e.scopes||[],i=n.includes("myglasgow");if("everything"!==s&&"myglasgow"!==s&&!n.includes(s))return;const a=(e.label||"").toLowerCase(),l=(e.group||"").toLowerCase(),o=(e.keywords||[]).map((e=>e.toLowerCase()));let h=-1;a.startsWith(t)?h=0:a.includes(t)?h=1:l.includes(t)?h=2:o.some((e=>e.includes(t)||t.includes(e)))&&(h=3),"myglasgow"===s&&i&&(h-=.5),h>-1&&r.push({item:e,score:h})})),r.sort(((e,t)=>e.score!==t.score?e.score-t.score:e.item.label.length-t.item.label.length)),r.slice(0,4).map((e=>({type:"page",label:e.item.label,group:e.item.group,href:e.item.href})))}deriveSuggestTerm(e){const t=e.toLowerCase().replace(/[^\p{L}\p{N}'-]+/gu," ").split(" ").filter(Boolean);if(t.length<=4)return e;const s=t.filter((e=>e.length>2&&!b.has(e)));return s.find((e=>!f.has(e)))||s[0]||e}async fetchSuggestions(e){if("people"===this.filterKey)return this.fetchPeopleSuggestions(e);const t=g[this.filterKey]||g.everything,s=this.deriveSuggestTerm(e);try{const e=await fetch(`https://glasgow-search.funnelback.squiz.cloud/s/suggest.json?show=6&sort=0&alpha=0.5&fmt=json++&profile=_default&collection=${t}&partial_query=${encodeURIComponent(s)}`);if(!e.ok)return null;const r=await e.json();return Array.isArray(r)&&r.length?r.map((e=>{if(!e||!e.disp)return null;const t="string"==typeof e.disp?e.disp:e.disp.title;if(!t)return null;return{disp:this.decodeEntities(t),level:e.disp.listMetadata?.T?.[0]}})).filter(Boolean).map((({disp:e,level:t})=>({type:"query",label:e,level:t,href:this.siteSearchUrl(e)}))):[]}catch(e){return null}}async fetchPeopleSuggestions(e){const t=function personTokens(e){const t=String(e||"").toLowerCase().replace(/[^\p{L}\p{N}'-]+/gu," ").split(" ").map((e=>e.replace(/^['-]+|['-]+$/g,""))).filter((e=>e&&!b.has(e)&&!c.has(e)));return[...new Set(t)]}(e);if(!t.length)return[];const s=t.slice(-3).reverse();let r;try{r=await Promise.all(s.map((async e=>{const t=await fetch("https://www.gla.ac.uk/feeds/stafforgjson/index.html/search/keyword/"+encodeURIComponent(e));if(!t.ok)throw new Error(`staff feed returned ${t.status}`);const s=await t.json();return Array.isArray(s)?s:[]})))}catch(e){return null}const n=new Map;r.forEach((e=>{e.forEach((e=>{e&&Array.isArray(e.entries)&&e.entries.forEach((e=>{e&&"object"==typeof e&&e.url&&(n.has(e.url)||n.set(e.url,e))}))}))}));const i=[...n.values()].map((e=>({entry:e,...scorePerson(e,t)}))).sort(((e,t)=>t.matched-e.matched||t.score-e.score||personSortKey(e.entry).localeCompare(personSortKey(t.entry)))),a=t.length>1?i.filter((({matched:e})=>e>1)):[];return(a.length?a:i).map((({entry:e})=>({type:"page",label:personName(e),group:personJob(e),href:e.url}))).slice(0,6)}siteSearchUrl(e){const t="https://www.gla.ac.uk/search/?query="+encodeURIComponent(e);return"everything"!==this.filterKey?`${t}&filter=${this.filterKey}`:t}formAction(){return"everything"===this.filterKey?p:`${p}?filter=${this.filterKey}`}setFilter(e,t="pointer"){const s=this.filterKey;if(this.filterKey=e,s!==e&&this.ga.scopeChange(s,e,t),this.filterBtns.forEach((t=>{const s=t.getAttribute("data-filter")===e;t.classList.toggle("searchbanner-filter--active",s),s?t.setAttribute("aria-pressed","true"):t.removeAttribute("aria-pressed")})),this.form.setAttribute("action",this.formAction()),this.input.placeholder=this.placeholderFor(e),this.clearSubmitHint(),this.open&&this.lastTerm){this.suggestTimer&&(clearTimeout(this.suggestTimer),this.suggestTimer=null);const e=++this.fetchSeq,t=this.lastTerm,s=this.matchPages(t);this.lastTerm=t,this.lastPages=s,this.lastQueries=[],this.activeIndex=-1,t.length>=2?(this.renderResults(s,[],t,"pending"),this.ga.results("pending","scope_change"),this.fetchSuggestions(t).then((r=>{e===this.fetchSeq&&(this.lastQueries=r||[],this.activeIndex=-1,this.renderResults(s,r,t,null===r?"error":"ok"),this.ga.results(null===r?"error":"ok","scope_change"))}))):(this.renderResults(s,[],t,"ok"),this.ga.results("ok","scope_change"))}else this.open&&this.showQuicklinks();this.open&&!this.filterPressIsTouch&&this.input.focus(),this.filterPressIsTouch=!1}showQuicklinks(){this.clearSuggestions();const e=m.find((e=>e.key===this.filterKey)),t=e&&e.emptyState;if(this.quicklinks.classList.add("searchbanner-quicklinks--show"),t){if(this.scopehint.dataset.scope!==this.filterKey){this.scopehint.dataset.scope=this.filterKey;const e=(t.examples||[]).map((e=>`<button type="button" class="searchbanner-example" data-term="${this.escapeHtml(e)}">${this.escapeHtml(e)}</button>`)).join("");this.scopehint.innerHTML=`\n <p class="searchbanner-scopehint-text">${t.hint}</p>\n ${e?`<p class="searchbanner-scopehint-examples">
1\n <span class="searchbanner-scopehint-label">Try</span>\n ${e}\n </p>`:""}`}this.scopehint.classList.add("searchbanner-scopehint--show")}else this.scopehint.classList.remove("searchbanner-scopehint--show")}clearSuggestions(){this.suggestions.textContent="",this.suggestions.classList.remove("searchbanner-suggestions--show")}renderResults(e,t,s,r="ok"){t=t||[];const n=[],i=new Map;t.forEach((e=>{const t=function programmeLevelGroup(e){if(!e)return null;const t=String(e).trim();if(!t)return null;const s=t.toLowerCase(),r=d.findIndex((e=>e.aliases.includes(s)));return r>-1?{key:d[r].key,label:d[r].label,order:r}:{key:`other:${s}`,label:t,order:d.length}}(e.level),s=t?t.label:"Suggested searches",r=t?t.key:"",a=t?t.order:d.length+1;if(!i.has(r)){const e={key:r,label:s,order:a,items:[]};i.set(r,e),n.push(e)}i.get(r).items.push(e)})),n.length>1&&n.sort(((e,t)=>e.order-t.order));const a=n.flatMap((e=>e.items)),l=n.flatMap((e=>e.items.map((()=>e.label))));this.results=[...e,...a,{type:"term",label:s,href:this.siteSearchUrl(s)}],this.quicklinks.classList.remove("searchbanner-quicklinks--show"),this.scopehint.classList.remove("searchbanner-scopehint--show");const o="people"===this.filterKey?"People":"Pages";let h='<ul class="searchbanner-results" role="listbox">',c=!1,u=0,p=null;this.results.forEach(((n,i)=>{if("page"===n.type)c||(c=!0,h+=`<li class="searchbanner-section" role="presentation" aria-hidden="true"><span>${o}</span></li>`),h+=`<li class="searchbanner-result searchbanner-result--page" role="option" data-index="${i}">\n <a href="${n.href}">\n <span class="searchbanner-result-label">${this.escapeHtml(n.label)}</span>\n <span class="searchbanner-result-meta">${this.escapeHtml(n.group)}</span>\n </a>\n </li>`;else if("query"===n.type){const e=l[u];if(u+=1,e&&e!==p){p=e;h+=`<li class="searchbanner-section${"Suggested searches"===e?"":" searchbanner-section--level"}" role="presentation" aria-hidden="true"><span>${this.escapeHtml(e)}</span></li>`}h+=`<li class="searchbanner-result searchbanner-result--query" role="option" data-index="${i}">\n <a href="${n.href}">\n <span class="searchbanner-result-searchicon" aria-hidden="true">${this.searchGlyph()}</span>\n <span class="searchbanner-result-label">${this.escapeHtml(n.label)}</span>\n </a>\n </li>`}else"ok"!==r||e.length||t.length||(h+="people"===this.filterKey?'<li class="searchbanner-hint" role="presentation">No people matched – try just the surname</li>':'<li class="searchbanner-hint" role="presentation">No suggested matches – press Enter to search everything</li>'),h+=`<li class="searchbanner-result searchbanner-result--term" role="option" data-index="${i}">\n <a href="${n.href}">\n <span class="searchbanner-result-label">Search for â${this.escapeHtml(s)}â</span>\n </a>\n </li>`})),h+="</ul>",this.suggestions.innerHTML=h,this.suggestions.classList.add("searchbanner-suggestions--show")}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}decodeEntities(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'|'/g,"'")}setActive(e){const t=this.suggestions.querySelector(".searchbanner-result--active");t&&t.classList.remove("searchbanner-result--active"),this.activeIndex=e;const s=this.suggestions.querySelector(`.searchbanner-result[data-index="${e}"]`);s&&(s.classList.add("searchbanner-result--active"),s.scrollIntoView({block:"nearest"}))}onKeydown(e){const t=this.results.length;if(!t&&"Escape"===e.key)return e.preventDefault(),e.stopPropagation(),void this.closeBanner(!0,"escape");if("ArrowDown"===e.key){e.preventDefault();const s=this.activeIndex>=t-1?0:this.activeIndex+1;this.setActive(s)}else if("ArrowUp"===e.key){e.preventDefault();const s=this.activeIndex<=0?t-1:this.activeIndex-1;this.setActive(s)}else"Enter"===e.key?this.activeIndex>=0&&this.results[this.activeIndex]&&(e.preventDefault(),this.ga.suggestion(this.activeIndex,"keyboard"),window.location.href=this.results[this.activeIndex].href):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),this.closeBanner(!0,"escape"))}}}}]); 2//# sourceMappingURL=gu-searchbanner.b250fa53.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.