PageSourceSearch

https://www.prague.com/media/js/common.js

js prague.com collected 2026-10-02 18:55:22 UTC 7,650 bytes, 224 lines download raw bytes

1function parseQueryStringToArray(queryString) {
2    if (queryString === '') return [];
3    var result = [];
4    var nameValuePairs = queryString.substr(1).split('&');
5    for (var i=0; i<nameValuePairs.length; i ++) {
6        var nameValuePair = nameValuePairs[i].split('=');
7        var name = nameValuePair[0];
8        var value = decodeURIComponent(nameValuePair[1]);
9        result.push({name: name, value: value});
10    }
11    return result;
12}
13
14function arrayToDict(array) {
15    var resultDict = {};
16    for (var i=0; i<array.length; i++) {
17        if (resultDict.hasOwnProperty(array[i].name)) {
18            var origValue = resultDict[array[i].name];
19            resultDict[array[i].name] = [origValue];
20            resultDict[array[i].name].push(array[i].value);
21        } else {
22            resultDict[array[i].name] = array[i].value;
23        }
24    }
25    return resultDict;
26}
27
28function parseQueryString() {
29    $.QueryArray = parseQueryStringToArray(window.location.search);
30    $.QueryDict = arrayToDict($.QueryArray);
31}
32
33(function() {
34    parseQueryString();
35})();
36
37if (!window.console) {
38    console = {
39        log: function() {}
40    };
41}
42
43function supportsHistory() {
44    return window.history && window.history.pushState;
45}
46
47// Datepicker basics
48var DATEPICKER_DATE_FORMAT = 'dd/mm/yy';
49var EAN_MAX_STAY_DAYS = 28;
50
51function dpFormatDate(date) {
52    function pad(value) {return (value < 10) ? '0' + value : value;}
53    return [pad(date.getDate()), pad(date.getMonth() + 1), date.getFullYear()].join('/');
54}
55
56function dpParseDate(dateStr) {
57    var dateParts = dateStr.split('/');
58    return new Date(parseInt(dateParts[2]), parseInt(dateParts[1])-1, parseInt(dateParts[0]));
59}
60
61function generateRandomId() {
62    return (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toUpperCase();
63}
64
65(function($) {
66    $.fn.extend({
67        fancyiframe: function(options) {
68            if (typeof options === 'undefined') {
69                options = {};
70            }
71            if (typeof options.width === 'undefined') {
72                options.width = 650;
73            }
74            if (typeof options.height === 'undefined') {
75                options.height = 350;
76            }
77            options.iframe = true;
78            if (typeof options.pluginName === 'undefined') {
79                options.pluginName = 'fancyiframe';
80            }
81            this.fancypopup(options);
82        },
83        fancypopup: function(options) {
84            if (typeof options === 'undefined') {
85                options = {
86                    width: 650,
87                    height: 350
88                };
89            }
90            var pluginName = typeof options.pluginName === 'undefined' ? 'fancypopup' : options.pluginName;
91            var animTimeMs = 300;
92            return this.each(function () {
93                var openerLink = $(this);
94                var wrapId = options.id;
95                if (typeof options.id === 'undefined') {
96                    var linkId = openerLink.attr('id');
97                    if (linkId) {
98                        wrapId = openerLink.attr('id') + '-' + pluginName;
99                    } else {
100                        wrapId = generateRandomId() + '-' + pluginName;
101                    }
102                }
103                openerLink.on('click', function (event) {
104                    var wrap = $('#' + wrapId);
105                    var iframe;
106                    event.preventDefault();
107                    if (wrap.length === 0) {
108                        wrap = $('<div id="' + wrapId + '" class="' + pluginName + '"/>').appendTo('body');
109                        if (options.iframe === true) {
110                            iframe = $('<iframe src="' + openerLink.attr('href') +
111                                '" frameborder="no" border="0" width="100%" height="100%"/>');
112                            iframe.appendTo(wrap);
113                        } else if (options.content !== 'undefined') {
114                            var content = options.content;
115                            content.detach();
116                            content.appendTo(wrap);
117                        }
118                        wrap.find('.close-popup').on('click', function(event) {
119                            event.preventDefault();
120                            wrap.dialog('close');
121                        });
122                        wrap.dialog({
123                            modal: true,
124                            width: options.width,
125                            height: options.height,
126                            draggable: false,
127                            dialogClass: pluginName,
128                            show: {
129                                duration: animTimeMs
130                            },
131                            hide: {
132                                duration: animTimeMs
133                            },
134                            open: function(event, ui) {
135                                $('.ui-widget-overlay.ui-front').on('click', function () {
136                                    if (wrap.dialog('isOpen')) {
137                                        wrap.dialog('close');
138                                    }
139                                });
140                            }
141                        });
142                    }
143                    if (!wrap.dialog('isOpen')) {
144                        wrap.dialog('open');
145                    }
146                    if (options.iframe === true) {
147                        if (iframe.attr('src') != openerLink.attr('href')) {
148                            iframe.src = openerLink.attr('href');
149                        }
150                    }
151                });
152            });
153        }
154    });
155})($);
156
157// cookies
158function supportsLocalStorage() {
159    var storage, result, uid = new Date().toISOString();
160    try {
161        (storage = window.localStorage).setItem(uid, uid);
162        result = storage.getItem(uid) == uid;
163        storage.removeItem(uid);
164        return result && storage;
165    } catch (exception) {
166        return false;
167    }
168}
169
170function LocalStorage() {
171    this.get = function(key) {
172        return window.localStorage.getItem(key);
173    };
174    this.set = function(key, value) {
175        return window.localStorage.setItem(key, value);
176    };
177    this.del = function(key) {
178        return window.localStorage.removeItem(key);
179    };
180}
181
182function CookieStorage() {
183    this.get = getCookie;
184    this.set = setCookie;
185    this.del = removeCookie;
186}
187
188function getCookie(name) {
189    var dc = document.cookie;
190    var prefix = name + "=";
191    var begin = dc.indexOf("; " + prefix);
192    if (begin == -1) {
193        begin = dc.indexOf(prefix);
194        if (begin !== 0) return null;
195    } else
196        begin += 2;
197    var end = document.cookie.indexOf(";", begin);
198    if (end == -1)
199        end = dc.length;
200    return decodeURIComponent(dc.substring(begin + prefix.length, end));
201}
202
203function setCookie(name, value, expires, path, domain, secure) {
204    if (typeof value === "object") {
205        if (value.expires !== "undefined") {
206            expires = value.expires;
207        }
208        if (value.value !== "undefined") {
209            value = value.value;
210        }
211    }
212    var curCookie = name + "=" + escape(value) +
213        ((expires) ? "; expires=" + expires.toGMTString() : "") +
214        ((path) ? "; path=" + path : "; path=/") +
215        ((domain) ? "; domain=" + domain : "") +
216        ((secure) ? "; secure" : "");
217    document.cookie = curCookie;
218}
219
220function removeCookie(name) {
221    setCookie(name, '', new Date(1970, 0, 1, 0, 0, 1));
222}
223
224window.browserStorage = supportsLocalStorage() ? new LocalStorage() : new CookieStorage();

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.