PageSourceSearch

https://www.startlapjatekok.hu/assets/javascripts/common.js

js startlapjatekok.hu collected 2026-10-02 18:24:31 UTC 11,517 bytes, 356 lines download raw bytes

1/**
2 * Common scripts
3 * @copyright	Concoder Hungary Kft © 2012		http://www.concoder.com
4 * @author		József Keresztesi				[email protected]
5 * @version		1.0
6 * @since		1.0
7 */
8 
9var qDefaultValue = '';
10var popupActive = false;
11//in pixels
12var exitPopupTrigger = 20;
13
14
15function cGetCookie(cname) {
16	var name = cname + "=";
17	var ca = document.cookie.split(';');
18	for(var i = 0; i < ca.length; i++) {
19		var c = ca[i];
20		while (c.charAt(0) == ' ') {
21			c = c.substring(1);
22		}
23		if (c.indexOf(name) == 0) {
24			return c.substring(name.length, c.length);
25		}
26	}
27	return "";
28}
29
30function cSetCookie(cname, cvalue, exdays) {
31	if(exdays == -1){
32		document.cookie = cname + "=" + cvalue + ";";
33		return;
34	}
35	var d = new Date();
36	d.setTime(d.getTime() + (exdays*24*60*60*1000));
37	var expires = "expires="+d.toUTCString();
38	document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
39}
40
41 
42$( document ).ready( function() {
43	// Search input
44	$( '#q' ).focus( function() {
45		qDefaultValue = $( this ).val();
46		$( this ).addClass( 'focus' ).val( '' );
47	} ).blur( function() {
48		var self = this;
49		setTimeout( function() {
50			$( self ).removeClass( 'focus' ).val( qDefaultValue );
51		}, 100 );
52	} );
53
54	popupTriggerWatcher($(".exit-bg-fade"));
55
56	// Column heights
57	var hL = $( '.content > .main'    ).height();
58	var hR = $( '.content > .sidebar' ).height();
59	var hM = ( hL > hR ? hL : hR );
60	//$( '.content > .main'    ).height( hM + 'px' );
61	//$( '.content > .sidebar' ).height( hM + 'px' );
62	
63	// Slideshows
64	var slideshows = $( '.featuredgames-block .slideshow' );
65	$.each( slideshows, function( ix, slideshow ) {
66		$( this )
67			.mouseover( function() { $( this ).addClass( 'hover' ); } )
68			.mouseout( function() { $( this ).removeClass( 'hover' ); } );
69		$( this )
70			.find( '.prev' )
71			.mouseover( function() { $( this ).addClass( 'hover' ); } )
72			.mouseout( function() { $( this ).removeClass( 'hover' ); } )
73			.click( function() {
74				var l = $( slideshow ).scrollLeft();
75				var w = $( slideshow ).find( '.slides' ).attr( 'rel' ) * 370;
76				$( slideshow ).scrollLeft( ( l ? l : w ) - 370 );
77			} );
78		$( this )
79			.find( '.next' )
80			.mouseover( function() { $( this ).addClass( 'hover' ); } )
81			.mouseout( function() { $( this ).removeClass( 'hover' ); } )
82			.click( function() {
83				var l = $( slideshow ).scrollLeft();
84				var w = $( slideshow ).find( '.slides' ).attr( 'rel' ) * 370;
85				$( slideshow ).scrollLeft( l < w - 370 ? l + 370 : 0 );
86			} );
87		if( $( slideshow ).find( '.slides' ).attr( 'rel' ) * 1 > 1 )
88			setInterval( function() {
89				if( !$( slideshow ).hasClass( 'hover' ) ) {
90					sW = $( slideshow ).find( '.slides' ).attr( 'rel' ) * 370;
91					sL = $( slideshow ).scrollLeft();
92					sL = ( sL < sW - 370 ? sL + 370 : 0 );
93					$( slideshow ).scrollLeft( sL );
94				}
95			}, 3000 );
96	} );
97	
98	// Polls
99/*
100	var polls = $( '.poll-block' );
101	$.each( polls, function( ix, poll ) {
102		$( poll ).find( '.answers div span' ).click( function() {
103			$( poll ).find( '.answers div span' ).removeClass( 'active' );
104			$( this ).addClass( 'active' );
105			$( poll ).find( '.button' ).removeClass( 'hidden' );
106		} );
107		$( poll ).find( '.button' ).click( function() {
108			if( $( poll ).find( '.answers div span.active' ).size() ) {
109				var aID = $( poll ).find( '.answers div span.active' ).parent().attr( 'rel' ) * 1;
110				var pID = $( poll ).attr( 'rel' ) * 1;
111				var num = $( poll ).find( '.results div[rel="' + aID + '"] label' ).attr( 'rel' ) * 1;
112				var sum = 0;
113				$( poll ).find( '.results div[rel="' + aID + '"] label' ).attr( 'rel', num + 1 );
114				var divs = $( poll ).find( '.results div' );
115				$.each( divs, function( ix, div ) {
116					if( ix )
117						sum += ( $( div ).find( 'label' ).attr( 'rel' ) * 1 );
118				} );
119				$.each( divs, function( ix, div ) {
120					if( ix ) {
121						per = $( div ).find( 'label' ).attr( 'rel' ) * 1;
122						per = Math.round( sum ? per / ( sum / 100 ) * 10 : 0 ) / 10;
123						$( div ).find( 'span' ).html( per + '%' );
124					}
125				} );
126				$( poll ).find( '.side-inner' ).scrollLeft( 300 );
127				$.ajax( {
128					url   : 'szavazas?pid=' + pID + '&aid=' + aID,
129					cache : false,
130					async : true
131				} );
132			}
133		} );
134	} );
135*/
136
137	// Toplists
138	var toplists = $( '.toplist-block' );
139	$.each( toplists, function( ix, toplist ) {
140		$( toplist ).find( '.tabs .tab' ).click( function() {
141			$( toplist ).find( '.tabs .tab' ).removeClass( 'active' );
142			$( this ).addClass( 'active' );
143			rel = $( this ).attr( 'rel' ) + '_' + $( toplist ).find( '.tabs' ).attr( 'rel' );
144			$( toplist ).find( '.category' ).removeClass( 'hidden' ).addClass( 'hidden' );
145			$( toplist ).find( '.category[rel="' + rel + '"]' ).removeClass( 'hidden' );
146		} );
147		$( toplist ).find( '.select a' ).click( function() {
148			if( !$( toplist ).find( '.select' ).hasClass( 'hover' ) ) {
149				$( toplist ).find( '.select a' ).removeClass( 'hidden' ).addClass( 'hidden' );
150				$( toplist ).find( '.select' ).addClass( 'hover' );
151			} else {
152				$( toplist ).find( '.select' ).removeClass( 'hover' );
153				$( toplist ).find( '.tabs' ).attr( 'rel', $( this ).attr( 'rel' ) );
154				rel = $( toplist ).find( '.tab.active' ).attr( 'rel' ) + '_' + $( this ).attr( 'rel' );
155				$( toplist ).find( '.category' ).removeClass( 'hidden' ).addClass( 'hidden' );
156				$( toplist ).find( '.category[rel="' + rel + '"]' ).removeClass( 'hidden' );
157				$( this ).removeClass( 'hidden' );
158			}
159		} );
160	} );
161	
162	// Category header
163	var cHeader = $( '.categoryheader-block' );
164	$( cHeader ).find( '.select a' ).click( function( e ) {
165		if( !$( cHeader ).find( '.select' ).hasClass( 'hover' ) ) {
166			e.stopPropagation();
167			$( cHeader ).find( '.select a' ).removeClass( 'hidden' ).addClass( 'hidden' );
168			$( cHeader ).find( '.select' ).addClass( 'hover' );
169			return false;
170		} else {
171			$( cHeader ).find( '.select' ).removeClass( 'hover' );
172			$( this ).removeClass( 'hidden' );
173		}
174	} );
175	
176	// Game column heights
177	if( $( '.game-bottom' ).size() > 0 ) {
178		/*
179		setInterval( function() {
180			var hC = $( '.game-bottom .sidebar-block.comments .side-inner' ).height();
181			var hS = $( '.game-bottom .sidebar-block.shares .side-inner'   ).height();
182			var hM = ( hC > hS ? hC : hS );
183			$( '.game-bottom .sidebar-block.comments .side-inner' ).css( 'min-height', hM + 'px' );
184			$( '.game-bottom .sidebar-block.shares .side-inner'   ).css( 'min-height', hM - 20 + 'px' );
185		}, 200 );
186		*/
187	}
188	
189	// Game sending block
190	var gsVal = $( '.gamesend-block textarea' ).val();
191	var gsRel = $( '.gamesend-block textarea' ).attr( 'rel' );
192	$( '.gamesend-block textarea' ).removeClass( 'blur' );
193	if( gsVal == gsRel )
194		$( '.gamesend-block textarea' ).addClass( 'blur' );
195	$( '.gamesend-block textarea' ).focus( function() {
196		$( this ).removeClass( 'blur' );
197		gsVal = $( this ).val();
198		gsRel = $( this ).attr( 'rel' );
199		if( gsVal == gsRel )
200			$( this ).val( '' );
201	} );
202	$( '.gamesend-block textarea' ).blur( function() {
203		if( !$( this ).val() ) {
204			$( this ).val( $( this ).attr( 'rel' ) );
205			$( this ).addClass( 'blur' );
206		}
207	} );
208	
209	// Stars
210	var stars = $( '.stars.active' );
211	$.each( stars, function( ix, star ) {
212		$( star ).mousemove( function( e ) {
213			if( $( star ).hasClass( 'active' ) ) {
214				var mX = e.pageX;
215				var sX = $( this ).offset().left;
216				var sW = $( this ).find( '> span' ).width();
217				var sV = ( mX - sX ) / sW + 0.25;
218				for( i = 0; i < 5; i++ ) {
219					var sC = ( sV > i * 1 + 1 ? 'f' : ( sV >= i * 1 + 0.5 ? 'h' : 'e' ) );
220					$( star ).find( ':nth-child(' + ( i + 1 ) + ')' ).removeClass( 'f' ).removeClass( 'e' ).removeClass( 'h' ).addClass( sC );
221				}
222			}
223		} ).mouseout( function() {
224			if( $( star ).hasClass( 'active' ) ) {
225				sV = $( this ).attr( 'rel' ) * 1;
226				for( i = 0; i < 5; i++ ) {
227					var sC = ( sV > i * 1 + 1 ? 'f' : ( sV >= i * 1 + 0.5 ? 'h' : 'e' ) );
228					$( star ).find( ':nth-child(' + ( i + 1 ) + ')' ).removeClass( 'f' ).removeClass( 'e' ).removeClass( 'h' ).addClass( sC );
229				}
230			}
231		} ).click( function( e ) {
232			$( star ).removeClass( 'active' );
233			var mX = e.pageX;
234			var sX = $( this ).offset().left;
235			var sW = $( this ).find( '> span' ).width();
236			var sV = ( mX - sX ) / sW + 0.25;
237			    sV = Math.ceil( sV / 0.5 ) * 0.5 - 0.5;
238			var id = $( star ).parent().attr( 'rel' ) * 1;
239			$( star ).next( '.rate' ).hide();
240			$.ajax( {
241				url   : '/ertekeles?id=' + id + '&val=' + sV,
242				cache : false,
243				async : true
244			} );
245		} );
246	} );
247
248    // Flash warning
249    try {
250        if( location.toString().match(/\/jatekok\/.+$/) ){
251            if( document.cookie.indexOf('flash-warning-dismissed') == -1 ){
252                var $fw = $(
253                    '<div class="flash-warning">'+
254                    '<a href="javascript:;">Rendben!</a>'+
255                    '<p>Bizonyos böngészők korlátozhatják a Flash tartalom megjelenítését. Játékaink nagy része ezzel a technológiával készült, így ha nem jelenik meg tartalom, egyszerűen csak engedélyezni kell a Flash beépülő modul futását a böngészőben.</p>' +
256                    '</div>');
257                $fw.appendTo('body');
258                $fw.find('> a').click(function(){
259                    var d = new Date;
260                    d.setDate(d.getDate() + 365);
261                    document.cookie = "flash-warning-dismissed=yes;expires="+d.toUTCString()+";path=/";
262                    $fw.fadeOut(300, function(){
263                        $fw.remove();
264                    });
265                });
266                $fw.fadeIn();
267            }
268        }
269    } catch(e) {
270    }
271
272} );
273
274function popupSetCookie(){
275	var info = $(".exit-exit").data("info");
276	var epuCookie = cGetCookie("exitPopUp"+info.type);
277	if(epuCookie){
278		epuCookie = JSON.parse( epuCookie);
279	}
280	else{
281		epuCookie = [];
282	}
283	epuCookie.push({id:info.id, expiry:Date.now()});
284	cSetCookie("exitPopUp"+info.type, JSON.stringify(epuCookie));
285
286}
287
288function popupShow(){
289	var info = $(".exit-exit").data("info");
290	var epuCookie = cGetCookie("exitPopUp"+info.type);
291	var ret = true;
292	if(epuCookie){
293		epuCookie = JSON.parse(epuCookie);
294		var newCookies = [];
295		$.each(epuCookie, function(i, value){
296			//if(Date.now() < value.expiry+48*60*60*1000){
297			if(Date.now() < value.expiry+300*1000){
298				newCookies.push(value);
299				if(value.id == info.id){
300					ret = false;
301				}
302			}
303		});
304		cSetCookie("exitPopUp"+info.type, JSON.stringify(newCookies), 10);
305	}
306	return ret;
307}
308
309function popupTriggerWatcher(elem){
310    var lastMouseMovement = 0;
311    var helper = 0;
312    if (elem.length > 0) {
313		if(!popupShow()){
314			return false;
315		}
316
317        $(window).mousemove(function (event) {
318            if(helper == 0) {
319                lastMouseMovement = event.clientY;
320                helper = 1;
321            }
322            if(lastMouseMovement < event.clientY)
323                helper = 0;
324            if (!popupActive && event.clientY <= exitPopupTrigger && lastMouseMovement > event.clientY) {
325                openPopup(elem);
326
327            }
328        });
329    }
330}
331
332function openPopup(popupElem){
333	popupActive = true;
334
335    popupElem.fadeIn(200).css("display", "flex");
336
337    var exitTrigger = [
338        "exit-bg-fade",
339        "exit-exit",
340        "exit-exit-x"
341    ];
342
343    popupElem
344        .closest(".exit-bg-fade")
345        .click(function(event){
346            $.each(exitTrigger, function(i, triggerElem){
347                if($(event.target).attr("class") == triggerElem){
348					popupElem.fadeOut(200);
349					if($(event.target).attr("class") == "exit-exit-x"){
350						popupSetCookie();
351					}
352					return false;
353				}
354            });
355        });
356}

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.