1$(document).ready(function(){ 2 3 let v = { 4 5 titleText : $('#titleText'), 6 bannerHeader : $('#bannerHeader'), 7 bannerIntroText : $('#bannerIntroText'), 8 featuredNewsIntroSection : $('#featuredNewsIntroSection'), 9 10 language : { 11 current : $('#langAsNo').text(), 12 }, 13 14 date : { 15 current : '', 16 }, 17 18 smhi : getSmhiIds(), 19 20 dayIntro : { 21 ui : { 22 introSunUp : $('#introSunUp'), 23 introSunDown : $('#introSunDown'), 24 }, 25 language : {}, 26 }, 27 28 visibleMigrationSection : getVisibleMigrationSectionIds(), 29 30 stagingSection : getStagingSectionIds(), 31 32 ringingSection : getRingingSectionIds(), 33 34 gallerySection : $('#gallerySectionBody'), 35 gallerySectionBottom : $('#gallerySectionBottomBody'), 36 37 blogDay : getBlogDaySection(), 38 39 }; 40 41 42 function getTexts() { 43 44 v.language.dateTexts = getDateTexts(v.language.current); 45 v.visibleMigrationSection.language = getTextsBlogVisibleMigration(v.language.current); 46 v.ringingSection.language = getTextsBlogRinging(v.language.current); 47 v.smhi.language = getTextsBlogSmhi(v.language.current); 48 v.stagingSection.language = getTextsBlogStagingSection(v.language.current); 49 50 // E N G E L S K A 51 if (v.language.current === '1'){ 52 53 v.language.langAsString = 'en'; 54 v.lang = { 55 langAsString : 'en', 56 locale : 'en-US', 57 }; 58 v.language.decDelimiter = '.'; 59 v.language.locale = 'en-US'; 60 61 v.language.titleText = 'Falsterbo Bird Observatory - Home' 62 v.language.bannerHeader = 'Home - Falsterbo Bird Observatory'; 63 64 v.dayIntro.language = { 65 introSunUp : 'Sunrise at ', 66 introSunDown: ' and sunset ', 67 weatherFrom : 'Falsterbo weather:', 68 tenDays : 'ten days prognosis', 69 and : ' and ', 70 short : 'short term', 71 }; 72 73 74 75 v.language.photo = 'Photo: '; 76 77 v.language.supportUs = 'Support us'; 78 v.language.swishIntro = ''; // empty in english 79 v.language.swishNumber = ''; // empty in english 80 v.language.otherWays = 'Other ways of supporting us'; 81 82 v.language.ringFound = 'Found a ring?'; 83 v.language.ringReportHere = 'Report it here'; 84 v.language.galleryHeader = 'Gallery'; 85 v.language.galleryIntro = 'The 3 most recent pics.'; 86 v.language.lokalt = ''; 87 88 89 v.language.supporters = 'Financial supporters'; 90 91 92 v.language.headerSenasteNytt = 'News'; 93 v.language.headerAndraNyheter = 'Featured news'; 94 v.language.featuredNewsDisclaimer = 'No featured news published at the moment.'; 95 v.language.featuredNewsIngress = 'This section contains the tree most recent featured news, deemed to be a little more interesting than the <a href="/blog/?lang=en">average daily update.</a>'; 96 } 97 98 99 // S V E N S K A 100 if (v.language.current === '2') { 101 v.language.langAsString = 'sv'; 102 v.lang = { 103 langAsString : 'sv', 104 locale : 'sv-SE', 105 }; 106 v.language.decDelimiter = ','; 107 v.language.locale = 'sv-SE'; 108 109 v.language.titleText = 'Falsterbo FÃ¥gelstation - Hem' 110 v.language.bannerHeader = 'Hem - Falsterbo FÃ¥gelstation'; 111 112 v.dayIntro.language = { 113 114 introSunUp : 'Solen gÃ¥r upp ', 115 introSunDown : ' och ned ', 116 weatherFrom : 'Falsterboväder:', 117 tenDays : 'tiodagarsprognos ', 118 and : ' och ', 119 short : 'kortprognos', 120 121 }; 122 123 124 v.language.photo = 'Foto: '; 125 126 v.language.supportUs = 'Stöd oss'; // empty in english 127 v.language.swishIntro = 'Swish '; // empty in english 128 v.language.swishNumber = '123 196 24 55'; // empty in english 129 v.language.otherWays = 'Andra sätt att stödja oss'; 130 131 v.language.ringFound = 'Upphittad ring?'; 132 v.language.ringReportHere = 'Rapportera här'; 133 v.language.galleryHeader = 'Galleri'; 134 v.language.galleryIntro = 'Galleriet - de tre senaste'; 135 v.language.lokalt = 'Lokalt'; 136 137 v.language.supporters = 'Finansiella supporters'; 138 139 v.language.webShopHeader = 'Senaste i webshopen'; 140 v.language.headerSenasteNytt = 'Senaste nytt'; 141 v.language.headerAndraNyheter = 'Ãldre extra läsvärda dagboksblad'; 142 v.language.featuredNewsIngress = 'Nedan publiceras de tre senaste dagboksbladen som anses mer läsvärda än de vanliga <a href="/blog/">dagliga blog sidorna.</a>'; 143 v.language.pageHeader = 'Falsterbo FÃ¥gelstation'; 144 v.language.featuredNewsDisclaimer = 'Inga extra läsvärda dagboksblad publicerade för stunden.'; 145 v.language.pageIntro = 'Page intro!'; 146 147 } 148 149 } 150 151 152 function setTexts(){ 153 154 v.titleText.text(v.language.titleText); 155 156 // banner 157 v.bannerHeader.text(v.language.bannerHeader); 158 v.bannerIntroText.text(v.language.bannerIntroText); 159 160 v.dayIntro.ui.introSunUp.text(v.dayIntro.language.introSunUp); 161 v.dayIntro.ui.introSunDown.text(v.dayIntro.language.introSunDown); 162 163 $('#weatherFrom').text(v.dayIntro.language.weatherFrom); 164 $('#tenDays').text(v.dayIntro.language.tenDays);
165 $('#and').text(v.dayIntro.language.and); 166 $('#short').text(v.dayIntro.language.short); 167 168 v.smhi.ui.smhiHeader.text(v.smhi.language.smhiHeader); 169 170 v.smhi.ui.smhiHeaderTime.text(v.smhi.language.smhiHeaderTime); 171 172 173 v.smhi.ui.smhiHeaderClouds.text(v.smhi.language.smhiHeaderClouds); 174 v.smhi.ui.smhiHeaderClouds.attr('title', v.smhi.language.smhiHeaderCloudsTitle); 175 176 v.smhi.ui.smhiHeaderWind.text(v.smhi.language.smhiHeaderWind); 177 v.smhi.ui.smhiHeaderWind.attr('title', v.smhi.language.smhiHeaderWindTitle); 178 179 v.smhi.ui.smhiHeaderTemp.text(v.smhi.language.smhiHeaderTemp); 180 v.smhi.ui.smhiHeaderTemp.attr('title', v.smhi.language.smhiHeaderTempTitle); 181 182 v.smhi.ui.smhiHeaderWindChill.text(v.smhi.language.smhiHeaderChillFactor); 183 v.smhi.ui.smhiHeaderWindChill.attr('title', v.smhi.language.smhiHeaderChillFactorTitle); 184 185 v.smhi.ui.smhiHeaderVisibility.text(v.smhi.language.smhiHeaderVisibility); 186 v.smhi.ui.smhiHeaderVisibility.attr('title', v.smhi.language.smhiHeaderVisibilityTitle); 187 188 v.smhi.ui.smhiHeaderUpdated.text(v.smhi.language.smhiHeaderUpdated); 189 v.smhi.ui.smhiHeaderHour.text(v.smhi.language.smhiHeaderHour); 190 v.smhi.ui.smhiHeaderMinute.text(v.smhi.language.smhiHeaderMinute); 191 v.smhi.ui.smhiHeaderSecond.text(v.smhi.language.smhiHeaderSecond); 192 v.smhi.ui.smhiHeaderSedan.text(v.smhi.language.smhiHeaderSedan); 193 v.smhi.ui.smhiHeaderWeatherType.text(v.smhi.language.smhiHeaderWeatherType); 194 195 v.smhi.ui.smhiHeaderComment.text(v.smhi.language.smhiHeaderComment); 196 197 v.ringingSection.ui.ringingSectionHeader.text(v.ringingSection.language.header); 198 199 $('.supportUs').text(v.language.supportUs); 200 $('.swish-intro').text(v.language.swishIntro); 201 $('.swish-number').text(v.language.swishNumber); 202 $('#alternativSupport').text(v.language.otherWays); 203 204 205 v.stagingSection.ui.header.text(v.stagingSection.language.header); 206 v.stagingSection.ui.rrInfo.text(v.stagingSection.language.rrInfo); 207 v.stagingSection.ui.rrHere.text(v.stagingSection.language.rrHere); 208 209 $('#galleryHeader').text(v.language.galleryHeader); 210 $('[id^=galleryIntro]').text(v.language.galleryIntro); 211 212 $('.ringFound').text(v.language.ringFound); 213 $('.ringReportHere').text(v.language.ringReportHere); 214 215 $('#lokalt').text(v.language.lokalt); 216 217 $('#supporters').text(v.language.supporters); 218 219 $('#smhiInfo').text(v.smhi.language.smhiInfo); 220 $('#smhiInfoII').text(v.smhi.language.smhiInfoII); 221 $('#webShopHeader').text(v.language.webShopHeader); 222 $('#headerSenasteNytt').text(v.language.headerSenasteNytt); 223 $('#headerAndraNyheter').text(v.language.headerAndraNyheter); 224 $('#featuredNewsIngress').html(v.language.featuredNewsIngress); 225 226 $('#pageHeader').text(v.language.pageHeader); 227 $('#pageIntro').html(v.language.pageIntro); 228 $('#smhiShortPrognosisText').html(v.smhi.language.smhiShortPrognosisText); 229 230 } 231 232 233 function populateWeatherInfo(){ 234 235 // Get the most recent weather reading - in current language 236 let weatherData = v.allData['weatherData']; 237 238 let general = weatherData[0]; 239 let comments = weatherData[1]; 240 241 let timme = getRightTime(general[0].TIME, general[0].DATUM ); 242 v.smhi.ui.smhiDataTime.text(timme); 243 v.smhi.ui.smhiDataClouds.text(general[0].CLOUDS); 244 v.smhi.ui.smhiDataWindDirection.text(general[0].WIND); 245 v.smhi.ui.smhiDataWindForce.text(general[0].vsty); 246 247 v.smhi.ui.smhiDataTemp.text( formatTemperatureValueAsString( v, general[0].TEMP ) + ' °C'); 248 let sikt = parseFloat(general[0].SIKT); 249 if (sikt > 5){ 250 sikt = Math.round(sikt); 251 } 252 v.smhi.ui.smhiDataVisibility.text(sikt); 253 254 let l = comments.length; 255 let txt = ''; 256 for (let i = 0; i < l; i++) { 257 txt += ', ' + comments[i].TEXT; 258 } 259 v.smhi.ui.smhiDataComment.text(txt.substring(2)); 260 261 //plug in "n. appl." if temperature is outside the range of applicability 262 const intTemp = parseFloat(general[0]["TEMP"]); 263 const intWind = parseInt(general[0].vsty) 264 265 if ((intTemp > 10) || (intWind <= 2)) { 266 v.smhi.ui.smhiDataChillFactor.text("-----"); 267 v.smhi.ui.smhiDataChillFactor.attr('title', v.smhi.language.smhiChillFactorNotApplicable); 268 } else { 269 let wc = getWindChillValue(intTemp, intWind); 270 v.smhi.ui.smhiDataChillFactor.text( formatTemperatureValueAsString( v, wc ) + ' °C' ) ; 271 v.smhi.ui.smhiDataChillFactor.attr('title', v.smhi.language.smhiHeaderChillFactorTitle); 272 } 273 274 } 275 276 277 function buildNewsSection() { 278 279 // first (most recent entry 280 v.blogDay.node = $('#theMostRecentBlogEntry'); 281 v.blogDay.node.empty(); 282 v.blogDay.node.toggleClass('blogPage', true); 283 v.blogDay.node.toggleClass('container', true); 284 285 // Get the most recent news item -> most recently published (in current language) 286 let pageData = v.allData['firstBlogEntry']; 287 288 compileBlogDayAllPageSections(pageData, v, '1'); 289 290 // Build a "blogPage" for each featured news (day) 291 const featuredNews = $('#featuredNewsBody'); 292 let featuredNewsPieces = v.allData['featuredNews']; 293 let numberOfNewsPieces = featuredNewsPieces.length; 294 if (numberOfNewsPieces > 0){ 295 v.featuredNewsIntroSection.toggleClass('mg-hide-element', false); 296 } 297 298 for (let i = 0; i < numberOfNewsPieces; i++) { 299 300 let pageData = featuredNewsPieces[i];
301 let ymd = pageData['newsData']["DATE"]; 302 303 let featuredNewPiece = '<div id="featuredNewsItem-' + ymd + '" class="blogPage container mb-3"></div>'; 304 featuredNews.append(featuredNewPiece); 305 v.blogDay.node = $('#featuredNewsItem-' + ymd); 306 compileBlogDayAllPageSections(pageData, v, '1'); 307 308 } 309 310 } 311 312 313 function populateIntro(){ 314 315 let d = new Date(); 316 let y = d.getFullYear(); 317 318 let m = d.getMonth() + 1; // javaScript! 319 if (m < 10){ 320 m = '0' + m; 321 } 322 323 let dag = d.getDate(); 324 if (dag < 10){ 325 dag = '0' + dag; 326 } 327 328 const url = 'https://sholiday.faboul.se/dagar/v2.1/' + y + '/' + m + '/' + dag; 329 330 fetch(url).then(function(response) { 331 332 // Examine the text in the response, make comma delimited list of names 333 // Format it nicely depending on the number of names, one, two (or three). 334 response.json().then(function(data) { 335 let x = data.dagar; 336 let names = x[0]["namnsdag"]; 337 338 let str = ''; 339 340 names.forEach(function( item ) { 341 str = str + item + ', '; 342 }); 343 344 str = str.substring(0, str.length-2); 345 if (str.indexOf(',', str) > 0){ 346 let str1 = str.substring(0, str.lastIndexOf(',')); 347 let str2 = str.substring(str.lastIndexOf(',') + 1); 348 str = str1 + v.dayIntro.language.introAnd + str2; 349 } 350 // $('#introNamesData').text(str); 351 352 }); 353 354 }); 355 } 356 357 358 function loadImages(){ 359 360 v.gallerySection.empty(); 361 v.gallerySectionBottom.empty(); 362 363 let pics = v.allData['picData']; 364 365 pics.forEach(function (pic) { 366 367 const titleText = pic['PLATS'] + ', ' + pic['DATUM'].substring(0,10) + ', ' + v.language.photo + pic['FNAMN'] + ' ' + pic['ENAMN'] + pic['WEBTEXT']; 368 let photoSide = '<div class="d-flex justify-content-center">'; 369 photoSide += '<a href="/galleri/#maxipic-' + pic['ID'] + '.jpg"><img src="/v2images/minipics/minipic-' + pic['ID'] + '.jpg" alt="icon" class="fboPhotoHomeBottom rounded img-fluid" title="' + titleText +'"></a>'; 370 photoSide += '</div>'; 371 v.gallerySection.append(photoSide); 372 373 let photoBottom = '<div class="fboPhotoHomeBottom">'; 374 photoBottom += '<a href="/galleri/#maxipic-' + pic['ID'] + '.jpg"><img src="/v2images/minipics/minipic-' + pic['ID'] + '.jpg" alt="icon" class="rounded img-fluid" title="' + titleText +'"></a>'; 375 photoBottom += '</div>'; 376 v.gallerySectionBottom.append(photoBottom); 377 378 }) 379 380 } 381 382 383 function loadAllData(){ 384 385 $.ajax({
386 type:"GET", 387 async: true, 388 url: "../api/getHomePageData.php?lang=" + v.language.current, 389 success: function(d) { 390 391 v.allData = JSON.parse(d); 392 393 loadImages(); 394 populateWeatherInfo(); 395 396 buildNewsSection(); 397 398 } 399 400 }) 401 402 } 403 404 405 $(document).on('click', '.btnVisibleMigration', function(){ 406 407 const clickedId = $(this).attr('id'); 408 const s = 'visibleMigrationSectionBody-' + clickedId.substring(clickedId.length-10); 409 410 let visibleMigrationSection = $('#'+s); 411 412 if (visibleMigrationSection.hasClass('mg-hide-element')){ 413 visibleMigrationSection.toggleClass('mg-hide-element', false); 414 $(this).text(v.visibleMigrationSection.language.hideData); 415 } else { 416 visibleMigrationSection.toggleClass('mg-hide-element', true); 417 $(this).text(v.visibleMigrationSection.language.showData); 418 } 419 420 }); 421 422 getTexts(); 423 setTexts(); 424 v.blogDay.node.html(mgGetDivWithSpinnerImg()); 425 426 v.date.current = getNowAsYMD(); 427 $('#introDayData').text(capitalizeFirstLetter(getFormattedDate(v.date.current, v))); 428 429 430 populateIntro(); 431 loadAllData(); 432 433 434});
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.