1"use strict";(self.webpackChunkuniversity_of_glasgow=self.webpackChunkuniversity_of_glasgow||[]).push([[6269],{11088:function(t,e,i){i.r(e),i.d(e,{default:function(){return TwitterFeed}});var s=i(14309);class TwitterFeed{constructor(t){this.el=t,this.twitterid=this.el.dataset.twitterid.replace("@",""),this.twitteridarray=this.el.dataset.twitterid.replaceAll("@","").split(",").map((t=>t.trim())),this.isgroup=1!==this.twitteridarray.length,this.numberoftweets=this.el.dataset.twittercount,this.hasheading=!!this.el.dataset.heading,this.feed=`/feeds/twitter/main.html?screenname=${this.twitterid}&count=${this.numberoftweets}`,this.tempFix()}getFeeds(t){try{if(this.isgroup){const e=t.map((t=>fetch(`/feeds/twitter/main.html?screenname=${t}&count=${this.numberoftweets}`)));Promise.all(e).then((t=>Promise.all(t.map((t=>t.json()))))).then((t=>{this.data=t,this.appendfeed(t),this.clickhandler(),this.addheader()}))}else t.map((t=>{fetch(`/feeds/twitter/main.html?screenname=${t}&count=${this.numberoftweets}`).then((t=>t.json())).then((t=>{this.data=t,this.appendfeed(t),this.clickhandler(),this.addheader()}))}))}catch(t){throw console.log(t),t}}appendfeed(t){const e=t.flat(1).sort(((t,e)=>+Date.parse(e.created_at)-+Date.parse(t.created_at)));let i=document.createElement("ul"),s=!1;e.forEach(((t,e)=>{e<this.numberoftweets&&(i.insertAdjacentHTML("beforeend",`\n <li>\n <a href="https://www.twitter.com/${t.user.id}/status/${t.id_str}" target="blank">\n ${this.isgroup?`<strong>${t.user.screen_name}</strong> `:""}${t.text}\n </a>\n </li>`),s=!0)})),s&&this.el.insertAdjacentElement("beforeend",i)}addheader(){let t="";if(this.isgroup){t=this.hasheading?`<h2 style="text-wrap:normal">${this.el.dataset.heading}</h2>`:'<h2 style="text-wrap:normal">Group tweets</h2>';const e=document.querySelector(".twitter_tweet"),i=document.querySelector(".twitter_link");e.parentNode.removeChild(e),i.parentNode.removeChild(i)}else t=`\n <a href="https://www.twitter.com/${this.twitterid}" target="blank">\n <img class="twitter_profile_pic" width="48" height="48" alt="${this.data[0].user.name} icon" src="${this.data[0].user.profile_image_url_https}" />\n ${this.hasheading?`<h2 style="text-wrap:normal">${this.el.dataset.heading}</h2>`:`<h2 style="text-wrap:normal">${this.data[0].user.name} on Twitter</h2>`}\n </a>\n `;this.el.insertAdjacentHTML("afterbegin",t)}clickhandler(){this.el.nextElementSibling.classList.contains("twitter_tweet")&&this.el.nextElementSibling.addEventListener("click",(t=>{window.open("https://twitter.com/intent/tweet?text=%40"+this.twitterid,"","width=650, height=270")}))}tempFix(){console.log(this.el.parentNode.parentNode.classList.contains("contentPanel"));const t=this.el.parentNode.parentNode.classList.contains("contentPanel");let e=`<a class="twitter-timeline" data-height="400" href="https://twitter.com/${this.twitterid}">Tweets by ${this.twitterid}</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`;t&&(e=`<p class="calltoaction cobalt x"><a href="https://twitter.com/${this.twitterid}">Follow @${this.twitterid}</p></li></ul>`),this.el.insertAdjacentHTML("beforebegin",e),s.A.injectScript("https://platform.twitter.com/widgets.js"),this.el.nextElementSibling.style.display="none",this.el.nextElementSibling.nextElementSibling.style.display="none",this.el.style.display="none"}}}}]); 2//# sourceMappingURL=gu-twitterfeed.8ae87a69.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.