PageSourceSearch

https://radiolom-msk.ru/themes/custom/forest/js/utils.js

js radiolom-msk.ru collected 2026-10-04 13:24:05 UTC 10,014 bytes, 245 lines download raw bytes

1//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2function mainMenu() {
3	document.getElementById("menu__main").classList.toggle("menu__main--active");
4	document.getElementById("fader--menu__main").classList.toggle("fader--active");
5}
6
7function popupUser() {
8	document.getElementById("popup-user").classList.toggle("popup-user--active");
9}
10
11window.addEventListener('load', function () {
12	const superbrands = document.querySelector('.superbrands');
13	if (!superbrands) return;
14
15	const alreadyScrolled = window.scrollY > 500;
16
17	if (!alreadyScrolled) {
18		// Dacă NU e scrollat deja, eliminăm clasa după 0.5 secunde
19		setTimeout(() => {
20			superbrands.classList.remove('superbrands--hidden');
21		}, 100);
22	}
23
24	// Scroll handler: adaugă clasa dacă se scrollează peste 500px
25	function onScroll() {
26		if (window.scrollY > 500) {
27			superbrands.classList.add('superbrands--hidden');
28			window.removeEventListener('scroll', onScroll);
29		}
30	}
31
32	// Dacă nu e deja scrollat, ascultăm scroll-ul
33	if (!alreadyScrolled) {
34		window.addEventListener('scroll', onScroll);
35	}
36});
37
38document.addEventListener('DOMContentLoaded', function(){
39
40	$(".__sablon5").each( function (){
41
42		const el = $(this);
43		el.data( "page", 1 );
44		el.find( ".__sablon5--left" ).on( "click", function(){
45			sablon5Scroll( el, -1 );
46		});
47		el.find( ".__sablon5--right" ).on( "click", function(){
48			sablon5Scroll( el, 1 );
49		});
50
51	});
52
53});
54
55function sablon5Scroll( el, direction ){
56
57	const wrapper = el.find( ".__sablon5--wrapper" );
58	let page = el.data( "page" );
59	let pages = Math.ceil( wrapper.children().length / 5 );
60	let lastIndex = wrapper.children().length - 5;
61
62	if( page == pages && direction == 1 ){
63		el.data( "page", 1 )
64		sablon5ScrollToIndex(wrapper, 0);
65		return;
66	}
67	if ( page == 1 && direction == -1 ){
68		el.data( "page", pages )
69		sablon5ScrollToIndex(wrapper, lastIndex);
70		return;
71	}
72
73	page+= direction;
74	el.data( "page", page )
75	index = Math.min( lastIndex, 5*(page - 1) );
76	sablon5ScrollToIndex( wrapper, index );
77
78}
79
80function sablon5ScrollToIndex( el, index ){
81	el.css( "transform", "translateX(calc(-" + 20*index + "% - " + 6*index + "px))" );
82}
83
84var scrollPosition = window.scrollY;
85var logoContainer = document.getElementsByClassName('header')[0];
86window.addEventListener('scroll', function() {
87	scrollPosition = window.scrollY;
88	if (scrollPosition >= 62) {
89		logoContainer.classList.add('header--scroll');
90	} else {
91		logoContainer.classList.remove('header--scroll');
92	}
93});
94//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
95
96document.addEventListener('DOMContentLoaded', function(){
97
98	new WOW().init();
99	$("#__content iframe").each(function(){
100		if ( $(this).hasClass( "__youtube" ) ){
101			if ( !$(this).parent().is("#__content") ) $(this).unwrap();
102			$(this).wrap( "<figure><div class='thumb video-deschidere'></div></figure>");
103		}
104	});
105	$("#__content a").each(function(){$(this).attr("target", "_blank");});
106
107	$("form.comentariu-nou").on("submit", function(e){
108		e.preventDefault();
109		data = {id:$(this).data("id"), text:$("#field3").val()};
110		if ( !data.text ){ $("#field3").focus();return;}
111
112		$.post( BASE_URL + "api/comment.post.php", data).done(function(response){
113			if ( response.success ){
114				$("#__comments").show();
115				$("#__comments").append( response.html );
116			}
117
118		});
119
120		$("#field3").val("");
121	});
122
123	if ( $(".articol-wrapper").length && $(".articol-wrapper").first().data("id") ){
124		$.get( BASE_URL + "api/news.hits.php", {id: $(".articol-wrapper").first().data("id") });
125	}
126
127	if ( $(".articol--program").length ){
128		$(".program__zile a").each( function(index){
129			$(this).on( "click", function(e){
130				e.preventDefault();
131				$(".__day").hide();
132				$(".program__zile a").removeClass( "active" );
133				$(".__day").eq(index).show();
134				$(".program__zile a").eq(index).addClass( "active" );
135			});
136		});
137	}
138
139	var servertime=0;
140	var serverrequestsent = false;
141	if ( $(".widget-live__posturi").length || $( "#__player" ).length ) {
142
143		setInterval(function () {
144
145			if ( $( "#__player" ).length && $(".player").data("duration")) {
146				$(".player").data("elapsed", $(".player").data("elapsed") + 1);
147				let elapsed = 100 * $(".player").data("elapsed") / $(".player").data("duration");
148				if (elapsed > 100) elapsed = 100;
149				$(".player .player__timeline__progress").css("width", elapsed + "%");
150			}
151			$(".widget-live .widget-live__post").each(function () {
152				if ( $(this).data( "duration" ) ){
153					$(this).data("elapsed", $(this).data("elapsed") + 1);
154					let elapsed = 100 * $(this).data("elapsed") / $(this).data("duration");
155					if (elapsed > 100) elapsed = 100;
156					$(this).find(".widget-live__post__progress__inner").css("width", elapsed + "%");
157				}else{
158					$(this).find(".widget-live__post__progress__inner").css("width", "100%");
159				}
160			});
161		}, 1000);
162
163		setInterval( function(){
164
165			if ( servertime ) servertime+= 30;
166			let sendrequest = false;
167			if ( servertime ){
168				$(".widget-live .widget-live__post").each(function () {
169					if ( $(this).data( "endtime" ) && servertime >= $(this).data( "endtime" ) ){
170						sendrequest = true;
171					}
172				});
173			}
174
175			if ( !serverrequestsent && ( !servertime || sendrequest ) ){
176				if ( sendrequest ) console.log( "sendrequest = true -> Send request at " + ( new Date( 1000 * servertime ) ) );
177				if ( !servertime ) console.log( "servertime = 0 -> Send request at " + ( new Date( 1000 * servertime ) ) );
178
179				let params = $("#__player").length ? {id: $(".player").data("id"), pid: $(".player").data("pid") } : {};
180				serverrequestsent = true;
181
182        // $.get( "https://www.romania-actualitati.ro/api/live.php", params).done(function (response) {
183				// 	//console.log(response);
184        //
185				// 	serverrequestsent = false;
186				// 	servertime = response.time;
187				// 	console.log( "New servertime " + ( new Date( 1000 * servertime ) ) );
188				// 	console.log( "________________________________________________________" );
189				// 	$(".widget-live .widget-live__post").each(function () {
190				// 		if ( !$(this).data( "active" ) ) return;
191				// 		let id = $(this).data("id");
192				// 		$(this).find(".widget-live__post__ora").html(response.stations[id] ? response.stations[id].schedule : "Acum live");
193				// 		$(this).find(".widget-live__post__emisiune").html(response.stations[id] ? response.stations[id].title : $(this).data( "name" ) );
194				// 		$(this).data( "duration", response.stations[id] ? response.stations[id].duration : 0 );
195				// 		$(this).data( "elapsed", response.stations[id] ? response.stations[id].elapsed : 0 );
196				// 		$(this).data( "endtime", response.stations[id] ? response.stations[id].endtime : 0 );
197				// 		//$(this).find(".widget-live__post__progress__inner").css("width", response.stations[id] ? response.stations[id].elapsed : "0%");
198				// 	});
199        //
200				// 	if ($("#__player").length) {
201        //
202				// 		$(".program__item").each(function () {
203				// 			//if (!$(this).data("start")) return;
204				// 			if (response.time > $(this).data("start")) $(this).hide();
205				// 		});
206        //
207				// 		$(".player").data("elapsed", response.current.elapsed ? response.current.elapsed : 0);
208				// 		if (response.current.id != $(".player").data("pid")) {
209				// 			$(".player .thumb").html( response.current.image ? "<img src='" + response.current.image + "' />" : "" );
210				// 			$(".player .player__titlu").html(response.current.title ? response.current.title : "");
211				// 			$(".player .player__realizatori").html(response.current.subtitle ? response.current.subtitle : "").css( "display", response.current.subtitle ? "" : "none"  );
212				// 			$(".player .player__descriere").html(response.current.description ? response.current.description : "").css( "display", response.current.description ? "" : "none"  );
213				// 			$(".player .player__orar").html(response.current.schedule ? response.current.schedule : "").css( "display", response.current.schedule ? "" : "none"  );
214				// 			$(".player .player__timeline__start").html(response.current.start ? response.current.start : "");
215				// 			$(".player .player__timeline__end").html(response.current.stop ? response.current.stop : "");
216				// 			$(".player").data("duration", response.current.duration ? response.current.duration : 0);
217				// 		}
218				// 		$(".player").data("pid", response.current.id);
219        //
220				// 	}
221        //
222				// });
223
224			}
225		}, 30000 );
226
227	}
228
229});
230/******************************************************************************************************************************************************************************/
231function isValidEmail(email) {
232	var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
233	return pattern.test(email);
234};
235
236function parseYoutubeUrl(url){
237	var pattern = /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(\?\S*)?$/;
238	if(url.match(pattern)){
239		return url.match(pattern)[1];
240	}
241	return false;
242}
243/******************************************************************************************************************************************************************************/
244
245

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.