PageSourceSearch

https://www.simonovice.cz/jsphp/tts/tts_legacy.js.php?v=v6.5.0&lang=cs&float=1

js simonovice.cz collected 2026-10-03 18:02:41 UTC 12,087 bytes, 257 lines download raw bytes

1var hlasEngine = '0';
2var currentElm = new Object();
3var noPlayableElms = new Array();
4const baseHref = window.location.origin + '/';
5var cekani = null;
6var lastPlayer = -1;
7
8function HidePlayer(playerId) {
9    jQuery('#jquery_jplayer_' + playerId.toString()).jPlayer('stop');
10    jQuery('#jp_container_' + playerId.toString()).css('display', 'none');
11    jQuery('#tts_wrap_' + playerId.toString()).css('background-position', '0 0');
12    if (jQuery('#tts_wrap_' + playerId.toString()).hasClass('float'))
13        jQuery('#tts_wrap_' + playerId.toString() + '.float').css('float', 'left');
14    return false;
15}
16
17function CreatePlayer(speechUrl, index) {
18    var strIndex = index.toString();
19    var player = '<div id="jquery_jplayer_' + strIndex + '" class="jp-player"><\/div>' +
20        '<div id="jp_container_' + strIndex + '" class="jp-audio">' +
21        '<div class="jp-type-single">' +
22        '<div class="jp-gui jp-interface">' +
23        '<ul class="jp-controls">' +
24        '<li><a href="javascript:void(0);" class="jp-play">Play<\a><\/li>' +
25        '<li><a href="javascript:void(0);" class="jp-pause">Pause<\a><\/li>' +
26        '<li><a href="javascript:void(0);" class="jp-stop">Stop<\a><\/li>' +
27        '<\/ul>' +
28        '<div class="jp-progress" id="jplayer_bar_' + strIndex + '">' +
29        '<div class="jp-seek-bar" style="width:100%">' +
30        '<div class="jp-play-bar" style="width:0%"><\/div>' +
31        '<\/div>' +
32        '<\/div>' +
33        '<div class="jp-divider" id="jplayer_divider_' + strIndex + '"><\/div>' +
34        '<div class="jp-volume-bar" id="jplayer_volume_' + strIndex + '">' +
35        '<div class="jp-volume-bar-value" style="width:100%"><\/div>' +
36        '<\/div>' +
37        '<a class="jp-close" href="javascript:void(0);" onclick="return HidePlayer(' + strIndex + ');"><\/a>' +
38        '<\/div>' +
39        '<\/div>' +
40        '<div class="jp-no-solution">Pro přehrání potřebujete minimálně Adobe Flash. <a href="http://get.adobe.com/flashplayer/" target="_blank">zde ke stažení<\/a><\/div>' +
41        '<div class="hidden2"></div>' +
42        '<\/div>';
43    jQuery(jQuery(currentElm).data('wrapper')).append(player);
44    jQuery("#jquery_jplayer_" + strIndex).jPlayer({
45        ready: function () {
46            jQuery(this).jPlayer("setMedia", {
47                mp3: speechUrl
48            });
49        },
50        swfPath: "https://www.simonovice.cz/js/jplayer/",
51        supplied: "mp3",
52        preload: 'metadata',
53        volume: 1,
54        muted: false,
55        backgroundColor: '#000000',
56        errorAlerts: false,
57        warningAlerts: false,
58        cssSelector: {
59            videoPlay: '.hidden2',
60            play: '.jp-play',
61            pause: '.jp-pause',
62            stop: '.jp-stop',
63            seekBar: '.jp-seek-bar',
64            playBar: '.jp-play-bar',
65            mute: '.hidden2',
66            unmute: '.hidden2',
67            volumeBar: '.jp-volume-bar',
68            volumeBarValue: '.jp-volume-bar-value',
69            volumeMax: '.hidden2',
70            currentTime: '.hidden2',
71            duration: '.hidden2',
72            fullScreen: '.hidden2',
73            restoreScreen: '.hidden2',
74            repeat: '.hidden2',
75            repeatOff: '.hidden2',
76            gui: '.jp-gui',
77            noSolution: '.jp-no-solution'
78        },
79        cssSelectorAncestor: "#jp_container_" + strIndex
80    });
81}
82
83function DecodeResult(speech_data) {
84    switch (speech_data.status) {
85        case -1: //err
86            jQuery(jQuery(currentElm).data('wrapper')).css('display', 'none');
87            alert(speech_data.msg);
88            if (noPlayableElms.indexOf(currentElm) != -1)
89                noPlayableElms.splice(noPlayableElms.indexOf(currentElm), 1);
90            break;
91        case 0: //ok
92            if (lastPlayer != -1)
93                HidePlayer(lastPlayer);
94            var currentIndex = jQuery(currentElm).data('index');
95            CreatePlayer(speech_data.url, currentIndex);
96            lastPlayer = currentIndex;
97            jQuery(jQuery(currentElm).data('wrapper')).attr('title', 'Klikněte pro přečtení textu');
98            jQuery('#tts_loading_' + currentIndex).css('display', 'none');
99            jQuery('#tts_wrap_' + currentIndex).css('background-position', '-137px 0');
100            if (jQuery('#tts_wrap_' + currentIndex).hasClass('float')) {
101                jQuery('#tts_wrap_' + currentIndex + '.float').css('background-position', '-48px 0');
102                jQuery('#tts_wrap_' + currentIndex + '.float').css('float', 'none');
103            }
104            if (jQuery.jPlayer.platform.android) {
105                jQuery('#jquery_jplayer_' + currentIndex).bind(jQuery.jPlayer.event.ready, function (event) {
106                    jQuery('#jquery_jplayer_' + currentIndex).jPlayer('pause');
107                });
108            } else {
109                jQuery('#jquery_jplayer_' + currentIndex).bind(jQuery.jPlayer.event.ready, function (event) {
110                    jQuery('#jquery_jplayer_' + currentIndex).jPlayer('play');
111                });
112            }
113            if (jQuery.jPlayer.platform.mobile || jQuery.jPlayer.platform.tablet) {
114                jQuery('#jplayer_bar_' + currentIndex).css('width', '123px');
115                jQuery('#jplayer_volume_' + currentIndex).css('display', 'none');
116                jQuery('#jplayer_divider_' + currentIndex).css('display', 'none');
117            }
118            break;
119        case 1: //unknown hash
120            var textHash = jQuery(currentElm).data('sha1');
121            var textToSend = jQuery(currentElm).data('text');
122            jQuery.ajax(
123                {
124                    url: 'https://tts.gc-system.cz/modules/tts_srv/get_speech.php',
125                    type: 'POST',
126                    async: false,
127                    data: {
128                        hash: textHash,
129                        text: textToSend,
130                        hlas: hlasEngine,
131                        base: baseHref,
132                        lang: 'cs'
133                    },
134                    success: function (result) {
135                        DecodeResult(result);
136                    }
137                }
138            );
139            if (noPlayableElms.indexOf(currentElm) == -1) {
140                noPlayableElms.push(currentElm);
141                if (cekani == null)
142                    cekani = setInterval("CheckPlayable()", 2500);
143            }
144            break;
145        case 2: //wait
146            jQuery(jQuery(currentElm).data('wrapper')).attr('title', 'Text se převádí');
147            if (noPlayableElms.indexOf(currentElm) == -1) {
148                noPlayableElms.push(currentElm);
149                if (cekani == null)
150                    cekani = setInterval("CheckPlayable()", 2500);
151            }
152            break;
153        default:
154            break;
155    }
156}
157
158function GetSpeech(oEl) {
159    currentElm = oEl;
160    var elIndex = jQuery(oEl).data('index').toString();
161    if (jQuery('#jp_container_' + elIndex).css('display') != undefined) {
162        if (jQuery('#jp_container_' + elIndex).css('display') == 'none') {
163            if (lastPlayer != -1)
164                HidePlayer(lastPlayer);
165            jQuery('#jp_container_' + elIndex).css('display', 'block');
166            jQuery('#tts_wrap_' + elIndex).css('background-position', '-137px 0');
167            if (jQuery('#tts_wrap_' + elIndex).hasClass('float'))
168                jQuery('#tts_wrap_' + elIndex + '.float').css('float', 'none');
169            jQuery('#jquery_jplayer_' + elIndex).jPlayer('play');
170            lastPlayer = jQuery(oEl).data('index');
171            return;
172        }
173    }
174    if (noPlayableElms.indexOf(oEl) == -1) {
175        jQuery('#tts_loading_' + jQuery(oEl).data('index')).css('display', 'block');
176        jQuery.ajax(
177            {
178                url: 'https://tts.gc-system.cz/modules/tts_srv/get_speech.php',
179                type: 'POST',
180                async: false,
181                traditional: true,
182                data: {hash: jQuery(oEl).data('sha1')},
183                success: function (result) {
184                    DecodeResult(result);
185                }
186            }
187        );
188    }
189}
190
191function InitReadable() {
192    var intCounter = 0;
193    var reg_he = /<\/h[1-6]>/gi; //mezera za nadpisy
194    var reg_hs = /<h[1-6]>/gi; //mezera pred nadpisy
195    var reg_nr_a = /<a[^>]+class="not_readable[^>]*>.*?<\/a>/gi;
196    var reg_nr_sp = /<span[^>]+class="not_readable[^>]*>.*?<\/span>/gi;
197    var reg_nr_p = /<p[^>]+class="not_readable[^>]*>.*?<\/p>/gi;
198    var reg_nr_div = /<div[^>]+class="not_readable[^>]*>.*?<\/div>/gi;
199    var reg_p = /<\/(dd|dt|li|p|div|td|th|caption)>/gi;
200    var reg_br = /<br[^>]*>/gi;
201    jQuery('.readable').each(function (index) {
202        var textToRead = jQuery(this).clone();
203        jQuery('script', textToRead).remove();
204        jQuery('style', textToRead).remove();
205        var testEmpty = strip_tags(textToRead.html().replace(reg_nr_a, '').replace(reg_nr_sp, '').replace(reg_nr_p, '').replace(reg_nr_div, '').replace('&nbsp;', ' ')).trim();
206        if (testEmpty.length != 0) {
207            var cleanText = textToRead.html().replace(reg_he, "$&[~gcm_insert_pause~]").replace(reg_hs, "[~gcm_insert_pause~]$&").replace(reg_nr_a, '').replace(reg_nr_sp, '').replace(reg_nr_p, '').replace(reg_nr_div, '').replace(reg_p, '[~gcm_insert_pause~]$&').replace(reg_br, '[~gcm_insert_pause~]').trim();
208            var textHash = sha1(hlasEngine + cleanText);
209            jQuery(this).data('sha1', textHash);
210            var ttsWrap = '<div id="tts_wrap_' + intCounter.toString() + '" class="tts_wrap cs" onclick="return GetSpeech(jQuery(this).data(\'rElm\'));" title="Přečíst nahlas"><span class="lcs">Přečíst nahlas<\/span><div class="tts_loading" id="tts_loading_' + intCounter.toString() + '" onclick="return false;" title="Čekejte, prosím"><\/div><\/div>';
211            var ttsElm = jQuery(ttsWrap).prependTo(this);
212            jQuery(this).data('index', intCounter);
213            jQuery(this).data('wrapper', ttsElm);
214            jQuery(this).data('text', cleanText);
215            jQuery(ttsElm).data('rElm', this);
216        }
217        intCounter++;
218    });
219    var readList = jQuery('.readable_list').first();
220    if (readList) {
221        var allText = '';
222        jQuery('.readable_item').each(function (index) {
223            var subTextToRead = jQuery(this).clone();
224            jQuery('script', subTextToRead).remove();
225            var testSubText = strip_tags(subTextToRead.html().replace(reg_nr_a, '').replace(reg_nr_sp, '').replace(reg_nr_p, '').replace(reg_nr_div, '').replace('&nbsp;', ' ')).trim();
226            if (testSubText.length > 0) {
227                var subText = subTextToRead.html().replace(reg_he, "$&[~gcm_insert_pause~]").replace(reg_hs, "[~gcm_insert_pause~]$&").replace(reg_nr_a, '').replace(reg_nr_sp, '').replace(reg_nr_p, '').replace(reg_nr_div, '').replace(reg_p, '[~gcm_insert_pause~]$&').replace(reg_br, '[~gcm_insert_pause~]').trim();
228                allText += subText + '[~gcm_insert_pause~]';
229            }
230        });
231        if (allText.length > 0) {
232            var textHash = sha1(hlasEngine + allText);
233            jQuery(readList).data('sha1', textHash);
234            var ttsWrap = '<div id="tts_wrap_' + intCounter.toString() + '" class="tts_wrap cs" onclick="return GetSpeech(jQuery(this).data(\'rElm\'));" title="Přečíst nahlas>"><span class="lcs">Přečíst nahlas<\/span><div class="tts_loading" id="tts_loading_' + intCounter.toString() + '" onclick="return false;" title="Čekejte, prosím"><\/div><\/div>';
235            var ttsElm = jQuery(ttsWrap).prependTo(readList);
236            jQuery(readList).data('index', intCounter);
237            jQuery(readList).data('wrapper', ttsElm);
238            jQuery(readList).data('text', allText);
239            jQuery(ttsElm).data('rElm', readList);
240        }
241    }
242}
243
244function CheckPlayable() {
245    if (noPlayableElms.length == 0) {
246        if (cekani) {
247            clearInterval(cekani);
248            cekani = null;
249        }
250        return;
251    } else {
252        GetSpeech(noPlayableElms.shift());
253    }
254}
255window.onload = function () {
256    InitReadable();
257};

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.