PageSourceSearch

https://seattlespectator.com/wp-content/plugins/radio-station/js/radio-station.js?ver=1782810088

js seattlespectator.com collected 2026-10-02 07:46:34 UTC 9,844 bytes, 256 lines download raw bytes

1/* -------------------- */
2/* Radio Station Script */
3/* -------------------- */
4
5/* Shortened Helpers */
6function radio_el(id) {return document.getElementById(id);}
7function radio_els(classname) {return document.getElementsByClassName(classname);}
8
9/* Smooth Scrolling */
10function radio_scroll_to(id) {
11	elem = document.getElementById(id);
12	var jump = parseInt((elem.getBoundingClientRect().top - 50) * .2);
13	document.body.scrollTop += jump;
14	document.documentElement.scrollTop += jump;
15	if (!elem.lastjump || elem.lastjump > Math.abs(jump)) {
16		elem.lastjump = Math.abs(jump);
17		setTimeout(function() { radio_scroll_to(id);}, 100);
18	} else {elem.lastjump = null;}
19}
20
21/* Get Day of Week */
22function radio_get_weekday(d) {
23	if (d == '0') {day = 'sunday';}
24	else if (d == '1') {day = 'monday';}
25	else if (d == '2') {day = 'tuesday';}
26	else if (d == '3') {day = 'wednesday';}
27	else if (d == '4') {day = 'thursday';}
28	else if (d == '5') {day = 'friday';}
29	else if (d == '6') {day = 'saturday';}
30	return day;
31}
32
33/* Cookie Value Function */
34/* since @2.3.2 */
35radio_cookie = {
36	set: function (name, value, days) {
37		if (days) {
38			var date = new Date();
39			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
40			var expires = '; expires=' + date.toUTCString();
41		} else {var expires = '';}
42		document.cookie = 'radio_' + name + '=' + JSON.stringify(value) + expires + '; path=/';
43	},
44	get : function(name) {
45		var nameeq = 'radio_' + name + '=', ca = document.cookie.split(';');
46		for(var i=0; i < ca.length; i++) {
47			var c = ca[i];
48			while (c.charAt(0) == ' ') {
49				c = c.substring(1,c.length);
50				if (c.indexOf(nameeq) == 0) {
51					/* 2.5.0: fix for possible empty value */
52					value = c.substring(nameeq.length, c.length).trim();
53					if ((value == '') || (value == 'undefined') || (typeof value == 'undefined')) {return null;}
54					return JSON.parse(value);
55				}
56			}
57		}
58		return null;
59	},
60	delete : function(name) {
61		document.cookie = 'radio_' + name +  '=; expires=-1; path=/';
62	}
63}
64
65/* Debounce Delay Callback */
66var radio_resize_debounce = (function () {
67	var debounce_timers = {};
68	return function (callback, ms, uniqueId) {
69		if (!uniqueId) {uniqueId = "nonuniqueid";}
70		if (debounce_timers[uniqueId]) {clearTimeout (debounce_timers[uniqueId]);}
71		debounce_timers[uniqueId] = setTimeout(callback, ms);
72	};
73})();
74
75/* User Timezone Display */
76function radio_timezone_display() {
77	if (typeof radio_display_override == 'function') {
78		override = radio_display_override();
79		if (override) {return;}
80	}
81	/* 2.5.18: display for both clock and timezone shortcodes */
82	if (jQuery('.radio-user-zone').length || jQuery('.radio-user-timezone').length) {
83		userdatetime = new Date();
84		useroffset = -(userdatetime.getTimezoneOffset());
85		/* if ((useroffset * 60) == radio.timezone.offset) {return;} */
86		if (typeof jstz == 'function') {tz = jstz.determine().name();}
87		else {tz = Intl.DateTimeFormat().resolvedOptions().timeZone;}
88		if (tz.indexOf('/') > -1) {
89			tz = tz.replace('_',' '); parts = tz.split('/');
90			region = parts[0]; loc = parts[1];
91			code = radio_timezone_code(tz); /* console.log(code); */
92			/* console.log(radio.timezone.zonename_override); */
93			if ((typeof radio.timezone.zonename_override != 'undefined') && radio.timezone.zonename_override) {code = radio.timezone.zonename_override;}
94			if (jQuery('.radio-user-zone').length) {
95				jQuery('.radio-user-zone-title').css('display','inline-block');
96				jQuery('.radio-user-zone').each(function() {
97					format = jQuery(this).attr('data-format');
98					formatted = radio_timezone_format(format,code,region,loc,useroffset);
99					jQuery(this).html(formatted).css('display','inline-block');					
100				});
101			}			
102			if (jQuery('.radio-user-timezone').length) {
103				jQuery('.radio-user-timezone-title').css('display','inline-block');
104				jQuery('.radio-user-timezone').each(function() {
105					format = jQuery(this).attr('data-format');
106					formatted = radio_timezone_format(format,code,region,loc,useroffset);
107					jQuery(this).html(formatted).css('display','inline-block');
108				});
109				
110			}
111		}
112	}
113}
114
115/* Format Timezone Display */
116function radio_timezone_format(format,code,region,loc,offset) {
117	houroffset = parseInt(offset);
118	if (houroffset == 0) {userzone = ' [UTC]';}
119	else {
120		houroffset = houroffset / 60;
121		if (houroffset > 0) {userzone = ' [UTC+'+houroffset+']';}
122		else {userzone = ' [UTC'+houroffset+']';}
123	}
124	f = format.split('-'); formatted = '';
125	if ((f[0] == '1') && (code != '')) {formatted += code+' ';}
126	if ((f[1] == '1') || (f[2] == '1')) {
127		if ((f[0] == '1') && (code != '')) {formatted += '(';}
128		if (f[2] == '1') {formatted += loc;}
129		if ((f[1] == '1') && (f[2] == '1')) {formatted += ', ';}	
130		if (f[1] == '1') {formatted += region;}
131		if ((f[0] == '1') && (code != '')) {formatted += ')';}
132	}
133	if (f[3] == '1') {formatted += ' '+userzone;}
134	return formatted;
135}
136
137/* Get Timezone Code */
138function radio_timezone_code(timezone) {
139	datetime = new Date();
140	if ((typeof moment == 'function') && (typeof moment.tz == 'function')) {
141		zonetimedate = moment(datetime.toISOString()).tz(timezone);
142		code = zonetimedate.format('z');
143	} else {
144		locale = 'en-US';
145		formatter = new Intl.DateTimeFormat(locale, {timeZone: timezone, timeZoneName: 'short'});
146		timezoneparts = formatter.formatToParts(datetime).find(part => part.type === 'timeZoneName');
147		if (timezoneparts) {code = timezoneparts.value;} else {code = '';}
148		if (code.indexOf('GMT') > -1) {code = '';}
149	}
150	return code;
151}
152
153/* Retrigger Responsive Schedules */
154function radio_responsive_schedules() {
155	if (jQuery('.master-program-schedule').length) {radio_table_responsive(false,false);}
156	if (jQuery('.master-schedule-tabs').length) {radio_tabs_responsive(false,false);}
157	if (jQuery('.master-schedule-grid').length) {radio_grid_responsive(false);}
158	if (jQuery('.master-schedule-calendar').length) {radio_calendar_responsive(false);}
159}
160
161/* Update Time Displays */
162function radio_convert_times() {
163	/* schedule: .show-time; widgets: .current-shift, .upcoming-show-schedule; show page: .show-shift-time, .override-time, subscribe: .show-list-time */
164	jQuery('.show-time, .current-shift, .upcoming-show-shift, .show-shift-time, .override-time, .show-list-time').each(function() {
165		/* console.log(jQuery(this)); */
166		if (radio.convert_show_times || jQuery(this).hasClass('show-list-time')) {
167			start = jQuery(this).find('.rs-start-time');
168			end = jQuery(this).find('.rs-end-time');
169			starthtml = start.html(); starttime = start.attr('data'); startformat = start.attr('data-format');
170			endhtml = end.html(); endtime = end.attr('data'); endformat = end.attr('data-format');
171			startdisplay = radio_user_time(starttime, startformat);
172			enddisplay = radio_user_time(endtime, endformat);
173			if (jQuery(this).find('.rs-day').length) {
174				dayhtml = jQuery(this).find('.rs-day').html();
175				dayformat = jQuery(this).find('.rs-day').attr('data-format');
176				userday = radio_user_time(starttime, dayformat);
177			}
178			if ((starthtml != startdisplay) || (endhtml != enddisplay)) {
179				if (radio.debug) {console.log('Start: '+starthtml+' => '+startdisplay+' - End: '+endhtml+' => '+enddisplay);}
180				showusertime = jQuery(this).parent().find('.show-user-time').show();
181				showusertime.find('.rs-start-time').html(startdisplay);
182				showusertime.find('.rs-end-time').html(enddisplay);
183				if (showusertime.find('.rs-day').length) {
184					if (dayhtml != userday) {daydisplay = userday;} else {daydisplay = '';}
185					if (radio.debug) {console.log('Day: '+dayhtml+' => '+daydisplay);}
186					showusertime.find('.rs-day').html(daydisplay);
187				}
188			} else {jQuery(this).parent().find('.show-user-time').hide();}
189			if (jQuery(this).find('.rs-start-date').length) {
190				date = jQuery(this).find('.rs-start-date');
191				datehtml = date.html(); datetime = date.attr('data'); dateformat = date.attr('data-format');
192				datedisplay = radio_user_time(datetime, dateformat);
193				if (datehtml == datedisplay) {datedisplay = '';}
194				if (radio.debug) {console.log('Date: '+datehtml+' => '+datedisplay);}
195				showusertime = jQuery(this).parent().find('.show-user-time');
196				showusertime.find('.rs-start-date').html(datedisplay);
197			}
198		}
199	});
200	if (radio.convert_show_times && jQuery('.show-time').length) {radio_responsive_schedules();}
201}
202
203/* Convert To Time Display */
204function radio_user_time(time, format) {
205	if (typeof radio_user_override == 'function') {
206		override = radio_user_override(time, format);
207		if (override) {return override;}
208	}
209	datetime = new Date(time * 1000);
210	zonetime = moment(datetime.toISOString());
211	formatted = radio_convert_time(zonetime, format);
212	return formatted;
213}
214
215/* Convert Time to Formatted Time */
216function radio_convert_time(zonetime, format) {
217	formatted = '';
218	for (var i = 0; i < format.length; i++) {
219	    k = format.charAt(i);
220	    v = radio_format_key(zonetime, k);
221	    formatted += v;
222	}
223	return formatted;
224}
225
226/* Format Time Key */
227function radio_format_key(zonetime, key) {
228	v = key;
229	for (i in radio.moment_map) {
230		if (i == key) {
231			k = radio.moment_map[i];
232			v = zonetime.format(k);
233			if (((i == 'd') || (i == 'm') || (i == 'h') || (i == 'H') || (i == 'i') || (i == 's')) && (v < 10)) {v = '0'+v;}
234			else if (i == 'D') {v = radio.labels.sdays[v];}
235			else if (i == 'l') {v = radio.labels.days[v];}
236			else if (i == 'N') {v++;}
237			else if (i == 'S') {d = zonetime.format('D'); v.replace(d, '');}
238			else if (i == 'F') {v = radio.labels.months[v];}
239			else if (i == 'M') {v = radio.labels.smonths[v];}
240			else if ((i == 'a') || (i == 'A')) {
241				if (v.substr(0,1) == 'a') {v = radio.units.am;}
242				if (v.substr(0,1) == 'p') {v = radio.units.pm;}
243				if (i == 'A') {v = v.toUpperCase();}
244			}
245		}
246	}
247	return v;
248}
249
250/* Pageload Function */
251if (typeof jQuery == 'function') {
252	jQuery(document).ready(function() {
253		radio_timezone_display();
254		radio_convert_times();
255	});
256}

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.