PageSourceSearch

https://www.kristberg.at/system/modules/ncmPackages/assets/ncm.rooms_frontend.js

js kristberg.at collected 2026-10-02 12:33:29 UTC 13,714 bytes, 328 lines download raw bytes

1// which site are we on?
2var siteType = false;
3
4jQuery(function() {
5    
6    // set sitetype
7    switch (true) {
8        case (typeof ncmRoomListMinPrices != "undefined"): // roomlist
9            siteType = "roomlist";
10            break;
11        
12        case (typeof ncmRoomDetailsMinPrices != "undefined"): // roomdetails
13            siteType = "roomdetails";
14            break;
15
16        default: // don't contiunue
17            return false;
18    }
19
20	// store list url in cookie
21	if (siteType == "roomlist") {
22		// store the selected date index in a cookie
23		jQuery.cookie("room_list_url_" + jQuery("html").attr("lang"), window.location, {path:'/'});
24	}
25	
26	// replace list links with the link stored in cookie
27	if (siteType == "roomdetails") {
28		var list_url = jQuery.cookie("room_list_url_" + jQuery("html").attr("lang"));
29		if (list_url) {
30            // TODO: check the link a.room-list-link if it has a classname to avoid this (dont-overwrite-room-list-link)
31			jQuery("a.room-list-link").not('.dont-overwrite-room-list-link').attr("href", list_url);
32		}
33	}
34	
35//    // onclick
36//    jQuery("div[data-onclick]").each(function() {       
37//        jQuery(this).css('cursor','pointer');
38//        var link = window.location.protocol + '//' + window.location.hostname;// + '/';
39//        jQuery(this).on('click', function(e) {
40//            if (e.target == this) {
41//				var url = jQuery(this).attr('data-onclick');
42//				if (url.substring(0, 1) != '/') {
43//					url = '/' + url;
44//				}
45//                window.location = link + url;
46//            }
47//        }).on('click', '> *', function(e) {
48//			if ((e.target.nodeName != 'A') && (e.target.parentNode.nodeName != 'A')) {
49//				var url = jQuery(this).parents().attr('data-onclick');
50//				if (url.substring(0, 1) != '/') {
51//					url = '/' + url;
52//				}
53//                window.location = link + url;
54//            } else if (e.target.nodeName == 'A') {
55//				var url = jQuery(e.target).attr('href');
56//				if (url.substring(0, 1) != '/') {
57//					url = '/' + url;
58//				}
59//                window.location = link + url;
60//			}
61//       });
62//    });
63    
64    // ie8-9 workaround for image carousels
65    // @TODO: find the reason...
66    if (jQuery("body").hasClass("ie8") || jQuery("body").hasClass("ie9")) {
67        jQuery("#main").on("click", ".imgcarousel .carousel-control", function(event) {
68            event.stopPropagation();
69            jQuery(this).closest(".imgcarousel").carousel(jQuery(this).data("slide"));
70            return false;
71        });
72        jQuery("#main").on("click", ".pricecarousel .carousel-control", function(event) {
73            event.stopPropagation();
74            jQuery(this).closest(".pricecarousel").carousel(jQuery(this).data("slide"));
75            return false;
76        });
77    }
78    
79    // event for all price carousels
80    jQuery(".pricecarousel").on("slide.bs.carousel", function(event) {
81
82        // actual room
83        var room_id = jQuery(this).data("room-id");
84
85        // indexes
86        //var slideFrom = jQuery(this).find('.active').index();
87        var slideTo = event.relatedTarget ? jQuery(event.relatedTarget).index() : (parseInt(jQuery.cookie("room_date_index_" + room_id)) || 0);
88
89        // detail functionality
90        if (siteType == "roomdetails") {
91            // turn on the loading class
92            //jQuery("#room-price-container_" + room_id).find(".room_preis_indicator").show();
93            //jQuery("#room-price-container_" + room_id).find(".room_preis_wrapper").hide();
94
95            // loading indicator
96            try {
97                if (event.relatedTarget) {
98					
99					jQuery.blockUI({
100                            message : '<div class="message"><div class="loader"></div><br /> ' + CONTAO_LANGUAGE.ncmRoomDetails.room_ajax_text + '</div>'
101            
102                    });
103                }
104            } catch(e) {
105            }
106           
107            // update the price(s)
108            try {
109                //debug(ncmRoomDetailsMinPrices[room_id][slideTo]);
110                var price_key_counter = 0;
111				jQuery.each(ncmRoomDetailsMinPrices[room_id][slideTo], function(key, value) {
112					var field = jQuery("#rooms_"+key+"_ab_value_" + room_id).text(value);
113                    var currency_field = jQuery("#rooms_"+key+"_ab_currency_" + room_id);
114                    if (currency_field.size()) {
115                        if (currency_field.attr("data-special-text") == value) {
116                            currency_field.hide();
117                        } else {
118                            currency_field.show();
119                        }
120                    }
121                    //console.dir(currency_field);
122                    var price_key = Math.floor(price_key_counter/2)*2;
123                    
124                    // update texts
125                    if (typeof ncmRoomDetailsPriceDescriptionTexts != "undefined" ) {
126                        jQuery("#rooms_"+price_key+"_price_description_text_" + room_id).html(ncmRoomDetailsPriceDescriptionTexts[room_id][slideTo][price_key]);
127                    }
128                    if (typeof ncmRoomDetailsPriceDescriptionTitles != "undefined" ) {
129                        jQuery("#rooms_"+price_key+"_price_description_title_" + room_id).html(ncmRoomDetailsPriceDescriptionTitles[room_id][slideTo][key]);
130                    }
131                    
132					if (value) {
133						//debug("show field: " + "#rooms_"+key+"_ab_value_" + room_id);
134						field.closest(".price_wrapper").addClass("visible").removeClass("hidden").show();
135					} else {
136						//debug("hide field: " + "#rooms_"+key+"_ab_value_" + room_id);
137						field.closest(".price_wrapper").addClass("hidden").removeClass("visible").hide();
138					}
139                    
140                    // add/remove push columns
141                    var check_field_selector = false;
142                    if (field.attr("data-version2")) {
143                        check_field_selector = "#rooms_" + field.attr("data-version1-key") + "_ab_value_" + room_id;
144                    } else if (field.attr("data-version1")) {
145                        check_field_selector = "#rooms_" + field.attr("data-version2-key") + "_ab_value_" + room_id;
146                    }
147                    if (check_field_selector && jQuery(check_field_selector).size()) {
148                        debug("check_field_selector: " + check_field_selector + " current field:" + key + " check_field: " + field.attr("data-version1-key"));
149                        var $check_field = jQuery(check_field_selector);
150                        jQuery.each(['xs', 'sm', 'md', 'lg'], function(ekey, environment) {
151                            var matches;
152                            var regexp = new RegExp("col-" + environment + "-((no)?push)-([0-9]+)");
153                            //console.log(regexp);
154                            if (matches = field.closest(".price_wrapper").attr("class").match(regexp)) {
155                                if ($check_field.closest(".price_wrapper").hasClass("visible")) {
156                                    debug("check field is visible");
157                                    field.closest(".price_wrapper").removeClass("col-" + environment + "-nopush-" + matches[3]).addClass("col-" + environment + "-push-" + matches[3]);
158                                } else { // remove push
159                                    debug("check field is hidden");
160                                    field.closest(".price_wrapper").removeClass("col-" + environment + "-push-" + matches[3]).addClass("col-" + environment + "-nopush-" + matches[3]);
161                                }
162                            }
163                        });
164                    }
165                    price_key_counter++;
166				});
167				
168				// show hide elements
169                var visibility_counter = 0;//fix even/odd to color just the visible elements (even and odd)
170                var visibility_array = ["visible-odd", "visible-even"];//fix even/odd
171				jQuery(".selection_rooms .item_detail").each(function() {
172					if (jQuery(this).find(".price_wrapper.visible").size()) {
173						debug("show:" + jQuery(this).attr("data-pricelevel"));
174                        jQuery(this).addClass(visibility_array[visibility_counter % 2]);//fix even/odd
175                        visibility_counter=visibility_counter+1;//fix even/odd
176						jQuery(this).addClass("visible").removeClass("hidden").show();
177						jQuery(".selection_rooms .pricelevel[data-pricelevel="+jQuery(this).attr("data-pricelevel")+"]").addClass("visible").removeClass("hidden").show(); 
178					} else {
179						debug("hide:" + jQuery(this).attr("data-pricelevel"));
180						jQuery(this).addClass("hidden").removeClass("visible").hide();
181						jQuery(".selection_rooms .pricelevel[data-pricelevel="+jQuery(this).addClass("hidden").removeClass("visible").attr("data-pricelevel")+"]").hide(); 
182					}
183				});
184
185                // store the selected date index in a cookie
186                jQuery.cookie("room_date_index_" + room_id, slideTo, {path:'/'});
187
188            } catch (e) {
189                debug(e);
190            }
191        }
192        
193        // list functionality
194        if (siteType == "roomlist") {
195            // turn on the loading class
196            jQuery("#room_preis_ab_" + room_id).find(".room_preis_indicator").show();
197            jQuery("#room_preis_ab_" + room_id).find(".room_preis_wrapper").hide();
198           
199            // update the price
200            try {
201                jQuery("#rooms_preis_ab_value_" + room_id).text(ncmRoomListMinPrices[room_id][slideTo]);
202              
203                // store the selected date index in a cookie
204                jQuery.cookie("room_date_index_" + room_id, slideTo, {path:'/'});
205                
206            } catch (e) {
207                debug(e);
208            }
209        }
210    });
211
212    // event for all price carousels
213    jQuery(".pricecarousel").on("slid.bs.carousel", function(event) {
214
215        // actual room
216        var room_id = jQuery(this).data("room-id");
217        // detail functionality
218        if (siteType == "roomdetails") {
219            // turn off the loading class
220            //jQuery("#room-price-container_" + room_id).find(".room_preis_indicator").hide();
221            //jQuery("#room-price-container_" + room_id).find(".room_preis_wrapper").show();
222            // loading
223            try {
224                jQuery.unblockUI();
225            } catch (e) {
226                
227            }
228        }
229    
230        // list functionality
231        if (siteType == "roomlist") {
232            // turn off the loading class
233            jQuery("#room_preis_ab_" + room_id).find(".room_preis_indicator").hide();
234            jQuery("#room_preis_ab_" + room_id).find(".room_preis_wrapper").show();
235        }
236    });
237
238    // swipe
239	jQuery(".pricecarousel, .imgcarousel").swipe({
240	    //onSwipe:function(direction, data){
241	    swipe:function(event, direction, distance, duration, fingerCount) {
242            switch (direction) {
243                case "left":
244                    jQuery(this).carousel("next");
245                    break;
246                case "right":
247                    jQuery(this).carousel("prev");
248                    break;
249                //case "up":
250                //case "down":
251                //case "none":
252                //  window.scrollBy(0,data.distY * -1);
253                //  break;
254            }
255	    },
256        click:function(event) {
257            if (jQuery(this).hasClass("imgcarousel")) {
258                jQuery(this).find('.active a').trigger("click");
259            }
260        },
261	    //threshold:50,
262	    allowPageScroll:"vertical"
263	});
264    
265    // trigger
266    if (siteType == "roomdetails") {
267        jQuery(".pricecarousel").trigger("slide.bs.carousel", {});
268    }
269});
270
271// room sliding on room category list pages
272jQuery('.showRooms').click(function() {
273	jQuery(this).next('.room_category_rooms_wrapper').slideToggle();
274});
275
276jQuery('.closeRooms').click(function() {
277	jQuery(this).parents('.room_category_rooms_wrapper').slideToggle();
278});
279
280// carousel thumbnails
281jQuery(window).on("enterenvironment startwindowresize windowresize", function(event, params) {
282
283    jQuery(".carousel-thumbnails").each(function() {
284        if (jQuery(this).attr("data-initialised")) {
285            return;
286        }
287        
288        var $carousel = jQuery(jQuery(this).attr("data-carousel"));
289        if (!$carousel.size()) {
290            return;
291        }
292        var $thumbnails = jQuery(this);
293        
294        // set selected
295        var selected = $carousel.find(".item.active").attr("data-index");
296        
297        // selected
298        $carousel.on("slid.bs.carousel", function() {
299            var selected = $carousel.find(".item.active").attr("data-index");
300            $thumbnails.find(".carousel-thumbnail").removeClass("selected").filter("[data-index="+selected+"]").addClass("selected");
301        });
302        
303        $thumbnails.find("img").css("cursor", "pointer").on("click", function() {
304            $carousel.carousel(parseInt(jQuery(this).closest(".carousel-thumbnail").attr("data-index")));            
305        }) . each(function() {
306            if (jQuery(this).closest(".carousel-thumbnail").attr("data-index") == selected) {
307                jQuery(this).closest(".carousel-thumbnail").addClass("selected");
308            }
309        });
310        
311        $thumbnails.attr("data-initialised", "1");
312    });
313});
314
315// form functions
316jQuery(function() {
317    jQuery("select.form_ncm_rooms_room_id_select").on("change", function() {
318        // reset
319        jQuery("fieldset.roomForm input[type=hidden]").val(0);
320        
321        var token = jQuery(this).val();
322        if (!token) {
323            return;
324        }
325        
326        jQuery("input[name=anz_"+token+"]").val(1);
327    });
328});

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.