1/* LastResort JS file */ 2 3$(document).ready(function () 4{ 'use strict'; 5 6// function to turn a slice name into a selector reference for the corresponding <section> tag 7function GetSectionTagRef(SliceName) { 8 return 'section.' + SliceName + ' '; 9} 10 11var SectionTag, SectionTags; // will be used to hold required slices 12function SectionTagExists(SliceName) { 13 if (SectionTags.hasClass(SliceName)) { 14 SectionTag = SectionTags.filter(GetSectionTagRef(SliceName)); 15 if (SectionTag.length !== 0) { // at least one slice exists, great. You could have more than one in theory. 16 return true; 17 } 18 } 19 SectionTag = undefined; // remove all data. 20 return false; 21} 22 23// function to test if text exists. 24var sAttrText, sAttrText2, sAttrText3, sAttrText4; // Results come back in these variables. 25var DollarTextarea = $("<textarea/>"); // store this once. 26function TextExists(attrText, bSplit) { 27 28 if (attrText === undefined) {return false;} 29 if (attrText === null) {return false;} 30 31 var TextToProcess = attrText.trim(); 32 if (TextToProcess === '') {return false;} 33 34 // decode the text, so that &lt; becomes < etc. 35 // This works by turning into HTML and then turning back into text. 36 if (TextToProcess.indexOf('&') !== -1) { // we could use the .includes('&') method, but it is quite new, so some browsers can't cope. 37 TextToProcess = DollarTextarea.html(TextToProcess).text(); 38 } 39 if (TextToProcess === '') {return false;} 40 41 sAttrText = ''; // set return values to blank. 42 sAttrText2 = ''; 43 sAttrText3 = ''; 44 sAttrText4 = ''; 45 if (bSplit) { 46 var arrSplitText = TextToProcess.split('*'); 47 sAttrText = arrSplitText[0].trim(); 48 if (arrSplitText.length > 1) {sAttrText2 = arrSplitText[1].trim();} 49 if (arrSplitText.length > 2) {sAttrText3 = arrSplitText[2].trim();} 50 if (arrSplitText.length > 3) {sAttrText4 = arrSplitText[3].trim();} 51 } else { 52 sAttrText = TextToProcess; 53 } 54 55 return (sAttrText + sAttrText2 + sAttrText3 + sAttrText4 !== ''); 56} 57 58// Make slides work if they have a link, but no caption. 59function FixBxSlider(SliceName) { 60 if (SectionTagExists(SliceName)) { // check if slice exists, and load into SectionTag if it does 61 SectionTag.find('img').each(function() { 62 var ThisImg = $(this); 63 if(!ThisImg.next().hasClass('caption')){ // No caption at all 64 if (TextExists(ThisImg.parent().attr('href'), false)) { // but there is a link... 65 var ButtonLink = '<a class="slideButton Invisible" href="' + sAttrText + '"> </a>'; 66 var caption = '<div class="caption">' + ButtonLink + '</div>'; 67 $(caption).insertAfter(ThisImg); 68 //console.log(sAttrText); 69 } 70 } 71 }); 72 } 73} 74 75// Make slides work if they have a link, but no caption. 76function FixBxSliderNewTabButtons(SliceName) { 77 if (SectionTagExists(SliceName)) { // check if slice exists, and load into SectionTag if it does 78 SectionTag.find('a.slideButton').each(function() { 79 var ThisA = $(this); 80 var P = ThisA.parent(); 81 var bTargetBlank = (P.parent().attr('target') === "_blank") 82 || (P.prev().prev().attr('target') === "_blank"); 83 if(bTargetBlank){ 84 ThisA.attr('target','_blank'); 85 } 86 }); 87 } 88} 89 90var bOnTouchDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0); 91var BodyTag = $('body'); 92var bLoggedIn = BodyTag.hasClass('logged_in_user'); 93SectionTags = BodyTag.find('section'); // Store all the section tags to speed up later code. 94var bOnContentPage = SectionTags.hasClass('slice_content_page'); 95var bOnHomePage = SectionTags.hasClass('slice_SlidesFullWidth'); 96 97// Hide the visitor widget if the article does not publicly exist. 98if (!bLoggedIn && SectionTagExists('SeekerBox')) { 99 if(SectionTag.children('div.FullSeekerArticle').find('div.ArticleBody').length === 0){ 100 SectionTag.addClass('HideElement').hide(); 101 } 102} 103 104if (bOnHomePage) { 105 // hide the Covid banner if empty 106 if (SectionTagExists('CoronaVirus')) { 107 if(SectionTag.find('div.ArticleBody').length === 0){ 108 SectionTag.hide(); 109 } 110 } 111 112 // hide the service times/location slice if empty 113 if (SectionTagExists('slice_ServiceText_L')) { 114 var Blocks = SectionTag.find('div.blocks'); 115 if(Blocks.length === 1){ 116 if(Blocks.find('div.ArticleBody').length === 0){ 117 SectionTag.hide(); 118 } 119 } 120 } 121 122 if(bOnTouchDevice){ 123 // Make slides work on touch devices if they have a link, but no caption. 124 FixBxSlider('slice_SlidesFullWidth'); 125 FixBxSlider('slice_WhatsOnSlidesEB_L'); 126 } 127 FixBxSliderNewTabButtons('slice_SlidesFullWidth'); 128 FixBxSliderNewTabButtons('slice_WhatsOnSlidesEB_L'); 129} 130 131// Make sure anchor links do not dissappear behind a fixed header. 132if (bOnContentPage) { 133 var iHeaderHeight = 0; 134 if (SectionTagExists('slice_Header_L')) { 135 var CssPosition = SectionTag.css('position'); 136 if (CssPosition === 'fixed'){ // only do if we have a fixed header. 137 iHeaderHeight = SectionTag.outerHeight(); 138 } 139 } 140 if (iHeaderHeight > 0 && SectionTagExists('slice_content_page')) { 141 var HashLinks = SectionTag.find('a:not([href="#"])[href^="#"]'); 142 HashLinks.click(function(){ 143 window.setTimeout(function(){window.scrollBy(0, -iHeaderHeight);}, 250);
143 // wait 250ms, then scroll down, so link is not under the header. 144 }); 145 } 146} 147 148 // Fix issue with scrolling on search results pages. 149 var SP = BodyTag.find('section.slice_system_page._publisher_search_aspx div.system_pager'); 150 if(SP.length > 0){ 151 var Pager = SP.find('span[id$="_dpArticles"]'); 152 if(Pager.length === 1){ 153 var A = Pager.find('a.system_pager_next'); 154 var S = A.attr('href'); 155 if(typeof S !== typeof undefined){ 156 S = S.replace('javascript:_','javascript:window.scrollTo(0,0);_'); 157 A.attr('href', S); 158 } 159 A = Pager.find('a.system_pager_prev'); 160 S = A.attr('href'); 161 if(typeof S !== typeof undefined){ 162 S = S.replace('javascript:_','javascript:window.scrollTo(0,0);_'); 163 A.attr('href', S); 164 } 165 A = Pager.find('select'); 166 S = A.attr('onchange'); 167 if(typeof S !== typeof undefined){ 168 S = S.replace('javascript:s','javascript:window.scrollTo(0,0);s'); 169 A.attr('onchange', S); 170 } 171 } 172 Pager = SP.find('span[id$="dpEvents"]'); 173 if(Pager.length === 1){ 174 var A = Pager.find('a.system_pager_next'); 175 var S = A.attr('href'); 176 if(typeof S !== typeof undefined){ 177 S = S.replace('javascript:_','javascript:window.scrollTo(0,0);_'); 178 A.attr('href', S); 179 } 180 A = Pager.find('a.system_pager_prev'); 181 S = A.attr('href'); 182 if(typeof S !== typeof undefined){ 183 S = S.replace('javascript:_','javascript:window.scrollTo(0,0);_'); 184 A.attr('href', S); 185 } 186 A = Pager.find('select'); 187 S = A.attr('onchange'); 188 if(typeof S !== typeof undefined){ 189 S = S.replace('javascript:s','javascript:window.scrollTo(0,0);s'); 190 A.attr('onchange', S); 191 } 192 } 193 } 194 195// Hide mobile register link on sites that don't need it. 196 if(!bLoggedIn){ 197 var HSB = BodyTag.find('div.HiddenStatusBar'); 198 if(HSB.length > 0){ 199 if(HSB.find('a.register_link').length === 0){ 200 BodyTag.find('header ul.slicknav_nav li.ExtraLink a[href]').each(function(){ 201 var T = $(this); 202 var S = T.attr('href').trim().toLowerCase(); 203 if(S === '/user/registration.aspx'){T.parent().addClass('HideElement').hide();} 204 }); 205 } 206 } 207 } 208 209});
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.