PageSourceSearch

https://www.mesto-zruc.cz/jsphp/tts/tts.js.php?v=v6.5.0e&lang=cs&float=1

js mesto-zruc.cz collected 2026-10-01 12:34:57 UTC 14,128 bytes, 269 lines download raw bytes

1if (!Array.prototype.indexOf) {
2    Array.prototype.indexOf = function (elt /*, from*/) {
3        var len = this.length >>> 0;
4        var from = Number(arguments[1]) || 0;
5        from = (from < 0) ? Math.ceil(from) : Math.floor(from);
6        if (from < 0)
7            from += len;
8        for (; from < len; from++) {
9            if (from in this && this[from] === elt)
10                return from;
11        }
12        return -1;
13    };
14}
15
16var hlasEngine = '0';
17var currentElm = new Object();
18var noPlayableElms = new Array();
19const baseHref = window.location.origin + '/';
20var cekani = null;
21var lastPlayer = -1;
22var currentlyPlaying = null;
23
24function GetQueryUrl() {
25    if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 9)
26        return baseHref + 'modules/tts/get_speech_cli.php';
27    else
28        return 'https://tts.gc-system.cz/modules/tts_srv/get_speech.php';
29}
30function HidePlayer(playerId) {
31    jQuery('#jp_container_' + playerId.toString()).css('display', 'none');
32    jQuery('#tts-wrap_' + playerId.toString()).css('background-position', '0 0');
33    if (jQuery('#tts-wrap_' + playerId.toString()).hasClass('float'))
34        jQuery('#tts-wrap_' + playerId.toString() + '.float').css('float', 'left');
35    return false;
36}
37function addElement(index, element) {
38    var targetElementId = 'tts-close_' + index;
39    var targetElement = document.getElementById(targetElementId);
40    if (targetElement && targetElement.parentNode) {
41        var parentElement = targetElement.parentNode;
42        var nextSibling = targetElement.nextSibling;
43
44        if (nextSibling) {
45            parentElement.insertBefore(element, nextSibling);
46        } else {
47            parentElement.appendChild(element);
48        }
49    }
50}
51function CreatePlayer(speechUrl, index) {
52    var strIndex = index.toString();
53    var existingPlayer = document.getElementById(strIndex);
54
55    if (currentlyPlaying && currentlyPlaying !== existingPlayer) {
56        currentlyPlaying.pause();
57        currentlyPlaying.currentTime = 0;
58    }
59
60    if (existingPlayer) {
61        if (existingPlayer.src !== speechUrl) {
62            existingPlayer.src = speechUrl;
63        }
64        existingPlayer.play();
65        currentlyPlaying = existingPlayer;
66    } else {
67        var playerWrapper = document.createElement('div');
68        playerWrapper.id = 'tts_wrapper_' + strIndex;
69        playerWrapper.className = 'audio-wrapper';
70        playerWrapper.style.position = 'relative';
71        document.getElementById('tts-wrap_' + strIndex).style.display = 'none';
72        document.getElementById('tts-loader_' + strIndex).style.display = 'block';
73        document.getElementById('tts-loader_' + strIndex).focus();
74
75        var player = document.createElement('audio');
76        player.src = speechUrl;
77        player.controls = true;
78        player.autoplay = true;
79        player.id = 'tts_audio_' + strIndex;
80        player.className = 'mt-2';
81
82        player.onloadeddata = function() {
83            document.getElementById('tts-loader_' + strIndex).style.display = 'none';
84            document.getElementById('tts-close_' + strIndex).style.display = 'block';
85            document.getElementById('tts-close_' + strIndex).focus();
86
87        };
88
89        player.onplay = function() {
90            if (currentlyPlaying && currentlyPlaying !== player) {
91                currentlyPlaying.pause();
92                currentlyPlaying.currentTime = 0;
93            }
94            currentlyPlaying = player;
95        };
96
97        var closeButton = document.getElementById('tts-close_' + strIndex);
98
99        closeButton.onclick = function() {
100            playerWrapper.remove();
101            document.getElementById('tts-wrap_' + strIndex).style.display = 'block';
102            document.getElementById('tts-close_' + strIndex).style.display = 'none';
103            document.getElementById('tts-wrap_' + strIndex).focus();
104
105        };
106
107        playerWrapper.appendChild(player);
108        addElement(strIndex, playerWrapper);
109    }
110}
111function loader(currentElm, elIndex) {
112    var loader = document.getElementById('tts-loader_' + elIndex);
113    document.getElementById('tts-wrap_' + elIndex).style.display = 'none';
114    document.getElementById('tts-loader_' + elIndex).style.display = 'block';
115
116    }
117
118function DecodeResult(speech_data) {
119    switch (speech_data.status) {
120        case -1: //err
121            jQuery(jQuery(currentElm).data('wrapper')).css('display', 'none');
122            alert(speech_data.msg);
123            var idx = noPlayableElms.indexOf(currentElm);
124            if (idx !== -1) {
125                noPlayableElms.splice(idx, 1);
126            }
127            break;
128        case 0: //ok
129            if (lastPlayer != -1)
130                HidePlayer(lastPlayer);
131            var currentIndex = jQuery(currentElm).data('index');
132            CreatePlayer(speech_data.url, currentIndex);
133            lastPlayer = currentIndex;
134            break;
135        case 1: //unknown hash
136            var textHash = jQuery(currentElm).data('sha1');
137            var textToSend = jQuery(currentElm).data('text');
138            jQuery.ajax(
139                {
140                    url: GetQueryUrl(),
141                    type: 'POST',
142                    async: false,
143                    data: {
144                        hash: textHash,
145                        text: textToSend,
146                        hlas: hlasEngine,
147                        base: baseHref,
148                        lang: 'cs'
149                    },
150                    success: function (result) {
151                        DecodeResult(result);
152                    }
153                }
154            );
155             if (noPlayableElms.indexOf(currentElm) === -1) {
156                noPlayableElms.push(currentElm);
157                loader(currentElm);
158                if (cekani == null)
159                    cekani = setInterval("CheckPlayable()", 2500);
160            }
161            break;
162            break;
163        case 2: //wait
164            if (noPlayableElms.indexOf(currentElm) == -1) {
165                noPlayableElms.push(currentElm);
166                if (cekani == null)
167                    cekani = setInterval("CheckPlayable()", 2500);
168            }
169            break;
170        default:
171            break;
172    }
173}
174function GetSpeech(oEl) {
175    currentElm = oEl;
176    var elIndex = jQuery(oEl).data('index').toString();
177    loader(currentElm, elIndex);
178    if (noPlayableElms.indexOf(oEl) == -1) {
179        jQuery.ajax(
180            {
181                url: GetQueryUrl(),
182                type: 'POST',
183                async: false,
184                traditional: true,
185                data: {hash: jQuery(oEl).data('sha1')},
186                success: function (result) {
187                    DecodeResult(result);
188                }
189            }
190        );
191    }
192}
193
194function InitReadable() {
195    var intCounter = 0;
196    var reg_he = /<\/h[1-6]>/gi; //mezera za nadpisy
197    var reg_hs = /<h[1-6]>/gi; //mezera pred nadpisy
198    var reg_nr_a = /<a[^>]+class="not_readable[^>]*>.*?<\/a>/gi;
199    var reg_nr_sp = /<span[^>]+class="not_readable[^>]*>.*?<\/span>/gi;
200    var reg_nr_p = /<p[^>]+class="not_readable[^>]*>.*?<\/p>/gi;
201    var reg_nr_div = /<div[^>]+class="not_readable[^>]*>.*?<\/div>/gi;
202    var reg_p = /<\/(dd|dt|li|p|div|td|th|caption)>/gi;
203    var reg_br = /<br[^>]*>/gi;
204    jQuery('.readable').each(function (index) {
205        var textToRead = jQuery(this).clone();
206        jQuery('script', textToRead).remove();
207        jQuery('style', textToRead).remove();
208        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();
209        if (testEmpty.length != 0) {
210            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();
211            var textHash = sha1(hlasEngine + cleanText);
212            jQuery(this).data('sha1', textHash);
213            var ttsWrap = '<div class="tts-controls">' +
214                '<button id="tts-wrap_' + intCounter.toString() + '" class="tts-wrap cs btn btn-primary gcm-btn-secondary" onclick="return GetSpeech(jQuery(this).data(\'rElm\'));" title="Přečíst nahlas" style="max-width:fit-content;margin-top:5px;margin-bottom:5px;"><div class="lcs" style="display:flex;align-items:center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" style="height:20px;fill:currentColor;margin-right:5px"><!--!Font Awesome Free v7.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--><path d="M112 416L160 416L294.1 535.2C300.5 540.9 308.7 544 317.2 544C336.4 544 352 528.4 352 509.2L352 130.8C352 111.6 336.4 96 317.2 96C308.7 96 300.5 99.1 294.1 104.8L160 224L112 224C85.5 224 64 245.5 64 272L64 368C64 394.5 85.5 416 112 416zM505.1 171C494.8 162.6 479.7 164.2 471.3 174.5C462.9 184.8 464.5 199.9 474.8 208.3C507.3 234.7 528 274.9 528 320C528 365.1 507.3 405.3 474.8 431.8C464.5 440.2 463 455.3 471.3 465.6C479.6 475.9 494.8 477.4 505.1 469.1C548.3 433.9 576 380.2 576 320.1C576 260 548.3 206.3 505.1 171.1zM444.6 245.5C434.3 237.1 419.2 238.7 410.8 249C402.4 259.3 404 274.4 414.3 282.8C425.1 291.6 432 305 432 320C432 335 425.1 348.4 414.3 357.3C404 365.7 402.5 380.8 410.8 391.1C419.1 401.4 434.3 402.9 444.6 394.6C466.1 376.9 480 350.1 480 320C480 289.9 466.1 263.1 444.5 245.5z"/></svg> Přečíst nahlas<\/div><\/button>
214' +
215                '<div role="alert" id="tts-loader_' + intCounter.toString() + '" class="btn btn-primary gcm-btn-secondary" style="display: none; cursor:wait; max-width: fit-content;margin-top:5px;margin-bottom:5px;">Text se převádí<\/div>' +
216                '<button id="tts-close_' + intCounter.toString() + '" class="btn btn-primary gcm-btn-secondary" aria-label="Zavřít Přečíst nahlas" style="display: none; max-width: fit-content;margin-top:5px;margin-bottom:5px;">Zavřít<\/button>' +
217                '<\/div>';
218            var ttsElm = jQuery(ttsWrap).prependTo(this);
219            jQuery(this).data('index', intCounter);
220            jQuery(this).data('wrapper', ttsElm);
221            jQuery(this).data('text', cleanText);
222            jQuery('#tts-wrap_' + intCounter.toString()).data('rElm', this);
223        }
224        intCounter++;
225    });
226    var readList = jQuery('.readable_list').first();
227    if (readList) {
228        var allText = '';
229        jQuery('.readable_item').each(function (index) {
230            var subTextToRead = jQuery(this).clone();
231            jQuery('script', subTextToRead).remove();
232            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();
233            if (testSubText.length > 0) {
234                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();
235                allText += subText + '[~gcm_insert_pause~]';
236            }
237        });
238        if (allText.length > 0) {
239            var textHash = sha1(hlasEngine + allText);
240            jQuery(readList).data('sha1', textHash);
241            var ttsWrap = '<div class="tts-controls">' +
242                '<button id="tts-wrap_' + intCounter.toString() + '" class="tts-wrap cs btn btn-primary gcm-btn-secondary" onclick="return GetSpeech(jQuery(this).data(\'rElm\'));" title="Přečíst nahlas" style="max-width:fit-content;margin-top:5px;margin-bottom:5px;"><div class="lcs" style="display:flex;align-items:center"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" style="height:20px;fill:currentColor;margin-right:5px"><!--!Font Awesome Free v7.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--><path d="M112 416L160 416L294.1 535.2C300.5 540.9 308.7 544 317.2 544C336.4 544 352 528.4 352 509.2L352 130.8C352 111.6 336.4 96 317.2 96C308.7 96 300.5 99.1 294.1 104.8L160 224L112 224C85.5 224 64 245.5 64 272L64 368C64 394.5 85.5 416 112 416zM505.1 171C494.8 162.6 479.7 164.2 471.3 174.5C462.9 184.8 464.5 199.9 474.8 208.3C507.3 234.7 528 274.9 528 320C528 365.1 507.3 405.3 474.8 431.8C464.5 440.2 463 455.3 471.3 465.6C479.6 475.9 494.8 477.4 505.1 469.1C548.3 433.9 576 380.2 576 320.1C576 260 548.3 206.3 505.1 171.1zM444.6 245.5C434.3 237.1 419.2 238.7 410.8 249C402.4 259.3 404 274.4 414.3 282.8C425.1 291.6 432 305 432 320C432 335 425.1 348.4 414.3 357.3C404 365.7 402.5 380.8 410.8 391.1C419.1 401.4 434.3 402.9 444.6 394.6C466.1 376.9 480 350.1 480 320C480 289.9 466.1 263.1 444.5 245.5z"/></svg> Přečíst nahlas<\/div><\/button>' +
243                '<div role="alert" id="tts-loader_' + intCounter.toString() + '" class="btn btn-primary gcm-btn-secondary" style="display: none; cursor:wait; max-width: fit-content;margin-top:5px;margin-bottom:5px">Text se převádí<\/div>' +
244                '<button id="tts-close_' + intCounter.toString() + '" class="btn btn-primary gcm-btn-secondary" aria-label="Zavřít Přečíst nahlas" style="display: none; max-width: fit-content;margin-top:5px;margin-bottom:5px;">Zavřít<\/button>' +
245                '<\/div>';
246            var ttsElm = jQuery(ttsWrap).prependTo(readList);
247            jQuery(readList).data('index', intCounter);
248            jQuery(readList).data('wrapper', ttsElm);
249            jQuery(readList).data('text', allText);
250            jQuery('#tts-wrap_' + intCounter.toString()).data('rElm', readList);
251        }
252    }
253}
254
255function CheckPlayable() {
256    if (noPlayableElms.length === 0) {
257        if (cekani) {
258            clearInterval(cekani);
259            cekani = null;
260        }
261        return;
262    } else {
263        GetSpeech(noPlayableElms.shift());
264    }
265}
266
267window.onload = function () {
268    InitReadable();
269};

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.