1/* (C)2019 Endis Ltd. 2No permission is given to use any code in this file, except on an Endis/ChurchInsight website. 3 4This file is for generic fixes to any system page, and is rolled out across all templates, as of 30-Oct-2018. 5It only needs to appear in the header for system page templates (not home or content etc.) 6URL of the page is: /Images/Content/2414/Templates/47287/SystemPage.js 7On US: /Images/Content/1000000487/Templates/1000010205/SystemPage.js 8*/ 9 10$(document).ready(function () 11{ 'use strict'; 12 13// work out what kind of page we are on. 14var PageType = window.location.pathname.toLowerCase(); 15 16// Deal with extra '/' characters 17PageType = PageType.replace(/\/+/g, "_"); 18if(PageType.endsWith('_')){PageType = PageType.substr(0,PageType.length - 1);} 19 20if (PageType.endsWith(".aspx")) { 21 PageType = PageType.substring(0, PageType.indexOf(".aspx")); 22 PageType = PageType.replace(/\//g, "_"); // replace all / to _ Have to use \/ to get a / in the reg-ex. The g denotes a global exchange. 23 PageType = PageType + "_aspx"; 24} 25 26// function to turn a slice name into a selector reference for the corresponding <section> tag 27function GetSectionTagRef(SliceName) { 28 return 'section.' + SliceName + ' '; 29} 30 31var SectionTag, SectionTags; // will be used to hold required slices 32function SectionTagExists(SliceName) { 33 if (SectionTags.hasClass(SliceName)) { 34 SectionTag = SectionTags.filter(GetSectionTagRef(SliceName)); 35 if (SectionTag.length !== 0) { // at least one slice exists, great. You could have more than one in theory. 36 return true; 37 } 38 } 39 SectionTag = undefined; // remove all data. 40 return false; 41} 42 43 var bKeepChecking = true; 44 var iCount = 0; 45 var HeaderCols; 46 function HeaderColsCheck(){ 47 if(bKeepChecking){ 48 HeaderCols.each(function(){ 49 var T = $(this); 50 //console.log(T.innerWidth()); 51 if(T.innerWidth() < 10 && T.text() !== ''){ 52 T.text(''); 53 } 54 }); 55 iCount++; 56 if(iCount > 10){bKeepChecking = false;} 57 } 58 } 59 60var BodyTag = $('body'); 61SectionTags = BodyTag.find('section'); // Store all the section tags to speed up later code. 62 63//var bOnSystemPage = SectionTags.hasClass('slice_system_page'); 64//var bOnSystemPopupPage = BodyTag.hasClass('system_popup') || (window.location.href.toLowerCase().indexOf('popup=yes') !== -1); 65//var bUserLoggedIn = BodyTag.hasClass('logged_in_user'); 66 67var SystemSlice, PNs, bOldPhoneCode; 68if (SectionTagExists("slice_system_page")) { // check if slice exists, and load into SectionTag if it does 69 SystemSlice = SectionTag; 70 if(!SystemSlice.hasClass(PageType)){ // class appears to be missing 71 72 // First, remove possible bad class names caused by lots of '/' characters. 73 SystemSlice.attr('id','slice_system_page');
74 var x = document.getElementById("slice_system_page").className; 75 var arr = x.split(' '); 76 for(var i = 0; i < arr.length; i++){ 77 var S = arr[i]; 78 if (S.indexOf('/') !== -1) {SystemSlice.removeClass(S);} 79 } 80 81 // Add on the class name 82 SystemSlice.addClass(PageType); // add class onto <section> tag, so CSS can locate it. 83 } 84 85 // Fix profile page headers, so they can go full width. 86 if (PageType === '_myarea_profilefamily_aspx' || PageType === '_myarea_profilepersonal_aspx' || PageType === '_myarea_profilenew_aspx') { 87 var PH = SystemSlice.find('td.profileheader'); 88 PH.attr('colspan','2').next().remove(); // make cell span 2 columns, and remove the next (now un-needed cell). 89 } 90 91 // On the registration page, if there is only group to apply to, then hide that section. 92 if (PageType === '_user_registration_aspx') { 93 var REG = SystemSlice.find('div[id$="$outerdiv_ctls_registration"]'); 94 if(REG.length === 1){ 95 if(REG.find('input[type="checkbox"]').length === 1){ 96 REG.hide(); 97 } 98 } 99 } 100 101 // On the My Wallet page, if there is no data, then show a note to that effect 102 if (PageType === '_myarea_mywallet_aspx') { 103 var WT = SystemSlice.find('table.card-payment table.gridstyle'); 104 if(WT.length === 1){ 105 if(WT.find('tr.griditemrow').length === 0){ 106 WT.hide(); 107 $('<div>There is no editable card information in your wallet.</div>').insertAfter(WT); 108 } 109 } 110 } 111 112 // On the media page, remove download and length's for YouTube entries. 113 if (PageType === '_media_allmedia_aspx') { 114 var MRFF = SystemSlice.find('div.media_recording_file_format'); 115 MRFF.each(function(){ 116 var T = $(this); 117 var S = T.text().trim(); 118 if(S === 'Streaming' || S === 'Web Link' || S.startsWith('Streaming')){ // external video 119 120 // Check if there might be an MP3 somewhere. 121 var bHideDetails = true; 122 T.parent().parent().children().children('div.media_recording_file_format').each(function(){ 123 var T2 = $(this); 124 if(T2.text().trim().startsWith('MP3')){bHideDetails=false;} 125 }); 126 127 if(bHideDetails){ 128 var UL = T.parent().parent().parent().next().find('ul.media_recording_details'); 129 var LI = UL.children(); 130 LI.eq(0).hide(); 131 LI.eq(2).hide(); 132 } 133 } 134 }); 135 } 136 137 // On the address book, set phone numbers to be tel: links. 138 if (PageType === '_address_addressbook_aspx') { 139 140 bOldPhoneCode = SystemSlice.find('a.disable-exit-overlay').length === 0; 141 142 if(bOldPhoneCode){ 143 PNs = SystemSlice.find('div.address_phone_number'); 144 PNs.each(function(){ 145 var T = $(this); 146 var S = T.text().trim(); 147 var H = S.replace('(','').replace(')','').replace(' ',''); // good for tel: 148 if(H.startsWith('07')) { // assume a UK mobile number 149 S = S.replace('(','').replace(')',''); 150 } 151 var Atag = '<a href="tel:' + H + '">' + S + '</a>'; 152 T.html(Atag); 153 }); 154 } 155 } 156 157 158 if(PageType === '_rotas_rota_aspx') { 159 HeaderCols = SystemSlice.find('table.rota-table.gridstyle.floatThead-table th.gridheader'); 160 if(HeaderCols.length > 0){ 161 162 //window.setTimeout(function(){HeaderColsCheck();},1000); // delay by 1 second 163 window.setInterval(function(){HeaderColsCheck();}, 100); 164 165 } 166 } 167 168} 169 170// Check pop-ups. These are outside of <section.slice_system_page> 171if(BodyTag.hasClass('_address_details_aspx')) { 172 173 bOldPhoneCode = BodyTag.find('a.disable-exit-overlay').length === 0; 174 if(bOldPhoneCode){ 175 176 PNs = BodyTag.find('table.shadedbox td.addressfield'); 177 PNs.each(function(){ 178 var T = $(this); 179 var S = T.text().trim(); 180 if (S === 'mobile:') { 181 T = T.next(); 182 S = T.text().trim(); 183 var H = S.replace('(','').replace(')','').replace(' ',''); // good for tel: 184 if(H.startsWith('07')) { // assume a UK mobile number 185 S = S.replace('(','').replace(')',''); 186 } 187 var Atag = '<a href="tel:' + H + '">' + S + '</a>'; 188 T.html(Atag); 189 } 190 }); 191 192 // Deal with family phone numbers 193 PNs = BodyTag.find('img[src="/images/telephone.gif"]'); 194 PNs.each(function(){ 195 var T = $(this); 196 T = T.next(); // should be a <b> tag. 197 if(T.children('a').length === 0){ // If there is an <a> tag already then do nothing. 198 S = T.text().trim(); 199 var H = S.replace('(','').replace(')','').replace(' ',''); // good for tel: 200 if(H.startsWith('07')) { // assume a UK mobile number 201 S = S.replace('(','').replace(')',''); 202 } 203 var Atag = '<a href="tel:' + H + '">' + S + '</a>'; 204 T.html(Atag); 205 } 206 }); 207 } 208 209} 210 211});
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.