1$(document).ready(function () { 2 $(document).find('#regDropDown').change(function () { 3 var date = new Date(); 4 date.setTime(date.getTime() + (24 * 60 * 60 * 1000)); 5 document.cookie = "Edition=" + $(this).val() + "; expires=" + date.toGMTString() + "; path=/"; 6 window.location.href = $(this).find('option:selected').attr('data-to'); 7 }); 8 9 if ($('#news-alert').length && $('#example').length) { 10 GetNewsAlert(); 11 } 12 13 if ($('#topReadsOfWeek').length) { 14 hydrateTopReads(); 15 } 16 17 if ($('#opinion1').length) { 18 $('#opinion1').owlCarousel({ 19 items: 2, 20 nav: true, 21 margin: 0, 22 startPosition: '0', 23 autoplay: true, 24 autoplayTimeout: 3000, 25 autoplayHoverPause: true, 26 loop: true, 27 responsive: { 28 320: { 29 items: 1 30 }, 31 425: { 32 items: 1 33 }, 34 550: { 35 items: 1 36 }, 37 768: { 38 items: 2 39 }, 40 1024: { 41 items: 3 42 }, 43 1200: { 44 items: 3 45 } 46 } 47 }); 48 $("#opinion1 .owl-prev").html('<span class="fa fa-angle-left"></span>'); 49 $("#opinion1 .owl-next").html('<span class="fa fa-angle-right"></span>'); 50 } 51 52 scheduleVideoNewsLoad(); 53 54 55 function GetNewsAlert() { 56 var ApiDataUrl = "/api/Search/GetNewsAlert"; 57 $.getJSON(ApiDataUrl, function (data) { 58 var alertHtml = ''; 59 $.each(data, function (i, item) { 60 var slugUrl = convertToSlug(item.newsId, item.title); 61 var label = item.label != null ? item.label : "agency-wire"; 62 alertHtml += '<li><a href="/article/' + label + '/' + slugUrl + '" class="text-decoration"><span class="fg-black">â</span> ' + item.title + '</a></li>'; 63 }); 64 $('#news-alert').html(alertHtml); 65 if ($('#example').length) { 66 $('#example').breakingNews(); 67 } 68 }); 69 } 70 71 function GetVideoNews() { 72 var ApiDataUrl = "/api/Search/GetHomeVideoNews/" + encodeURI(_edition); 73 $.getJSON(ApiDataUrl, function (data) { 74 var videohtml = ''; 75 $.each(data, function (i, item) { 76 var slugUrl = convertToSlug(item.id, item.title); 77 var newsImage = item.fileThumbUrl; //item.fileThumbUrl.indexOf("devdiscourse.blob.core.windows.net") != -1 ? item.fileThumbUrl : item.fileThumbUrl; 78 var label = item.label != null ? item.label : "agency-wire"; 79 videohtml += '<div class="item"><a href="/news/videos/' + slugUrl + '" title="' + item.title.split('"').join('') + '" class="text-decoration"><div class="news-card bg-gray lazy" data-src="/img?imageUrl=' + newsImage + '?width=435&height=245&format=jpeg&mode=crop&quality=60"><div style="width:100%;height:100%;background-color:rgba(0,0,0,.3);padding:15px"><div class="media" style="bottom:15px;position:absolute"><div class="media-left"><div class="text-center" style="color: #fff; width: 40px; font-size: 17px; border: 2px solid #fff; border-radius: 50%; height: 40px; line-height: 40px; padding-left: 3px;"><span class="fa fa-play"></span></div></div><div class="media-body"><h3 class="no-margin" style="color:#fff;font-size:18px;line-height:1.26">' + item.title + '</h3></div></div></div></div></a></div>'; 80 }); 81 82 $('#videoNews').html('<h2 class="section-title2"><span style="background-color:#f4f4f4">DevShots</span>' + '</h2><div id="videoCarousel" class="owl-carousel">' + videohtml + '</div>'); 83 84 85 $('.lazy').lazy(); 86 87 88 $(document).find('#videoCarousel').owlCarousel({ 89 items: 3, 90 nav: true, 91 dots: false, 92 margin: 45, 93 startPosition: '0', 94 autoplay: true, 95 autoplayTimeout: 3000, 96 autoplayHoverPause: true, 97 loop: false, 98 responsive: { 99 320: { 100 items: 1 101 }, 102 425: { 103 items: 1 104 }, 105 550: { 106 items: 2 107 }, 108 768: { 109 items: 2 110 }, 111 1024: { 112 items: 3 113 }, 114 1200: { 115 items: 3 116 } 117 } 118 }); 119 120 $("#videoCarousel .owl-prev").html('<span class="fa fa-angle-left"></span>'); 121 $("#videoCarousel .owl-next").html('<span class="fa fa-angle-right"></span>');
122 $("#videoCarousel .owl-next").click(function () { 123 if ($(this).hasClass('disabled')) { 124 $(this).css('width', '100px').html('<a href="/news/videos" style="color:#fff;font-size:14px">View All</a>'); 125 } 126 }); 127 $("#videoCarousel .owl-prev").click(function () { 128 $(".owl-next").css('width', '40px').html('<span class="fa fa-angle-right"></span>'); 129 }); 130 }); 131 } 132 133 function scheduleVideoNewsLoad() { 134 var videoContainer = document.getElementById('videoNews'); 135 if (!videoContainer) { 136 return; 137 } 138 139 var hasLoaded = false; 140 function loadVideoNewsOnce() { 141 if (hasLoaded) { 142 return; 143 } 144 145 hasLoaded = true; 146 GetVideoNews(); 147 } 148 149 if (!('IntersectionObserver' in window)) { 150 loadVideoNewsOnce(); 151 return; 152 } 153 154 var observer = new IntersectionObserver(function (entries) { 155 $.each(entries, function (_, entry) { 156 if (entry.isIntersecting) { 157 observer.disconnect(); 158 loadVideoNewsOnce(); 159 return false; 160 } 161 }); 162 }, { 163 rootMargin: '250px 0px' 164 }); 165 166 observer.observe(videoContainer); 167 } 168 169 function hydrateTopReads() { 170 var $container = $('#topReadsOfWeek'); 171 if ($container.find('.trend-title, .also-title, .read-more-btn').length) { 172 return; 173 } 174 175 $.getJSON('/api/Search/GetLatestNews/' + encodeURIComponent(_edition)) 176 .done(function (items) { 177 if (!items || !items.length) { 178 $container.html('<p class="text-muted">Top reads will appear here shortly.</p>'); 179 return; 180 } 181 182 var html = '<div class="row">'; 183 $.each(items, function (index, item) { 184 var label = item.label || 'agency-wire'; 185 var slugUrl = convertToSlug(item.newId, item.title || ''); 186 var imageUrl = item.imageUrl ? '/img?imageUrl=' + item.imageUrl + '&width=360&height=200&mode=crop' : '/images/defaultImage.jpg'; 187 188 html += '<div class="col-xs-12 col-sm-6 col-md-4 p-t-10">'; 189 html += '<a href="/article/' + label + '/' + slugUrl + '" class="text-decoration">'; 190 html += '<img src="/Content/transparent.png?width=36&height=20&mode=crop" data-src="' + imageUrl + '" class="img-responsive lazy" alt="' + escapeHtml(item.title || 'Top read') + '" />'; 191 html += '<h3 class="trend-title no-margin p-t-10">' + escapeHtml(item.title || '') + '</h3>'; 192 html += '</a>'; 193 html += '</div>'; 194 195 if ((index + 1) % 3 === 0 && index !== items.length - 1) { 196 html += '</div><div class="row">'; 197 } 198 }); 199 200 html += '</div><a href="/news-analysis" class="read-more-btn">Read More</a>'; 201 $container.html(html); 202 $('.lazy').lazy(); 203 }) 204 .fail(function () { 205 $container.html('<p class="text-muted">Top reads are temporarily unavailable.</p>'); 206 }); 207 } 208 209 function convertToSlug(newsId, str) { 210 str = str.replace(/^\s+|\s+$/g, ''); 211 str = str.toLowerCase(); 212 var from = "à áäâèéëêìÃïîòóöôùúüûñç·/_,:;"; 213 var to = "aaaaeeeeiiiioooouuuunc------"; 214 for (var i = 0, l = from.length; i < l; i++) { 215 str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); 216 } 217 str = str.replace(/[^a-z0-9 -]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-'); 218 return newsId + "-" + str; 219 } 220 221 function escapeHtml(str) { 222 return String(str) 223 .replace(/&/g, '&') 224 .replace(/</g, '<') 225 .replace(/>/g, '>') 226 .replace(/"/g, '"') 227 .replace(/'/g, '''); 228 } 229});
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.