PageSourceSearch

http://eduweb-project.eu/plugins/system/gspeech/includes/js/gspeech_pro.js?version=2.0.2

js eduweb-project.eu collected 2026-10-05 01:55:43 UTC 15,218 bytes, 521 lines download raw bytes

1(function($) {
2$(document).ready(function() {
3	
4	function check_pro_version_by_class() {
5		if($(".tooltip_inner.powered_by").is(":visible"))
6			return true;
7		return false;
8	}
9	
10	$('.greeting_block').each(function(i){
11		if(i > 1) {
12			$(this).next('.sound_container_pro').remove();
13			$(this).prev('.gspeech_selection').remove();
14		}
15	});
16	
17	function navigate_tooltip($tooltip) {
18		
19		
20		var center_offset_x = parseFloat($tooltip.parent('span').find('.sound_container_pro ').width() / 2);
21		var tooltip_width = parseFloat($tooltip.find('.tooltip_inner').width());
22		
23		if($tooltip.find('.the-tooltip').hasClass('center')) {
24			var final_offset = -1 * ((tooltip_width / 2) * 1 + 14 * 1 - center_offset_x * 1);
25			$tooltip.css({'left': final_offset, opacity: 0,display: 'block'});
26		}
27		else if($tooltip.find('.the-tooltip').hasClass('left')) {
28			var final_offset = -32 * 1 + center_offset_x * 1;
29			$tooltip.css({'left': final_offset, opacity: 0,display: 'block'});
30		}
31		else if($tooltip.find('.the-tooltip').hasClass('right')) {
32			var final_offset = 32 * 1 + center_offset_x * 1;
33			$tooltip.css({'left': final_offset, opacity: 0,display: 'block'});
34		}
35		
36		
37		if($tooltip.find('.the-tooltip').hasClass('top')) {
38			$tooltip.css({'top': -200});
39			var new_opacity = 0.95;
40			$tooltip.stop(false,false).animate( {
41				top: 1,
42				opacity: new_opacity
43			},300,'easeOutBack');
44		}
45		else if($tooltip.find('.the-tooltip').hasClass('bottom')) {
46			if($tooltip.find('.tooltip_inner').hasClass('powered_by'))
47				var new_opacity = 0.95;
48			else
49				var new_opacity = 0.95;
50			
51			var h = -1 * parseFloat($tooltip.parent('span').find('.sound_container_pro ').height());
52			$tooltip.css({'bottom': -200});
53			$tooltip.stop(false,false).animate( {
54				bottom: h,
55				opacity: new_opacity
56			},300,'easeOutBack');
57		}
58	}
59	function hide_tooltip($tooltip) {
60		if($tooltip.find('.the-tooltip').hasClass('top')) {
61			$tooltip.stop(true,true).delay(200).animate( {
62				top: -200,
63				opacity: 0
64			},300,'easeInBack',function() {
65				$(this).hide();
66			});
67		}
68		else if($tooltip.find('.the-tooltip').hasClass('bottom')) {
69			$tooltip.stop(true,true).delay(200).animate( {
70				bottom: -200,
71				opacity: 0
72			},300,'easeInBack',function() {
73				$(this).hide();
74			});
75		}
76	}
77	
78	//show backlinks
79	function show_backlinks() {
80		$('.sound_container_pro').each(function() {
81			$tooltip = $(this).next('.sexy_tooltip');
82			setTimeout(function() {
83				navigate_tooltip($tooltip);
84			},1500);
85		})
86	};
87	show_backlinks();
88	
89	$('.sound_container_pro').each(function(i) {
90		$elem = $(this);
91		var autoplay = $(this).attr("autoplaypro");
92		var speechtimeout =$(this).attr("speechtimeout");
93		if(isNaN(speechtimeout))
94			speechtimeout = 0;
95		speechtimeout = parseFloat(speechtimeout);
96		var selector =$(this).attr("selector");
97		var event =$(this).attr("eventpro");
98		
99		if(selector != '' && event != '' && createtriggerspeechcount < 1) {
100			createtriggerspeech($elem,speechtimeout,selector,event);
101			createtriggerspeechcount ++;
102		}
103		else if(autoplay == 1) {
104			triggerspeech($elem,speechtimeout);
105		};
106		
107	});
108	
109	function triggerspeech($elem,speechtimeout) {
110		speechtimeoutfinal = speechtimeoutfinal + speechtimeout*1 + 200*1;
111		setTimeout(function() {
112			stop_all_speakers_pro($('.sound_container_pro'));
113			clearAllPlayers();
114			setTimeout(function() {
115				make_speeching($elem);
116			},10);
117		},speechtimeoutfinal);
118	};
119	
120	function createtriggerspeech($elem,speechtimeout,selector,event) {
121		$("" + selector + "").bind(event, function() {
122			var $active_elem = $(this);
123			var new_htm = $active_elem.html().replace(/<\/?[^>]+>/gi, '');
124			var new_val = $active_elem.val().replace(/<\/?[^>]+>/gi, '');
125			stop_all_speakers_pro($('.sound_container_pro'));
126			clearAllPlayers();
127			
128			var htm = $elem.children('.sound_text_pro').html();
129			if(htm == 'gspeech_html' || $elem.children('.sound_text_pro').attr("htm") == 'gspeech_html') {
130				$elem.children('.sound_text_pro').attr("htm","gspeech_html");
131				$elem.children('.sound_text_pro').html(new_htm);
132			}
133			else if(htm == 'gspeech_value' || $elem.children('.sound_text_pro').attr("htm") == 'gspeech_value') {
134					$elem.children('.sound_text_pro').attr("htm","gspeech_value");
135					$elem.children('.sound_text_pro').html(new_val);
136			}
137			setTimeout(function() {
138				make_speeching($elem);
139			},speechtimeout);
140		});
141	};
142	
143	var speech_enable_count = 1;
144	$('.sound_container_pro').each(function(i) {
145		$this = $(this);
146		if($(this).hasClass("greeting_block"))
147			++speech_enable_count;
148		if(i < speech_enable_count) {
149			var h1 = $(this).parent('span').height();
150			var h2 = $(this).height();
151			var w = $(this).width();
152			var delta_w = w - 8;
153			var delta = (h1 - h2)/2;
154			$(this).parent('span').css({top: delta + 'px'});
155			var delta_htm = '<label style="width: ' + delta_w + 'px;display: inline-block">&nbsp;</label>';
156			$(this).parent('span').after(delta_htm);
157			
158		} else {
159			$(this).remove();
160		}
161	});
162	
163	$('.sound_container_pro').hover(function() {
164		var $selection = $(this).parent('span').prev('.gspeech_selection');
165		var roll = $selection.attr("roll");
166		roll = roll == '' ? 1 : roll;
167		--roll;
168		
169		var an_time = parseFloat(gspeech_animation_time[roll]);
170		var speaker_op = parseFloat(gspeech_spoa[roll] / 100);
171		
172		$(this).stop().animate({
173			opacity: speaker_op
174		},an_time);
175		
176		$selection.stop().animate({
177			backgroundColor: gspeech_bca[roll],
178			color: gspeech_ca[roll]
179		},an_time);
180		
181		navigate_tooltip($(this).prev('.sexy_tooltip'));
182		
183	},function() {
184		var $selection = $(this).parent('span').prev('.gspeech_selection');
185		var roll = $selection.attr("roll");
186		roll = roll == '' ? 1 : roll;
187		--roll;
188		
189		
190		
191		//onmouseleave, fade back
192		if(! $(this).hasClass('active')) {
193			var an_time = parseFloat(gspeech_animation_time[roll]);
194			var speaker_op = parseFloat(gspeech_spop[roll] / 100);
195			$(this).stop().animate({
196				opacity: speaker_op
197			},an_time);
198		};
199		
200		if(! $selection.hasClass('active')) {
201			$selection.stop().animate({
202				backgroundColor: gspeech_bcp[roll],
203				color: gspeech_cp[roll]
204			},an_time);
205		};
206		
207		//hide_tooltip
208		hide_tooltip($(this).prev('.sexy_tooltip'));
209	});
210	
211	$('.sound_container_pro').mousedown(function() {
212		pro_container_clicked = true;
213		basic_plg_enable = false;
214	});
215	
216	$("body").mousedown(function() {
217		if($('.sound_container_pro.active').length > 0 && !pro_container_clicked)
218			basic_plg_enable = true;
219			
220		stop_all_speakers_pro($('.sound_container_pro'));
221		clearAllPlayers();
222		reset_opacities();
223		$('.sound_container_pro').removeClass('active');
224		$('.gspeech_selection').removeClass('active');
225	});
226	
227	$('.sound_container_pro').click(function() {
228		if(!check_pro_version_by_class()) {
229			alert('To hide a backlink please purchase a GSpeech PRO version');
230			return false;
231		}
232		make_speeching($(this));
233	});
234	
235	function reset_opacities() {
236		$('.sound_container_pro').each(function() {
237			var $selection = $(this).parent('span').prev('.gspeech_selection');
238			var roll = $selection.attr("roll");
239			roll = roll == '' ? 1 : roll;
240			--roll;
241			var an_time = parseFloat(gspeech_animation_time[roll]);
242			var speaker_op = parseFloat(gspeech_spop[roll] / 100);
243			$(this).animate({opacity: speaker_op},an_time)
244		})
245	}
246	
247	function make_speeching($elem) {
248		
249		var sel_txt = $elem.children('.sound_text_pro').html();
250		if(speechtxt != sel_txt) {
251			var $selection = $elem.parent('span').prev('.gspeech_selection');
252			$selection.stop().removeAttr("style").addClass('active');
253			$elem.addClass('active');
254			
255			var lang = $elem.attr("language");
256			lang = lang == '' ? lang_identifier : lang;
257			
258			blinking_enable_pro = true;
259			blink_start_enable_pro = true;
260			
261			//animate to active opacity
262			var roll = $elem.attr("roll");
263			roll = roll == '' ? 1 : roll;
264			--roll;
265			var speaker_op = parseFloat(gspeech_spoa[roll] / 100);
266			$elem.stop().fadeTo(400,speaker_op);
267			
268			//rotate me
269			rotate_speaker_pro($elem);
270			
271			clearAllPlayers();
272			make_audio_pro($elem.children('.sound_text_pro'),$elem,lang);
273		}
274		speechtxt = sel_txt;
275		setTimeout(function() {
276			speechtxt = '';
277		},100);
278	};
279	
280	function stop_speaker_pro($elem) {
281		basic_plg_enable = true;
282		clearAllPlayers();
283		$elem.rotate({animateTo:360});
284		
285		var roll = $elem.attr("roll");
286		roll = roll == '' ? 1 : roll;
287		--roll;
288		var speaker_op = parseFloat(gspeech_spop[roll] / 100);
289		$elem.stop().fadeTo(400,speaker_op).removeClass('active');
290		
291		for(f in blink_timer) {
292			clearTimeout(blink_timer[f]);
293		}
294		for(f in rotate_timer) {
295			clearInterval(rotate_timer[f]);
296		}
297	};
298	
299	function stop_all_speakers_pro($elem) {
300		clearAllPlayers();
301		$('.sound_container_pro.active').rotate({animateTo:360});
302		
303		var roll = $elem.attr("roll");
304		roll = roll == '' ? 1 : roll;
305		--roll;
306		
307		var speaker_op = parseFloat(gspeech_spop[roll] / 100);
308		$elem.stop().removeClass('active');
309		
310		for(f in blink_timer) {
311			clearTimeout(blink_timer[f]);
312		}
313		for(f in rotate_timer) {
314    		clearInterval(rotate_timer[f]);
315		}
316	};
317
318	function rotate_speaker_pro($elem) {
319		var angle = 0;
320		rotate_timer_element = setInterval(function(){
321		      angle+=3;
322		      $elem.rotate(angle);
323		},15);
324		rotate_timer.push(rotate_timer_element);
325	};
326	
327	function blink_speaker_pro($elem) {
328		if(blink_start_enable_pro) {
329			$elem.fadeTo(200,0.2);
330			blink_start_enable_pro = false;
331		}
332		else {
333			$elem.fadeTo(200,1);
334			blink_start_enable_pro = true;
335		}
336		var t = setTimeout(function() {
337			blink_speaker_pro($elem);
338		},800);
339		blink_timer.push(t);
340	};
341	
342	function change_speaker_animation_pro($elem) {
343		if(blinking_enable_pro) {
344			for(f in rotate_timer) {
345	    		clearInterval(rotate_timer[f]);
346			}
347			$elem.rotate({animateTo:0});
348        	blink_speaker_pro($elem);
349		}
350		blinking_enable_pro = false;
351	};
352
353	//main function which creates audio
354	function make_audio_pro($txt_element,$elem,lang) {
355		selected_txt = $txt_element.html();
356		var 
357			words_array = new Array(),
358			sent_array = new Array(),
359			sent_index = 0;
360		
361		words_array = selected_txt.split(/[^\S]+/);
362
363		for(var i = 0; i < words_array.length; i++) {
364			if(sent_array[sent_index] == undefined) {
365				sent_array[sent_index] = '';
366			}
367
368			var total_l = sent_array[sent_index].length + words_array[i].length;
369			if(sent_array[sent_index].length < speech_text_length && total_l < speech_text_length) {
370    				sent_array[sent_index] += words_array[i] + ' ';
371			}
372			else {
373				++sent_index;
374				sent_array[sent_index] = words_array[i] + ' ';
375			}
376		};
377
378		var players_count = sent_array.length;
379
380		var htm_cont = '';
381		for(var i = 0; i < players_count; i++) {
382			htm_cont += '<audio id="player' + i + '" src="' + streamerphp_folder + 'gspeech.mpeg" type="' + translation_audio_type + '" controls="controls"></audio>';
383		};
384		$("#sound_audio").html(htm_cont);
385
386		for(var i = 0; i < players_count; i++) {
387			create_htm(i,players_count,lang);
388		};
389
390				// new version addings
391
392		function gs_get_token(encoded_text) {
393			var query = encoded_text;
394			var cM = function(a) {
395			    return function() {
396			        return a
397			    }
398			};
399			var of = "=";
400			var dM = function(a, b) {
401			    for (var c = 0; c < b.length - 2; c += 3) {
402			        var d = b.charAt(c + 2),
403			            d = d >= t ? d.charCodeAt(0) - 87 : Number(d),
404			            d = b.charAt(c + 1) == Tb ? a >>> d : a << d;
405			        a = b.charAt(c) == Tb ? a + d & 4294967295 : a ^ d
406			    }
407			    return a
408			};
409
410			var eM = null;
411			var cb = 0;
412			var k = "";
413			var Vb = "+-a^+6";
414			var Ub = "+-3^+b+-f";
415			var t = "a";
416			var Tb = "+";
417			var dd = ".";
418			var hoursBetween = Math.floor(Date.now() / 3600000);
419			window.TKK = hoursBetween.toString();
420
421			fM = function(a) {
422			    var b;
423			    if (null === eM) {
424			        var c = cM(String.fromCharCode(84)); // char 84 is T
425			        b = cM(String.fromCharCode(75)); // char 75 is K
426			        c = [c(), c()];
427			        c[1] = b();
428			        // So basically we're getting window.TKK
429			        eM = Number(window[c.join(b())]) || 0
430			    }
431			    b = eM;
432
433			    // This piece of code is used to convert d into the utf-8 encoding of a
434			    var d = cM(String.fromCharCode(116)),
435			        c = cM(String.fromCharCode(107)),
436			        d = [d(), d()];
437			    d[1] = c();
438			    for (var c = cb + d.join(k) +
439			            of, d = [], e = 0, f = 0; f < a.length; f++) {
440			        var g = a.charCodeAt(f);
441
442			        128 > g ? d[e++] = g : (2048 > g ? d[e++] = g >> 6 | 192 : (55296 == (g & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (g = 65536 + ((g & 1023) << 10) + (a.charCodeAt(++f) & 1023), d[e++] = g >>
442 18 | 240, d[e++] = g >> 12 & 63 | 128) : d[e++] = g >> 12 | 224, d[e++] = g >> 6 & 63 | 128), d[e++] = g & 63 | 128)
443			    }
444
445
446			    a = b || 0;
447			    for (e = 0; e < d.length; e++) a += d[e], a = dM(a, Vb);
448			    a = dM(a, Ub);
449			    0 > a && (a = (a & 2147483647) + 2147483648);
450			    a %= 1E6;
451			    return a.toString() + dd + (a ^ b)
452			};
453
454			var token = fM(query);
455			
456			return token;
457		}
458
459		function gs_replace_ch(str) {
460			var str = str.replace("'", "");
461			str = str.replace('"', '');
462			str = str.replace('', '');
463			str = str.replace('/', '');
464			str = str.replace('&nbsp;', '');
465			// str = str.replace('&', '');
466
467			return str;
468		}
469		
470		function create_htm(i,players_count,lang) {
471			$('#player' + i).mediaelementplayer({
472				success: function (mediaElement, domObject) {
473					//detect media end
474					players[i] = mediaElement;
475
476
477		            // sets src
478					var encoded_text = gs_replace_ch(sent_array[i]);
479					var token = gs_get_token(encoded_text);
480					encoded_text = encodeURIComponent(encoded_text);
481					var embed_url = streamerphp_folder + 'streamer.php?q=' + encoded_text + '&l=' + lang + '&tr_tool=' +translation_tool + '&token=' + token;
482					mediaElement.setSrc(embed_url);
483
484		            //play next audio, when current ends
485		            mediaElement.addEventListener('pause', function(e) {
486    	        		try {
487    	        			players[i + 1].play()
488    	        		} catch(e){}
489		        	}, false);
490
491		        	players[0].addEventListener('progress', function(e) {
492    		            	change_speaker_animation_pro($elem);
493		        	}, false);
494
495		        	if(i == players_count - 1) {
496    		        	players[players_count - 1].addEventListener('pause', function(e) {
497    		        		stop_speaker_pro($elem);
498    		        	}, false);
499		        	}
500		        	
501		            mediaElement.load();
502		            
503		            if(i == 0) {
504		            	mediaElement.play();
505		            }
506		        }
507			});
508		}
509		
510	};
511	
512	function clearAllPlayers() {
513		for(var c in players) {
514			players[c] = '';
515		}
516		$('#sound_audio').html('');
517	};
518	
519				
520});
521})(sexyJ);

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.