PageSourceSearch

https://www.thanet.gov.uk/wp-content/themes/thanet/js/covid-popup.js?ver=1.0.7

js thanet.gov.uk collected 2026-10-02 05:21:34 UTC 5,754 bytes, 132 lines download raw bytes

1(function ($) {
2	"use strict";
3	if ($(".covid-19-btn").length > 0) {
4		var england = false,
5			thanet = false,
6			latestDate = 0,
7			latestDateStats = 0,
8			normThisWeek = 0,
9			engNormThisWeek = 0,
10			thisWeek = 0,
11			weekDiff = 0,
12			weekDiffDir = '',
13			totalCases = 0,
14			deaths = 0,
15			deathsDate = "",
16			urls = {
17				thanet:
18					'https://api.coronavirus.data.gov.uk/v1/data?filters=areaType=ltla;areaName=thanet&structure={"date":"date","areaName":"areaName","areaCode":"areaCode","newCasesByPublishDate":"newCasesByPublishDate","cumCasesByPublishDate":"cumCasesByPublishDate","newDeathsByDeathDate":"newDeathsByDeathDate","cumDeathsByDeathDate":"cumDeaths28DaysByPublishDate", "newCasesBySpecimenDate" : "newCasesBySpecimenDate", "newCasesBySpecimenDateRollingSum": "newCasesBySpecimenDateRollingSum", "newCasesBySpecimenDateRollingRate":"newCasesBySpecimenDateRollingRate", "cumOnsDeathsByRegistrationDate":"cumOnsDeathsByRegistrationDate", "newCasesBySpecimenDateChange":"newCasesBySpecimenDateChange", "newCasesBySpecimenDateDirection":"newCasesBySpecimenDateDirection"}',
19				england:
20					'https://api.coronavirus.data.gov.uk/v1/data?filters=areaType=nation;areaName=england&structure={"date":"date","areaName":"areaName","areaCode":"areaCode","newCasesByPublishDate":"newCasesByPublishDate","cumCasesByPublishDate":"cumCasesByPublishDate","newDeathsByDeathDate":"newDeathsByDeathDate","cumDeathsByDeathDate":"cumDeaths28DaysByPublishDate", "newCasesBySpecimenDate" : "newCasesBySpecimenDate", "newCasesBySpecimenDateRollingSum": "newCasesBySpecimenDateRollingSum", "newCasesBySpecimenDateRollingRate":"newCasesBySpecimenDateRollingRate", "cumOnsDeathsByRegistrationDate":"cumOnsDeathsByRegistrationDate", "newCasesBySpecimenDateChange":"newCasesBySpecimenDateChange", "newCasesBySpecimenDateDirection":"newCasesBySpecimenDateDirection"}',
21			};
22		$.ajax({
23			url: encodeURI(urls.thanet),
24			cache: false,
25			method: "GET",
26		})
27			.done(function (json) {
28				if (json) {
29					if (json.data) {
30						thanet = json.data;
31						handleData();
32					}
33				}
34			})
35			.fail(function (msg) {
36				console.log("Ajax Failed");
37			});
38		$.ajax({
39			url: encodeURI(urls.england),
40			cache: false,
41			method: "GET",
42		})
43			.done(function (json) {
44				if (json) {
45					if (json.data) {
46						england = json.data;
47						handleData();
48					}
49				}
50			})
51			.fail(function (msg) {
52				console.log("Ajax Failed");
53			});
54
55		function handleData() {
56			if (thanet && england) {
57				var start = 0,
58					end   = start + 50;
59				for (var i = start; i < end; i++) {
60					if (start === i) {
61						totalCases = thanet[i].cumCasesByPublishDate;
62						latestDate = thanet[i].date;
63					}
64					deaths = deaths
65						? deaths
66						: thanet[i].cumOnsDeathsByRegistrationDate;
67					deathsDate = deaths && ! deathsDate ? thanet[i].date : deathsDate;
68					thisWeek = thisWeek ? thisWeek : thanet[i].newCasesBySpecimenDateRollingSum;
69					normThisWeek = thisWeek && ! normThisWeek ? thanet[i].newCasesBySpecimenDateRollingRate : normThisWeek;
70					latestDateStats = thisWeek && ! latestDateStats ? thanet[i].date : latestDateStats;
71					engNormThisWeek = thisWeek && ! engNormThisWeek ? england[i].newCasesBySpecimenDateRollingRate : engNormThisWeek;
72					weekDiff = thisWeek && ! weekDiff ? thanet[i].newCasesBySpecimenDateChange : weekDiff;
73					weekDiffDir = thisWeek && ! weekDiffDir ? thanet[i].newCasesBySpecimenDateDirection : weekDiffDir;
74				}
75				deathsDate = deathsDate.split("-");
76				var ltDate = latestDate.split("-");
77				var ltDateStats = latestDateStats.split("-");
78				var avgComp = engNormThisWeek > normThisWeek ? "Below" : "Above";
79				var sixDaysAgo = new Date(
80					new Date().getTime() -( 60 * 60 * 24 * 1000 * 6 )
81				);
82				if (weekDiffDir === 'UP') {
83					$(".covid-badge-up").css("display","flex");
84				} else {
85					$(".covid-badge-down").css("display","flex");
86				}
87				$("#daily-deaths").html(deaths);
88				$("#avg-comparison").html(avgComp);
89				$("#deaths-date").html( deathsDate[2] + '/' + deathsDate[1] + '/' + deathsDate[0].replace('2020', '20' ) );
90				$(".covid-lt-date").html( ltDate[2] + '/' + ltDate[1] + '/' + ltDate[0].replace('2020', '20' ) );
91				$(".covid-lt-date-stats").html( ltDateStats[2] + '/' + ltDateStats[1] + '/' + ltDateStats[0].replace('2020', '20' ) );
92				$(".covid-weekly-diff").html(weekDiff);
93				$('.six-days-ago').html( sixDaysAgo.toLocaleDateString('en-UK').split('/')[1] + '/' + sixDaysAgo.toLocaleDateString('en-UK').split('/')[0] + '/' + sixDaysAgo.toLocaleDateString('en-UK').split('/')[2] )
94				$("#nat-weekly-cases-normalized").html(
95					(engNormThisWeek)
96				);
97				$("#weekly-cases-normalized").html((normThisWeek));
98				$("#weekly-cases").html(thisWeek);
99				$("#total-cases").html(totalCases);
100				$(".covid-19-btn, .close-popup-img").click(function () {
101                    if ( $(this).hasClass("active") ) {
102                        $(this).attr("tabindex","0");
103                    } else {
104						$(this).attr("tabindex","3");
105						setTimeout(function(){ $(".banner-header a").focus(); }, 500);
106                    }
107					$(".covid-19-btn").toggleClass("active");
108					$(".covid-19-banner").toggleClass("active");
109					if (
110						typeof Cookies.get("thanet_covid_" + latestDate) ===
111						"undefined"
112					) {
113						Cookies.set("thanet_covid_" + latestDate, "true", {
114							expires: new Date(
115								new Date().getTime() + 60 * 60 * 24 * 1000
116							),
117						});
118					}
119				});
120				$(".covid-19-btn").removeClass("spinning");
121				if (
122					typeof Cookies.get("thanet_covid_" + latestDate) ===
123					"undefined"
124				) {
125					$(".covid-19-btn").toggleClass("active");
126					$(".covid-19-banner").toggleClass("active");
127					$(".covid-19-btn").attr("tabindex","3");
128				}
129			}
130		}
131	}
132})(jQuery);

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.