PageSourceSearch

https://superleague.co.uk/plugins/match_slider/script.js

js superleague.co.uk collected 2026-10-02 07:23:11 UTC 8,414 bytes, 340 lines download raw bytes

1//console.log('match slider loaded 2');
2
3
4
5function loadSlick(){
6	// news video slider
7	// console.log('load slick');
8	if( $('.match-center-slider').length ) {
9		
10		let element = $('.match-center-slider');
11		let params = element.data('params');
12
13		console.log(params);
14
15		console.log('slider loaded');
16		element.slick({
17			arrows: true,
18			prevArrow: '<div class="video-left"><i class="far fa-chevron-left"></i></div>',
19			nextArrow: '<div class="video-right"><i class="far fa-chevron-right"></i></div>',
20			dots: false,
21			slidesToShow: 4,
22			slidesToScroll: 1,
23			responsive: [
24				{
25					breakpoint: 1200,
26					settings: {
27					slidesToShow: 3,
28					slidesToScroll: 3,
29					}
30				},
31				{
32					breakpoint: 993,
33					settings: {
34					slidesToShow: 2,
35					slidesToScroll: 2
36					}
37				},
38				{
39					breakpoint: 769,
40					settings: {
41					slidesToShow: 1,
42					slidesToScroll: 1
43					}
44				}
45				],
46			autoplay: false,
47			autoplaySpeed: 5000,
48			adaptiveHeight: true,
49			infinite: false,
50		});
51		element.on("afterChange", function() {
52			slide = $(this).slick('slickCurrentSlide');
53			total = $(this)[0].slick.slideCount;
54
55			var pos = ((100 / total) * slide);
56			$(this).parent().find('.slick-nav-bar .progress').css({'left':pos+'%'});
57			console.log('afterChange');
58		});
59		element.on("setPosition", function() {
60			$('.wow',this).addClass('wow-visible');
61			console.log('setPosition');
62		});
63		element.slick('slickGoTo',params.desktopViewStart,true);
64
65		
66	}
67	
68
69}
70
71function otherSliders(){
72	
73	$('.rl-slick-feature-slider').slick({
74		arrows: false,
75		//prevArrow: false,
76		//nextArrow: false,
77		dots: true,
78		slidesToShow: 1,
79		slidesToScroll: 1,
80		autoplay: true,
81		autoplaySpeed: 5000,
82		adaptiveHeight: true
83	});
84
85	$('.rl-slick-match-slider').slick({
86		arrows: false,
87		//prevArrow: false,
88		//nextArrow: false,
89		dots: false,
90		slidesToShow: 1,
91		slidesToScroll: 1,
92		autoplay: false,
93		autoplaySpeed: 5000,
94		adaptiveHeight: true,
95		infinite: false
96	});
97
98	// get total matches panels
99	var totalMatches = $('.rl-slick-match-slider .matches').length;
100
101	// determin which panel to load on
102	var slideToLoad = $('.rl-slick-match-slider').data("load-panel");
103	var dates = $('.rl-slick-match-slider').data("all-dates");
104
105
106	$('.rl-slick-match-slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
107	  console.log('test slide ',nextSlide);
108	});
109
110	$('.controls .next').click(function(e){
111		e.preventDefault();
112		$('.rl-slick-match-slider').slick('slickNext');
113	});
114	$('.controls .prev').click(function(e){
115		e.preventDefault();
116		$('.rl-slick-match-slider').slick('slickPrev');
117	});
118
119	// after the matches slide determin whether to show the nav controls
120	$('.rl-slick-match-slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
121	  	display_nav_controls(currentSlide,totalMatches,dates);
122	});
123
124	// slide to the right slide
125	$('.rl-slick-match-slider').slick('slickGoTo',slideToLoad,true);
126	display_nav_controls(slideToLoad,totalMatches,dates);
127
128
129	function display_nav_controls(currentSlide,totalMatches,dates) {
130		
131		if( (currentSlide+1) ==totalMatches) {
132		  $('.controls .next').hide();
133		} else {
134		  $('.controls .next').show().find('span').html(dates[currentSlide+2]);
135		}
136		if(currentSlide==0) {
137		  $('.controls .prev').hide();
138		} else {
139		  $('.controls .prev').show().find('span').html(dates[currentSlide]);
140		}
141
142		$('.current-date').html(dates[currentSlide+1]);
143
144	}
145
146	// poll live match data
147	var matchesToPoll = new Array();
148	var liveMatches = false;
149	$('.rl-slick-match-slider .matches').each(function(i) {
150		if( $(this).data('live')=='yes') {
151
152			$(this).find('.match').each(function(m){
153				matchID = $(this).data('match-id');
154				matchesToPoll.push(matchID);
155			});
156
157			liveMatches = true;
158		}
159
160	});
161
162	// now poll the live matches
163	if(liveMatches) {
164
165		var params = {'matches':matchesToPoll.toString(), 'type':'score'};
166
167		setInterval(function(){ 
168
169			$.ajax({
170				url: '/ajaxAPI',
171				data: {'ajax': 1,'type':'loadPlugin','plugin':'match_slider','params':params}
172			}).done(function(data){
173				
174				var mID = 0;
175
176				jsonData = JSON.parse(data);
177
178				//console.log(jsonData);
179				
180				// remove these two lines after testing
181				//jsonData = {"3620":{"matchID":"3620","match_latest":"20:30<br \/><span class=\"uk-kickoff\">UK: 19:30<\/span>"},"3621":{"matchID":"3621","match_latest":"20:00"},"3623":{"matchID":"3623","match_latest":"20:00"},"3622":{"matchID":"3622","match_latest":"10-20"}};
182				//console.log(jsonData);
183
184				// mobile view
185				$('.rl-slick-match-slider .matches').each(function(i) {
186					if( $(this).data('live')=='yes') {
187						$(this).find('.match').each(function(e){
188							mID = $(this).data('match-id');
189							newData = jsonData[mID];
190							if(newData) {
191								$(this).find('.match-latest').html(newData.match_latest);
192								$(this).find('.match-inplay-status').html(newData.match_inplay_status);
193							}
194
195						});
196					}
197				});
198
199				// desktop view
200				$('.match-center-slider .match').each(function(i) {
201					mID = $(this).data('match-id');
202					newData = jsonData[mID];
203					if(newData) {
204						//console.log(newData,mID);
205						$(this).find('.match-latest').html(newData.match_latest);
206						$(this).find('.match-inplay-status').html(newData.match_inplay_status);
207					}
208				});
209
210			});
211
212		}, 10000);
213
214	}
215
216}
217
218
219function initialise_clicks() {
220	$('a.switch-comp').off().on('click',function(e){
221
222		e.preventDefault();
223		$('a.switch-comp').removeClass('active');
224		$(this).addClass('active');
225
226		if($(this).data('type') == 'mobile') {
227			params = $('.rugby-league-feature-match-slider').data("params");
228			parentPlugin = $('#home-match-slider');
229			// var slider = '.rl-slick-match-slider';
230			var slider = '.rugby-league-feature-match-slider';
231		} else {
232			params = $(this).parents('.news-grid-videos-slider-plugin').data("params");
233			parentPlugin = $(this).parents('.news-grid-videos-slider-plugin');
234			var slider = '.match-center-slider';
235		}
236		// parentPlugin = $('.news-grid-videos-slider-plugin');
237
238		params.compID = $(this).data('comp-id');
239
240		loadMatches(slider,params);
241
242		
243	});
244	
245}
246
247
248function loadMatches(slider,params) {
249
250	// load data
251	// parentPlugin.find(slider).load('/ajaxAPI '+ slider +' > *',{'ajax': 1,'type':'loadPlugin','plugin':'match_slider','params':params}, function(response, status, xhr) {
252	// 	// $('.rl-slick-match-slider').slick('reInit');
253	// 	const sliders = document.querySelectorAll('.slick-initialized');
254	// 	sliders.forEach(item => {
255	// 		$(item).slick('unslick');
256	// 	})
257	// 	loadSlick();
258	// 	otherSliders();
259	// 	initialise_clicks();
260	// });
261
262	$.ajax({
263		url: '/ajaxAPI',
264		type: 'POST',
265		data: {'ajax': 1,'type':'loadPlugin','plugin':'match_slider','params':params},
266		dataType: 'HTML'
267	}).done(function(data){
268		const sliders = document.querySelectorAll('.slick-initialized');
269		sliders.forEach(item => {
270			$(item).slick('unslick');
271		})
272		let divParentId = parentPlugin.parents('[data-parent]').attr('id');		
273		if (!divParentId) {
274			divParentId = parentPlugin.find('[data-parent]').attr('id');
275		}
276		$(document.getElementById(divParentId)).html(data);
277		loadSlick();
278		otherSliders();
279		initialise_clicks();
280	});
281
282
283}
284
285
286$(function() {
287
288	//console.log(matchesToPoll.toString());
289		
290
291		// console.log('live data');
292
293		// var params = {'divisionID':1};
294
295		// parentPlugin = $('.rugby-league-feature-match-slider');
296
297		// setInterval(function(){ 
298		// // load data
299		// 	parentPlugin.find('.rl-slick-match-slider').load('/ajaxAPI .rl-slick-match-slider > *',{'ajax': 1,'type':'loadPlugin','plugin':'feature_match_slider','params':params}, function(response, status, xhr) {
300		// 		console.log('new data');
301		// 	});
302
303		// }, 3000);
304
305		loadSlick();
306		otherSliders();
307
308		initialise_clicks();
309
310
311	// $('a.switch-comp').click(function(e){
312
313	// 	e.preventDefault();
314
315		
316	// 	if($(this).data('type') == 'mobile') {
317	// 		params = $('.rugby-league-feature-match-slider').data("params");
318	// 		parentPlugin = $('#home-match-slider');
319	// 		// var slider = '.rl-slick-match-slider';
320	// 		var slider = '.rugby-league-feature-match-slider';
321	// 	} else {
322	// 		params = $(this).parents('.news-grid-videos-slider-plugin').data("params");
323	// 		parentPlugin = $(this).parents('.news-grid-videos-slider-plugin');
324	// 		var slider = '.match-center-slider';
325	// 	}
326	// 	// parentPlugin = $('.news-grid-videos-slider-plugin');
327
328	// 	params.compID = $(this).data('comp-id');
329
330
331		
332
333	// });
334
335
336
337
338
339	
340});

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.