var hotelmap = { overlayElement : null, properties : {} } ; /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Hotelmap|Library|Utility Functions * Description: Generic Util functions for use within HM * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : Yay! * ------------------------------------------------------------------------- */ var debug_enabled = false; var location_path = false; var has_calendar_hash = false; function getLingualDate(date, options) { try { var options = (options) ? options : { weekday: 'short', year: 'numeric', month: 'long', day: 'numeric' }; var final_str = date.toLocaleDateString(attributes.language.replace("_", "-"), options); return final_str; } catch (noDateValidException) { console.log("error"); console.dir(noDateValidException); return false; } } /** * Instructs browser to make hash uri change. * * @param newHash * @param details */ function makeHashChange(newHash, details) { try { if (newHash != "calendar" || !has_calendar_hash) { if (!location_path) { location_path = location.href.replace(location.hash, ""); if (newHash == "calendar") { has_calendar_hash = true; } } history.pushState(details, document.title, location_path + "#" + newHash); } } catch (pushStateException) { // Empty. } } /** * Switch the language of the map when selected from the map drop down. * This intercepts urls found in the shortcodes area which map to the index * project. * * @param destination * @param languagecode */ function switchLanguageFromCalendarDropDown(destination, languagecode) { // Allow for shortcodes and always default the base option of // adding the languages to end of the url - old style! try { if (shortcodes && shortcodes[languagecode]) { location.href = shortcodes[languagecode].destination; } else { location.href = destination; } } catch (switchCalendarException) { location.href = destination; } } function clearViewFromHashChange(remCal, remTray, remDetail) { //cal try { if (remCal) { hotelmap.library.utility.overlay(80, '#000', false, 154); hotelmap.calendar.panel.parentNode.removeChild(hotelmap.calendar.panel); } } catch (e_1) {} try { if (remDetail) { hotelmap.detail_panel.parentNode.removeChild(hotelmap.detail_panel); } } catch (e_2) {} try { if (remTray) { hotelmap.infopanel.container.parentNode.removeChild(hotelmap.infopanel.container); hotelmap.infopanel.isClosed = true; } } catch (e_3) {} } /** * Create a new hash event * * @param event */ function makeHashEventActive(event) { if (event && event.state && event.state.model) { switch (event.state.model) { case "calendar": clearViewFromHashChange(false, true, true); // Make sure we haven't already got one of thse. if ($("#caldhad").length == 0) { hotelmap.calendar.init(); } break; case "tray": clearViewFromHashChange(true, false, true); break; case "search": clearViewFromHashChange(true, true, true); break; } } } window.onpopstate = function(event) { makeHashEventActive(event); }; function debugMessage(message) { if (debug_enabled == true) console.log("debug: " + message); } function runRoutingDistance(dataBindElement, mode) { try { $(".walk_dis_" + hotelmap.infopanel.hmid).html(""); hotelmap.walking_times_data[hotelmap.infopanel.hmid] = ""; hotelmap.infopanel.process_height(); } catch (infProcHeightException) {} } // Processing Session Request. function processSessionRequest(data) { if (data && data.responseText) { var postloadSessionData = JSON.parse(data.responseText); if (postloadSessionData.session > '') { attributes.session = postloadSessionData.session; } if (postloadSessionData.auth > '') { attributes.authcode = postloadSessionData.auth; } } } var language_fields = {}; function doAddLang() { $.each($("[langid]"), function() { var langid = $(this).attr("langid"); var langreset = $(this).attr("allowreset"); var langtarget = $(this).attr("langtarget"); if (!language_fields[langid] || langreset) { language_fields[langid] = true; if (langtarget) { $(this).attr(langtarget, translations["LNG_" + langid]); // + " (TR)"); } else { $(this).html(translations["LNG_" + langid]); //+ " (TR)"); } if (langid == "FRMATEN") { var sentence = translations["LNG_" + langid]; //[ATTENDEES] attendees are expected at [EVENT] this [MONTH] at [VENUE]. These visitors are staying in hotels mainly in [COUNT] hotel hubs, all with easy access to the venue. var countPoint = (!attributes.pointers) ? "popular" : (attributes.pointers.length + 1); sentence = sentence.replace("[ATTENDEES]", attributes.eventAttendees); sentence = sentence.replace("[EVENT]", attributes.pagedata.title); sentence = sentence.replace("[MONTH]", translations["LNG_AUTOLONGMONTHS" + attributes.event.date_start.month]); sentence = sentence.replace("[VENUE]", attributes.pagedata.subtitle); try { sentence = sentence.replace("[COUNT]", countPoint); } catch (e123) {} $(this).html(sentence); } } }); } /** * This is a temporary work around to disable distances for specific hotels * whilst we implement a better routing option */ function canRunDistanceCheck(mapid, hmid) { try { if (attributes.disable_distance_checks[mapid][hmid]) { return false; } } catch (invalidAttributeReferenceException) { // Empty. } return true; } /** * Post calendar runner */ var doCustomFramePostCalendarHasBeenRun = false; function doCustomFramePostCalendar() { if (attributes.custom_frames && attributes.custom_frames.enabled == true && !doCustomFramePostCalendarHasBeenRun) { if (!$("div").hasClass("hubframeshown")) { $.ajax( "frames/custom_frames/loader?mapReference=" + attributes.map_identity + "&auth=" + attributes.authcode + "&target=" + attributes.custom_frames.source, { 'complete': function(data) { var d = JSON.parse(data.responseText); //console.dir(d); var p = document.createElement("div"); $(p).addClass("custom_frame hubframeshown"); $(p).append(d.data); $("body").append($(p)); bindPickerWtmEvents(); //hotelmap.library.utility.overlay(80,'#000',true, 999); var closeIcon = hotelmap.library.utility.element( "img", { 'position': 'absolute', 'right': '-10px', 'top': '-10px', 'zIndex': '9999', 'cursor': 'pointer', 'z-index': '999999' }, { 'src': attributes.host + 'resource/images/gfx_v2/close.png', 'id': 'hdhjd' } ); $(".shadowyman").append(closeIcon); $(closeIcon).click(function() { doCustomFramePostCalendarHasBeenRun = true; setTimeout(function() { $(".custom_frame").fadeOut( 300, function() { $(this).remove() } ); hotelmap.library.utility.overlay(80, '#000', false, 154); }, 50); }); doAddLang(); $(".hub_title").html(attributes.pagedata.title); $(".hub_sub_title").html($("#prim_subtitle").html()); } } ); } } } function bindPickerWtmEvents() { $(".inner[hm-type='jump']").click(function() { doCustomFramePostCalendarHasBeenRun = true; var latlon = $(this).attr("hm-latlon").split(","); hotelmap.maps.zoomToPoint(latlon[0], latlon[1], parseInt(latlon[2]) + 1); $(".custom_frame").fadeOut(300, function() { $(this).remove() }); hotelmap.library.utility.overlay(80, '#000', false, 154); /* Server Automation mode, send through cal set */ if (attributes.automation_mode == "server") { hotelmap.auto_demo.server.send_notify("doWTMClose", latlon[0] + "," + latlon[1] + "," + (parseInt(latlon[2]) + 1)); } }); } function inIframe() { try { return window.self !== window.top } catch (a) { return true; } } function userdata(field, value) { var session = attributes.session; var mapsession = attributes.mapsession; var mapid = attributes.map_identity; var zoom = attributes.zoomlevel; var lat = attributes.latitude; var lon = attributes.longitude; if (!window.isbot) { $.ajax("/map/services/reporting/userdata?auth=" + attributes.authcode + "&id=" + mapid + "&lat=" + lat + "&lon=" + lon + "&zoom=" + zoom + "&session=" + session + "&mapsession=" + mapsession + "&f=" + field + "&v=" + escape(value), { 'complete': function(data) { processSessionRequest(data); } }); } } function usermetadata(type, data) { var session = attributes.session; var mapsession = attributes.mapsession; var mapid = attributes.map_identity; if (!window.isbot) { $.ajax("/map/services/reporting/userdata?auth=" + attributes.authcode + "&mode=meta&id=" + mapid + "&type=" + type + "&v=" + escape(data) + "&session=" + session + "&mapsession=" + mapsession, { 'complete': function(data) { processSessionRequest(data); } }); } } /** * NEW RUNTIMES */ hotelmap.runtime = { applyHeaders: function(title, subtitle) { hotelmap.heading_items.title.innerHTML = "HotelMapTM " + translations.LNG_HMFOR + " " + title; hotelmap.heading_items.subtitle.innerHTML = subtitle; try { document.title = "HotelMap " + translations.LNG_HMFOR + " " + title; } catch (titleSettingException) {} hotelmap.calendar.title = title; hotelmap.calendar.subtitle = (subtitle.length > 57) ? subtitle.substr(0, 57) + ".." : subtitle; } }; String.prototype.rtrim = function(s) { return this.replace(new RegExp(s + "*$"), ''); }; function capitaliseFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } if (!hotelmap.library) hotelmap.library = {}; /* define: hotelmap.library.utility */ function id_check_input(obj, dest) { if (obj.value.length == 1) { document.getElementById(dest).focus(); try { document.getElementById(dest).select(); } catch (ekl) {} } } function similarity(s1, s2) { var longer = s1; var shorter = s2; if (s1.length < s2.length) { longer = s2; shorter = s1; } var longerLength = longer.length; if (longerLength == 0) { return 1.0; } return (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength); } function editDistance(s1, s2) { s1 = s1.toLowerCase(); s2 = s2.toLowerCase(); var costs = new Array(); for (var i = 0; i <= s1.length; i++) { var lastValue = i; for (var j = 0; j <= s2.length; j++) { if (i == 0) costs[j] = j; else { if (j > 0) { var newValue = costs[j - 1]; if (s1.charAt(i - 1) != s2.charAt(j - 1)) newValue = Math.min(Math.min(newValue, lastValue), costs[j]) + 1; costs[j - 1] = lastValue; lastValue = newValue; } } } if (i > 0) costs[s2.length] = lastValue; } return costs[s2.length]; } function deg2rad(deg) { return deg * (Math.PI / 180) } function translate(i) { try { var j = "LNG_" + i; if (translations[j]) document.getElementById(j).innerHTML = translations[j]; } catch (e) {} } /* public functions available externally */ function frameClose() { hotelmap.library.utility.close(); } var iterations = 0; var transparency = 100; function closeInformationWindow() { hotelmap.detail_panel_id = ""; //hotelmap.rhp.push_to_packet("CLICK_CLOSEINFWINDOW","1"); iterations = 0; transparency = 100; runGradientClose(); hotelmap.library.json.get("resource/script/hmww-tap?point=INFO_PANEL&tid=" + attributes.ref_codal_tid + "&"); } function getRandomArbitrary(min, max) { return Math.round(Math.random() * (max - min) + min); } function isWithin(lat, lon) { lat = parseFloat(lat); lon = parseFloat(lon); var boundary = hotelmap.maps.getQueryPosition(); //console.log("LL: " + lat + ", " + lon); //console.dir(boundary); return (lat > boundary[0] && lat < boundary[2] && lon > boundary[3] && lon < boundary[1]) ? true : false; } function runGradientClose() { if (attributes.isIE) { hotelmap.library.utility.overlay(90, '#000', false, 154); hotelmap.detail_panel.parentNode.removeChild(hotelmap.detail_panel); } else { if (iterations < 20) { transparency = transparency - 5; iterations++; hotelmap.library.utility.setTrans(hotelmap.detail_panel, transparency); hotelmap.library.utility.setTrans(hotelmap.overlayElement, transparency - 10); setTimeout(function() { runGradientClose(); }, 20); } else { iterations = 0; transparency = 100; hotelmap.library.utility.overlay(90, '#000', false, 154); hotelmap.detail_panel.parentNode.removeChild(hotelmap.detail_panel); } } } function removeUpdatingRatesLayer() { /* Remove any remaining rate progress elements from the screen */ try { hotelmap.calendar.preload.parentNode.removeChild(hotelmap.calendar.preload); } catch (e1) {} } function infoPanelFocus(hotelId, setter) { window.tagging.setHotelPopup(); makeHashChange("hotel", { model: 'hotel', hmid: hotelId, setter: setter }); /* Remove any remaining rate progress elements from the screen */ removeUpdatingRatesLayer(); //hotelmap.rhp.push_to_packet("CLICK_INFOPANELFOCUS",hotelId+"|"+setter); hotelmap.graphics.zoomInScreen(null, 920, 634, '#FFFFFF', function() { var user_string = ""; if (attributes.additional_params) { for (var i = 0; i < attributes.additional_params.length; i++) { var param = attributes.additional_params[i]; user_string += "" + param.parameter_name + "=" + param.parameter_value + "&"; } } if (hotelmap.calendar.postLoadHotel) { user_string += "&waitNode=true"; hotelmap.calendar.initialiseHotelId = ""; hotelmap.calendar.postLoadHotel = false; user_string += "&panel=" + hotelmap.calendar.panelPush; } else { user_string += "&panel=summary"; } hotelmap.userstatistics.pop_panels++; userdata("countHotelsPopup", hotelmap.userstatistics.pop_panels); usermetadata("FULL_INFO_POPUP", hotelId); //console.log("user_stirng: " + user_string); //console.log("Processing HMID " + hotelId + " with SearchID: " + hotelmap.modules.feedprocess.search_id_reference[hotelId]); var iframe = hotelmap.library.utility.element( "iframe", { 'width': '920px', 'height': '634px', 'overflow': 'hidden', 'zIndex': '997' }, { 'allowtransparency': 'yes', 'wmode': 'Opaque', 'width': '920px', 'height': '634px', 'scrolling': 'no', 'frameBorder': 'no', 'id': 'frame', 'src': 'frames/details/landing?dir=' + attributes.direction + '&agentID=' + attributes.agentID + '&displayRates=' + hotelmap.modules.feedprocess.payViewType + '&' + user_string + '&affiliateCode=' + attributes.affiliateCode + '&searchID=' + hotelmap.modules.feedprocess.search_id_reference[hotelId] + '&hmid=' + hotelId + '&mapProCode=' + attributes.map_identity + '&host=' + attributes.remote + '&' //' } //attributes.searchid ); hotelmap.detail_panel_id = hotelId + "|" + setter; hotelmap.detail_panel.innerHTML = ""; hotelmap.detail_panel.appendChild(iframe); }, setter); } function closeAndShowCal(hotelID, panel) { if (!hotelID) { hotelmap.library.utility.overlay(60, '#000', false, 154); } hotelmap.detail_panel.parentNode.removeChild(hotelmap.detail_panel); hotelmap.detail_panel_id = ""; //hotelmap.library.utility.overlay(90,'#000',false, 174); hotelmap.calendar.init(); if (hotelID) { hotelmap.calendar.panelPush = panel; hotelmap.calendar.initialiseHotelId = hotelID; hotelmap.calendar.hasShownElement = false; hotelmap.calendar.postLoadHotel = true; } } /* utility functions */ hotelmap.library.utility = { applyAttributes: function(o, styles) { if (o && styles) { for (var i in styles) { o[i] = styles[i]; } } }, applyStyles: function(o, styles) { if (o && styles) { for (var i in styles) { o.style[i] = styles[i]; } } }, focusMoments: {}, focusOnZone: function(plat, plon, latmin, latmax, lonmin, lonmax, ID) { if (latmax && lonmax && latmax != 0 && lonmax != 0) // Is it an area? { hotelmap.disable = true; if (hotelmap.library.utility.focusMoments[ID]) { hotelmap.maps.zoomToPoint(plat, plon, hotelmap.library.utility.focusMoments[ID]); } else { hotelmap.maps.zoomToPoint(plat, plon, 5); var proceed = false; var start = 5; var zoomInModeInterval = setInterval( function() { //latmin, lonmin, latmax, lonmax if (hotelmap.maps.isInZone(latmin, lonmin, latmax, lonmax)) { start++; hotelmap.maps.zoomToPoint(plat, plon, start); } else { // hotelmap.disable=false; // hotelmap.maps.zoomToPoint( plat, plon, start-1 ) ; setTimeout(function() { hotelmap.modules.feedprocess.get_new_hotel_listing(); }, 500); clearInterval(zoomInModeInterval); // hotelmap.library.utility.focusMoments[ID] = start-1; } }, 100 ); } } }, isIEResizeEvent: function() { if (attributes.isIpad == true) return false; return true; if (!attributes.isIE || attributes.isLowIE) return true; // All other browsers behave correctly. var dims = hotelmap.library.utility.getDimensions(); if (dims[0] != hotelmap.IEDIMS[0] || dims[1] != hotelmap.IEDIMS[1]) { hotelmap.IEDIMS = dims; return true; } else { return false; } }, /** * Frame closer * @returns */ close: function() { if (hotelmap.detail_panel) { try { hotelmap.detail_panel.parentNode.removeChild(hotelmap.detail_panel); hotelmap.library.utility.overlay(90, '#000', false, 154); } catch (e) {} } }, /** * Transparency setter * @param obj * @param level * @returns */ setTrans: function(obj, level) { level = parseInt(level); if (obj && level >= 0 && level <= 100) { obj.hidOpac = level; obj.style.MozOpacity = level / 100; obj.style.opacity = level / 100; obj.style.filter = "alpha(opacity=" + level + ")"; try { if (attributes.isLowIE && obj.allowSubSet && obj.childNodes && obj.childNodes.length > 0) { for (var i = 0; i < obj.childNodes.length; i++) { hotelmap.library.utility.setTrans(obj.childNodes[i], level); } } } catch (e) {} } }, /** * Quick DIV * @param id * @param text * @returns */ quickdiv: function(id, text) { return hotelmap.library.utility.element("div", {}, { 'innerHTML': text, 'id': id }); }, /** * Quick DIV * @param id * @param text * @returns */ makediv: function(id, text) { return hotelmap.library.utility.element("div", {}, { 'innerHTML': text, 'className': id }); }, /** * deflect * Stops hotel collision so much. Note that 1 degree is 112.12KM */ deflect: function(lat, lon, distanceInMetres, direction) { //Earth�s radius, sphere var R = 6378137; //offsets in meters var dn = 0; var de = 0; if (direction == "lat") { dn = distanceInMetres; } else { de = distanceInMetres; } //Coordinate offsets in radians var dLat = dn / R; var dLon = de / (R * Math.cos(Math.PI * lat / 180)); //OffsetPosition, decimal degrees var latO = lat + dLat * 180 / Math.PI; var lonO = lon + dLon * 180 / Math.PI; /* var k1 = 1/112; // 1000M var m1 = k1/1000; var result = m1 * distanceInMetres ; var outcome = parseFloat(coordinate) + parseFloat(result); console.log("Current: " + coordinate ); console.log("Outcome: " + outcome); */ return [latO, lonO]; }, grabImageBase: function(imageObject) { console.log(imageObject); console.log("Dimensions: " + imageObject.width + " x " + imageObject.height); var canvas = document.getElementById("cn"); //document.createElement("canvas"); canvas.width = imageObject.width; canvas.height = imageObject.height; var context = canvas.getContext("2d"); context.drawImage(imageObject, 0, 0); boxBlurCanvasRGB("cn", 0, 0, 256, 256, 23, 2); //canvas.style.webkitFilter = "blur(10px)"; /* code that actually blurs the image goes here */ //var dataURI = canvas.toDataUrl("image/png"); //console.log(dataURI); }, /** * overlay * Creates [or uses existing] overlay. * @param color string (hex) * @param $doShow boolean */ overlay: function(transparency, color, doShow, zIndex) { if (!hotelmap.calendar.postLoadHotel) { hotelmap.ui = (hotelmap.ui) ? hotelmap.ui : _("ui"); if (hotelmap.overlayElement != null) { hotelmap.overlayElement.style.backgroundColor = color; hotelmap.library.utility.setTrans(hotelmap.overlayElement, transparency); hotelmap.overlayElement.style.display = (doShow) ? '' : 'none'; } else { var dimensions = hotelmap.library.utility.getDimensions(); hotelmap.overlayElement = hotelmap.library.utility.element("div", { 'zIndex': zIndex, 'position': 'fixed', 'left': '0px', 'top': '0px', 'width': '100%', 'height': '100%' }, {}); hotelmap.library.utility.setTrans(hotelmap.overlayElement, transparency); hotelmap.ui.appendChild(hotelmap.overlayElement); hotelmap.library.utility.overlay(transparency, color, doShow); } } }, /** * getDimensions * Returns the current browser dimensions * @return array[w,h] */ getDimensions: function() { var viewportwidth; var viewportheight; if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth, viewportheight = window.innerHeight } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportwidth = document.documentElement.clientWidth, viewportheight = document.documentElement.clientHeight } else { viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight } //if ( attributes.dvid == "MOB_SAFARI_TAB" || attributes.dvid == "MOB_SAFARI") // { // viewportwidth = screen.width; // viewportheight = screen.height; // } // alert( viewportwidth +", " + viewportheight); return new Array(viewportwidth, viewportheight); }, /** * pushFullScreenMap * Redundant? */ pushFullScreenMap: function(objectName) { var dimensions = hotelmap.library.utility.getDimensions(); hotelmap.object_map = (hotelmap.object_map) ? hotelmap.object_map : document.getElementById(objectName); hotelmap.object_map.style.position = 'absolute'; hotelmap.object_map.style.left = '0px'; hotelmap.object_map.style.top = '0px'; hotelmap.object_map.style.width = dimensions[0] + 'px'; hotelmap.object_map.style.height = dimensions[1] + 'px'; if (hotelmap.engine_map) setTimeout(function() { hotelmap.engine_map.resize(); }, 100); //hotelmap.object_map.style.width = "200px"; //hotelmap.object_map.style.height = "300px"; }, pushSpecificScreenMap: function(objectName, left, top, width, height) { var dimensions = hotelmap.library.utility.getDimensions(); hotelmap.object_map = (hotelmap.object_map) ? hotelmap.object_map : document.getElementById(objectName); hotelmap.object_map.style.position = 'absolute'; hotelmap.object_map.style.left = left + 'px'; hotelmap.object_map.style.top = top + 'px'; hotelmap.object_map.style.width = width + 'px'; hotelmap.object_map.style.height = height + 'px'; //if ( hotelmap.engine_map ) setTimeout(function(){ hotelmap.engine_map.resize(); }, 100 ); //hotelmap.object_map.style.width = "200px"; //hotelmap.object_map.style.height = "300px"; }, /** * styles * Apply styling elements to an object * @param obj DOM * @param attributes JSON attribute array */ styles: function(obj, attributes) { if (attributes) for (var a in attributes) if (a && attributes[a]) try { obj.style[a] = attributes[a]; } catch (e) {} }, /** * attributes * Apply styling elements to an object * @param obj DOM Node * @param attributes JSON attribute array */ attributes: function(obj, attributes) { if (attributes) for (var a in attributes) if (a && attributes[a]) try { obj[a] = attributes[a]; } catch (e) {} }, /** * element * Creates a new DOM element * @param name - DOM name * @param styles - JSON styles * @param attributes - JSON attr * @return Returns a new DOM element node. */ element: function(name, styles, attributes) { var element = document.createElement(name); hotelmap.library.utility.styles(element, styles); hotelmap.library.utility.attributes(element, attributes); //element.die=function(){ this.parentNode.removeChild(this); } //element.ping=function(){ console.log("Element PING: Alive");} return element; }, /** * rn * Round a number to N dec * @param num - the number * @param dec - decimal places * @return double */ rn: function(num, dec) { var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); return result; }, generateID: function(length) { var sequence = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; var preSequence = "NID_"; var id = preSequence; for (var i = 0; i < length; i++) id += sequence[hotelmap.library.utility.rnd1random(0, sequence.length)]; return id; }, rnd1random: function(from, to) { return from + Math.floor(Math.random() * (to + 1)); }, calculateSecondsBetweenDates: function(date1) { var t1 = date1; var t2 = new Date(); var dif = t1.getTime() - t2.getTime() var Seconds_from_T1_to_T2 = dif / 1000; var Seconds_Between_Dates = Math.abs(Seconds_from_T1_to_T2); return Seconds_Between_Dates; } }; /** * * Base64 encode / decode * http://www.webtoolkit.info/ * **/ var Base64 = { // private property _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode: function(input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode: function(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode: function(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode: function(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }; function _(id) { return document.getElementById(id); } /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Hotelmap|Core|Library|Events * Description: Event based routines for the hotelmap core * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : Ensure that only event based routines go in here. * ------------------------------------------------------------------------- */ if ( !hotelmap.library ) hotelmap.library = {} ; /* define: hotelmap.library.events */ hotelmap.library.events = { triggers : {}, /** * add_window_event * Add a browser based event handler * @param eventType [load,click etc] * @param func [the function to run] */ initialiseEvent : function( eventType, func ) { if (window.addEventListener) { window.addEventListener(eventType, func, false); } else if (window.attachEvent) { window.attachEvent('on'+eventType, func); } }, /** * preventLoadEvent * Prevents the loading of hotel information for a specific event */ preventLoadEvent : function() { clearInterval( hotelmap.properties['new_hotel_listing_interval'] ) ; }, /** * addTriggerEvent * */ addTriggerEvent : function( triggerID, funcAction ) { if ( !hotelmap.library.events.triggers[triggerID] ) hotelmap.library.events.triggers[triggerID] = []; hotelmap.library.events.triggers[triggerID].push(funcAction); }, callTriggerEvent : function( triggerID ) { if ( hotelmap.library.events.triggers[triggerID] ) { for ( var i = 0 ; i < hotelmap.library.events.triggers[triggerID].length ; i++ ) { try { hotelmap.library.events.triggers[triggerID][i]; } catch ( triggerException ) { alert("triggerException: " + triggerException.message); } } } } } ; /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Hotelmap|Core|Library|JSON * Description: HTTP XML Request / JSON Handler * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : Don't edit this - it should be pretty static code. * ------------------------------------------------------------------------- */ if (!hotelmap.library) hotelmap.library = {}; /* define: hotelmap.library.json */ hotelmap.library.json = { counter: 0, /** * get_handle * Obtain a valid AJAX handler * @return AJAX Handler Object */ get_handle: function() { var ajaxHandle = null; if (window.XMLHttpRequest) { ajaxHandle = new XMLHttpRequest(); } else if (window.ActiveXObject) { _msxml_progid = ['MSXML2.XMLHTTP.6.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']; for (var i = 0; i < _msxml_progid.length; i++) { try { ajaxHandle = new ActiveXObject(this._msxml_progid[i]); break; } catch (ajaxHandleException) { /* Null Value */ } } if (ajaxHandle == null) { ajaxHandle = new ActiveXObject('Microsoft.XMLHTTP'); } } return ajaxHandle; }, staggered_get: function(url) { if (hotelmap.library.json.counter < 20) { hotelmap.library.json.counter++; var delta_url = ("" + Math.random()).split(".")[1].substring(0, 7); url = url + "verification=" + attributes.verification + "&pdr=" + delta_url + "&auth=" + attributes.authcode; var ajaxHandle = hotelmap.library.json.get_handle(); if (ajaxHandle != null) { ajaxHandle.onreadystatechange = function() { hotelmap.library.json.parse_staggered(ajaxHandle); }; ajaxHandle.open("GET", url, true); ajaxHandle.send(null); } } else { setTimeout(function() { hotelmap.library.json.staggered_get(url); }, 1000); } }, /** * parse * Process an incoming handler on the correct state * @param handle */ parse_staggered: function(handle) { if (handle.readyState == 4 && handle.status == 200) { if (handle.responseText) { var response = handle.responseText; if (response) { hotelmap.library.json.counter--; try { eval(response); } catch (e) { hotelmap.library.json.post( "services/reporting/jserror", "error=" + e.message + "&block=" + response + "&verification=" + attributes.verification + "&auth=" + attributes.authcode ); console.error("Error Report: " + e.message); } response = null; } } } }, /** * get * @param url string * @param doEval boolean [do evaluation of return] */ get: function(url, doEval) { if (!window.isbot) { var delta_url = ("" + Math.random()).split(".")[1].substring(0, 7); var destination = url + "&auth=" + attributes.authcode + "&pdr=" + delta_url; $.ajax(destination, { 'complete': function(data) { if (data && data.responseText) { $responseSet = data.responseText; try { eval($responseSet); } catch (parseException) { hotelmap.library.json.post( "services/reporting/jserror", "error=" + parseException.message + "&block=" + $responseSet + "&verification=" + attributes.verification + "&auth=" + attributes.authcode ); response = null; } } } }); } }, post: function(url, post) { var ajaxHandle = hotelmap.library.json.get_handle(); if (ajaxHandle) { ajaxHandle.onreadystatechange = function() {}; ajaxHandle.open("POST", url, true); ajaxHandle.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // ajaxHandle.setRequestHeader("Content-length", post.length); // ajaxHandle.setRequestHeader("Connection", "close"); ajaxHandle.send(post); } }, postRun: function(url, post) { var ajaxHandle = hotelmap.library.json.get_handle(); if (ajaxHandle) { ajaxHandle.onreadystatechange = function() { hotelmap.library.json.parse(ajaxHandle); }; ajaxHandle.open("POST", url, true); ajaxHandle.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // ajaxHandle.setRequestHeader("Content-length", post.length); // ajaxHandle.setRequestHeader("Connection", "close"); ajaxHandle.send(post); } }, /** * parse * Process an incoming handler on the correct state * @param handle */ parse: function(handle) { if (handle.readyState == 4 && handle.status == 200) { if (handle.responseText) { var response = handle.responseText; if (response) { try { eval(response); } catch (e) { hotelmap.library.json.post( "services/reporting/jserror", "error=" + e.message + "&block=" + response + "&verification=" + attributes.verification + "&auth=" + attributes.authcode ); response = null; } } } } } }/** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Hotelmap|Modules|Process Hotel Feeds * Description: Process the incomign hotel feeds for display. * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : CORE interface for searching hotels. * ------------------------------------------------------------------------- */ if (!hotelmap.modules) hotelmap.modules = {}; /* define: hotelmap.modules.feedprocess */ hotelmap.modules.feedprocess = { zoom_level: null, hotels: {}, pixel_sets: {}, pins: [], base_to_search: [], base_timeout: null, cached_rates: {}, rate_icons: {}, base_searcher: {}, has_searched: false, hotel_length: 0, resetCoordinates: true, hasDoneHotels: false, isZoomMode: false, payViewType: false, loop_pop: '', pop_done: false, doPaymentTypeProcess: function() { var showall = ((attributes.filtering.showPayLater && attributes.filtering.showPayNow) || (!attributes.filtering.showPayLater && !attributes.filtering.showPayNow)) ? true : false; if (showall) { hotelmap.modules.feedprocess.payViewType = false; } else { if (attributes.filtering.showPayLater) { hotelmap.modules.feedprocess.payViewType = "PAY_LATER"; } else { hotelmap.modules.feedprocess.payViewType = "PAY_NOW"; } } // Search the hotelmap based on the new settings. hotelmap.calendar.search(); }, get_new_hotel_listing_by_zoom: function() { hotelmap.modules.feedprocess.get_new_hotel_listing(); hotelmap.modules.feedprocess.isZoomMode = true; }, /** * get_new_hotel_listing * On each movement this will get the local host listings nearby */ get_new_hotel_listing: function() { try { hotelmap.maps.zoomer.maintainOrder(); } catch (maintainOrderException) { console.log("Maintain: " + e1.message); } if (hmwwas && hmwwas.HOTEL_AREAS_ALLOWED == "ON" && hotelmap.calendar.searched) { if (!hotelmap.modules.feedprocess.hasDoneHotels) { hotelmap.library.json.get("resource/script/hmww-tap?point=VIEWING_HOTELS&tid=" + attributes.ref_codal_tid + "&"); hotelmap.modules.feedprocess.hasDoneHotels = true; } var zoom = hotelmap.maps.getZoom(); var current_center_coordinates = hotelmap.maps.getCenter(); attributes.latitude = current_center_coordinates.lat; attributes.longitude = current_center_coordinates.lon; attributes.zoomlevel = zoom; if (zoom > 6 && hotelmap.search_data.dates.arrival && !window.isbot) { clearTimeout(hotelmap.modules.feedprocess.base_timeout); clearInterval(hotelmap.properties['new_hotel_listing_interval']); hotelmap.properties['new_hotel_listing_interval'] = setInterval( function() { var recommended = 0; if (attributes.isRecommendedHotelAutoSet == 1 && (attributes.isRecommendedHotelSender == 1 || attributes.dvid != 'DESKTOP')) { recommended = 1; } clearInterval(hotelmap.properties['new_hotel_listing_interval']); var coords = hotelmap.maps.getQueryPosition(); var center = hotelmap.maps.getCenter(); var destination_url = "services/hotels/local_hotel_feed?rec=" + recommended + "&mcode=" + attributes.request_uri + "&starRank=" + attributes.star_rankings + "&hotel_requirements=" + attributes.hotel_requirements + "&zt=hotelmap.maps.getZoom&class=" + attributes.hotel_class + "&query=" + coords[0] + "," + coords[1] + "," + coords[2] + "," + coords[3] + "&zoom_level=" + zoom + "&cb=hotelmap.modules.feedprocess.process_result_set&originSet=" + attributes.initial_lat + "," + attributes.initial_lon + "¢er=" + center.lat + "," + center.lon + "&affiliate=" + attributes.affiliateCode + "&"; hotelmap.library.json.get(destination_url); }, 100 ); } else { hotelmap.modules.feedprocess.remove_all_pins(); } } hotelmap.exclusivedeals.process(); }, /** * check_rate * Do we have a valid cached rate? * @param hmid */ check_rate: function(hmid) { return (hotelmap.modules.feedprocess.cached_rates[hmid]) ? true : false; }, search_id_reference: {}, /** * rates * Process an incoming rate feed. * @param rates JSON */ rates: function(rates, searchid) { attributes.total_search_count--; if (attributes.total_search_count <= 0) { attributes.total_search_count = 0; try { $(".connecting").hide(); } catch (conShow) {} } if (rates.length > 0) { for (var i = 0; i < rates.length; i++) { hotelmap.modules.feedprocess.search_id_reference[rates[i].hmid] = searchid; // Create a search reference ID hotelmap.modules.feedprocess.cached_rates[rates[i].hmid] = rates[i]; hotelmap.userstatistics.rates_loaded++; // Exclusive specific.. if (attributes.show_exclusive_specific) { for (var k = 0; k < attributes.show_exclusive_specific.condition_values.length; k++) { if (attributes.show_exclusive_specific.condition_values[k] == rates[i].hmid) { attributes.exclusive_hotels[rates[i].hmid] = true; } } } // Pink Circle - We can auto-dump certain hotels if we want. try { if (attributes.pinkCirclePromos && attributes.pinkCirclePromos.length > 0) { for (var pCount = 0; pCount < attributes.pinkCirclePromos.length; pCount++) { if (rates[i].hmid == attributes.pinkCirclePromos[pCount]) { rates[i].memberRate = 1; } } } } catch (pinkCircleRateException) { // Empty. } /** * Hotel Planner Adjustmet. * This is for testing only and can be removed later. */ try { if (attributes.hpl_circles) { var localFeedsAvailable = JSON.parse(rates[i].feedsAvailable); if (localFeedsAvailable[0] == "HPL") { rates[i].memberRate = 1; } else if (localFeedsAvailable.includes("HPL")) { rates[i].memberRate = 2; } else { rates[i].memberRate = 0; } } } catch (hplCircles) { // console.log("Error in hplCirlces " + hplCircles.message); } if (attributes.runDemoScreenGrab == "NO" && attributes.zoomlevel > 12 && rates[i].memberRate > 0 && rates[i].rate > 0 && rates[i].rate < 9999 && ( attributes.map_identity == "142958" || attributes.map_identity == '145489' || attributes.map_identity == '145171' || attributes.show_member_rates || attributes.show_exclusive_rates)) { if (attributes.hpl_circles) { //console.log(">>>> " . attributes.member_rates_color); var hpl_color = (rates[i].memberRate == 2) ? "#0000FF" : "#FF0000"; attributes.highlighthotels.push({ "color": hpl_color, "hotel": rates[i].hmid, "name": "" }); attributes.promoted_hotels[rates[i].hmid] = true; } else if (!attributes.show_member_rates && !attributes.show_exclusive_rates) { attributes.highlighthotels.push({ "color": attributes.member_rates_color, "hotel": rates[i].hmid, "name": "" }); attributes.promoted_hotels[rates[i].hmid] = true; } else if (attributes.show_member_rates) { var tmpcolor = attributes.member_rates_color; try { if (attributes.show_member_rates.settings == rates[i].hmid) { tmpcolor = "#FF00ED"; } } catch (colorSettingException) { } attributes.highlighthotels.push({ "color": tmpcolor, "hotel": rates[i].hmid, "name": "" }); attributes.promoted_hotels[rates[i].hmid] = true; } else if (attributes.show_exclusive_rates) { attributes.exclusive_hotels[rates[i].hmid] = true; } try { $("div[hm-hmid='" + rates[i].hmid + "']")[0].isAutoActiveNode = true; $("div[hm-hmid='" + rates[i].hmid + "']")[0].runFromRatePoint = true; } catch (e) {} } } } try { if (attributes.resultviewer) { hotelmap.resultviewer.addResults(rates); } } catch (rvException) {} hotelmap.modules.feedprocess.push_rates_to_screen(); attributes.searchid = searchid; hotelmap.hotel_highlight.pushToHotels(); hotelmap.exclusivedeals.process(); setTimeout( function() { hotelmap.sorting.rightpanel.sort( hotelmap.rightpanel.listings.hotelcontainer ); }, 2000 ); }, /** * push_rates_to_screen * Push any and all rates we have obtained to the screen. */ push_rates_to_screen: function() { for (var i in hotelmap.modules.feedprocess.rate_icons) { var ri = hotelmap.modules.feedprocess.rate_icons[i]; var rv = hotelmap.modules.feedprocess.check_rate(i); if (!ri.rate_done && rv) { ri.rate_done = true; hotelmap.hotelicon.create_rate_icon( ri, hotelmap.modules.feedprocess.cached_rates[i] ); ri.hmid = i; try { hotelmap.infopanelisfocused.find(i); } catch (epep) {} } } hotelmap.sorting.rightpanel.sort( hotelmap.rightpanel.listings.hotelcontainer ); try { hotelmap.focushotel.auto_panel_initialiser(); } catch (focusException) {} hotelmap.pushsearchdone = true; }, __do_internal_query: function(url) { if (attributes.searchid && attributes.searchid != 'undefined') { url += "&searchID=" + attributes.searchid + "&"; } url += "&cb=hotelmap.modules.feedprocess.rates&"; url += (hotelmap.modules.feedprocess.has_searched) ? "&newSearch=N&" : "&newSearch=Y&"; url += "&roomConfig=" + hotelmap.criteraJSON + "&"; url += "¤cy=" + hotelmap.search_data.currency; url += "&arrival=" + hotelmap.search_data.dates.arrival.yyyymmdd; url += "&departure=" + hotelmap.search_data.dates.departure.yyyymmdd + "&"; url += "&mapid=" + attributes.map_identity + "&affcode=" + attributes.affiliateCode + "&"; url += "&PIN=" + attributes.pin_number + "&"; url += "&langCode=" + attributes.language + "&"; if (hotelmap.modules.feedprocess.payViewType) { if (hotelmap.modules.feedprocess.payViewType == "PAY_LATER") { url += "&rateType=PHR&"; } else if (hotelmap.modules.feedprocess.payViewType == "PAY_NOW") { url += "&rateType=PNR&"; } } if (attributes.additional_params) { for (var i = 0; i < attributes.additional_params.length; i++) { var param = attributes.additional_params[i]; url += "" + param.parameter_name + "=" + param.parameter_value + "&"; } } attributes.total_search_count++; try { if (!attributes.showOnly) { $(".connecting").fadeIn(); } } catch (conShow) { } hotelmap.library.json.staggered_get(url); }, /** * distance_between_points * Calculates the distance between two sets of latitude and longitude * @param point1 , format = {'lat':0,'lon':0} * @param point2 * @return double * - Added: 15th March 2013 */ distance_between_points: function(point1, point2) { var lat1 = point1.lat; var lon1 = point1.lon; var lat2 = point2.lat; var lon2 = point2.lon; var R = 6371; // Radius of the earth in km var dLat = deg2rad(lat2 - lat1); // deg2rad below var dLon = deg2rad(lon2 - lon1); var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d = R * c; // Distance in km return d; }, /** * sort_bases_closet_to_focus * Sort the bases so that those closest to the hotel load first. * @param latitude * @param longitude * - Added: 15th March 2013 */ sort_bases_closet_to_focus: function() { // Obtain the current center point var center = hotelmap.maps.getCenter(); // Ensure that we have some bases to search before we try and sort them. if (hotelmap.modules.feedprocess.base_to_search && hotelmap.modules.feedprocess.base_to_search.length > 0) { // Create our sort method. Use the distance to point as our priority moment. hotelmap.modules.feedprocess.base_to_search.sort( function(a, b) { var centeral_point = { 'lat': center.lat, 'lon': center.lon }; var point_location_1 = { 'lat': hotelmap.modules.feedprocess.rate_icons[a].data.primary_data.latitude, 'lon': hotelmap.modules.feedprocess.rate_icons[a].data.primary_data.longitude }; var point_location_2 = { 'lat': hotelmap.modules.feedprocess.rate_icons[b].data.primary_data.latitude, 'lon': hotelmap.modules.feedprocess.rate_icons[b].data.primary_data.longitude }; var a_distance = hotelmap.modules.feedprocess.distance_between_points(centeral_point, point_location_1); var b_distance = hotelmap.modules.feedprocess.distance_between_points(centeral_point, point_location_2); hotelmap.modules.feedprocess.rate_icons[a].data.primary_data.my_distance = a_distance; hotelmap.modules.feedprocess.rate_icons[b].data.primary_data.my_distance = b_distance; return a_distance - b_distance; } ); } }, // END /** * hotelmap.modules.feedprocess.query * Process any outstanding requests to search for rates. */ query: function() { try { hotelmap.modules.feedprocess.sort_bases_closet_to_focus(); } catch (distanceSortOrderException) { } if (!window.isbot && hmwwas && hmwwas.HOTEL_RATES_ALLOWED == "ON" && hotelmap.search_data.dates.arrival) { var url = "services/hotels/search_hotels?rdsg=" + attributes.runDemoScreenGrab + "&bases="; var base_search_count = 0; var spawn_search = 0; var spawn_temp = attributes.spawn_requests; if (hotelmap.modules.feedprocess.base_to_search.length < 10) { spawn_temp = Math.round(attributes.spawn_requests / 2); } if (hotelmap.modules.feedprocess.base_to_search.length > 0 && !window.isbot) { for (var i = 0; i < hotelmap.modules.feedprocess.base_to_search.length; i++) { if (!hotelmap.modules.feedprocess.check_rate(hotelmap.modules.feedprocess.base_to_search[i]) && !hotelmap.modules.feedprocess.base_searcher[hotelmap.modules.feedprocess.base_to_search[i]]) { attributes.statistics.rate_responses++; base_search_count++; spawn_search++; hotelmap.modules.feedprocess.base_searcher[hotelmap.modules.feedprocess.base_to_search[i]] = 1; url += hotelmap.modules.feedprocess.base_to_search[i] + ","; if (spawn_search == spawn_temp) { hotelmap.modules.feedprocess.__do_internal_query(url); var url = "services/hotels/search_hotels?rdsg=" + attributes.runDemoScreenGrab + "&bases="; var base_search_count = 0; var spawn_search = 0; } } } if (spawn_search > 0) { hotelmap.modules.feedprocess.__do_internal_query(url); } } hotelmap.modules.feedprocess.has_searched = true; hotelmap.modules.feedprocess.push_rates_to_screen(); } }, /** * showCluster * @param filters * Return the count of hotels within a cluster.. */ showCluster: function(filters) { var show = 0; var brand_filtered = false; var reduce = false; //console.dir(filters); // -- // Are we brand filtering? for (var i in hotelmap.brandlinks) { if (hotelmap.brandlinks[i].filtered) brand_filtered = true; } // -- // Brand Filtered: // Only show specific brands and then ensure the star rating is included. if (brand_filtered) { show = 0; for (var i in hotelmap.brandlinks) { if (hotelmap.brandlinks[i].filtered) { if (filters.brands[i]) { if (attributes.filtering.show5star && filters.brands[i].five > 0) show = show + filters.brands[i].five; if (attributes.filtering.show4star && filters.brands[i].four > 0) show = show + filters.brands[i].four; if (attributes.filtering.show3star && filters.brands[i].three > 0) show = show + filters.brands[i].three; if (attributes.filtering.show2star && filters.brands[i].two > 0) show = show + filters.brands[i].two; if (attributes.filtering.show1star && filters.brands[i].one > 0) show = show + filters.brands[i].one; } } } } else // -- // Only process star requirements { show = 0; if (attributes.filtering.show5star && filters.five > 0) show = show + filters.five; if (attributes.filtering.show4star && filters.four > 0) show = show + filters.four; if (attributes.filtering.show3star && filters.three > 0) show = show + filters.three; if (attributes.filtering.show2star && filters.two > 0) show = show + filters.two; if (attributes.filtering.show1star && filters.one > 0) show = show + filters.one; } return (show > 0) ? show : 0; }, processExtendedFilterSystem: function(filter) { var show = 0; }, /** * isBrandFiltered * Single hotel test for showing. */ isBrandFiltered: function(brandid) { show = true; for (var i in hotelmap.brandlinks) { if (hotelmap.brandlinks[i].filtered) { show = false; } } try { if (brandid && hotelmap.brandlinks[brandid].filtered) { show = true; } } catch (brandExceptionPoint) { } return show; }, showHotel: function(hotel) { var show = false; var found = false; if (!attributes.filtering.show3star) { attributes.filtering.show2star = attributes.filtering.show1star = false; } if (attributes.filtering.show5star && hotel.stars >= 5) show = true; if (attributes.filtering.show4star && hotel.stars >= 4 && hotel.stars < 5) show = true; if (attributes.filtering.show3star && hotel.stars >= 3 && hotel.stars < 4) show = true; if (attributes.filtering.show2star && hotel.stars >= 2 && hotel.stars < 3) show = true; if (attributes.filtering.show1star && ((hotel.stars >= 0 && hotel.stars < 2) || hotel.stars == "")) show = true; if (attributes.filtering.internet && hotel.INI != "1") show = false; if (attributes.filtering.restaurant && hotel.RST != "1") show = false; if (attributes.filtering.freeparking && hotel.PRK != "1") show = false; if (attributes.filtering.swimming && hotel.SWM != "1") show = false; if (attributes.filtering.fitness && hotel.FTN != "1") show = false; if (attributes.filtering.rated && (hotel.tripRating < 4)) show = false; // console.log("Filtering element: (rated:"+attributes.filtering.rated+") (val:"+hotel.tripRating+") (show:"+show+")"); if (hotelmap.rightpanel.tabseries == "SHORTLIST" && show == true) { for (var i = 0; i < hotelmap.favorites.container.childNodes.length; i++) { if (hotel.hmid == hotelmap.favorites.container.childNodes[i].hotel_id) { found = true; } } if (!found) show = false; } return show; }, /** * hotelmap.modules.feedprocess.remove_all_pins * Clear all visible pins from the screen. */ remove_all_pins: function() { hotelmap.maps.removeAllLayerContent(); }, /** * This is a post process runner which scans the hotels on the map for * ratings and popularity information so we can promote specific hotels * based on rankings and such */ popularity_scanner: function(data_set) { var map_id = attributes.map_identity; var hmid_stack = ""; for (var i = 0; i < data_set.length; i++) { hmid_stack += "hmids[]=" + data_set[i].hmid + "&"; } $.ajax("services/hotels/popularity?auth=" + attributes.authcode + "&" + hmid_stack + "mapID=" + escape(map_id) + "&auth=" + attributes.authcode, { dataType: "json", 'complete': function(data) { if (data && data.responseText) { var json = JSON.parse(data.responseText); var count = 0; for (var hotel_order in json.popularity_by_map) { if (count == 0) { var hotel = json.popularity_by_map[hotel_order]; var hmid = hotel['hmid']; } count++; } for (var hotel_order in json.popularity_by_area) { if (count == 0) { var hotel = json.popularity_by_area[hotel_order]; var hmid = hotel['hmid']; } count++; } if (count == 0) { hotelmap.library.utility.overlay(80, '#000', false, 154); } else { var element = hotelmap.modules.feedprocess.hotels[hmid]; for (var i in hotelmap.modules.feedprocess.pixel_sets) { // Create a group point (cluster icon) if (hotelmap.modules.feedprocess.pixel_sets[i].length > 3) { if (!hotelmap.maps.disable_zones) { for (var j = 0; j < hotelmap.modules.feedprocess.pixel_sets[i].length; j++) { if (hotelmap.modules.feedprocess.pixel_sets[i][j] == hmid) { $("#BLOCKER_" + i.replace('-', '').replace('%', '')).remove(); hotelmap.modules.feedprocess.pixel_sets[i].splice(j, 1); delete hotelmap.cluster_items[hmid]; hotelmap.modules.feedprocess.new_group_point(i, hotelmap.modules.feedprocess.pixel_sets[i].length, hotelmap.modules.feedprocess.pixel_sets[i]); } } } } } if (!hotelmap.hotelicon.feedpoints[element.hmid]) //if (!$("#map").find("#"+element.hmid).length) { hotelmap.modules.feedprocess.create_new_searching_point(element, 'mostpopular'); } else { hotelmap.modules.feedprocess.run_filter_check(element); } } } } }); }, /** * If a parameter request from the url asks that we only show one * hotel then filter out our hotel data set and only show information * about that hotel. This also has the added benefit of preventing * searches for hotels we don't care about. * * @param dataset */ processSingleHotelRequest: function(dataset) { if (attributes.showOnly > 0 && dataset.length > 0) { return dataset.filter(function(ref) { if (ref.hmid == attributes.showOnly) { return ref; } }); } else { return dataset; } }, /** * hotelmap.modules.feedprocess.process_result_set * Process the incoming data set for the current position * @param data_set - JSON data block * @see services/hotels/hotelfeed for JSON format. */ process_result_set: function(data_set) { var total_length = 0; try { if (data_set && data_set.schedule) attributes.schedule = data_set.extended; } catch (noScheduleAttached) {} try { if (data_set && data_set.listings) { data_set = data_set.listings; total_length = data_set.length; } } catch (noListingAttachedException) {} data_set = hotelmap.modules.feedprocess.processSingleHotelRequest( data_set ); /* Ensure the connecting icon is removed when there are no results */ if (total_length == 0) try { $(".connecting").hide(); } catch (conShow) {} /* Fix the no hotels issues */ hotelmap.modules.feedprocess.HotelListings = { 'total': total_length, 'searched': 0, 'groupings': 0, 'groupSearchPoints': 0 }; hotelmap.active_hotel_icons = []; var zeroCount = false; if (!data_set) zeroCount = true; data_set = (data_set) ? data_set : []; if (!hotelmap.modules.feedprocess.pop_done) { if ($("html").hasClass("mostpopular")) { this.popularity_scanner(data_set); hotelmap.modules.feedprocess.pop_done = true; } } //hotelmap.modules.feedprocess.total_hotel_count = data_set.length ; //console.log("Loading; " + hotelmap.modules.feedprocess.total_hotel_count + " hotels" ) ; hotelmap.modules.feedprocess.zoom_level = hotelmap.maps.getZoom(); hotelmap.hotelicon.process_feed_points(); if (hotelmap.modules.feedprocess.zoom_level != hotelmap.modules.feedprocess.old_zoom) { //hotelmap.rightpanel.listings.hotelcontainer.innerHTML = ""; $(hotelmap.rightpanel.listings.hotelcontainer).find(".rightPanelCoreContainer").remove(); hotelmap.hotelicon.feedpoints = {}; hotelmap.modules.feedprocess.remove_all_pins(); hotelmap.hotelicon.right_panel_elements = {}; } hotelmap.cluster_items = {}; hotelmap.modules.feedprocess.pixel_collider = []; hotelmap.modules.feedprocess.base_to_search = []; hotelmap.modules.feedprocess.old_zoom = hotelmap.maps.getZoom(); hotelmap.modules.feedprocess.hotel_length = data_set.length; hotelmap.modules.feedprocess.get_element_groupings(data_set); hotelmap.counter_groups = 0; hotelmap.counter_standard = 0; // IF zoom is more than 14 OR // IF zoom is more than 8 and the number of hotels is less than the defined limit if ((hotelmap.modules.feedprocess.zoom_level > 15 || (hotelmap.modules.feedprocess.zoom_level > 9 && hotelmap.modules.feedprocess.hotel_length < attributes.hotels.maximum_hotel_limit_in_view)) && hotelmap.modules.feedprocess.hotel_length < attributes.collision.maximum_search_limit) // Now we show rates, if applicable. { // Cycle the points along the route and search them all. for (var i in hotelmap.modules.feedprocess.pixel_sets) { for (var j = 0; j < hotelmap.modules.feedprocess.pixel_sets[i].length; j++) { if (!hotelmap.maps.disable_hotels) { var element = hotelmap.modules.feedprocess.hotels[hotelmap.modules.feedprocess.pixel_sets[i][j]]; if (!hotelmap.hotelicon.feedpoints[element.hmid]) //if (!$("#map").find("#"+element.hmid).length) { hotelmap.modules.feedprocess.create_new_searching_point(element); } else { hotelmap.modules.feedprocess.run_filter_check(element); } } } } } else { // Clusters become available at this point.. var recommended = (attributes.isRecommendedHotelAutoSet == 1 && (attributes.isRecommendedHotelSender == 1 || attributes.dvid != 'DESKTOP')) ? 1 : 0; // Cycle the points along the route for (var i in hotelmap.modules.feedprocess.pixel_sets) { // Create a group point (cluster icon) if (hotelmap.modules.feedprocess.pixel_sets[i].length > 3 && !recommended && attributes.disableClustering == false) { if (!hotelmap.maps.disable_zones) { hotelmap.modules.feedprocess.new_group_point(i, hotelmap.modules.feedprocess.pixel_sets[i].length, hotelmap.modules.feedprocess.pixel_sets[i]); } } else { // Search items, as they are alone in a wilderness. if (!hotelmap.maps.disable_points && hotelmap.modules.feedprocess.zoom_level > 9) { for (var j = 0; j < hotelmap.modules.feedprocess.pixel_sets[i].length; j++) { var element = hotelmap.modules.feedprocess.hotels[hotelmap.modules.feedprocess.pixel_sets[i][j]]; if (!hotelmap.hotelicon.feedpoints[element.hmid]) //if (!$("#map").find("#"+element.hmid).length) { hotelmap.modules.feedprocess.create_new_searching_point(element); } else { hotelmap.modules.feedprocess.run_filter_check(element); } } } } } } hotelmap.modules.feedprocess.query(); try { hotelmap.eventicon.init(); } catch (e1) {} // // This hook allows for multi-venue pointers if (attributes.pointers != null) { for (var i = 0; i < attributes.pointers.length; i++) { pointers.addPointer(attributes.pointers[i]) } } // // This hook allows for saved pointers if (attributes.searchLocations && !attributes.pointers) { for (var i in attributes.searchLocations) { if (attributes.searchLocations[i]) pointers.addLocationPointer(attributes.searchLocations[i]); } } try { clearTimeout(hotelmap.pir); hotelmap.pir = setTimeout(function() { hotelmap.leftpanel.process_icon_requests(); }, 500); } catch (e2) {} hotelmap.sorting.rightpanel.sort(hotelmap.rightpanel.listings.hotelcontainer); hotelmap.hotelicon.remove_from_incoming_data_set(data_set); if (zeroCount) hotelmap.rightpanel.tabReference["onmap"].counterText.innerHTML = "(0)"; hotelmap.modules.feedprocess.HotelListings.searched = hotelmap.modules.feedprocess.HotelListings.total - hotelmap.modules.feedprocess.HotelListings.groupings; hotelmap.modules.feedprocess.HotelListings.percentNotShown = Math.round((hotelmap.modules.feedprocess.HotelListings.groupings / hotelmap.modules.feedprocess.HotelListings.total) * 100) /*BREAK*/ //clearTimeout(hotelmap.dcc); //hotelmap.dcc = setTimeout(function(){ // hotelmap.modules.feedprocess.do_collision_check(); //},200); setTimeout(function() { hotelmap.hotel_highlight.pushToHotels(); }, 1000); // Remove the right side items which you've filtered away. if (attributes.enable_listing_modifications) { $(".rightPanelCoreContainer[hm-active-view='no']").hide(); } // We're missing an sorting element where there are no hotels to search. // Thus, when a user zoomes in and the hotels are already searched the ordering element // is not initialised. try { setTimeout(function() { hotelmap.sorting.rightpanel.sort(hotelmap.rightpanel.listings.hotelcontainer); }, 10); } catch (sortingCallException) { /* we dont care about this. */ } }, create_new_searching_point: function(element, popular) { /* Allows a single show only hotel to appear */ if ((attributes.showOnly > 0 && element.hmid == attributes.showOnly) || attributes.showOnly == 0) { if (element.isRecommendedViewEnabled == 1 && element.isUnRecommendedListing == true) { if (attributes.isRecommendedIconEnabled == true) { var icon_unrec_hotel = document.createElement("div"); $(icon_unrec_hotel).addClass("icon_unrec_hotel"); $(icon_unrec_hotel).attr("hm-set-back-pointer", "true"); var point = hotelmap.modules.feedprocess.new_point(element, icon_unrec_hotel); } } else { var searching_icon = hotelmap.hotelicon.create_hotel_searching_icon(0, Math.round(element.stars), element.numRooms, element, false); var point = hotelmap.modules.feedprocess.new_point(element, searching_icon); point.rate_done = false; point.latitude = element.latitude; point.longitude = element.longitude; hotelmap.modules.feedprocess.base_to_search.push(element.hmid); hotelmap.modules.feedprocess.rate_icons[element.hmid] = point; point.hmid = element.hmid; if (popular == 'mostpopular') { hotelmap.modules.feedprocess.loop_pop = setInterval(function() { if ($("#" + element.hmid).length) { clearInterval(hotelmap.modules.feedprocess.loop_pop); setTimeout(function() { var pin = $("#" + element.hmid).parent().parent().parent().clone(); $(pin).addClass("popular_pin").css({ 'z-index': '999999' }).attr('id', element.hmid); $("body").append(pin); $("body").append(''); $(".mpclose").on('click', function() { $(".popular_pin").fadeOut(function() { $(this).remove(); }); $(".mpclose").fadeOut(function() { $(this).remove(); hotelmap.library.utility.overlay(80, '#000', false, 154); }); }); var lbl = '
'; lbl += 'Most popular hotel'; lbl += '
'; $(pin).append(lbl + '
' + element.hotelName + '
'); setTimeout(function() { var iconpin = $(pin).find("#icon-pin"); $(iconpin).css({ 'left': '-' + (iconpin.width() / 2) + 'px' }); }, 50); setTimeout(function() { $(".popular_pin").fadeOut(function() { $(this).remove(); }); $(".mpclose").fadeOut(function() { $(this).remove(); hotelmap.library.utility.overlay(80, '#000', false, 154); }); }, 10000); }, 50); } }, 250); } } } }, run_filter_check: function(element) { try { if (!hotelmap.modules.feedprocess.showHotel(element) || element.fullybooked) { if (attributes.isLowIE) { //hotelmap.modules.feedprocess.rate_icons[element.hmid].style.display = "none"; [rem change jim] hotelmap.library.utility.setTrans(hotelmap.modules.feedprocess.rate_icons[element.hmid], 40); hotelmap.modules.feedprocess.rate_icons[element.hmid].HMHide = true; } else { hotelmap.library.utility.setTrans(hotelmap.modules.feedprocess.rate_icons[element.hmid], 40); hotelmap.modules.feedprocess.rate_icons[element.hmid].className = 'icon_grey_scale'; hotelmap.modules.feedprocess.rate_icons[element.hmid].HMHide = true; } } else { if (!element.fullybooked) { if (attributes.isLowIE) { //hotelmap.modules.feedprocess.rate_icons[element.hmid].style.display = ""; hotelmap.library.utility.setTrans(hotelmap.modules.feedprocess.rate_icons[element.hmid], 100); hotelmap.modules.feedprocess.rate_icons[element.hmid].HMHide = false; } else { hotelmap.library.utility.setTrans(hotelmap.modules.feedprocess.rate_icons[element.hmid], 100); hotelmap.modules.feedprocess.rate_icons[element.hmid].className = ''; hotelmap.modules.feedprocess.rate_icons[element.hmid].HMHide = false; //console.log("GREY"); } } } /** Show ICON moved from hotelfeed low level remover **/ if (!hotelmap.modules.feedprocess.isBrandFiltered(element.brandID)) { hotelmap.library.utility.setTrans(hotelmap.modules.feedprocess.rate_icons[element.hmid], 40); hotelmap.modules.feedprocess.rate_icons[element.hmid].className = 'icon_grey_scale'; hotelmap.modules.feedprocess.rate_icons[element.hmid].HMHide = true; } // Cross Node Activity Check. hotelmap.modules.feedprocess.runCrossNodeActiveCheck( element.hmid, hotelmap.modules.feedprocess.rate_icons[element.hmid].HMHide ); } catch (eeee) {} }, /** * Process a node and determine if it's active or not. * * @param hmid - HotelMap Hotel ID * @param isHidden - Is the item to be hidden? */ runCrossNodeActiveCheck: function(hmid, isHidden) { try { // Lets obtain the right-side container reference. var rsContainer = $(".rightPanelCoreContainer[hm-ref='" + hmid + "']"); // Determine if we're showing or not. // This was previously set to remove full booked, but this // is perhaps not what was required. For the moment, active-view // is now set to yes by default. $(rsContainer).attr("hm-active-view", "yes"); // Comment above live and add this back in to revert. // if (isHidden == true) { // $(rsContainer).attr("hm-active-view", "yes"); // } else { // $(rsContainer).attr("hm-active-view", "yes"); // } } catch (crossElementDetailsException) { // Empty. } }, /** * addPinSmall * Adds a small ID pin for development * @param x INT map x * @param y INT map y * @param col HEX col string */ addPinSmall: function(x, y, col) { // NULL }, /** * new_group_point * Create a new group area pointer set. * @param points [format=string=XXXX%XXXXX] * @param counter string */ new_group_point: function(points, counter, data) { var clus = { five: 0, four: 0, three: 0, two: 0, one: 0, brands: {}, ini: 0, rst: 0, swm: 0, ftn: 0, prk: 0, s5: { ini: 0, rst: 0, swm: 0, ftn: 0, prk: 0 }, s4: { ini: 0, rst: 0, swm: 0, ftn: 0, prk: 0 }, s3: { ini: 0, rst: 0, swm: 0, ftn: 0, prk: 0 }, s2: { ini: 0, rst: 0, swm: 0, ftn: 0, prk: 0 }, s1: { ini: 0, rst: 0, swm: 0, ftn: 0, prk: 0 } }; var starClusterReferences = { "5": { "ref": "s5", "clus": "five" }, "4": { "ref": "s4", "clus": "four" }, "3": { "ref": "s3", "clus": "three" }, "2": { "ref": "s2", "clus": "two" }, "1": { "ref": "s1", "clus": "one" } }; var counterElements = ["INI", "RST", "SWM", "FTN", "PRK"]; //console.dir(data); var attached_bases = []; for (var j = 0; j < data.length; j++) { var element = hotelmap.modules.feedprocess.hotels[data[j]]; var searched = false; /* Decide if we have a hidden hotel item */ if (hotelmap.distance_checker[element.hmid] < 1.3 || element.likeScore > 0) { hotelmap.modules.feedprocess.base_to_search.push(element.hmid); var point = hotelmap.hotelicon.create_hotel_searching_icon(0, Math.round(element.stars), element.numRooms, element, true); var point = hotelmap.modules.feedprocess.new_point(element, point); point.rate_done = false; point.latitude = element.latitude; point.longitude = element.longitude; hotelmap.modules.feedprocess.base_to_search.push(element.hmid); hotelmap.modules.feedprocess.rate_icons[element.hmid] = point; point.hmid = element.hmid; attached_bases.push(element.hmid); searched = true; hotelmap.modules.feedprocess.HotelListings.groupSearchPoints++; } else { hotelmap.modules.feedprocess.HotelListings.groupings++; } try { if (element.stars > 0 && element.stars < 6) { var starClusterReference = starClusterReferences[element.stars]; clus[starClusterReference.clus]++; for (var scCount = 0; scCount < counterElements.length; scCount++) { if (element[counterElements[scCount]] == "1") { clus[starClusterReference.ref][counterElements[scCount].toLowerCase()]++; } } } } catch (clusterGeneratioNException) { // Error Processing. } if (element.brandID) { if (!clus.brands[element.brandID]) { clus.brands[element.brandID] = { five: 0, four: 0, three: 0, two: 0, one: 0 }; } switch (element.stars) { case 5: clus.brands[element.brandID].five++; break; case 4: clus.brands[element.brandID].four++; break; case 3: clus.brands[element.brandID].three++; break; case 2: clus.brands[element.brandID].two++; break; case 1: clus.brands[element.brandID].one++; break; } } /** * Creating blockers - remove any corresponding hotel ICONS */ for (var i in hotelmap.properties.shapes.objects) { var child = hotelmap.properties.shapes.objects[i]; if (child.identity == element.hmid) { try { hotelmap.properties.shapes.removeObject(child); } catch (e1) { } if (!searched) { try { hotelmap.hotelicon.right_panel_elements[child.identity].parentNode.removeChild(hotelmap.hotelicon.right_panel_elements[child.identity]); hotelmap.hotelicon.right_panel_elements[child.identity] = 0; } catch (e2) { } } } } } /* New Mean Routine for calculating the base for cluster ICONS */ var minCord = hotelmap.modules.feedprocess.min[points]; var maxCord = hotelmap.modules.feedprocess.max[points]; var counter = total_x = total_y = 0; //console.log("------------------------------"); //console.log("points: " + points + "length: " + hotelmap.modules.feedprocess.coordinate_saves[points].length + "minCord: " + minCord + " maxcord:"+ maxCord ); for (var i = 0; i < hotelmap.modules.feedprocess.coordinate_saves[points].length; i++) { var point_node = hotelmap.modules.feedprocess.coordinate_saves[points][i]; //console.log("PointNode: " + point_node.x + ", " + point_node.y); //console.log("CordMeasure: " + minCord.x + ", " + maxCord.x); //console.log("CordMeasure: " + minCord.y + ", "+ maxCord.y); if (point_node.x >= minCord.x && point_node.x <= maxCord.x) { if (point_node.y >= minCord.y && point_node.y <= maxCord.y) { counter++; total_x += point_node.x; total_y += point_node.y; } } } //console.log("Post"); x = total_x / counter; y = total_y / counter; var point = hotelmap.hotelicon.blocker_icon(0, 0, 0, clus); point.base_references = {}; for (var g = 0; g < attached_bases.length; g++) { //console.log(">"); hotelmap.cluster_items[attached_bases[g]] = point; point.base_references[attached_bases[g]] = true; } var useTheselats = false; var worldPosition = hotelmap.maps.mapPixelsToPosition(x, y); if (useTheselats) { worldPosition.lat = attributes.latitude; worldPosition.lon = attributes.longitude; } //console.log(x+","+y+" - "+worldPosition.lat+", "+worldPosition.lon); var ico = hotelmap.maps.addIcon(point, worldPosition.lat, worldPosition.lon, "BLOCKER", points); return ico; }, pixel_collider: [], do_collision_check: function() { if (hotelmap.do_check) return false; hotelmap.do_check = true; //console.log("do_collision_check"); // Obejct copy point. var object_copy = []; for (var i in hotelmap.properties.shapes.objects) object_copy.push(hotelmap.properties.shapes.objects[i]); for (var i = 0; i < object_copy.length; i++) { try { var theNode = object_copy[i].pinImage.parentNode; var nx1 = parseInt(theNode.style.left); var ny1 = parseInt(theNode.style.top); var nx2 = nx1 + 50; var ny2 = ny1 + 27; for (var j in hotelmap.properties.shapes.objects) { try { var negative = false; var testItem = hotelmap.properties.shapes.objects[j].pinImage.parentNode; var tx1 = parseInt(testItem.style.left); var ty1 = parseInt(testItem.style.top); var tx2 = tx1 + 50; var ty2 = ty1 + 27; // The Icon top/left is in the way! if (nx1 > tx1 && nx1 < tx2 && ny1 > ty1 && ny1 < ty2) { //console.log("Batch"); theNode.style.left = (tx2 + 5) + "px"; theNode.style.top = (ty2 + 5) + "px"; // negative = true; } if (nx2 < tx2 && nx2 > tx1 && ny1 > ty1 && ny1 < ty2) { theNode.style.left = (ny1 - 30) + "px"; theNode.style.top = (ny2 + 3) + "px"; } //if ( nx1 == tx1 ) { // theNode.style.left = ( nx1 +5 ) + "px"; // negative = true; //} //if ( ny1 == ty1 ) { // theNode.style.top = ( ny1 +5 ) + "px"; // negative = true; //} //if ( negative ) i--; } catch (noInternalPinException) { console.log("noInternalPinException: " + noInternalPinException.message + " / " + negative); } } } catch (noPinException) { console.log("noPinExceptionL " + noPinException.message); } } hotelmap.do_check = false; }, do_collision_check1: function() { // return false; //console.log("Hello"); var objects = []; var ref = []; for (var i in hotelmap.properties.shapes.objects) objects.push(hotelmap.properties.shapes.objects[i]); for (var i = 0; i < objects.length; i++) { try { var primaryTest = objects[i].pinImage.parentNode; // console.dir(hotelmap.properties.shapes.objects[i]); //console.log("Icon ID: " + i ) ; ref[i]++; if (primaryTest) { var primaryItemX = parseInt(primaryTest.style.left); // Left point var primaryItemY = parseInt(primaryTest.style.top); // Top Point var primaryItemXR = primaryItemX + 30; // Right side point; var primaryItemYR = primaryItemY + 60; // Bottom Point. //console.log("=========================================================="); for (var j in hotelmap.properties.shapes.objects) { try { if (testItem != primaryTest) { try { var testItem = hotelmap.properties.shapes.objects[j].pinImage.parentNode; var testItemX = parseInt(testItem.style.left); var testItemY = parseInt(testItem.style.top); var testItemXR = testItemX + 50; var testItemYR = testItemY + 69; var differenceX = Math.abs(testItemX - primaryItemX); var differenceY = Math.abs(testItemY - primaryItemY); var differenceXR = Math.abs(testItemXR - primaryItemXR); var differenceYR = Math.abs(testItemYR - primaryItemYR); //console.log(">> " + differenceX + " , " + differenceY ) ; var positiveOutCome = ((differenceX < 5 || differenceY < 5) && (differenceX > 0 && differenceY > 0)) ? true : false; var negativeOutCome = ((differenceXR < 5 || differenceYR < 5) && (differenceYR > 0 && differenceYR > 0)) ? true : false; if (positiveOutCome && negativeOutCome) { var n = Math.ceil(Math.random() * 10); var isODD = (n === 0 || !!(n && !(n % 2))); if (isODD) positiveOutCome = false; } if (positiveOutCome || negativeOutCome) { // console.dir(primaryTest); // console.dir(hotelmap.properties.shapes.objects[i].getCenter()); //console.log("Movement of icon pushed.."); if (positiveOutCome) { primaryTest.style.left = (primaryItemX + getRandomArbitrary(25, 45)) + "px"; primaryTest.style.top = (primaryItemY + getRandomArbitrary(25, 45)) + "px"; } else { primaryTest.style.left = (primaryItemX - getRandomArbitrary(25, 45)) + "px"; primaryTest.style.top = (primaryItemY - getRandomArbitrary(25, 45)) + "px"; } if (ref[i] < 20) { i--; } else { console.log("Limite reached.."); } //console.dir(primaryTest); // console.dir(hotelmap.properties.shapes.objects[i].getCenter()); //console.log(primaryTest.getPosition()); } //primaryTest..style.border = '3px solid #FF0000 !important'; } catch (CRT) { //console.log("Exception: " + CRT.message); } } else { console.log("OOps"); } } catch (CarryOnThen) { //console.log("Exception: " + CarryOnThen.message); } } } } catch (e) {} // //console.log("child: x: " + child.domX); //console.log("child: y: " + child.domY); } }, do_collision_provider: function(point, latitude, longitude, count, move_vert, move_horiz) { var pixels = hotelmap.maps.mapPositionToPixels(latitude, longitude); var left = pixels.x; var right = pixels.x + 50; var top = pixels.y; var bottom = pixels.y + 35; attributes.collision.show_collisions = true; var count = 0; // // So how many hotels should be in a view before we consider rearranging them? if (hotelmap.modules.feedprocess.datasetlength > 100 || attributes.collision.isMapCollisionEnabled) { //console.log("Collision enabled.."); //console.log("Number of items in pixel collider: " + hotelmap.modules.feedprocess.pixel_collider.length ) ; // // Cycle the feed and process each element. for (var i = 0; i < hotelmap.modules.feedprocess.pixel_collider.length; i++) { var node = hotelmap.modules.feedprocess.pixel_collider[i]; var distance_differenceX = Math.abs(Math.round(left) - Math.round(node.x)); var distance_differenceY = Math.abs(Math.round(top) - Math.round(node.y)); //console.log("Comparing: X diff: " + Math.abs(Math.round(left)-Math.round(node.x))); ///console.log("Comparing: Y diff: " + Math.abs(Math.round(top)-Math.round(node.y))); //console.log("================================================================="); if (distance_differenceX < 40 && distance_differenceY < 40) { // if ( point ) point.style.border = '1px solid #000'; } var n_left = node.x; var n_right = node.x + 50; var n_top = node.y; var n_bottom = node.y + 35; if (right <= n_right && right > n_left && top > n_top && top <= n_bottom) { //if ( point ) point.style.borderTop = '1px solid #FF0000'; pixels.x += 0 - (25 - Math.floor(Math.random() * 5)); pixels.y += (Math.floor(Math.random() * 35)); left = pixels.x; top = pixels.y; bottom = top + 35; right = left + 50; } if (bottom <= n_bottom && bottom >= n_top && left < n_right && left > n_left) { //if ( point ) point.style.borderLeft = '1px solid #00FF00'; pixels.x += 0 - (25 - Math.floor(Math.random() * 5)); pixels.y = n_top + 2; left = pixels.x; top = pixels.y; bottom = top + 35; right = left + 50; } if (left >= n_left && left <= n_right && top >= n_top && top <= n_bottom) { //if ( point ) point.style.borderRight = '1px solid #000'; //console.log("C!"); if (left >= n_left && left <= n_right) { pixels.x += (25 + Math.floor(Math.random() * 5)); pixels.y += (Math.floor(Math.random() * 5)); left = pixels.x; top = pixels.y; bottom = top + 35; right = left + 50; //if (attributes.collision.show_collisions ) node.style.border = '2px solid #000'; //console.log("Collision A"); // node.style.border = "1px solid #FF0000"; } if (top >= n_top && top <= n_bottom) { pixels.x += (Math.floor(Math.random() * 5)); pixels.y += (20 + Math.floor(Math.random() * 5)); left = pixels.x; top = pixels.y; bottom = top + 35; right = left + 50; //if ( attributes.collision.show_collisions ) node.style.border = '2px solid #000'; //console.log("Collision B"); // node.style.border = "1px solid #00FF00"; // if ( point ) point.style.borderBottom = '1px solid #0000FF'; } } if (right < (node.x + 50) && right > (node.x + 20)) { pixels.x = pixels.x - (25 + Math.floor(Math.random() * 5)); pixels.y += (Math.floor(Math.random() * 5)); left = pixels.x; top = pixels.y; bottom = top + 35; right = left + 50; //point.style.border = '1px solid #00FF00'; //if ( attributes.collision.show_collisions ) node.style.border = '2px solid #000'; //console.log("Collision C"); //node.style.border = "1px solid #0000FF"; // if ( point ) point.style.borderTop = '1px solid #FFFF00'; } if (bottom < n_bottom && (bottom) > n_top) { pixels.x += (Math.floor(Math.random() * 15)); pixels.y += (20 + Math.floor(Math.random() * 5)); left = pixels.x; top = pixels.y; bottom = top + 35; right = left + 50; //point.style.border = '1px solid #FF0000'; //if ( attributes.collision.show_collisions ) node.style.border = '2px solid #000'; //console.log("Collision D"); //node.style.border = "1px solid #FFFF00"; // if ( point ) point.style.borderLeft = '1px solid #00FFFF'; } } } var latlon = hotelmap.maps.mapPixelsToPosition(pixels.x, pixels.y); hotelmap.modules.feedprocess.pixel_collider.push(pixels); return { lat: latlon.lat, lon: latlon.lon }; }, do_collision_provider1: function(point, latitude, longitude, count, move_vert, move_horiz) { /* Defined by the pixels */ var pixels = hotelmap.maps.mapPositionToPixels(latitude, longitude); var dl = pixels.x; var dw = dl + 40 + Math.floor(Math.random() * 10);; var dt = pixels.y; var dh = dt + 26; console.log("Using: " + latitude + ", " + longitude + " width pixels: " + pixels.x + ", " + pixels.y); attributes.collision.show_collisions = true; for (var i = 0; i < hotelmap.modules.feedprocess.pixel_collider.length; i++) { var node = hotelmap.modules.feedprocess.pixel_collider[i]; var ll = hotelmap.maps.mapPixelsToPosition(node.x, node.y); var nl = node.x + 5; //+ 10; var nt = node.y; // - 10; var nw = nl + 40; var nh = nt + 26; var isInZone = false; var left = null; var top = null; if (dl >= nl && dl <= nw && dt >= nt && dt <= nh && !isInZone) { left = dl - 40 - Math.floor(Math.random() * 10); top = dt + Math.floor(Math.random() * 8);; isInZone = true; //console.log("TopLeft: " + dl + " TO " + nw); if (isInZone && attributes.collision.show_collisions) point.style.border = '2px solid #000'; } if (dl >= nl && dl <= nw && dh >= nt && dh <= nh && !isInZone) { top = (nt - (dh - dt)) + Math.floor(Math.random() * 8);; left = left + Math.floor(Math.random() * 10); isInZone = true; //console.log("BottomLeft " + dt + " TO " + top); if (isInZone && attributes.collision.show_collisions) point.style.border = '2px solid #0000FF'; } if (dw > nl && dw < nw && dh > nt && dh < nh && !isInZone) { top = top + Math.floor(Math.random() * 10); left = (nw - 10) + Math.floor(Math.random() * 15); isInZone = true; //console.log("BottomRight " + dl + " TO " + left); if (isInZone && attributes.collision.show_collisions) point.style.border = '2px solid #FF0000'; } if (dw > nl && dw < nw && dt > nt && dt < nh && !isInZone) { left = left - 30 - Math.floor(Math.random() * 10); top = dt + 26; isInZone = true; if (isInZone && attributes.collision.show_collisions) point.style.border = '2px solid #00FF00'; } if (Math.abs(dl - left) > 70) { left = dl + Math.floor(Math.random() * 40); top = top + Math.floor(Math.random() * 10); } if (Math.abs(dt - top) > 70) { top = dt + Math.floor(Math.random() * 40);; left = left + Math.floor(Math.random() * 10); } if (isInZone) { if (left > 0) pixels.x = left; if (top > 0) pixels.y = top; if (count < attributes.collision.recursive_limit) { count++; var latlon = hotelmap.maps.mapPixelsToPosition(pixels.x, pixels.y); latlon = hotelmap.modules.feedprocess.do_collision_provider(point, latlon.lat, latlon.lon, count, move_vert, move_horiz); latitude = latlon.lat; longitude = latlon.lon; } } } hotelmap.modules.feedprocess.pixel_collider.push(pixels); return { lat: latitude, lon: longitude }; }, /** * new_point * New basic point on the screen for a non-searching hotel - too far away! * @param element Hotel Info Node * @param point DOM Element to attach */ new_point: function(element, point) { if (attributes.collision.enabled && hotelmap.modules.feedprocess.hotel_length < attributes.collision.hotel_limit && !element.isMoved) { //console.log("Activiating"); var coords = hotelmap.modules.feedprocess.do_collision_provider(point, element.latitude, element.longitude, 0, null, null); return hotelmap.maps.addIcon(point, coords.lat, coords.lon, element.hmid); } return hotelmap.maps.addIcon(point, element.latitude, element.longitude, element.hmid); }, coordinate_references: {}, do_distance_check: function(hotelid) { }, /** * get_element_groupings * @param data_set [JSON object set] * Obtain the grouping setup for the hotels in question */ get_element_groupings: function(data_set) { // Reset groupings hotelmap.modules.feedprocess.pixel_sets = {}; // Reset the group settings. hotelmap.modules.feedprocess.min = {}; hotelmap.modules.feedprocess.max = {}; hotelmap.modules.feedprocess.coordinate_saves = []; hotelmap.modules.feedprocess.coordinate_references = []; // The distanbce of the groupings. var zoom_levels = { '9': '260', '10': '260', '11': '260', '12': '260', '13': '260', '14': '200', '15': '200', '16': '200', '17': '300', '18': '300', '19': '300', '20': '300', '21': '300' }; hotelmap.modules.feedprocess.datasetlength = data_set.length; // Whats our current zoom; var current_zoom = hotelmap.maps.getZoom(); // Defines the grouping space to actuall use. var col_set = zoom_levels[current_zoom]; // Realtime filtering - allows the cluster counting to work correctly. hotelmap.filter_counter = { one: 0, two: 0, three: 0, four: 0, five: 0 }; hotelmap.distance_checker = []; hotelmap.filter_brands = {}; attributes.filtering.totalRatings = 0; attributes.filtering.internetCount = 0; attributes.filtering.swimmingCount = 0; attributes.filtering.restaurantCount = 0; attributes.filtering.fitnessCount = 0; attributes.filtering.freeparkingCount = 0; var zoom = hotelmap.maps.getZoom(); var wSize = (deCarta.Utilities.tileSizeForZoom(zoom) * Math.pow(2, Math.floor(zoom - 1))); for (var i = 0; i < data_set.length; i++) // Cycle the references coming in. { var element = data_set[i]; // Get the single reference. element.latitude = parseFloat(element.latitude); element.longitude = parseFloat(element.longitude); // Define specific settings for each item sent through element.originalLatitude = element.latitude; element.originalLongitude = element.longitude; element.zoomLevel = current_zoom; // Create the branding quantity counter if (element.brandID) hotelmap.filter_brands[element.brandID] = (!hotelmap.filter_brands[element.brandID]) ? 1 : hotelmap.filter_brands[element.brandID] + 1; /** * DISTANCE CHECKING * This will enable us to search cluster points close to the venues whilst * not searching all clusters on the map. More than likely limited to the * nearest 40 or so hotels. */ var dis_data = { 'hmid': element.hmid, 'distance': element.distance }; hotelmap.distance_checker.push(dis_data); // Count the star counters if (element.stars == 5) hotelmap.filter_counter.five++; if (element.stars == 4) hotelmap.filter_counter.four++; if (element.stars == 3) hotelmap.filter_counter.three++; if (element.stars == 2) hotelmap.filter_counter.two++; if (element.stars == 1) hotelmap.filter_counter.one++; if (element.stars == "") hotelmap.filter_counter.one++; if (element.INI == 1) attributes.filtering.internetCount++; if (element.SWM == 1) attributes.filtering.swimmingCount++; if (element.RST == 1) attributes.filtering.restaurantCount++; if (element.FTN == 1) attributes.filtering.fitnessCount++; if (element.PRK == 1) attributes.filtering.freeparkingCount++; // Star & Liked Data var hotel_data = { stars: element.stars, liked: element.likeScore }; // Ensure total ratings are correctly updated if (element.tripRating >= 4) attributes.filtering.totalRatings++; // Deflect away specific hotels from each other when they are the same actual place. if (!hotelmap.modules.feedprocess.hotels[element.hmid]) { hotelmap.modules.feedprocess.hotels[element.hmid] = element; // Store the element /* Colision */ if (!hotelmap.modules.feedprocess.coordinate_references[element.latitude]) { hotelmap.modules.feedprocess.coordinate_references[element.latitude] = 1; } else { var arc = hotelmap.library.utility.deflect(element.latitude, element.longitude, 30, "lat"); element.latitude = arc[0]; hotelmap.modules.feedprocess.coordinate_references[element.latitude] = 1; } if (!hotelmap.modules.feedprocess.coordinate_references[element.longitude]) { hotelmap.modules.feedprocess.coordinate_references[element.longitude] = 1; } else { var arc = hotelmap.library.utility.deflect(element.latitude, element.longitude, 30, "lon"); element.longitude = arc[1]; hotelmap.modules.feedprocess.coordinate_references[element.longitude] = 1; } /* Colision */ } /** * This determines the average positioning of an element. It allows us * to group together the elements into zones. If we have a zone we can * use it to group. */ //var tmp = pixels ; //var tmp = hotelmap.maps.mapPositionToPixels( element.latitude, element.longitude ) ; // Ensure that the venue in not the hotel . if (attributes.hotel_identity != element.hmid && hotelmap.hotelSearchID != element.hmid) { // Create a generic point place for the X&Y. // e.g. if pixel = 13 and colset = 4 then = 12 // e.g. if pixel = 14 and colset = 4 then = 12 //pixels.x = Math.round( pixels.x /col_set ) * col_set ; //pixels.y = Math.round( pixels.y /col_set ) * col_set ; //key: -3448800%2080400 // Obtain our processed point locations. var element_latitude = parseFloat(element.latitude); var element_longitude = parseFloat(element.longitude); // Process the X&Y coordinates var x = element_longitude * wSize / 180; var y = Math.log(Math.tan((90 + element_latitude) * Math.PI / 360)) / (Math.PI / 180); y = y * wSize / 180; var tmp = { 'x': x, 'y': y }; // Locate them locally. x = Math.ceil(Math.round(x / 150)) * 150; y = Math.ceil(Math.round(y / 150)) * 150; var pixels = { 'x': x, 'y': y }; var key = pixels.x + "%" + pixels.y; } else { var pixels = hotelmap.maps.mapPositionToPixels(element.latitude, element.longitude); var tmp = pixels; var key = pixels.x + "%" + pixels.y; } // Create the groupings with reference to the hotel id if (!hotelmap.modules.feedprocess.pixel_sets[key]) hotelmap.modules.feedprocess.pixel_sets[key] = []; hotelmap.modules.feedprocess.pixel_sets[key].push(element.hmid); // If it doesnt exist yet, create it. if (!hotelmap.modules.feedprocess.min[key]) { hotelmap.modules.feedprocess.min[key] = { 'x': tmp.x, 'y': tmp.y }; hotelmap.modules.feedprocess.max[key] = { 'x': tmp.x, 'y': tmp.y }; // Create the new array for storing all the coordinates. hotelmap.modules.feedprocess.coordinate_saves[key] = []; } else { // Determine the minimum and maximum coordinates currently available. if (hotelmap.modules.feedprocess.min[key].x > tmp.x) hotelmap.modules.feedprocess.min[key].x = tmp.x; if (hotelmap.modules.feedprocess.min[key].y > tmp.y) hotelmap.modules.feedprocess.min[key].y = tmp.y; if (hotelmap.modules.feedprocess.max[key].x < tmp.x) hotelmap.modules.feedprocess.max[key].x = tmp.x; if (hotelmap.modules.feedprocess.max[key].y < tmp.y) hotelmap.modules.feedprocess.max[key].y = tmp.y; } // Create a collective set of the coordinates - this will allow us to weight the position more to the overall position of the hotels. hotelmap.modules.feedprocess.coordinate_saves[key].push(tmp); } // Out of the FOR loop hotelmap.distance_checker = hotelmap.sorting.sort_distance_check(hotelmap.distance_checker); } } /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Hotelmap|MapEngines|Decarta * Description: Implementation of the deCarta MAPPING API * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : Wrapper interface which works with deCarta * * * Altered the projection to make it compatible with other sources * ------------------------------------------------------------------------- */ /* define: hotelmap.maps */ hotelmap.maps = { current_engine_view : 'mapquest', current_engine_layer : null, markers : [], disable_points : false, disable_zones : false, disable_hotels : false, zonelayers : null, getCenter : function() { var center = hotelmap.engine_map.getCenter(); return center; }, focusOn : function( lat, lon ) { var position = new deCarta.Core.Position( lat, lon ); hotelmap.engine_map.centerOn( position, {'animated':false,'duration':0}) ; }, zoomToLevel : function(level) { var position = hotelmap.maps.getCenter(); //hotelmap.engine_map.zoomTo(level-1, position, true); hotelmap.engine_map.centerOn( position, {'animated':true,'duration':100}) ; hotelmap.engine_map.zoomTo(level, position, true); }, focusOnAnimated : function( lat, lon ) { var position = new deCarta.Core.Position( lat, lon ); hotelmap.engine_map.centerOn( position, {'animated':true,'duration':0}) ; if ( hotelmap.tinyMapReference ) hotelmap.tinyMapReference.centerOn(position, {'animated':false,'duration':0}); }, zoomToPoint : function( lat, lon, zoom ) { var position = new deCarta.Core.Position( lat, lon ); hotelmap.engine_map.centerOn( position, {'animated':false,'duration':0}) ; hotelmap.engine_map.zoomTo(zoom, position, true); if ( hotelmap.tinyMapReference ) hotelmap.tinyMapReference.centerOn(position, {'animated':false,'duration':0}); }, zoomOutBy : function(v) { hotelmap.engine_map.zoomOut(parseInt(v)); }, zoomBy: function(v){ hotelmap.engine_map.zoomIn(v); }, zoomIn : function() { hotelmap.engine_map.zoomIn(); }, zoomOut : function() { hotelmap.engine_map.zoomOut(); }, hideHotelLayer : function() { hotelmap.properties.shapes.hide(); }, showHotelLayer : function() { hotelmap.properties.shapes.show(); }, removeAllLayerContent : function() { hotelmap.properties.shapes.clear(); hotelmap.engine_map.render(); }, mapPixelsToPosition : function( x, y ) { var latlon = new deCarta.Core.Position( 0,0 ); latlon.setXY(x,y, hotelmap.maps.getZoom()); return {'lat': latlon.lat, 'lon': latlon.lon }; }, newPosition: function(lat,lon){ return new deCarta.Core.Position( lat, lon ); }, mapPositionToPixels : function( lat, lon ) { var latlon = new deCarta.Core.Position( lat, lon ); var projection = latlon.getPixelPoint( hotelmap.maps.getZoom() ); return {'x':projection.x, 'y':projection.y }; }, mapEvent : function( eventID, functionRunner ) { deCarta.Core.EventManager.listen(eventID, functionRunner, hotelmap.engine_map); }, getQueryPosition : function() { var visible_rectangle = hotelmap.engine_map.getVisibleRect() ; return [ hotelmap.library.utility.rn(visible_rectangle[3].lat, 6), hotelmap.library.utility.rn(visible_rectangle[2].lon, 6), hotelmap.library.utility.rn(visible_rectangle[0].lat, 6), hotelmap.library.utility.rn(visible_rectangle[0].lon, 6) ]; }, getBoundary : function() { var points = hotelmap.engine_map.getBoundingBox() return points; }, /** * isInZone * Is a specific area within the master map zone * @param latmin * @param lonmin * @param latmax * @param lonmax * @return boolean */ isInZone : function ( latmin, lonmin, latmax, lonmax ) { var coords = hotelmap.engine_map.getVisibleRect() ; /*console.log(" Testing: " + coords[0].lat + " > " +latmax ); console.log(" Testing: " + coords[0].lon + " < " +latmin ); console.log(" Testing: " + coords[1].lat + " > " +latmax ); console.log(" Testing: " + coords[1].lon + " > " +lonmax ); console.log(" Testing: " + coords[2].lat + " < " +latmin ); console.log(" Testing: " + coords[2].lon + " > " +lonmax ); console.log(" Testing: " + coords[3].lat + " < " +latmin ); console.log(" Testing: " + coords[3].lon + " < " + lonmin );*/ return ( coords[0].lat > latmax && coords[0].lon < latmin && coords[1].lat > latmax && coords[1].lon > lonmax && coords[2].lat < latmin && coords[2].lon > lonmax && coords[3].lat < latmin && coords[3].lon < lonmin ) ? true : false; }, getIcon : function( object_icon, lat, lon ) { var position = new deCarta.Core.Position( lat, lon ) ; ///console.log("Position: " + position); var xoffset = ( object_icon.xoffset ) ? object_icon.xoffset : (parseInt(object_icon.style.width)/2); var pin = new deCarta.Core.Pin({ position: position, image: object_icon, xOffset : xoffset, yOffset : parseInt(object_icon.style.height) }); object_icon.pin = pin; return pin; }, remIcon : function( pin ) { hotelmap.properties.shapes.removeObject(pin); hotelmap.engine_map.render(); }, addIcon : function( object_icon, lat, lon, identity, blockp ) { //console.log("NEW ICON"); var position = new deCarta.Core.Position( lat, lon ) ; ///console.log("Position: " + position); var xoffset = ( object_icon.xoffset ) ? object_icon.xoffset : (parseInt(object_icon.style.width)/2); var pin = new deCarta.Core.Pin({ position: position, image: object_icon, xOffset : xoffset, yOffset : parseInt(object_icon.style.height) }); object_icon.pin = pin; pin.identity = identity; if (blockp) { object_icon.id = identity+"_"+blockp.replace('-','').replace('%',''); } hotelmap.properties.shapes.addObject(pin); if ( object_icon.HMHide || $(object_icon).attr("hm-set-back-pointer") == "true" ) { setTimeout(function(){ //console.log(">> " + object_icon.parentNode.style.zIndex); try { object_icon.parentNode.style.zIndex = 99; } catch ( e ) { } //console.log(">> " + object_icon.parentNode.style.zIndex); }, 500); } if ( object_icon.myZPoint && !hotelmap.allowDropIcon){ setTimeout( function() { try { object_icon.parentNode.style.zIndex = object_icon.myZPoint; } catch ( eNoIcon ) {} }, 500 ); } return object_icon; }, render : function(){ hotelmap.engine_map.render(); }, getCenter : function() { return hotelmap.engine_map.getCenter(); }, getZoom : function() { return hotelmap.engine_map.getZoom(); }, useEngineLayer : function( engine_layer ) { hotelmap.engine_map.setMapStyle(engine_layer); }, useViewPort : function() { if ( attributes.viewport) hotelmap.maps.useEngineLayer(attributes.viewport); }, generateMapAt : function( object_reference, latitude, longitude, zoom ) { deCarta.Core.Configuration.projection = 'EPSG:3857'; eval(Base64.decode("ZGVDYXJ0YS5Db3JlLkNvbmZpZ3VyYXRpb24uY2xpZW50TmFtZSAJCQkJPSAiTG9uZG9uTWFya2V0aW5nIjsgLy8gSW5wdXQgY2xpZW50TmFtZSBiZXR3ZWVuIHF1b3Rlcw0KCWRlQ2FydGEuQ29yZS5Db25maWd1cmF0aW9uLmNsaWVudFBhc3N3b3JkIAkJCT0gIjU4ODUzZmRhZDA4M2M0MzIyZTVhN2FkMzQ4ZWM4MDE2Ijs=")); if ( attributes.isChrome ) { deCarta.Core.Configuration.useHardwareAcceleration = false; } else { deCarta.Core.Configuration.useHardwareAcceleration = true; } deCarta.Core.Configuration.usePrecaching = true; if ( attributes.ssl ){ // -- // Core Configuration System for SSL Tiles // REMVOE TO <<<<<< // deCarta.Core.Configuration.clientName = "hotelmapsnt:"; //deCarta.Core.Configuration.clientPassword = "vhd5YJtf23"; // deCarta.Core.Configuration.url= attributes.proto+"//hotelmap.decartahws.com/openls/JSON"; /** Tile config used for standard resolution devices (String)*/ //deCarta.Core.Configuration.defaultConfig = 'global-decarta'; deCarta.Core.Configuration.clientName = attributes.connections.clientName; // "hotelmaps:"; deCarta.Core.Configuration.clientPassword = attributes.connections.clientPassword; // "vhd5YJtf23"; deCarta.Core.Configuration.url= attributes.proto+""+attributes.connections.url; // attributes.proto+"//hotelmap.decartahws.com/openls/JSON"; deCarta.Core.Configuration.defaultConfig = attributes.connections.defaultConfig; // 'hotelmap'; deCarta.Core.Configuration.defaultHighResConfig = attributes.connections.defaultHighResConfig; // 'hotelmap'; //deCarta.Core.Configuration.streetTileHosts = ['https://maptiles-01.hotelmap.com','https://maptiles-02.hotelmap.com','https://maptiles-03.hotelmap.com']; // -- // <<<<<< // -- } //http://devengr4.dz.decarta.com/openls/image/TILE?LLMIN=0.0,0.0&LLMAX=0.005530185203987857,0.005493164062500000&CACHEABLE=true&DS=tomtom-world&WIDTH=256&HEIGHT=256&CLIENTNAME=map-sample-app&SESSIONID=485202352039&FORMAT=PNG&CONFIG=hotelmap&N=10921&E=-28 //deCarta.Core.Configuration.url = "http://devengr4.dz.decarta.com:8080/openls/JSON"; //deCarta.Core.Configuration.clientName = "map-sample-app"; //deCarta.Core.Configuration.clientPassword = "letmein"; //deCarta.Core.Configuration.dataSet = "tomtom-world"; //deCarta.Core.Configuration.defaultTransparentConfig = 'hotelmap'; //deCarta.Core.Configuration.defaultHighResConfig = 'hotelmap'; //deCarta.Core.Configuration.defaultConfig = 'hotelmap'; //deCarta.Core.Configuration.streetTileHosts = ['http://devengr4.dz.decarta.com']; /* * Setup: OPENLS server on trial */ //deCarta.Core.Configuration.imagePort = 8080; //deCarta.Core.Configuration.streetTileHosts = ['http://10.0.0.67']; // deCarta.Core.Configuration.urlVersion = 'auto'; //console.log("ZOOM: " + zoom); var position; if (attributes.override_lat && attributes.override_lng) { position = new deCarta.Core.Position( attributes.override_lat, attributes.override_lng ); } else { position = new deCarta.Core.Position( latitude, longitude ); } //Let's create a layer for the pin var shapesLayer = new deCarta.Mobile.MapOverlay({ name: 'Shapes', clustering: false, visible : true }); hotelmap.routeOverlay = new deCarta.Core.MapOverlay({ name: 'route' }); hotelmap.engine_map = new deCarta.Core.Map({ zoom: zoom, id: "map", center: position, minZoom : (( attributes.isAttView || attributes.custom_maps.isEventView ) ? attributes.min_zoom : 5), maxZoom : attributes.maxzooms, onReady : function() { //hotelmap.maps.tileLayer(); hotelmap.disable=true; hotelmap.maps.zoomIn(); hotelmap.disable=false; hotelmap.maps.zoomOut(); hotelmap.engine_map.addLayer(shapesLayer); hotelmap.engine_map.addLayer( hotelmap.routeOverlay); if ( !attributes.isHidden ) { var control = new deCarta.UI.OverviewControl({position: 'leftTop'}); hotelmap.engine_map.addControl(control); /* Scale Controls */ var scaleControlElement = new deCarta.UI.ScaleControl({position: 'leftTop'}); hotelmap.engine_map.addControl(scaleControlElement); hotelmap.count_adjustment.init(); } } }); if ( attributes.viewport && hotelmap.engine_map ) hotelmap.maps.useEngineLayer(attributes.viewport); hotelmap.properties['shapes'] = shapesLayer; hotelmap.engine_map.addLayer(shapesLayer); }, HMTileZones : function( isTurnedOn ) { if ( isTurnedOn ) { //console.log("Turned On"); hotelmap.maps.zonelayers = hotelmap.maps.tileLayer(); } else { //console.log("Turned Off"); hotelmap.maps.zonelayers.hide(); hotelmap.engine_map.removeLayer( hotelmap.maps.zonelayers ); hotelmap.maps.zonelayers=null; } }, getMBTile : function( x,y,z,a ){ var bound = Math.pow(2, z); y ++; x = (x + (bound /2)) % bound; y = (-y + (bound /2)) % bound; if (x < 0) x = bound + x; if (y < 0) y = bound + y; if (x==0.5&&y==0.5) { x = 0; y = 0; } var url = hotelmap.showMapBoxURI + z+'/'+x+'/'+y+(a?'@2x'+a:'.png'); return url; }, /** * tileLayer * Adds a customised overlay to the map */ tileLayer1 : function() { // Creates the basic tile store via deCarta var MyTileStore = function(opt){ deCarta.Core.TileStore.call(this, opt); this.baseUrl = 'http://tiles.mapbox.com'; }; // Prototype the object MyTileStore.prototype = new deCarta.Core.TileStore(); //extend the base class MyTileStore.prototype = deCarta.Utilities.extendObject(MyTileStore.prototype, { /** Overridden getTileUrl function */ getTileUrl: function(x, y, z) { var bound = Math.pow(2, z); y ++; x = (x + (bound /2)) % bound; y = (-y + (bound /2)) % bound; if (x < 0) x = bound + x; if (y < 0) y = bound + y; var url = 'https://c.tiles.mapbox.com/v3/scottberwicklondontown.map-hzr2r1y6/'+z+'/'+x+'/'+y+'.png'; return url; } }); // New Tile Layer var myTileLayer = new deCarta.Core.MapLayer({ tileStore: new MyTileStore() }); myTileLayer.setBackLayer = true; // Add the new LAYER hotelmap.engine_map.addLayer(myTileLayer); return myTileLayer; }, tileLayer : function() { hotelmap.maps.tileLayer1(); // Creates the basic tile store via deCarta var MyTileStore = function(opt){ deCarta.Core.TileStore.call(this, opt); }; // Prototype the object MyTileStore.prototype = new deCarta.Core.StreetTileStore(); // New Tile Layer var myTileLayer = new deCarta.Core.MapLayer({ tileStore: new MyTileStore() }); myTileLayer.setBackLayer = true; // Add the new LAYER hotelmap.engine_map.addLayer(myTileLayer); return myTileLayer; } } ;/** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Reporting * Description: Manages the reporting back to the server. * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : * ------------------------------------------------------------------------- */ hotelmap.reporting = { interval: null, tiles: 0, zooms: 0, inactive: 0, count: 0, /** * firstReport * Called by the initial loader */ firstReport: function() { // Run a first report as the user lands into the system hotelmap.reporting.doReport(true); // Setup the 30 second interval for continual reporting (up to 3 minutes) // hotelmap.reporting.pingReport(); }, /** * doReport * runs the report system back the server * @param runInitial (describes if it's the first call) */ doReport: function(runInitial) { // Ensure we have a last activity date if (attributes.lastActiveDate) { // How long has the user been idles var numberOfSeconds = hotelmap.library.utility.calculateSecondsBetweenDates(attributes.lastActiveDate); // Don't log after three minutes - waste of bandwidth if (numberOfSeconds < (60 * 3) && hotelmap.reporting.count < 1) { hotelmap.reporting++; var location = hotelmap.maps.getCenter(); var zoomlevel = hotelmap.maps.getZoom(); // Send the report out hotelmap.library.json.get("services/reporting/visitor_update?currency=" + attributes.currency_pref + "&runInitial=" + runInitial + "&zoom=" + zoomlevel + "&lat=" + location.lat + "&lon=" + location.lon + "&i=" + attributes.map_identity + "&e=" + attributes.engine[0] + "&ulat=" + attributes.usersession.lat + "&ulon=" + attributes.usersession.lon + "&uloc=" + attributes.usersession.loc + "&data=" + hotelmap.userstatistics.toString() + "&tidID=" + attributes.ref_codal_tid + "&"); userdata("isActiveUser", "YES"); } } }, /** * pingReport * Creates the 30 second interval for reporting */ pingReport: function() { hotelmap.reporting.interval = setInterval( function() { hotelmap.reporting.doReport(false); }, 120000 ); } }; /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Heading * Description: Heading elements * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- */ hotelmap.heading = { dimensions : null, heading_panel_core : null, /** * init * Initialises the heading object */ init : function( ) { // The core UI reference hotelmap.ui = (hotelmap.ui) ? hotelmap.ui : _("ui"); // Dimensions settings. var dimensions = hotelmap.library.utility.getDimensions(); hotelmap.heading.dimensions = dimensions; // The core heading element which will host most points var heading_core = hotelmap.library.utility.element("div",{'position':'fixed','left':'0px','top':'0px','width':"100%",'height':'51px','backgroundImage':'url('+attributes.host+'resource/images/gfx_v2/heading.png)','zIndex':'150'},{'id': 'hmoriginal_shadow_topper'}); if ( attributes.isHidden ) heading_core.style.display = "none"; // IE8- Specific Shadow Bar. Create the element, transparency and then add.. if ( attributes.isLowIE ) { hotelmap.heading.ieshad = hotelmap.library.utility.element("div",{'position':'absolute','left':'0px','top':'0px','width':"100%",'height':'54px','backgroundColor':'#000','zIndex':'150'},{}); hotelmap.library.utility.setTrans(hotelmap.heading.ieshad,20); hotelmap.ui.appendChild( hotelmap.heading.ieshad ) ; hotelmap.shadows.push(hotelmap.heading.ieshad) ; // Add reference to the shadow stack } // Assign a heading panel reference hotelmap.heading.heading_panel_core = heading_core; // Add the main UI hotelmap.ui.appendChild( heading_core ) ; // Add the availbale options //if ( !attributes.isHidden ) hotelmap.heading.add_show_panels_icon(); hotelmap.heading.add_main_heading_image(heading_core); //hotelmap.heading.add_hide_panels_icon(heading_core); hotelmap.heading.add_date_sections(heading_core); // hotelmap.heading.add_contact(heading_core); }, generic_menu_option : function( container, image_off, image_on, left_destination, func, isSecondGfx ) { // Utilisie the zindex correctly. var zindex = (container==hotelmap.ui) ? 149 : 151; // Decide on the specific graphics image var dir = (isSecondGfx) ? "gfx_v2" : "gfx_v1"; // Show image. var show_option = hotelmap.library.utility.element("img",{'position':'absolute','left': ( hotelmap.heading.dimensions[0] - left_destination ) + "px",'top':'0px' ,'zIndex':zindex,'cursor':'pointer'},{'src':attributes.host+'resource/images/'+dir+'/'+image_off}); // Actions! show_option.onmouseover = function() { this.src = attributes.host+"resource/images/"+dir+"/"+image_on; }; show_option.onmouseout = function(){ this.src = attributes.host+"resource/images/"+dir+"/"+image_off; }; show_option.onmousedown = function() { func(); }; // Resizing model for this element. hotelmap.library.events.initialiseEvent("resize", function() { if ( hotelmap.library.utility.isIEResizeEvent() ) { var dimensions = hotelmap.library.utility.getDimensions(); show_option.style.left = (dimensions[0]-left_destination) + "px"; } } ); // Appends container.appendChild( show_option ) ; }, /** * dates * Shows the date menu option, action and resizer * @param container * @returns */ dates : function( container ) { hotelmap.heading.generic_menu_option(container,"heading-dates-off.png", "heading-dates-on.png", 315, function() { try { _gaq.push(['_trackPageview', 'event/refine_dates']); } catch ( googleTrackVirtualPageViewException ){} hotelmap.calendar.init(); },false ); }, add_contact : function(heading_core){ var hide_container = hotelmap.library.utility.element("div", {'textAlign':'right','position':'absolute','left':( hotelmap.heading.dimensions[0] - 500 ) + "px",'top':'0px','width':'500px','height':'18px','overflow':'hidden','whiteSpace':'nowrap','cursor':'pointer'},{}); hotelmap.library.events.initialiseEvent("resize", function() { if ( hotelmap.library.utility.isIEResizeEvent() ) { var dimensions = hotelmap.library.utility.getDimensions(); hide_container.style.left = (dimensions[0]-500) + "px"; } } ); hide_container.innerHTML = "
  • 0207 494 2020
    | |
    "; heading_core.appendChild(hide_container); }, /** * add_show_panels_icon * Adds the lower show panel iconw hich brings back the panels */ add_show_panels_icon : function( ) { // The main SHOW container. var hide_container = hotelmap.library.utility.element("div", {'display':'none','position':'absolute','left':( hotelmap.heading.dimensions[0] - 500 ) + "px",'top':'0px','width':'500px','height':'18px','overflow':'hidden','whiteSpace':'nowrap','cursor':'pointer'},{}); // The internal elements (icon & text) var hide_image = hotelmap.library.utility.element("div", {'height':'18px'},{'innerHTML':''}); var hide_data = hotelmap.library.utility.element("div",{'whiteSpace':'nowrap','backgroundColor':'#2D5061','height':'18px','fontFamily':'"Open Sans"','fontWeight':'bold','color':'#93AEBD','paddingLeft':'5px','paddingRight':'9px','paddingTop':'3px','fontSize':'8px','overflow':'hidden'},{'innerHTML':translations.LNG_SHOWPANELS}); // References hide_data.id = "fr"; hide_image.id = "fr"; // Appends hide_container.appendChild( hide_data ) ; hide_container.appendChild( hide_image ) ; // Function. hide_container.onmousedown = function() { // Dimensions getter var dimensions = hotelmap.library.utility.getDimensions(); // From top to bot hotelmap.graphics.goTopToBottom( hotelmap.heading.heading_panel_core, 0, 5, 20); // Right pabel if ( hotelmap.rightpanel && hotelmap.rightpanel.panel ) { if ( hotelmap.infopanel.container ) try { hotelmap.infopanel.container.parentNode.removeChild(hotelmap.infopanel.container); hotelmap.infopanel.isClosed = true; } catch ( endException) {} hotelmap.graphics.goRightToLeft( hotelmap.rightpanel.panel, dimensions[0]-232, 5, 20 ); } var destX = ( attributes.isLowIE ) ? 15 : 10; // Left Pabel. if ( hotelmap.leftpanel && hotelmap.leftpanel.container ) hotelmap.graphics.goLeftToRight ( hotelmap.leftpanel.container, destX, 5, 20 ); // Show Shadow Panels setTimeout(function(){ if ( hotelmap.shadows && hotelmap.shadows.length > 0 ) for ( var i = 0 ; i < hotelmap.shadows.length ; i++ ) hotelmap.shadows[i].style.display = "" ; try { hotelmap.dv2_main.style.display = ""; } catch( noShadPanException ) {} } , 2000 ) ; }; // Appends hotelmap.ui.appendChild(hide_container); // Resizing hotelmap.library.events.initialiseEvent("resize", function() { if ( hotelmap.library.utility.isIEResizeEvent() ) { var dimensions = hotelmap.library.utility.getDimensions(); hide_container.style.left = (dimensions[0]-500) + "px"; } } ); }, add_date_sections : function( header ) { // Get dimensions var dimensions = hotelmap.library.utility.getDimensions(); // Create temporary date searching string var date_string = hotelmap.library.utility.quickdiv("search_string","Searching..."); // Apply post styling. hotelmap.library.utility.applyStyles( date_string, {'textAlign':'right','width':'700px'}) ; if (attributes.direction == 'rtl') { date_string.style.left = '0px'; } else { date_string.style.right = '0px'; } // Appends. header.appendChild(date_string); // Stupidly small WHITE hide / show cal image. var date_image = hotelmap.library.utility.element("img",{'cursor':'pointer','position':'absolute','left':(dimensions[0] - 23) + "px",'top':'31px'},{'src':attributes.host+'resource/images/gfx_v2/ItineraryButton.png','title':translations['LNG_RCHITEN'],'alt':translations['LNG_RCHITEN']}); // Appends to header. header.appendChild(date_string); //header.appendChild(date_image); // Internal references. hotelmap.heading.date_image = date_image; hotelmap.heading.date_string = date_string; }, /** * add_hide_panels_icon * Adds a new hide pabel icon to the header * @param header */ add_hide_panels_icon : function( header ) { // The hide element container var hide_container = hotelmap.library.utility.element("div", {'position':'absolute','left':( hotelmap.heading.dimensions[0] - 500 ) + "px",'top':'0px','width':'500px','height':'18px','overflow':'hidden','whiteSpace':'nowrap','cursor':'pointer'},{}); // The hide image var hide_image = hotelmap.library.utility.element("div", {'height':'18px'},{'innerHTML':''}); // The hide string, multi lingual of course. var hide_data = hotelmap.library.utility.element("div",{'whiteSpace':'nowrap','backgroundColor':'#2D5061','height':'18px','fontFamily':'"Open Sans"','fontWeight':'bold','color':'#93AEBD','paddingLeft':'5px','paddingRight':'9px','paddingTop':'3px','fontSize':'8px','overflow':'hidden'},{'innerHTML':translations.LNG_HIDEPANELS}); // Identity..? hide_data.id = "fr"; hide_image.id = "fr"; // Appends. hide_container.appendChild( hide_data ) ; hide_container.appendChild( hide_image ) ; // Main Append header.appendChild( hide_container ) ; // Auto resize element hotelmap.library.events.initialiseEvent("resize", function() { if ( hotelmap.library.utility.isIEResizeEvent() ) { var dimensions = hotelmap.library.utility.getDimensions(); hide_container.style.left = (dimensions[0]-500) + "px"; } } ); // Hide element action hide_container.onclick = function() { try { hotelmap.dv2_main.style.display = "none"; } catch( noShadPanException ) {} // Ensure the results table is removed and the filter menu, if present. try{ _("results").style.display = "none"; } catch (e){} try { hotelmap.filters.menu.parentNode.removeChild(hotelmap.filters.menu); } catch ( e1){ } // Filters are inactive. hotelmap.filters.button.active = false; // Grab the dimensions. var dimensions = hotelmap.library.utility.getDimensions(); // Move the heading element from bottom to top hotelmap.graphics.goBottomToTop(hotelmap.heading.heading_panel_core, 0-54, 5, 20); // Now move the right pabel from right to left. if ( hotelmap.rightpanel && hotelmap.rightpanel.panel ) { if ( hotelmap.infopanel.container ) { try { hotelmap.infopanel.container.parentNode.removeChild(hotelmap.infopanel.container); hotelmap.infopanel.isClosed = true; } catch ( endException ) {} } hotelmap.graphics.goLeftToRight(hotelmap.rightpanel.panel, dimensions[0], 5, 20); } // Now move the left pabel from left to right if ( hotelmap.leftpanel && hotelmap.leftpanel.container ) hotelmap.graphics.goRightToLeft(hotelmap.leftpanel.container, -210, 5, 20); if ( hotelmap.shadows && hotelmap.shadows.length > 0 ) for ( var i = 0 ; i < hotelmap.shadows.length ; i++ ) hotelmap.shadows[i].style.display = "none" ; }; }, /** * add_main_heading_image * Adds the core heading image to the main header * @param header (DOM header object) */ add_main_heading_image : function( header ) { // The left side title image var heading_image = hotelmap.library.utility.element("div",{'position':'absolute','left':'0px','top':'0px','width':'100%','height':'51px'},{}); // The left side ICON (changes for events venues etc) var icon = hotelmap.library.utility.element("img", {'position':'absolute','top':'7px'},{'src':attributes.host+'resource/images/gfx_v1/title_icons/heading-icon1.png'}); if (attributes.direction == 'rtl') { icon.style.right = '10px'; } else { icon.style.left = '10px'; } var postString = ( attributes.language == "en_GB") ? "for" : " - " var tmpTitle = attributes.pagedata.title ; if ( tmpTitle.length > 80 && attributes.language == 'en_GB') { tmpTitle = tmpTitle.substr(0,60) + ".."; } // The primary title var title = hotelmap.library.utility.quickdiv("prim_title","HotelMapTM "+ postString + " "+ tmpTitle); // The sub title (low text) var subtitle = hotelmap.library.utility.quickdiv("prim_subtitle",attributes.pagedata.subtitle); if ( attributes.isSEOPage == "1" ) { subtitle.style.textDecoration = "underline"; subtitle.style.cursor = 'pointer'; subtitle.onclick = function(){ contentpoint.showContentSection(); } } if ( attributes.event_data.is_event == "Y" ) { var event_date_string = ( attributes.event_data.calstart == attributes.event_data.calend ) ? attributes.event_data.notes.end.long : attributes.event_data.notes.start.short + " - " + attributes.event_data.notes.end.short; subtitle.innerHTML += " | " + event_date_string ; } // Internal Reference of names. hotelmap.heading_items = { title: title,subtitle: subtitle}; // Add text to header image heading_image.appendChild(title); heading_image.appendChild(subtitle); // Append to CORE header. header.appendChild( heading_image ) ; header.appendChild( icon ); } }; /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: HotelMapWW-CurrentLocationModule * Description: The right side popout information panel * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : * ------------------------------------------------------------------------- */ hotelmap.rightpanel = { panel_enabled : true, panel : null, properties : {}, listcontainer : null, listings : null, favorites : null, active_panel : null, panel_settings : { width : 232, top : 75, lower : 35 }, /** * updateWithQuantity * When we are too zoomed out to show the hotels we update the quantity instead. */ updateWithQuantity : function() { /** * Custom Notice to zoom in * Poll the area to get the quantity of hotels. **/ // console.log("Mush"); //var coords = hotelmap.maps.getQueryPosition(); //hotelmap.library.json.get("services/hotels/area_quantity?coordinates=" + coords[0] + "," + coords[1] + "," + coords[2] + "," + coords[3]+"&cb=hotelmap.rightpanel.report_quantity&"); //hotelmap.rightpanel.tabReference["onmap"].counterText.innerHTML = "(0)"; }, /** * report_quantity * Call back function initialised from updateWithQuantity * @param json */ report_quantity : function( json ) { if ( json ) { if ( json.COUNTER > 0 ) { var notice = hotelmap.library.utility.element ( "div", { 'fontFamily':'arial', 'fontSize':'14px', 'color':'#444', 'padding':'20px' }, { 'innerHTML': 'There are ' + json.COUNTER + ' hotels on the map, zoom in to get rates' } ); //hotelmap.rightpanel.listings.hotelcontainer.innerHTML = ""; $(hotelmap.rightpanel.listings.hotelcontainer).find(".rightPanelCoreContainer").remove(); hotelmap.rightpanel.listings.hotelcontainer.appendChild(notice); } } }, /** * resize_right_panel * Window Resizer Event for right panel */ resize_right_panel : function() { if ( hotelmap.library.utility.isIEResizeEvent() ) { hotelmap.rightpanel.dimensions = hotelmap.library.utility.getDimensions(); var listing_height = ( hotelmap.rightpanel.dimensions[1] - hotelmap.rightpanel.panel_settings.lower - hotelmap.rightpanel.panel_settings.top ) ; listing_height = listing_height- 31; hotelmap.rightpanel.listcontainer.style.height = listing_height + "px"; hotelmap.rightpanel.listings.style.height = listing_height + "px"; hotelmap.rightpanel.favorites.style.height = listing_height + "px"; hotelmap.rightpanel.best.style.height = listing_height + "px"; hotelmap.rightpanel.listings.hotelcontainer.style.height = (listing_height-39) + "px"; hotelmap.rightpanel.favorites.hotelcontainer.style.height = (listing_height-33) + "px"; hotelmap.rightpanel.best.hotelcontainer.style.height = (listing_height-33) + "px"; hotelmap.rightpanel.panel.style.height = (hotelmap.rightpanel.dimensions[1]-hotelmap.rightpanel.panel_settings.lower-hotelmap.rightpanel.panel_settings.top)+22 + "px"; if ( hotelmap.rightpanel.block ) { if (attributes.direction == 'rtl') { hotelmap.rightpanel.block.style.right = (hotelmap.rightpanel.dimensions[0]-hotelmap.rightpanel.panel_settings.width) -2 + "px"; } else { hotelmap.rightpanel.block.style.left = (hotelmap.rightpanel.dimensions[0]-hotelmap.rightpanel.panel_settings.width) -2 + "px"; } hotelmap.rightpanel.block.style.height = (hotelmap.rightpanel.dimensions[1]-hotelmap.rightpanel.panel_settings.lower-hotelmap.rightpanel.panel_settings.top)+22 + "px"; } } }, /** * Tab Section Generator */ tab_sections : { /** * create_tab_series * Creates the series of tabs on the right menu * @param title_text * @param rID * @param clickFunction * @param image_source * @param state * @param width * @param height * @param left */ create_tab_series : function( title_text, rID, clickFunction, image_source, state, width, height, left ) { var src = "map-" + ((state)?"on":"off") + ".png"; var div = hotelmap.library.utility.element("div", {'cursor':'pointer','position':'absolute','top':'0px','width':width+'px','height':height+'px'}, {}); if (attributes.direction == 'rtl') { div.style.right = left+'px'; } else { div.style.left = left+'px'; } var img = hotelmap.library.utility.element("img", {'position':'absolute','top':'0px'}, {'src':attributes.host+'resource/images/gfx_v2/tabs2/'+src}); if (attributes.direction == 'rtl') { img.style.right = '0px'; } else { img.style.left = '0px'; } var txtcolor = (state) ? "#000" : "#FFF"; var txt = hotelmap.library.utility.element("div", {'textTransform':'uppercase','fontFamily':'"Open Sans",arial','fontWeight':'bold','fontSize':'10px','color':txtcolor,'position':'absolute','top':'4px'}, {'innerHTML':title_text+" "}); if (attributes.direction == 'rtl') { txt.style.right = '4px'; } else { txt.style.left = '4px'; } var counter = hotelmap.library.utility.element("span",{},{'innerHTML':'(0)'}); txt.appendChild(counter); div.counterText = counter; div.iconImage = img; div.textSet = txt; div.iconSourceOff = attributes.host+"resource/images/gfx_v2/tabs2/map-off.png"; div.iconSourceOn = attributes.host+"resource/images/gfx_v2/tabs2/map-on.png"; div.appendChild(img); div.appendChild(txt); hotelmap.rightpanel.tabcontainer.appendChild( div ); hotelmap.rightpanel.tabReference[image_source] = div; div.onmousedown = function() { for ( var i in hotelmap.rightpanel.tabReference ) { hotelmap.rightpanel.tabReference[i].iconImage.src = hotelmap.rightpanel.tabReference[i].iconSourceOff; hotelmap.rightpanel.tabReference[i].textSet.style.color = '#FFF'; } this.iconImage.src = this.iconSourceOn; this.textSet.style.color = '#000'; clickFunction(); }; }, /* ------------------------------------------------------------------------------------------------------ */ /** * create_hotel_list_panel * This is the listing panel used to show standard right panel rates. * @param listing_height * @returns */ create_hotel_list_panel : function(listing_height) { // A selection panel which allows ordering exists int his realm. var selectorMain = hotelmap.library.utility.element("div",{'whiteSpace':'nowrap','width':'10px','overflow':'hidden','fontFamily':'"Open Sans",arial','fontWeight':'bold','fontSize':'11px','color':'#000','position':'absolute','top':'29px'},{'innerHTML':translations.LNG_LISTBY+': '}); if (attributes.direction == 'rtl') { selectorMain.style.right = '5px'; } else { selectorMain.style.left = '5px'; } // Define the selection var selector = hotelmap.library.utility.element("select",{'width':'10px','fontFamily':'"Open Sans",arial','fontSize':'11px','color':'rgb(0,0,0)'},{}); //console.log("Order Default: " + attributes.orderDefault ) ; if ( attributes.order_default ) { // TRP Trip Advisor // HTN Hotel Name // DST Distance // PHL Pirce High Low // PLH Price Low High // STR Stars // PFR Pref Rate if ( attributes.order_default == "TRP" ) attributes.sorting = "rtg" ; if ( attributes.order_default == "HTN" ) attributes.sorting = "name_order" ; if ( attributes.order_default == "DST" ) attributes.sorting = "distance" ; if ( attributes.order_default == "PHL" ) attributes.sorting = "phl" ; if ( attributes.order_default == "PLH" ) attributes.sorting = "plh" ; if ( attributes.order_default == "STR" ) attributes.sorting = "stars" ; if ( attributes.order_default == "PFR" ) attributes.sorting = "pref_rate" ; if ( attributes.order_default == "DIS" ) attributes.sorting = "doSortByDiscountAmount"; // console.log("Attributes: " + attributes.sorting ); } // Select function selector.onchange = function(){ attributes.sorting = this.value; hotelmap.sorting.rightpanel.sort( hotelmap.rightpanel.listings.hotelcontainer ); //hotelmap.rhp.push_to_packet("CLICK_SORTING_OPTION",attributes.sorting); }; // Selection Options var ops = { 'rtg':translations.LNG_ORTRIP, 'distance':translations.LNG_ORDIST, 'plh':translations.LNG_ORPRLH, 'phl':translations.LNG_ORPRHL, 'stars':translations.LNG_ORST, 'pref_rate':translations.LNG_MEMB_RATE, 'name_order':translations.LNG_NAME_ORDER, 'doSortByDiscountAmount':translations.LNG_SRT_BY_DISCOUNT }; for ( var oper in ops ){ var op1 = hotelmap.library.utility.element("option",{'fontFamily':'"Open Sans",arial','fontSize':'11px','color':'rgb(109,109,109)'},{'value':oper,'innerHTML':ops[oper]}); if ( oper == attributes.sorting ){ // console.log("selected: " + attributes.sorting); op1.selected = "selected"; } selector.appendChild(op1); } // Add to.. selectorMain.appendChild( selector ); hotelmap.rightpanel.orderSelect = selectorMain; hotelmap.rpselect = selector ; // Main Element within the stage 2 container. hotelmap.rightpanel.listings = hotelmap.library.utility.element("div",{'position':'absolute','top':'0px','height':listing_height+"px",'width':hotelmap.rightpanel.panel_settings.width+"px",'display':''},{}); if (attributes.direction == 'rtl') { hotelmap.rightpanel.listings.style.right = '0px'; } else { hotelmap.rightpanel.listings.style.left = '0px'; } // Add to stage 2 hotelmap.rightpanel.listcontainer.appendChild( hotelmap.rightpanel.listings ); var rhcontainer = hotelmap.library.utility.element("div",{'overflow':'hidden','height': '100%','margin-top':'56px','position':'relative'},{'className':'outerrhp'}); // The container for the hotel elements hotelmap.rightpanel.listings.hotelcontainer = hotelmap.library.utility.element("div",{'border':'0px solid #FF0000','position':'absolute','top':'0','left':'0px','height':listing_height-39+"px",'width':"100%",'backgroundColor':'#F2F5F6'},{'id': 'hotelMainContainer','innerHTML':'','className':'test'}); hotelmap.rightpanel.listings.appendChild(hotelmap.rightpanel.orderSelect); var line = hotelmap.library.utility.element("img",{'position':'absolute','top':'55px','left':'0px','border':'0px solid #FF0000'},{'src':attributes.host+'resource/images/gfx_v2/rightpanel-line.gif'}); hotelmap.rightpanel.listings.appendChild(line); rhcontainer.appendChild(hotelmap.rightpanel.listings.hotelcontainer); hotelmap.rightpanel.listings.appendChild(rhcontainer); /* 03-07-2013 - maxi width adjustment for selector */ setTimeout( function() { selectorMain.style.width = selectorMain.scrollWidth + "px" ; var output = ( hotelmap.rightpanel.panel_settings.width - parseInt(selectorMain.style.width) ); selectorMain.style.width = hotelmap.rightpanel.panel_settings.width + "px"; selector.style.width = output + "px" ; }, 300 ) ; }, /* ------------------------------------------------------------------------------------------------------ */ /** * create_favourite_panel */ create_favourite_panel : function(listing_height) { // Favoruties coe container node hotelmap.rightpanel.favorites = hotelmap.library.utility.element("div",{'position':'absolute','top':'0px','left':'0px','height':listing_height+"px",'width':hotelmap.rightpanel.panel_settings.width+"px",'display':'none'},{}); // Add the main lister from stage 2 hotelmap.rightpanel.listcontainer.appendChild( hotelmap.rightpanel.favorites ); // Internal container for elements hotelmap.rightpanel.favorites.hotelcontainer = hotelmap.library.utility.element("div",{'position':'absolute','top':'24px','left':'0px','height':listing_height-31+"px",'width':hotelmap.rightpanel.panel_settings.width+"px",'backgroundColor':'#EBEBE9','overflow':'hidden'},{}); // Notify shortlists of our container fo this. hotelmap.favorites.set_favorite_container(hotelmap.rightpanel.favorites.hotelcontainer); // Visual Line and appenders var line = hotelmap.library.utility.element("img",{'display':'none','position':'absolute','top':'23px','left':'0px','border':'0px solid #FF0000'},{'src':attributes.host+'resource/images/gfx_v2/rightpanel-line.gif'}); hotelmap.rightpanel.favorites.appendChild(line); hotelmap.rightpanel.favorites.appendChild(hotelmap.rightpanel.favorites.hotelcontainer); hotelmap.rightpanel.favorites.hotelcontainer.line = line; }, /** * create_best_panel * Creates the INTERNAL pane which houses BEST icons. * @param listing_height */ create_best_panel : function(listing_height) { // The BEST panel hotelmap.rightpanel.best = hotelmap.library.utility.element("div",{'position':'absolute','top':'0px','left':'0px','height':listing_height+"px",'width':hotelmap.rightpanel.panel_settings.width+"px",'display':'none'},{}); // Add this to the "container" from stage 2 hotelmap.rightpanel.listcontainer.appendChild( hotelmap.rightpanel.best ); // Now add a further contains for the best elements hotelmap.rightpanel.best.hotelcontainer = hotelmap.library.utility.element("div",{'position':'absolute','top':'24px','height':listing_height-31+"px",'width':hotelmap.rightpanel.panel_settings.width+"px",'left':'0px','backgroundColor':'#EBEBE9','overflow':'hidden'},{}); // Add a visual LINE break var line = hotelmap.library.utility.element("img",{'display':'none','position':'absolute','top':'23px','left':'0px','border':'0px solid #FF0000'},{'src':attributes.host+'resource/images/gfx_v2/rightpanel-line.gif'}); hotelmap.rightpanel.best.appendChild(line); hotelmap.rightpanel.best.hotelcontainer.line = line; hotelmap.rightpanel.best.appendChild(hotelmap.rightpanel.best.hotelcontainer); } }, /** * create_listings_panel * STAGE2 - After init */ create_listings_panel : function() { // Caclulate the height available for listing. var listing_height = ( hotelmap.rightpanel.dimensions[1] - hotelmap.rightpanel.panel_settings.lower - hotelmap.rightpanel.panel_settings.top ) ; listing_height = listing_height - 31; // Left over.. // listcontainer = the entire internals of the right panel containers below the title. hotelmap.rightpanel.listcontainer = hotelmap.library.utility.element("div",{'position':'absolute','top':'30px','left':'0px', 'height':listing_height+"px",'width':hotelmap.rightpanel.panel_settings.width+"px",'backgroundColor':'#EBEBE9'},{}); // Add this to the main right panel hotelmap.rightpanel.panel.appendChild( hotelmap.rightpanel.listcontainer ) ; // This creates the main windows for each section to list in hotelmap.rightpanel.tab_sections.create_hotel_list_panel(listing_height); hotelmap.rightpanel.tab_sections.create_favourite_panel(listing_height); hotelmap.rightpanel.tab_sections.create_best_panel(listing_height); // This holds the tab icons for eacha section above. hotelmap.rightpanel.tabcontainer = hotelmap.library.utility.element("div",{'position':'absolute','top':'0px','left':'0px','width':'100%','height':'21px','border':'0px solid #FF0000','backgroundColor':'#315568'},{}); // NULL tab Reference hotelmap.rightpanel.tabReference = {}; // Append the core container hotelmap.rightpanel.listcontainer.appendChild( hotelmap.rightpanel.tabcontainer); // Create the specific "tab" icons and the functionality on click hotelmap.rightpanel.tab_sections.create_tab_series(translations.LNG_ONMAP, "ONMAP", function(){ hotelmap.rightpanel.best.style.display="none"; hotelmap.rightpanel.listings.style.display = "" ; hotelmap.rightpanel.favorites.style.display = "none"; hotelmap.rightpanel.tabseries = "MAP"; hotelmap.rightpanel.active_panel = hotelmap.rightpanel.listings.hotelcontainer; hotelmap.modules.feedprocess.get_new_hotel_listing(); }, "onmap", true, 116, 21, 1); hotelmap.rightpanel.tab_sections.create_tab_series(translations.LNG_SHORTLIST, "SHORTLIST", function(){ hotelmap.rightpanel.listings.style.display = "none" ; hotelmap.rightpanel.favorites.style.display = ""; hotelmap.rightpanel.best.style.display="none"; hotelmap.rightpanel.active_panel = hotelmap.rightpanel.favorites.hotelcontainer; hotelmap.rightpanel.tabseries = "SHORTLIST"; hotelmap.modules.feedprocess.get_new_hotel_listing(); }, "shortlist", false, 116, 21, 117); /*hotelmap.rightpanel.tab_sections.create_tab_series(translations.LNG_BEST, "BEST", function(){ hotelmap.rightpanel.listings.style.display = "none" ; hotelmap.rightpanel.favorites.style.display = "none"; hotelmap.rightpanel.best.style.display=""; hotelmap.rightpanel.active_panel = hotelmap.rightpanel.favorites.hotelcontainer; hotelmap.rightpanel.tabseries = "BEST"; hotelmap.modules.feedprocess.get_new_hotel_listing(); }, "best", false, 76, 21, 157);*/ }, /** * init * Initialise the right pabel container and create it. */ init : function( ) { // UI Reference hotelmap.ui = (hotelmap.ui) ? hotelmap.ui : _("ui"); // Current Dimensions hotelmap.rightpanel.dimensions = hotelmap.library.utility.getDimensions(); // The container right panel element hotelmap.rightpanel.panel = hotelmap.library.utility.element("div",{'position':'fixed','top': hotelmap.rightpanel.panel_settings.top + "px",'width': hotelmap.rightpanel.panel_settings.width + "px",'height': (hotelmap.rightpanel.dimensions[1]-hotelmap.rightpanel.panel_settings.lower-hotelmap.rightpanel.panel_settings.top)+18 + "px",'zIndex':'150','backgroundColor':'#EBEBE9','backgroundImage':'url('+attributes.host+'resource/images/gfx_v2/rightpanel-hotel-heading.jpg)','backgroundRepeat':'no-repeat','overflow':'hidden'},{'id' :'hmoriginal_shadow_rightpanel_leftlow'}); if (attributes.direction == 'rtl') { hotelmap.rightpanel.panel.style.left = '0px'; } else { hotelmap.rightpanel.panel.style.right = '0px' } if ( attributes.isHidden ) hotelmap.rightpanel.panel.style.display = "none"; // IE Shadow Block to give depth! if ( attributes.isLowIE && !attributes.isHidden ) { // Shadow Block hotelmap.rightpanel.block = hotelmap.library.utility.element("div",{'position':'absolute','top': hotelmap.rightpanel.panel_settings.top+3 + "px",'width': hotelmap.rightpanel.panel_settings.width + 10 + "px",'height': (hotelmap.rightpanel.dimensions[1]-hotelmap.rightpanel.panel_settings.lower-hotelmap.rightpanel.panel_settings.top)+18 + "px",'zIndex':'150','backgroundColor':'#000000'},{'className':'right_block'}); if (attributes.direction == 'rtl') { hotelmap.rightpanel.block.style.right = (hotelmap.rightpanel.dimensions[0]-hotelmap.rightpanel.panel_settings.width)-2+'px'; } else { hotelmap.rightpanel.block.style.left = (hotelmap.rightpanel.dimensions[0]-hotelmap.rightpanel.panel_settings.width)-2+'px'; } // Transparency hotelmap.library.utility.setTrans( hotelmap.rightpanel.block, 8 ) ; // Add.. hotelmap.ui.appendChild( hotelmap.rightpanel.block ) ; // Small borders for emphasis hotelmap.rightpanel.panel.style.borderLeft = '1px solid #aaa'; hotelmap.rightpanel.panel.style.borderBottom = '1px solid #aaa'; hotelmap.shadows.push(hotelmap.rightpanel.block) ; // Add reference to the shadow stack } // Top Panel Title for RP hotelmap.rightpanel.panel.appendChild( hotelmap.library.utility.quickdiv("rp_title",translations.LNG_HOTELS) ); // Add to main hotelmap.ui.appendChild( hotelmap.rightpanel.panel ) ; // Now create the inernals of the panel. hotelmap.rightpanel.create_listings_panel(); } }; /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: HotelMapWW-InformationPanel * Description: The right side popout information panel * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : * ------------------------------------------------------------------------- */ hotelmap.calendar = { /* =================================================================================================== */ searched : false, panel : null, dimensions : null, caldata : null, arrival : null, departure : null, loaded : false, /* =================================================================================================== */ /** * pretty_dates.months * Just a list of corresponding months */ pretty_dates : { months : [translations.LNG_AUTOLONGMONTHS1, translations.LNG_AUTOLONGMONTHS2, translations.LNG_AUTOLONGMONTHS3, translations.LNG_AUTOLONGMONTHS4, translations.LNG_AUTOLONGMONTHS5, translations.LNG_AUTOLONGMONTHS6, translations.LNG_AUTOLONGMONTHS7, translations.LNG_AUTOLONGMONTHS8, translations.LNG_AUTOLONGMONTHS9, translations.LNG_AUTOLONGMONTHS10, translations.LNG_AUTOLONGMONTHS11, translations.LNG_AUTOLONGMONTHS12] }, getShortDayName: function(date) { var a = new Date(date.year,date.month-1,date.day); var d = [translations.LNG_AUTOSHORTDAYS0, translations.LNG_AUTOSHORTDAYS1, translations.LNG_AUTOSHORTDAYS2, translations.LNG_AUTOSHORTDAYS3, translations.LNG_AUTOSHORTDAYS4, translations.LNG_AUTOSHORTDAYS5, translations.LNG_AUTOSHORTDAYS6]; return d[a.getDay()]; }, getDayName : function(date){ var a = new Date(date.year,date.month-1,date.day); var d = [translations.LNG_AUTOLONGDAYS0, translations.LNG_AUTOLONGDAYS1, translations.LNG_AUTOLONGDAYS2, translations.LNG_AUTOLONGDAYS3, translations.LNG_AUTOLONGDAYS4, translations.LNG_AUTOLONGDAYS5, translations.LNG_AUTOLONGDAYS6]; return d[a.getDay()]; }, getDateDifference : function( arrival, departure ) { var a = new Date(arrival.year,arrival.month-1,arrival.day); var d = new Date(departure.year,departure.month-1,departure.day); // The number of milliseconds in one day var ONE_DAY = 1000 * 60 * 60 * 24; // Convert both dates to milliseconds var date1_ms = d.getTime(); var date2_ms = a.getTime(); // Calculate the difference in milliseconds var difference_ms = Math.abs(date1_ms - date2_ms) // Convert back to days and return return Math.round(difference_ms/ONE_DAY); }, /** * getPrettyDateString * returns a prettyfied date string * @param dt Date Obejct */ getPrettyDateString : function( dt, showYear ) { var pretty_month = hotelmap.calendar.pretty_dates.months[(dt.month-1)] ; var pretty_date_ending = "th"; var pretty_date_temp = ""+dt.day; if(pretty_date_temp[(pretty_date_temp.length-1)]=="1") pretty_date_ending = "st"; if(pretty_date_temp[(pretty_date_temp.length-1)]=="2") pretty_date_ending = "nd"; if(pretty_date_temp[(pretty_date_temp.length-1)]=="3") pretty_date_ending = "rd"; if ( pretty_date_temp == "11" ) pretty_date_ending = "th"; if ( pretty_date_temp == "12" ) pretty_date_ending = "th"; if ( pretty_date_temp == "13" ) pretty_date_ending = "th"; var day_name = (hotelmap.calendar.getDayName(dt)).substr(0,3); if ( attributes.language != "en_GB" && attributes.language != "en_US" ) pretty_date_ending = ""; if ( attributes.language != "en_GB" && attributes.language != "en_US" ) { var day_name = hotelmap.calendar.getDayName(dt); } /* german addition of "." for numbers.. gosh */ if ( attributes.language == "de_DE" || attributes.language == 'is_IS' || attributes.language == 'sk_SK' ) pretty_date_temp += "."; if ( attributes.language == "sk_SK" ) { pretty_month = pretty_month.toLowerCase(); day_name = day_name.toLowerCase(); } var comma = ","; if ( attributes.language == "ar_SA") comma = ""; var final_str = ""+day_name +""+comma+" "+ pretty_date_temp+" "+pretty_month+""; // if ( attributes.language == "zh_TW" ) { // final_str = dt.year + " " + pretty_month+ pretty_date_temp + " " + day_name; // } if ( attributes.language == "zh_TW" || attributes.language == "zh_CN" || attributes.language == "ja_JP") { var tmpdate = new Date(dt.year,dt.month-1,dt.day); final_str = getLingualDate(tmpdate); } if ( showYear ) final_str += " "+dt.year; return final_str; }, getLongPrettyDateString : function( dt, showYear ) { var pretty_month = hotelmap.calendar.pretty_dates.months[(dt.month-1)] ; var pretty_date_ending = "th"; var pretty_date_temp = ""+dt.day; if(pretty_date_temp[(pretty_date_temp.length-1)]=="1") pretty_date_ending = "st"; if(pretty_date_temp[(pretty_date_temp.length-1)]=="2") pretty_date_ending = "nd"; if(pretty_date_temp[(pretty_date_temp.length-1)]=="3") pretty_date_ending = "rd"; if ( pretty_date_temp == "11" ) pretty_date_ending = "th"; if ( pretty_date_temp == "12" ) pretty_date_ending = "th"; if ( pretty_date_temp == "13" ) pretty_date_ending = "th"; /* german addition of "." for numbers.. gosh */ if ( attributes.language == "de_DE" || attributes.language == 'is_IS' || attributes.language == 'sk_SK' ) pretty_date_temp += "."; var day_name = (hotelmap.calendar.getDayName(dt)); if ( attributes.language == "sk_SK" ) { pretty_month = pretty_month.toLowerCase(); day_name = day_name.toLowerCase(); } var comma = (attributes.language == "ar_SA") ? "" :","; var final_str = ""+day_name +""+comma+" "+ pretty_date_temp+" "+pretty_month+""; if ( showYear ) final_str += " "+dt.year; if ( attributes.language == "zh_TW" || attributes.language == "zh_CN" || attributes.language == "ja_JP") { var tmpdate = new Date(dt.year,dt.month-1,dt.day); final_str = getLingualDate(tmpdate); } return final_str; }, /* =================================================================================================== */ /** * process_pre_calendar_selection_summary * Creates the calendar update string of summary check in data */ process_pre_calendar_selection_summary : function() { //console.log("Load:process_pre_calendar_selection_summary"); // -- // Create a string to show the summary of dates selected // Format: X night(s): Check-in XXth XXXXX, check-out: XXth XXXXX try { //console.log(">>"); // -- // Process to correct dates //hotelmap.search_data.dates.arrival = hotelmap.calendar_item.dates.arrival; //hotelmap.search_data.dates.departure = hotelmap.calendar_item.dates.depart; var check_in_date_string = hotelmap.calendar.getLongPrettyDateString( hotelmap.calendar_item.dates.arrival, true ); var check_out_date_string = hotelmap.calendar.getLongPrettyDateString( hotelmap.calendar_item.dates.depart, true ); var number_of_nights = hotelmap.calendar.getDateDifference(hotelmap.search_data.dates.departure,hotelmap.search_data.dates.arrival); var plural_string_type = (number_of_nights>1) ? "s" : ""; var final_string1 = "" + number_of_nights+" night"+plural_string_type+": Arrive " + check_in_date_string + ". Depart " + check_out_date_string; var final_string2 = "" + number_of_nights+" night"+plural_string_type+": Arrive " + check_in_date_string + ". Depart " + check_out_date_string; _("CAL_ARRIVAL_TEXT1").innerHTML = "" + check_in_date_string ; _("CAL_DEPART_TEXT1").innerHTML = "" + check_out_date_string ; _("CAL_NIGHTS1").innerHTML = "" + number_of_nights; if ( attributes.language == "lv_LV" ) { _("CAL_ARRIVAL_TEXT1").style.fontSize = "11px"; _("CAL_DEPART_TEXT1").style.fontSize = "11px"; } var comma1 = ","; if ( attributes.language == "ar_SA" ) comma1 = "،"; $(".comma").html(comma1+" "); _("nights_plural").innerHTML = ( parseInt(number_of_nights) > 1 ) ? translations.LNG_NIGHTS : translations.LNG_NIGHT; if ( attributes.language == "ru_RU" || attributes.language == "fr_FR" || attributes.language == "in_ID" || attributes.language == "nl_NL" || attributes.language == "vi_VN" || attributes.language == "lv_LV") { _("CAL_NIGHTS").style.fontSize = '11px'; } if ( attributes.language == "de_DE" ) { _("CAL_NIGHTS").style.fontSize = '10px'; } if ( attributes.auto_exec_cal ) { attributes.auto_exec_cal=false; setTimeout(function(){ hotelmap.calendar.panel.style.display = "none"; hotelmap.calendar.search(); }, 500); } } catch ( updateCalStringException ) {// //console.log("updateCalStringException: " + updateCalStringException.message ); } //console.log("Post:process_pre_calendar_selection_summary"); }, // -- // sendCalendarStoreInformation // sendCalendarStoreInformation : function( rooms, occupancy, arrival, departure ) { // Our current position - maybe we want this later..? var current_center_coordinates = hotelmap.maps.getCenter(); // Create the dataset. var dataset = { rooms : rooms, occupancy : occupancy, arrival : arrival, departure : departure, latitude : current_center_coordinates.lat, longitude : current_center_coordinates.lon, mapID : attributes.map_identity, mapURL : attributes.request_uri, title : Base64.encode(attributes.pagedata.title), subtitle : Base64.encode(attributes.pagedata.subtitle), iconsets : attributes.iconsets }; // Stringify the response var datasetAsString = JSON.stringify( dataset ) ; // Send the data through hotelmap.library.json.get("services/reporting/calUpdate?ds=" + datasetAsString + "&" ) ; }, /** * Search * Someone clicked on the searc button. Reset everything and * begin a new search. */ search : function() { // We need to reset before a new search as these are search specific. attributes.highlighthotels = []; window.tagging.setSearchRunning(); hotelmap.calendar.isInViewMode=false; makeHashChange("search", {model: 'search'}); //try { attributes.promoted_hotels = [] ; } catch ( ePOL) {} /* Server Automation mode, send through cal set */ if ( attributes.automation_mode == "server" ) { hotelmap.auto_demo.server.send_notify("doCalendarSearch", ""); } doCustomFramePostCalendar(); userdata("isCalendarDone","YES"); try { $(".connecting").show(); } catch ( conShow ) {} try { _("lthm").style.display = "none"; } catch(exlthm) { } var oldpt = attributes.price_type; //console.log("OLD PT: " + oldpt ) ; try { // console.log("Price Type Check"); if ( $("#price_type") ) { attributes.price_type = $("#price_type").val(); // console.log("Price Type Value: ["+$("#price_type").val()+"]"); } /// console.log("Outcome: " + attributes.price_type); if ( attributes.price_type == "" || attributes.price_type === undefined ) attributes.price_type = oldpt; } catch ( efg ) { attributes.price_type = oldpt ; }//RPN APN TCA //console.log("Attributes Price Type: " + attributes.price_type); try { if ( attributes.__initPriceType ) { attributes.price_type = attributes.__initPriceType; attributes.__initPriceType = false; } } catch ( eaip ){} if ( !hotelmap.calendar.searched ) { hotelmap.library.json.get("resource/script/hmww-tap?point=SEARCH&tid="+attributes.ref_codal_tid+"&"); } else { hotelmap.library.json.get("resource/script/hmww-tap?point=VIEWING_HOTELS&tid="+attributes.ref_codal_tid+"&"); } try { attributes.pin_number = ''; attributes.pin_number += ""+_("pin1").value ; attributes.pin_number += ""+_("pin2").value ; attributes.pin_number += ""+_("pin3").value ; attributes.pin_number += ""+_("pin4").value ; } catch ( pinException ) { // end } // -- // Reset search elements. hotelmap.modules.feedprocess.remove_all_pins(); hotelmap.modules.feedprocess.zoom_level = null; hotelmap.modules.feedprocess.hotels = {}; hotelmap.modules.feedprocess.pixel_sets = {}; hotelmap.modules.feedprocess.pins = []; hotelmap.modules.feedprocess.base_to_search = []; hotelmap.modules.feedprocess.base_timeout = null; hotelmap.modules.feedprocess.cached_rates = {}; hotelmap.modules.feedprocess.rate_icons = {}; hotelmap.modules.feedprocess.base_searcher = {}; hotelmap.modules.feedprocess.has_searched = false; attributes.searchid = ''; hotelmap.favorites.clear(); // hotelmap.best_hotels.clear(); //hotelmap.rightpanel.listings.hotelcontainer.innerHTML = ""; $(hotelmap.rightpanel.listings.hotelcontainer).find(".rightPanelCoreContainer").remove(); hotelmap.hotelicon.feedpoints = {}; hotelmap.modules.feedprocess.remove_all_pins(); hotelmap.hotelicon.right_panel_elements = {}; // -- // Process to correct dates hotelmap.search_data.dates.arrival = hotelmap.calendar_item.dates.arrival; hotelmap.search_data.dates.departure = hotelmap.calendar_item.dates.depart; try { hotelmap.search_data.currency = _("calendar_currency").options[_("calendar_currency").selectedIndex].value; } catch ( e1o ) {} try { hotelmap.search_data.currency = _("calendar_currency").options[_("calendar_currency").selectedIndex].value; } catch ( e2o ) {} /* This ensures that the embedded version, which is shown without a calendar defaults to the locale currency of the user. This was requested by an INF client (DEB) */ if ( attributes.isHidden ) hotelmap.search_data.currency = attributes.currency_pref; // -- // Create YYYMMDD hotelmap.search_data.dates.arrival.yyyymmdd = hotelmap.search_data.dates.arrival.year + "" + ((hotelmap.search_data.dates.arrival.month<10)?"0"+hotelmap.search_data.dates.arrival.month:hotelmap.search_data.dates.arrival.month) + "" + ((hotelmap.search_data.dates.arrival.day<10)?"0"+hotelmap.search_data.dates.arrival.day:hotelmap.search_data.dates.arrival.day) hotelmap.search_data.dates.departure.yyyymmdd = hotelmap.search_data.dates.departure.year + "" + ((hotelmap.search_data.dates.departure.month<10)?"0"+hotelmap.search_data.dates.departure.month:hotelmap.search_data.dates.departure.month) + "" + ((hotelmap.search_data.dates.departure.day<10)?"0"+hotelmap.search_data.dates.departure.day:hotelmap.search_data.dates.departure.day) // -- // Remove black overlay and get rid of the cal transparency = 100; iterations = 0; //alert(hotelmap.calendar.initialiseHotelId); //if ( !hotelmap.calendar.postLoadHotel ) //{ try { hotelmap.graphics.reverseFadeElement(hotelmap.calendar.panel, function() { if (!$("html").hasClass("mostpopular") && (!attributes.custom_frames.enabled)) { hotelmap.library.utility.overlay(80,'#000',false, 154); } if(doCustomFramePostCalendarHasBeenRun) { hotelmap.library.utility.overlay(80,'#000',false, 154); } try { hotelmap.calendar.panel.parentNode.removeChild(hotelmap.calendar.panel); } catch ( e12) {} }); } catch ( almksdhaksd ) {} //} else //{ // hotelmap.calendar.panel.parentNode.removeChild(hotelmap.calendar.panel); //} // -- // Populate the right side hotelmap.search_data.populate_right_menu_side(); // -- // We have some valid dates. hotelmap.calendar.searched = true; try { _gaq.push(['_trackPageview', 'event/calendar_search']); } catch ( googleTrackVirtualPageViewException ){} // -- // Grab a new hotel listing. hotelmap.modules.feedprocess.get_new_hotel_listing(); //if ( !hotelmap.feedback.shown_header){ setTimeout(function(){ hotelmap.heading.feedback_user_notice(); }, 2000); } //console.log(">> " + hotelmap.calendar.postLoadHotel); if ( hotelmap.calendar.postLoadHotel) { removeUpdatingRatesLayer(); // Adjust position on screen dims hotelmap.calendar.dimensions = hotelmap.library.utility.getDimensions(); var x = (hotelmap.calendar.dimensions[0]/2) - (300/2); var y = (hotelmap.calendar.dimensions[1]/2) - (200/2); // -- // Core cal hotelmap.calendar.preload = hotelmap.library.utility.element("div",{}, {'id':'loading_point','innerHTML':'
    '+translations.LNG_UPDATING+'
    '} ); hotelmap.ui.appendChild( hotelmap.calendar.preload ); setTimeout(function(){ hotelmap.library.utility.overlay(80,'#000',true, 999); },200); hotelmap.calendar.initLoaderPabel = setInterval ( function() { if ( hotelmap.calendar.hasShownElement && hotelmap.modules.feedprocess.check_rate(hotelmap.calendar.initialiseHotelId) && !hotelmap.variableNotice.active ) { clearInterval(hotelmap.calendar.initLoaderPabel); hotelmap.calendar.preload.parentNode.removeChild(hotelmap.calendar.preload); // console.log("Preload"); removeUpdatingRatesLayer(); infoPanelFocus( hotelmap.calendar.initialiseHotelId, false ) ; } }, 500 ); } // aug-13-cal-store-hook hotelmap.calendar.sendCalendarStoreInformation( hotelmap.search_data.rooms, hotelmap.search_data.occupancy, hotelmap.search_data.dates.arrival.yyyymmdd, hotelmap.search_data.dates.departure.yyyymmdd ); //hotelmap.search_data.rooms hotelmap.search_data.occupancy /** Data String for sending REMOTEHELPER data to the server **/ var dataString = "CUR:" + hotelmap.search_data.currency +"|"; dataString += "ARR:" + hotelmap.search_data.dates.arrival.year + "-" + hotelmap.search_data.dates.arrival.month + "-" + hotelmap.search_data.dates.arrival.day + "|"; dataString += "DEP:" + hotelmap.search_data.dates.departure.year + "-" + hotelmap.search_data.dates.departure.month + "-" + hotelmap.search_data.dates.departure.day + "|"; //hotelmap.rhp.push_to_packet("CLICK_CAL_DATA",dataString); var occData = {'setOC': hotelmap.search_data.occupancy, 'setRM': hotelmap.search_data.rooms, 'setPD': hotelmap.calendar_item.dates, 'setSD': hotelmap.search_data.dates} ; //hotelmap.rhp.push_to_packet("CLICK_CAL_OCCU",JSON.stringify(occData)); //hotelmap.rhp.push_to_packet("CLICK_CAL_SEARCH","1"); /** Data String for sending REMOTEHELPER data to the server **/ try { setTimeout(function(){ try { $(hotelmap.assist.panelref.phase).slideDown({'complete':function(){ /*setTimeout(function(){ $(hotelmap.assist.panelref.phase).slideUp(); } , 2000);*/ }}); } catch ( asdasdasd ) {} },1000); } catch ( e12 ) {} }, /* =================================================================================================== */ /** * init * Basic calendar boxing */ init : function() { window.tagging.setCalendarActive(); hotelmap.calendar.isInViewMode=true; makeHashChange("calendar", {model: 'calendar'}); hotelmap.calendar.isNewLoaded = true ; hotelmap.library.json.get("resource/script/hmww-tap?point=CALENDAR&tid="+attributes.ref_codal_tid+"&"); hotelmap.calendar.showSelection = ( attributes.event_data.is_event == "Y" && attributes.calendar_first_load ) ? false : true; attributes.calendar_first_load = false; hotelmap.userstatistics.calendars++; // if ( hotelmap.imageloader ) hotelmap.imageloader.init(); try { hotelmap.filters.disable_menu(); } catch ( menuExceptionPoint ) {} var showClose = true;//(hotelmap.calendar.loaded) ? true : false; // -- // Remove any previous container which was running an info view if ( hotelmap.infopanel.container ) { try { hotelmap.infopanel.container.parentNode.removeChild(hotelmap.infopanel.container); hotelmap.infopanel.isClosed = true; } catch ( endException) {} } if ( !hotelmap.calendar.loaded ) { hotelmap.calendar.loaded = true; hotelmap.calendar_item.dates.arrival.day = attributes.event.date_start.day; // depart hotelmap.calendar_item.dates.arrival.month = attributes.event.date_start.month; hotelmap.calendar_item.dates.arrival.year = attributes.event.date_start.year; hotelmap.calendar_item.dates.depart.day = attributes.event.date_end.day; // depart hotelmap.calendar_item.dates.depart.month = attributes.event.date_end.month; hotelmap.calendar_item.dates.depart.year = attributes.event.date_end.year; /** * Hook for allowing day events. In this case we want to have the check in * date one day prior to the event date and departure on the day - obviously * they can update this if they want. */ if ( attributes.event.eventDayItem.eventDayStart_Flag == "YES" ) { // REVERT START DATE TO DAY BEFORE hotelmap.calendar_item.dates.arrival.day = attributes.event.eventDayItem.start.day; // depart hotelmap.calendar_item.dates.arrival.month = attributes.event.eventDayItem.start.month; hotelmap.calendar_item.dates.arrival.year = attributes.event.eventDayItem.start.year; // REVERT THE END DAY TO DAY BEFORE. hotelmap.calendar_item.dates.depart.day = attributes.event.eventDayItem.end.day; // depart hotelmap.calendar_item.dates.depart.month = attributes.event.eventDayItem.end.month; hotelmap.calendar_item.dates.depart.year = attributes.event.eventDayItem.end.year; } } // -- // Black layer //hotelmap.library.utility.overlay(80,'#000',true, 154); // -- // Cal dimensions var width = 800; var height = 420; // -- // Adjust position on screen dims hotelmap.calendar.dimensions = hotelmap.library.utility.getDimensions(); var x = (hotelmap.calendar.dimensions[0]/2) - (width/2); var y = (hotelmap.calendar.dimensions[1]/2) - (height/2); // -- // Core cal hotelmap.calendar.panel = hotelmap.library.utility.element("div",{}, {'id':'caldhad'}); if (showClose) { hotelmap.calendar.closepanel = hotelmap.library.utility.element("img",{},{'className':'close','src':attributes.host+'resource/images/gfx_v2/close.png','id':'closepointercal'}); // Low IE Handler. if (attributes.isLowIE) { if (attributes.direction == 'rtl') { hotelmap.calendar.closepanel.style.right = "770px"; } else { hotelmap.calendar.closepanel.style.left = "770px"; } hotelmap.calendar.closepanel.style.top = "10px"; } hotelmap.calendar.panel.appendChild(hotelmap.calendar.closepanel); /** * Close Calender Event */ hotelmap.calendar.closepanel.onclick = hotelmap.calendar.closepanel.closeCalPan = function() { makeHashChange("search", {model: 'search'}); hotelmap.calendar.isInViewMode = false; if (!hotelmap.calendar.searched) { hotelmap.calendar.search(); } else { if (hotelmap.calendar.postLoadHotel) { infoPanelFocus(hotelmap.calendar.initialiseHotelId, false) ; try { hotelmap.calendar.panel.parentNode.removeChild( hotelmap.calendar.panel ); } catch (panelRemovalExceptionNotice) { } } else { hotelmap.library.utility.overlay(80,'#000',false, 154); hotelmap.calendar.panel.parentNode.removeChild(hotelmap.calendar.panel); } } } } hotelmap.ui = (hotelmap.ui) ? hotelmap.ui : _("ui"); hotelmap.library.utility.overlay(80,'#000',true, 999); hotelmap.ui.appendChild( hotelmap.calendar.panel ) ; if (!attributes.isLowIE) { hotelmap.library.utility.setTrans(hotelmap.calendar.panel,0); } // -- // Add contents hotelmap.calendar.add_ad_panel(); hotelmap.calendar.add_base_cal_housing(); iterations = 0; transparency = 0; if (!attributes.isLowIE) { setTimeout(function() { hotelmap.graphics.zoomElement( hotelmap.calendar.panel, 800,420,'#FFFFFF', function(){},false ); }, 300); } if (attributes.isHidden||attributes.isLaunched) { hotelmap.calendar.panel.style.display = "none"; hotelmap.calendar.search(); } /** * Lets wait until the calendar is loaded correctly before we * auto select a bunch of dates. * */ var waitForCalendarLoad = setInterval(function(){ if (hotelmap.calendar.showSelection && !hotelmap.calendar.searched) { clearInterval(waitForCalendarLoad); if (attributes.selectionDates && attributes.selectionDates.start) { try { hotelmap.calendar_item.select_date_period( attributes.selectionDates.start, attributes.selectionDates.end ); } catch (calException1){} } } },20); }, /* =================================================================================================== */ /** * add_base_cal_housing * Add left side content */ add_base_cal_housing : function() { hotelmap.calendar.caldata = hotelmap.library.utility.element("div",{},{'className':'caldata'}); hotelmap.calendar.panel.appendChild( hotelmap.calendar.caldata ); hotelmap.calendar_item.create_today_date(hotelmap.calendar_item.dates.today); //hotelmap.calendar_item.create_today_date(hotelmap.calendar_item.dates.arrival); //hotelmap.calendar_item.create_today_date(hotelmap.calendar_item.dates.depart); var calurl = (attributes.useMemCachedCalendar == "1") ? "calendar_html_1" : "calendar_html"; hotelmap.library.json.get("frames/"+calurl+"?auth="+attributes.authcode+"&dir="+attributes.direction+"&pt="+attributes.price_type+"&p_ht="+attributes.request_uri+"&p_sh="+attributes.params.show_language_preference+"&l="+attributes.language+"&h="+attributes.host+"&cbu="+attributes.currency_by_user+"&o=hotelmap.calendar.caldata&f=hotelmap.calendar_item.create_calendars¬=hotelmap.calendar_ages.initialise_child_age_verification&"); // -- // Call the feed for the internal cal contents. /*$.ajax("frames/calendar_html?pt="+attributes.price_type+"&p_ht="+attributes.request_uri+"&p_sh="+attributes.params.show_language_preference+"&l="+attributes.language+"&h="+attributes.host+"&cbu="+attributes.currency_by_user+"&o=hotelmap.calendar.caldata&f=hotelmap.calendar_item.create_calendars¬=hotelmap.calendar_ages.initialise_child_age_verification&", {'complete':function(data){ eval(data.responseText); var possible_logo_map = "M-" + attributes.map_identity ; if ( attributes.custom_logos[possible_logo_map] ) { $(".heading_image_top_hotel").attr("src", "/map/resource/images/gfx_v2/calendar/TopHotel.png"); $(".heading_image_calendar").attr("src", "/map/resource/images/gfx_v2/calendar/header_nobacking.jpg"); var logo = document.createElement("img"); $(logo).attr("src",attributes.custom_logos[possible_logo_map]); $(".logo_cal").append(logo); $(".logo_cal").show(); $(".heading_image_calendar").show(); $("#LNG_CALNOTE").html(""); $("#closepointercal").hide(); } else { $(".heading_image_top_hotel").attr("src", "/map/resource/images/gfx_v2/calendar/TopHotel.png"); $(".heading_image_calendar").attr("src", "/map/resource/images/gfx_v2/calendar/header.jpg"); $(".heading_image_top_hotel").show(); $(".heading_image_calendar").show(); } }});*/ }, /* =================================================================================================== */ /** * add_ad_panel * Create the right side panel */ add_ad_panel : function() { } }; /** * HotelMap Attendees * Experimental Device for demonstration current locations of booked users * Version: $Id$ * Notes: Testing Version May 2013 */ hotelmap.attendees = { init : function() { if ( attributes.isAttView ) // Attendee View Scope (see informa demo mode in CPRO) { hmwwas.HOTEL_AREAS_ALLOWED = "OFF" ; hmwwas.HOTEL_RATES_ALLOWED = "OFF" ; hotelmap.maps.zoomToPoint(30,0,2); hotelmap.leftpanel.mini_zoom(); //setTimeout(function(){ hotelmap.maps.zoomer.maintainOrder();} , 1000); // ZOOMEND Caller hotelmap.maps.mapEvent('zoomend', function() { //console.log("ZoomENd-1"); hotelmap.maps.zoomer.maintainOrder(); //console.log("ZoomEnd-2"); hotelmap.maps.removeAllLayerContent(); //console.log("ZoomEnd-3"); setTimeout(function(){hotelmap.attendees.runthis();},1000); } ); } }, newIcon : function( latitude, longitude, dataString, counter ) { var icon = hotelmap.library.utility.element("div", {'zIndex':'999999','width':'47px','height':'63px','backgroundRepeat':'no-repeat','backgroundImage':'url('+attributes.host+'/map/resource/images/gfx_v1/icons/hotels-zoom-2-medium.png)'},{}) ; icon.alt = icon.title = dataString;//"You have " + numPeople + " people staying at the " + hotelName; var iconText = hotelmap.library.utility.element("div", {'textAlign':'center','paddingTop':'3px','fontFamily':'Arial','color':'#FFF','fontWeight':'bold'},{'innerHTML':counter}); icon.appendChild( iconText ) ; latitude = parseFloat(latitude); longitude = parseFloat(longitude); hotelmap.maps.addIcon( icon, latitude, longitude, "BLOCKER") ; }, runthis : function() { hotelmap.maps.removeAllLayerContent(); if ( attributes.data_set ) {var pixel_plotter = []; for ( var i in attributes.data_set ) { var segments = i.split("|"); var numPeople = attributes.data_set[i][0] ; var hotelName = attributes.data_set[i][1]; var latitude = parseFloat(segments[0]); var longitude = parseFloat(segments[1]); /* Calculate the on screen coordinates */ var zoom = hotelmap.maps.getZoom(); var wSize = (deCarta.Utilities.tileSizeForZoom(zoom) * Math.pow(2, Math.floor(zoom - 1))); var x = longitude * wSize / 180; var y = Math.log(Math.tan((90 + latitude) * Math.PI / 360)) / (Math.PI / 180); y = y * wSize / 180; var ox = x; var oy = y; x = Math.ceil( Math.round(x / 50))*50 ; y = Math.ceil( Math.round(y / 50))*50 ; /* Create a key to bind them if ( hotelmap.maps.getZoom() != 17 ){ if ( hotelmap.maps.getZoom() < 14 ) { x = Math.ceil( Math.round(x / 100))*100 ; y = Math.ceil( Math.round(y / 100))*100 ; } else { } } */ var key = x + "-" +y; if ( !pixel_plotter[key]) { pixel_plotter[key] = []; pixel_plotter[key].push({'x':ox,'y':oy,'latitude':latitude, 'longitude':longitude, 'cmp':numPeople, 'id':hotelName}); } else { pixel_plotter[key].push({'x':ox,'y':oy,'latitude':latitude, 'longitude':longitude, 'cmp':numPeople, 'id':hotelName}); } } for ( var kName in pixel_plotter ) { var lat = 0; var lon = 0; var tit = 0; var cnt = 0; //console.log(">> " + kName ); if ( pixel_plotter[kName].length == 1 ) { var j = 0; var naming = (pixel_plotter[kName][j].cmp > 1 ) ? "people" : "person"; hotelmap.attendees.newIcon( pixel_plotter[kName][j].latitude, pixel_plotter[kName][j].longitude, "You have " + pixel_plotter[kName][j].cmp + " "+naming+ " staying at the " + pixel_plotter[kName][j].id, pixel_plotter[kName][j].cmp ); } else { var counter = 0; for ( var j = 0; j < pixel_plotter[kName].length ; j++ ) { counter = counter + parseInt(pixel_plotter[kName][j].cmp); lat = pixel_plotter[kName][j].latitude; lon = pixel_plotter[kName][j].longitude; tit = pixel_plotter[kName][j].id; } hotelmap.attendees.newIcon( lat,lon, counter + " staying in multiple hotels", counter ); } } //console.log("made"); } } /* init : function() { if ( attributes.isAttView ) // Attendee View Scope (see informa demo mode in CPRO) { hmwwas.HOTEL_AREAS_ALLOWED = "OFF" ; hmwwas.HOTEL_RATES_ALLOWED = "OFF" ; setTimeout(function(){ hotelmap.library.json.get("services/demos/get_attendees?id=DEMO&cb=hotelmap.attendees.parse&") ; }, 1000 ); //hotelmap.attendees.container = hotelmap.library.utility.element("div", {'border':'2px solid #CCC','position':'absolute','left':'-2px','top':'-2px','width':'200px','height':'500px','backgroundColor':'#FFF'}); //hotelmap.ui.appendChild(hotelmap.attendees.container); // ZOOMEND Caller hotelmap.maps.mapEvent('zoomend', function() { hotelmap.maps.zoomer.maintainOrder(); } ); } }, parse : function( data ) { hotelmap.attendees.data = data ; hotelmap.attendees.runner(); }, runner : function() { hotelmap.maps.removeAllLayerContent(); var data = hotelmap.attendees.data; if ( data && data.length > 0 ) { for ( var i = 0 ; i < data.length ; i++ ) { var hotel = data[i] ; if ( hotel ) { var numPeople = hotel.people ; var names = hotel.names; var hotelName = hotel.hotelName; var latitude = hotel.latitude; var longitude = hotel.longitude ; var hotelid = hotel.hmid; var icon = hotelmap.library.utility.element("div", {'zIndex':'999999','width':'47px','height':'63px','backgroundRepeat':'no-repeat','backgroundImage':'url(/map/resource/images/gfx_v1/icons/hotels-zoom-2-medium.png)'},{}) ; icon.alt = icon.title = "You have " + numPeople + " people staying here"; icon.names = names; var iconText = hotelmap.library.utility.element("div", {'textAlign':'center','paddingTop':'3px','fontFamily':'Arial','color':'#FFF','fontWeight':'bold'},{'innerHTML':numPeople}); icon.appendChild( iconText ) ; icon.onmousedown = function() { //var str = ""; //hotelmap.attendees.container.innerHTML = ""; //for ( var i in this.names ) //{ // str += this.names[i] + "
    "; //} //hotelmap.attendees.container.innerHTML = "
    Employees
    " + str + "
    "; } latitude = parseFloat(latitude); longitude = parseFloat(longitude); hotelmap.maps.addIcon( icon, latitude, longitude, "BLOCKER") ; } } } } */ } /** * HotelMap Attendees * Experimental Device for demonstration current locations of booked users * Version: $Id$ * Notes: Testing Version May 2013 */ hotelmap.companyview = { process : true, init : function() { if ( attributes.custom_maps.isCompanyView ) // Attendee View Scope (see informa demo mode in CPRO) { hmwwas.HOTEL_AREAS_ALLOWED = "OFF" ; hmwwas.HOTEL_RATES_ALLOWED = "OFF" ; setTimeout(function(){ hotelmap.library.json.get("services/demos/get_companies?id="+attributes.custom_maps.companyViewID+"&cb=hotelmap.companyview.parse&") ; }, 1000 ); //hotelmap.attendees.container = hotelmap.library.utility.element("div", {'border':'2px solid #CCC','position':'absolute','left':'-2px','top':'-2px','width':'200px','height':'500px','backgroundColor':'#FFF'}); //hotelmap.ui.appendChild(hotelmap.attendees.container); // ZOOMEND Caller hotelmap.maps.mapEvent('zoomend', function(){ clearTimeout(hotelmap.companyview.waiter ); hotelmap.companyview.waiter = setTimeout( function() { hotelmap.companyview.runner(); hotelmap.maps.zoomer.maintainOrder(); } , 1000 ); } ); // MOVEEND Caller hotelmap.maps.mapEvent('moveend', function(){ clearTimeout(hotelmap.companyview.waiter ); hotelmap.companyview.waiter = setTimeout( function(){ hotelmap.companyview.runner(); } , 1000 ); } ); } }, parse : function( data ) { hotelmap.companyview.data = data ; hotelmap.companyview.runner(); }, clear : function() { hotelmap.maps.removeAllLayerContent(); }, /** * Sanity Check the sets */ runCheckSet : function( pix_points ) { // console.log("Running check"); // console.dir( pix_points ) ; }, runner : function() { if ( hotelmap.companyview.process ) { var pixel_plotter = {}; hotelmap.maps.removeAllLayerContent(); var data = hotelmap.companyview.data; if ( data && data.length > 0 ) { //console.log(hotelmap.maps.getZoom()); for ( var i = 0 ; i < data.length ; i++ ) { var venue = data[i] ; if ( venue )// && ( venue.id ==1123 || venue.id ==1033)) { var latitude = parseFloat(venue.lat) ; var longitude = parseFloat(venue.lon) ; //if ( hotelmap.maps.isInZone( latitude, longitude, latitude, longitude )) //{ /* test */ var zoom = hotelmap.maps.getZoom(); var wSize = (deCarta.Utilities.tileSizeForZoom(zoom) * Math.pow(2, Math.floor(zoom - 1))); var x = longitude * wSize / 180; var y = Math.log(Math.tan((90 + latitude) * Math.PI / 360)) / (Math.PI / 180); y = y * wSize / 180; // console.log("X: " + x + ", Y:" + y); //var pixels = hotelmap.maps.mapPositionToPixels( latitude, longitude ) ; //console.log("pixels: " + pixels.x + ", " + pixels.y); // 46 by 41 var ox = x; var oy = y; if ( hotelmap.maps.getZoom() != 17 ){ if ( hotelmap.maps.getZoom() < 14 ) { x = Math.ceil( Math.round(x / 100))*100 ; y = Math.ceil( Math.round(y / 100))*100 ; } else { x = Math.ceil( Math.round(x / 50))*50 ; y = Math.ceil( Math.round(y / 50))*50 ; } } var key = x + "-" +y; //console.log(">"); if ( !pixel_plotter[key]) { pixel_plotter[key] = []; pixel_plotter[key].push({'x':ox,'y':oy,'latitude':latitude, 'longitude':longitude, 'cmp':venue.cmp, 'id':venue.id}); } else { pixel_plotter[key].push({'x':ox,'y':oy,'latitude':latitude, 'longitude':longitude, 'cmp':venue.cmp, 'id':venue.id}); } //if ( pixels.x > 0 && pixels.x < 3000 && pixels.y > 0 && pixels.y < 3000 ) //{ // pixel_plotter.push({'x': pixels.x, 'y':pixels.y}); //} //} } } hotelmap.companyview.runCheckSet( pixel_plotter ) ; //console.dir(pixel_plotter); for ( var k in pixel_plotter ) { //console.log("Plotting point: " + k ) ; //var icon = hotelmap.library.utility.element("div", {'zIndex':'999999','width':'46px','height':'41px','backgroundRepeat':'no-repeat','backgroundImage':'url(/map/resource/images/gfx_v1/title_icons/event-icon1.png)'},{}) ; //icon.title=icon.alt = pixel_plotter[k][0].cmp + "("+pixel_plotter[k][0].id+")"; //hotelmap.maps.addIcon( icon, pixel_plotter[k][0].latitude, pixel_plotter[k][0].longitude, "BLOCKER") ; //console.log("Point"); var quantity = pixel_plotter[k].length ; var naming = (quantity<2) ? pixel_plotter[k][0].cmp : ""+quantity ; //console.log("Quantity: " + quantity ) ; var sizing = (quantity<2) ? 7 : 11; if ( hotelmap.maps.getZoom() == 17 && quantity > 1 ) { naming = ""; for ( var p = 0 ; p < pixel_plotter[k].length ; p++ ) { naming += pixel_plotter[k][p].cmp ; if ( p != (pixel_plotter[k].length-1) ) naming += " & " ; } } hotelmap.companyview.addIcon( pixel_plotter[k][0].latitude, pixel_plotter[k][0].longitude, naming , sizing ) ; } } } }, addIcon : function( latitude, longitude, naming, sizing ) { sizing = (sizing) ? sizing : 7; var event_image_icon = hotelmap.library.utility.element("div",{'backgroundImage':'url('+attributes.host+'resource/images/gfx_v1/event-icon1.png)','width':'61px','height':'48px'},{}); event_image_icon.xoffset = 20; event_image_icon.eventIconIdentify = true; // The lower black title container var event_image_title = hotelmap.library.utility.element("div",{'position':'absolute','left':'0px','top':'48px','height':'39px','width':'0px','overflow':'hidden'},{}); // The black image actual var event_image_src = hotelmap.library.utility.element("img",{},{'src':'services/images/event/icon?small=true&sizer='+sizing+'&top='+Base64.encode(naming)+'&bottom=&'}); event_image_title.appendChild(event_image_src); event_image_icon.appendChild(event_image_title); event_image_src.myTitleSub = event_image_title; // The onloader - adjusting the position correctly. event_image_src.onload = function() { var t = this; setTimeout ( function() { var scrollwidth = t.myTitleSub.scrollWidth; t.myTitleSub.style.width = scrollwidth + "px"; t.myTitleSub.style.left = (0-(scrollwidth/2)) + 20 + "px"; },200 ); }; // Add the icon to the map hotelmap.maps.addIcon( event_image_icon, parseFloat(latitude),parseFloat(longitude), "BLOCKER" ) ; // If we're not IE low then make it slightly see through. if ( !attributes.isLowIE ) hotelmap.library.utility.setTrans( event_image_icon, 80 ) ; } } /* icon.alt = icon.title = "VENUE"; var iconText = hotelmap.library.utility.element("div", {'textAlign':'center','paddingTop':'3px','fontFamily':'Arial','color':'#FFF','fontWeight':'bold'},{'innerHTML':"X"}); icon.appendChild( iconText ) ; icon.onmousedown = function() { //var str = ""; //hotelmap.attendees.container.innerHTML = ""; //for ( var i in this.names ) //{ // str += this.names[i] + "
    "; //} //hotelmap.attendees.container.innerHTML = "
    Employees
    " + str + "
    "; } latitude = parseFloat(latitude); longitude = parseFloat(longitude); hotelmap.maps.addIcon( icon, latitude, longitude, "BLOCKER") ; */ /** * HotelMap Attendees * Experimental Device for demonstration current locations of booked users * Version: $Id$ * Notes: Testing Version May 2013 */ hotelmap.eventview = { process : true, init : function() { if ( attributes.custom_maps.isEventView ) // Attendee View Scope (see informa demo mode in CPRO) { //console.log("Initialising isEventView"); hmwwas.HOTEL_AREAS_ALLOWED = "OFF" ; hmwwas.HOTEL_RATES_ALLOWED = "OFF" ; hotelmap.maps.zoomToPoint(30,0,2); hotelmap.leftpanel.mini_zoom(); hotelmap.maps.zoomer.maintainOrder(); setTimeout(function(){ hotelmap.library.json.get("services/demos/get_events?id="+attributes.custom_maps.eventViewID+"&cb=hotelmap.eventview.parse&") ; }, 1000 ); // ZOOMEND Caller hotelmap.maps.mapEvent('zoomend', function(){ clearTimeout(hotelmap.eventview.waiter ); hotelmap.eventview.waiter = setTimeout( function() { hotelmap.eventview.runner(); hotelmap.maps.zoomer.maintainOrder(); } , 1000 ); } ); // MOVEEND Caller hotelmap.maps.mapEvent('moveend', function(){ clearTimeout(hotelmap.eventview.waiter ); hotelmap.eventview.waiter = setTimeout( function(){ hotelmap.eventview.runner(); } , 1000 ); } ); } }, parse : function( data ) { hotelmap.eventview.data = data ; hotelmap.eventview.runner(); }, clear : function() { hotelmap.maps.removeAllLayerContent(); }, /** * Sanity Check the sets */ runCheckSet : function( pix_points ) { // console.log("Running check"); // console.dir( pix_points ) ; }, runner : function() { //console.log("Runner.."); if ( hotelmap.eventview.process ) { var pixel_plotter = {}; hotelmap.maps.removeAllLayerContent(); var data = hotelmap.eventview.data; if ( data && data.length > 0 ) { for ( var i = 0 ; i < data.length ; i++ ) { var venue = data[i] ; if ( venue ) //&& ( venue.id ==673 || venue.id ==660)) { var latitude = parseFloat(venue.lat) ; var longitude = parseFloat(venue.lon) ; var zoom = hotelmap.maps.getZoom(); var wSize = (deCarta.Utilities.tileSizeForZoom(zoom) * Math.pow(2, Math.floor(zoom - 1))); var x = longitude * wSize / 180; var y = Math.log(Math.tan((90 + latitude) * Math.PI / 360)) / (Math.PI / 180); y = y * wSize / 180; if ( hotelmap.maps.getZoom() != 17 ){ if ( hotelmap.maps.getZoom() < 14 ) { x = Math.ceil( Math.round(x / 100))*100 ; y = Math.ceil( Math.round(y / 100))*100 ; } else { x = Math.ceil( Math.round(x / 50))*50 ; y = Math.ceil( Math.round(y / 50))*50 ; } } var key = x + "-" +y; if ( !pixel_plotter[key]) { pixel_plotter[key] = []; pixel_plotter[key].push({'x':x,'y':y,'latitude':latitude, 'longitude':longitude, 'cmp':venue.cmp, 'id':venue.id}); } else { pixel_plotter[key].push({'x':x,'y':y,'latitude':latitude, 'longitude':longitude, 'cmp':venue.cmp, 'id':venue.id}); } } } hotelmap.eventview.runCheckSet( pixel_plotter ) ; for ( var k in pixel_plotter ) { var quantity = pixel_plotter[k].length ; var naming = (quantity<2) ? pixel_plotter[k][0].cmp : ""+quantity ; var sizing = (quantity<2) ? 7 : 11; hotelmap.companyview.addIcon( pixel_plotter[k][0].latitude, pixel_plotter[k][0].longitude, naming , sizing ) ; } } } }, addIcon : function( latitude, longitude, naming, sizing ) { sizing = (sizing) ? sizing : 7; var event_image_icon = hotelmap.library.utility.element("div",{'backgroundImage':'url('+attributes.host+'resource/images/gfx_v1/event-icon1.png)','width':'61px','height':'48px'},{}); event_image_icon.xoffset = 20; event_image_icon.eventIconIdentify = true; // The lower black title container var event_image_title = hotelmap.library.utility.element("div",{'position':'absolute','left':'0px','top':'48px','height':'39px','width':'0px','overflow':'hidden'},{}); // The black image actual var event_image_src = hotelmap.library.utility.element("img",{},{'src':'services/images/event/icon?small=true&sizer='+sizing+'&top='+Base64.encode(naming)+'&bottom=&'}); event_image_src.className = 'ei eie'; event_image_title.appendChild(event_image_src); event_image_icon.appendChild(event_image_title); event_image_src.myTitleSub = event_image_title; // The onloader - adjusting the position correctly. event_image_src.onload = function() { var t = this; setTimeout ( function() { var scrollwidth = t.myTitleSub.scrollWidth; t.myTitleSub.style.width = scrollwidth + "px"; t.myTitleSub.style.left = (0-(scrollwidth/2)) + 20 + "px"; },200 ); }; // Add the icon to the map hotelmap.maps.addIcon( event_image_icon, parseFloat(latitude),parseFloat(longitude), "BLOCKER" ) ; // If we're not IE low then make it slightly see through. if ( !attributes.isLowIE ) hotelmap.library.utility.setTrans( event_image_icon, 80 ) ; } } hotelmap.calendar_item = { /*****************************************************************************************************************************/ /** Data **/ offsetx : 0, // Offset X in the cal image offsety : 56, // Offset Y in the cal image width : 30, // X,Y of a cal item element height : 30, arrival_item : null, // The arrival date currently selected departure_item : null, // The departure date currently selected loaded : false, references : { arrival : {}, departure : {} }, dates : // Arrival and departure month views. { today : { month : 0, year : 0, day : 0, ymd : 0, numdays:0 }, arrival : { month : 5, year : 2013, day : 1, ymd : 0, numdays:0 }, depart : { month : 5, year : 2013, day : 1, ymd : 0, numdays:0 } }, /* calendar object references */ calendars : { arrival : null, departure : null }, /*****************************************************************************************************************************/ is_day_name_processed : false, process_dates_view : function() { if (!hotelmap.calendar_item.is_day_name_processed || hotelmap.calendar.isNewLoaded) { hotelmap.calendar.isNewLoaded = false; hotelmap.calendar_item.is_day_name_processed = true; var arrival_cal = _("arrival_calendar"); var depart_cal = _("departure_calendar"); var d = []; if (attributes.language == "ar_SA") { d = [ translations.LNG_AUTOLONGDAYS1, translations.LNG_AUTOLONGDAYS2, translations.LNG_AUTOLONGDAYS3, translations.LNG_AUTOLONGDAYS4, translations.LNG_AUTOLONGDAYS5, translations.LNG_AUTOLONGDAYS6, translations.LNG_AUTOLONGDAYS0 ]; } else { d = [ translations.LNG_AUTOSHORTDAYS1, translations.LNG_AUTOSHORTDAYS2, translations.LNG_AUTOSHORTDAYS3, translations.LNG_AUTOSHORTDAYS4, translations.LNG_AUTOSHORTDAYS5, translations.LNG_AUTOSHORTDAYS6, translations.LNG_AUTOSHORTDAYS0 ]; } var increment = 0; var offset = 1; for (var i = 0 ; i < 7 ; i++) { var de = document.createElement("div"); $(de).addClass("dateitem_spec dateitem"); if (attributes.direction == 'rtl') { de.style.right = offset+'px'; } else { de.style.left = offset+'px'; } offset = offset + 31; de.innerHTML = d[increment].toUpperCase(); var ac = de.cloneNode(true); arrival_cal.appendChild(de); depart_cal.appendChild(ac); increment++; } } }, obtain_ymd : function( d ) { var numdays = this.__daysInMonth(d.month,d.year); var j = d.day; var m = d.month; var y = d.year; if (j<10) j="0"+j; if (m<10) m="0"+m; var ymd=y+""+m+""+j; return [y,m,d,numdays,ymd]; }, getv: function( year,month, day) { month = (month<10) ? "0" + month : month; day = (day<10) ? "0" + day : day; return year + "" + month + "" + day; }, /** * create_ymd * Create a checkable date string we can test with * @param d date object */ create_ymd : function(d) { var elements = hotelmap.calendar_item.obtain_ymd(d); d.numdays = elements[3]; d.ymd=elements[0]+""+elements[1]+""+elements[2]; }, getymd : function(d) { var elements = hotelmap.calendar_item.obtain_ymd(d); return {'ymd':elements[4],'days':elements[3]}; }, /*****************************************************************************************************************************/ create_today_date : function(target) { var today = target; var tmp = new Date(attributes.__mp_loc_time*1000); today.day = tmp.getDate(); today.month = tmp.getMonth()+1; today.year = tmp.getFullYear(); //console.dir(tmp); }, /** * do_sanity_check * Sanity checking on date entries */ do_sanity_check : function() { arrival_segments = this.getymd(hotelmap.search_data.dates.arrival ); depart_segments = this.getymd( hotelmap.search_data.dates.departure ); today_segments = this.getymd( hotelmap.calendar_item.dates.today ); if (arrival_segments.ymd >= depart_segments.ymd) { hotelmap.calendar_item.dates.depart.day = hotelmap.calendar_item.dates.arrival.day ; hotelmap.calendar_item.dates.depart.month = hotelmap.calendar_item.dates.arrival.month ; hotelmap.calendar_item.dates.depart.year = hotelmap.calendar_item.dates.arrival.year ; hotelmap.search_data.dates.departure.day = hotelmap.calendar_item.dates.arrival.day ; hotelmap.search_data.dates.departure.month = hotelmap.calendar_item.dates.arrival.month ; hotelmap.search_data.dates.departure.year = hotelmap.calendar_item.dates.arrival.year ; hotelmap.calendar_item.dates.depart.day++; hotelmap.search_data.dates.departure.day = hotelmap.calendar_item.dates.depart.day; if (hotelmap.search_data.dates.departure.day > depart_segments.days) { hotelmap.calendar_item.dates.depart.day = hotelmap.search_data.dates.departure.day = 1; hotelmap.calendar_item.dates.depart.month++; hotelmap.search_data.dates.departure.month=hotelmap.calendar_item.dates.depart.month; if (hotelmap.search_data.dates.departure.month > 12) { hotelmap.calendar_item.dates.depart.month = 1; hotelmap.calendar_item.dates.depart.year++; hotelmap.search_data.dates.departure.month = 1; hotelmap.search_data.dates.departure.year++; } } } }, /** * Automatically push the departure calendar forward one day from the arrival (if the arrival is clicked) */ do_cal_push_one_day : function() { var departTest = hotelmap.calendar_item.getv(hotelmap.search_data.dates.departure.year,hotelmap.search_data.dates.departure.month,hotelmap.search_data.dates.departure.day); var arriveTest = hotelmap.calendar_item.getv(hotelmap.search_data.dates.arrival.year,hotelmap.search_data.dates.arrival.month,hotelmap.search_data.dates.arrival.day); arrival_segments = this.getymd(hotelmap.search_data.dates.arrival ); depart_segments = this.getymd( hotelmap.search_data.dates.departure ); today_segments = this.getymd( hotelmap.calendar_item.dates.today ); hotelmap.calendar_item.dates.depart.day = hotelmap.calendar_item.dates.arrival.day ; hotelmap.calendar_item.dates.depart.month = hotelmap.calendar_item.dates.arrival.month ; hotelmap.calendar_item.dates.depart.year = hotelmap.calendar_item.dates.arrival.year ; hotelmap.search_data.dates.departure.day = hotelmap.calendar_item.dates.arrival.day ; hotelmap.search_data.dates.departure.month = hotelmap.calendar_item.dates.arrival.month ; hotelmap.search_data.dates.departure.year = hotelmap.calendar_item.dates.arrival.year ; hotelmap.calendar_item.dates.depart.day++; hotelmap.search_data.dates.departure.day = hotelmap.calendar_item.dates.depart.day; depart_segments = this.getymd(hotelmap.search_data.dates.departure); // FIX Point. This allows for the issues with the dates not turning over on new months. if (hotelmap.search_data.dates.departure.day > depart_segments.days) { hotelmap.calendar_item.dates.depart.day = hotelmap.search_data.dates.departure.day = 1; hotelmap.calendar_item.dates.depart.month++; hotelmap.search_data.dates.departure.month=hotelmap.calendar_item.dates.depart.month; if (hotelmap.search_data.dates.departure.month > 12) { hotelmap.calendar_item.dates.depart.month = 1; hotelmap.calendar_item.dates.depart.year= hotelmap.calendar_item.dates.arrival.year + 1; hotelmap.search_data.dates.departure.month = 1; hotelmap.search_data.dates.departure.year = hotelmap.calendar_item.dates.arrival.year+ 1; } } }, /*****************************************************************************************************************************/ /** * create_calendars * Creates the basic calendars for arrival and departure */ create_calendars : function() { try { $("#caldhad").show(); } catch ( edf ){} try { _("calendar_currency").onchange=function(){ hotelmap.search_data.currency = this.value; }; } catch ( edf2 ){} try { hotelmap.search_data.populate_calendar_string(); var currency = _("calendar_currency"); for (var i = 0 ; i < currency.options.length; i++) { if (currency.options[i].value==hotelmap.search_data.currency) { currency.options[i].selected="selected"; } } } catch (calenderPopulatedElementsException) { /* Empty */ } /** * Hook to allow multi title elements */ if (!hotelmap.calendar.title || !hotelmap.calendar.subtitle) { if (attributes.pagedata.title.length > 50) { hotelmap.calendar.title = attributes.pagedata.title.substr(0,48) + ".."; } else { hotelmap.calendar.title = attributes.pagedata.title; } if (attributes.language=="en_GB") { hotelmap.calendar.subtitle = (attributes.pagedata.subtitle.length>57) ? attributes.pagedata.subtitle.substr(0,57) + ".." : attributes.pagedata.subtitle; } else { hotelmap.calendar.subtitle =attributes.pagedata.subtitle; } } // - // Populated data in titles and sub titles try { _("calendar_content_PTITLE").innerHTML = hotelmap.calendar.title; _("calendar_content_PSUB").innerHTML = hotelmap.calendar.subtitle; } catch (erhdfk2) {} if ( attributes.pin_number ) { _("pin1").value = attributes.pin_number[0]; _("pin2").value = attributes.pin_number[1]; _("pin3").value = attributes.pin_number[2]; _("pin4").value = attributes.pin_number[3]; } translate("WHDN"); translate("ARRIVAL"); translate("DEPARTURE"); translate("ARR"); translate("DEP"); translate("CRQ"); translate("PINTXT"); translate("PIN"); translate("CUR"); translate("IN"); translate("FOR"); translate("CALNOTE"); // if ( attributes.language == "pt_BR" ) _("LNG_PINTXT").style.fontSize = '9px'; _("LNG_ARR1").innerHTML = translations.LNG_ARR; _("LNG_DEP1").innerHTML = translations.LNG_DEP; _("LNG_CAL_PRAT").innerHTML = translations.LNG_CAL_PRAT; _("LNG_PIN").innerHTML = translations.LNG_PIN; _("search_action_button").innerHTML = translations.LNG_BUTTON_LAUNCHNOW; // LAUNCH NOW if ( attributes.event_data.is_event == "Y") { var event_date_string = ( attributes.event_data.calstart == attributes.event_data.calend ) ? attributes.event_data.notes.end.long : attributes.event_data.notes.start.short + " - " + attributes.event_data.notes.end.short; _("calendar_content_PSUB").innerHTML += " | " + event_date_string ; } // -- // Update search data with search_data sets //hotelmap.search_data.adults = _("calendar_adults").options[_("calendar_adults").selectedIndex].value; //hotelmap.search_data.children = _("calendar_children").options[_("calendar_children").selectedIndex].value; //hotelmap.search_data.rooms = _("calendar_rooms").options[_("calendar_rooms").selectedIndex].value; try { _("search_action_button").onclick=function(){ hotelmap.calendar.search(); _("search_action_button").style.display = "none"; }; setTimeout( function(){ try {_("search_action_button").style.display = "" ;} catch ( calExceti1 ) {}}, 1000); } catch ( calExceti ) {} hotelmap.calendar_item.do_sanity_check(); /** Grab Elements **/ hotelmap.calendar_item.calendars.arrival = _("arrival_data"); hotelmap.calendar_item.calendars.departure = _("departure_data"); hotelmap.calendar_item.process_dates_view(); /** Reset contents **/ hotelmap.calendar_item.calendars.arrival.innerHTML = ''; hotelmap.calendar_item.calendars.departure.innerHTML = ''; /** Load calendars for the internal element housings **/ hotelmap.calendar_item.load_date_set( hotelmap.calendar_item.calendars.arrival ) ; hotelmap.calendar_item.load_date_set( hotelmap.calendar_item.calendars.departure ) ; /** Load the actual dates for the months chosen **/ try { hotelmap.calendar_item.load_month_options( hotelmap.calendar_item.calendars.arrival, hotelmap.calendar_item.dates.arrival, "arrival" ); hotelmap.calendar_item.load_month_options( hotelmap.calendar_item.calendars.departure, hotelmap.calendar_item.dates.depart, "departure" ); } catch( dateAttemptFailure ) { //console.log("dateAttemptFailure: " + dateAttemptFailure.message ); } hotelmap.calendar.process_pre_calendar_selection_summary(); hotelmap.calendar.showSelection = true; }, /*****************************************************************************************************************************/ /** * __daysInMonth * Get the dats in the specified month year * @param iMonth int * @param iYear int */ __daysInMonth : function(iMonth, iYear) { //console.log("Incoming: " + iMonth + ", " + iYear); //console.log(new Date(iYear, iMonth, 0).getDate()); return new Date(iYear, iMonth, 0).getDate(); }, /*****************************************************************************************************************************/ /** * __getDayName * Gets the name of the day * @param dayID int */ __getDayName : function( dayID ) { var days_long = [ translations.LNG_AUTOLONGDAYS0, translations.LNG_AUTOLONGDAYS1, translations.LNG_AUTOLONGDAYS2, translations.LNG_AUTOLONGDAYS3, translations.LNG_AUTOLONGDAYS4, translations.LNG_AUTOLONGDAYS5, translations.LNG_AUTOLONGDAYS6 ]; var days_short = [ translations.LNG_AUTOSHORTDAYS0, translations.LNG_AUTOSHORTDAYS1, translations.LNG_AUTOSHORTDAYS2, translations.LNG_AUTOSHORTDAYS3, translations.LNG_AUTOSHORTDAYS4, translations.LNG_AUTOSHORTDAYS5, translations.LNG_AUTOSHORTDAYS6 ]; return [days_long[dayID],days_short[dayID]]; }, /*****************************************************************************************************************************/ /** * __getMonthName * Get the month name * @param monthID int (-1) */ __getMonthName : function( monthID ) { var months = [ translations.LNG_AUTOLONGMONTHS1, translations.LNG_AUTOLONGMONTHS2, translations.LNG_AUTOLONGMONTHS3, translations.LNG_AUTOLONGMONTHS4, translations.LNG_AUTOLONGMONTHS5, translations.LNG_AUTOLONGMONTHS6, translations.LNG_AUTOLONGMONTHS7, translations.LNG_AUTOLONGMONTHS8, translations.LNG_AUTOLONGMONTHS9, translations.LNG_AUTOLONGMONTHS10, translations.LNG_AUTOLONGMONTHS11, translations.LNG_AUTOLONGMONTHS12 ] return months[monthID-1]; }, /*****************************************************************************************************************************/ /** * load_date_set * Create the housing elements for the target calendar * @param target DOM Node */ load_date_set : function( target ) { target.elements = {}; for (var r = 0 ; r < 6 ; r++) { for (var c = 0 ; c < 7 ; c++) { var x = hotelmap.calendar_item.offsetx + (c * (hotelmap.calendar_item.width+1)); var y = hotelmap.calendar_item.offsety + (r * (hotelmap.calendar_item.height+1)); var updates = {}; var item = hotelmap.library.utility.element( "div", {}, {'id':'cal_item','className':'calendar_zone_item'} ); var directional = (attributes.direction == 'rtl') ? "right" : "left"; updates[directional] = (x+1) + 'px'; updates['top'] = y + 'px'; $(item).css(updates); $(target).append($(item)); target.elements[r+"-"+c] = item; } } }, /** * Make the calendar pre select a specific date period. * This is used in the FeedConditions table and the values * are added to the attributes.selectionDates.<> set * Plus it's nice to have an automated way to select a bunch of dates * which we couldn't do before. * * @param start * @param end */ select_date_period: function(start, end) { /* Define the starting point */ hotelmap.calendar_item.dates.arrival.day = start.day; hotelmap.calendar_item.dates.arrival.month = start.month; hotelmap.calendar_item.dates.arrival.year = start.year; hotelmap.search_data.dates.arrival.day = start.day; hotelmap.search_data.dates.arrival.month = start.month; hotelmap.search_data.dates.arrival.year = start.year; /* Define our ending date */ hotelmap.calendar_item.dates.depart.day = end.day; hotelmap.calendar_item.dates.depart.month = end.month; hotelmap.calendar_item.dates.depart.year = end.year; hotelmap.search_data.dates.departure.day = end.day; hotelmap.search_data.dates.departure.month = end.month; hotelmap.search_data.dates.departure.year = end.year; /* Generate the calendars! */ hotelmap.calendar_item.create_calendars(); }, /*****************************************************************************************************************************/ /** * load_month_options * Load the date elements into the cal * @param target DOM Node * @param targetdate JSON date data * @param entity_defined String [arrival|departure] */ load_month_options : function( target, targetdate, entity_defined ) { try { var isDepartureCalendar = (entity_defined!="arrival") ? true : false ; target.cells = {}; /** The date we want to target **/ var date = new Date(targetdate.year,targetdate.month-1,1); /** Fill the DOM Node with target month and year string **/ _(entity_defined+"_month_name").innerHTML = this.__getMonthName(targetdate.month) + " " + date.getFullYear(); if ( attributes.language == "zh_TW" || attributes.language == "zh_CN" || attributes.language == "ja_JP" ) { // var target_month_point = (targetdate.month<10) ? "0"+targetdate.month: targetdate.month; // _(entity_defined+"_month_name").innerHTML = date.getFullYear() +"年 " + target_month_point + "月"; _(entity_defined+"_month_name").innerHTML = getLingualDate(date, { year: 'numeric', month: 'long'}); } /** Number of days in target month **/ var days_in_month = this.__daysInMonth(targetdate.month,targetdate.year); /** Define the actions of the left/right cal click buttons **/ _(entity_defined+"_left_cal").onclick = function() // previous month { targetdate.month--; if ( targetdate.month < 1 ){targetdate.month=12; targetdate.year--; } hotelmap.calendar_item.create_calendars(); }; _(entity_defined+"_right_cal").onclick = function() //next month { if ( targetdate.month == attributes.maxdates.month && targetdate.year == attributes.maxdates.year ) { alert("Sorry, you cannot search more than one year ahead"); } else { targetdate.month++; if ( targetdate.month > 12 ){ targetdate.month=1; targetdate.year++; } hotelmap.calendar_item.create_calendars(); } }; /** Begin the date cycling **/ var offset_counter = 0; // How far are we throught he offset? if > then print days var day_incrementor = 0; // Whats the day we're on var next_month_incrementor = 0; // Sequential incrment for the blanked out next month days var days_printed = false; // Have we printed the days yet for this month? var offset = date.getDay() - 1; // Offset of days to match the static image. if ( offset < 0 ) offset = 6; // Caters for JS sundays being 0 var previous_incrementor = offset-1; // Previous mOnth offset var dot_end_calendar = "" ; if ( attributes.language == "de_DE" || attributes.language == "is_IS" || attributes.language == "sk_SK" ) dot_end_calendar = "."; var push = false ; for ( var r = 0 ; r < 6 ; r++ ) // Cycle Rows { for ( var c = 0 ; c < 7 ; c++ ) // Cycle Columns { var item = target.elements[r+"-"+c]; // Define the target node in the cal r-c offset_counter++; // Add the offset - how many deep are we..? if ( day_incrementor >= days_in_month && !push){ day_incrementor = 0; push = true; } /** A valid day has been found in the target month **/ if ( offset_counter > offset ) { /** Fill the day and attach functions & data to the item node **/ day_incrementor++; days_printed = true; var today = new Date(attributes.__mp_loc_time*1000) ; // used to ensure we dont show dates in the past. var this_date = new Date(targetdate.year,targetdate.month-1,day_incrementor,23,59,59); if ( push ){ var tm = (targetdate.month-1) + 1 ; var yr = targetdate.year; if ( tm > 12 ) { tm = 0; yr++; } var this_date = new Date(yr,tm,day_incrementor,23,59,59); } var showDateAsSelectable = ( this_date >= today ) ? true : false ; var backGroundColor = ""; var arrivalDateAsTimePoint = new Date(hotelmap.search_data.dates.arrival.year,hotelmap.search_data.dates.arrival.month-1,hotelmap.search_data.dates.arrival.day); var departureDateAsTimePoint = new Date(hotelmap.search_data.dates.departure.year,hotelmap.search_data.dates.departure.month-1,hotelmap.search_data.dates.departure.day); var isThisDateBetweenAPeriodOfSelectedTime = false; //console.log(this_date + " is " + showDateAsSelectable); if ( this_date >= arrivalDateAsTimePoint && this_date <= departureDateAsTimePoint ) { backGroundColor = "#DBE3EE"; item.isLowLight = true; isThisDateBetweenAPeriodOfSelectedTime = true; } var canSelect = true; // -- // Days in the past we make unselected and a different color if (showDateAsSelectable) { item.innerHTML = "
    "+day_incrementor+""+dot_end_calendar+"
    "; if (push) { $(item).addClass("calendar_zone_item_pastpresent"); } if (isThisDateBetweenAPeriodOfSelectedTime && (hotelmap.calendar.showSelection || hotelmap.calendar.isPreDefinedDate)) { $(item).addClass("calendar_zone_item_eventperiod"); } } else { item.innerHTML = "
    "+day_incrementor+""+dot_end_calendar+"
    "; canSelect=false; } var days = this.__getDayName(this_date.getDay()); /** Massive Date data object - can be used later for anything we like.. **/ item.data = {}; item.data.origin = entity_defined; item.data.day_index = this_date.getDay(); item.data.day = this_date.getDate(); item.data.month = this_date.getMonth() + 1; item.data.year = this_date.getFullYear(); item.data.day_short = days[1]; item.data.day_long = days[0]; item.data.month_name = this.__getMonthName(this_date.getMonth() + 1); /* changelog: for date selection on top row with ugly orange line */ item.row_number = r ; var t_1 = (item.data.day<10) ? "0"+item.data.day : item.data.day; var t_2 = (item.data.month<10) ? "0"+item.data.month : item.data.month; var t_3 = item.data.year; item.data.comparison = t_3+""+t_2+""+t_1; item.data.format_send = item.data.day + "-" + item.data.month + "-" + item.data.year; item.data.r = r; item.data.c = c; item.data.days_in_month = days_in_month; target.cells[item.data.comparison] = item; item.turnON = function() { if (hotelmap.calendar.showSelection || hotelmap.calendar.isPreDefinedDate) { this.noHighLight = true; if (this.row_number == 0) { $(this).addClass("calendar_zone_item_selected_top_row"); } else { $(this).addClass("calendar_zone_item_selected"); } } }; /** Event selection **/ if (attributes.event_data.is_event == "Y" && !hotelmap.calendar.isPreDefinedDate) { var test_date = parseInt(item.data.comparison); var end_date = parseInt(attributes.event_data.calend); var start_date = parseInt(attributes.event_data.calstart); if ( test_date >= attributes.event_data.calstart && test_date <= attributes.event_data.calend ){ var img = hotelmap.library.utility.element("img", {'position':'absolute','left':'0px','top':'0px'},{'src':attributes.host+'resource/images/gfx_v2/event_top2.png'}); item.appendChild( img); } } /** Whats happens when we click.. **/ if ( showDateAsSelectable ) { item.onclick= item.ontouchdown = item.make_selector = function() { if ( parseInt(this.data.month) > attributes.maxdates.month && this.data.year >= attributes.maxdates.year ) { alert("Sorry, we can only search one year in advance"); } else if ( this.data.month == attributes.maxdates.month && this.data.year == attributes.maxdates.year && this.data.day == attributes.maxdates.day ) { alert("Sorry, we can only search one year in advance"); } else { this.turnON(); if ( this.data.origin == "arrival" ) { hotelmap.calendar_item.dates.arrival.day = this.data.day; hotelmap.calendar_item.dates.arrival.month = this.data.month; hotelmap.calendar_item.dates.arrival.year = this.data.year; hotelmap.search_data.dates.arrival.day = this.data.day; hotelmap.search_data.dates.arrival.month = this.data.month; hotelmap.search_data.dates.arrival.year = this.data.year; hotelmap.calendar_item.do_cal_push_one_day(); hotelmap.calendar_item.create_calendars(); } else { hotelmap.calendar_item.dates.depart.day = this.data.day; hotelmap.calendar_item.dates.depart.month = this.data.month; hotelmap.calendar_item.dates.depart.year = this.data.year; hotelmap.search_data.dates.departure.day = this.data.day; hotelmap.search_data.dates.departure.month = this.data.month; hotelmap.search_data.dates.departure.year = this.data.year; hotelmap.calendar_item.create_calendars(); } } }; } /** Over action **/ if (canSelect && !attributes.isIpad) { /** Date hover on/off point **/ item.onmouseover = function() { var view_text_name = this.data.day_long + ", " + this.data.day + " " + this.data.month_name ; //5月3日(木) if ( attributes.language == "ja_JP") { var target_month_point = (this.data.month<10) ? "0"+this.data.month:this.data.month; var target_day_point = (this.data.day<10) ? "0"+this.data.day:this.data.day; //var day_name = hotelmap.calendar.getShortDayName(dt); view_text_name = target_month_point + "月"+target_day_point+"日("+this.data.day_short+")"; } if ( this.data.origin == "arrival" ) { _("arrival_live_text").style.display = ""; _("arrival_live").innerHTML = view_text_name; } else { _("departure_live_text").style.display = ""; _("departure_live").innerHTML = view_text_name; } if (!this.noHighLight) { this.oldBack = this.style.backgroundImage; this.style.backgroundImage = 'url('+attributes.host+'resource/images/gfx_v2/calendar/hover.jpg)'; } }; /** Out action **/ item.onmouseout = function() { // Obtain the current checkin and checkout dates var check_in_date_string = hotelmap.calendar.getLongPrettyDateString( hotelmap.calendar_item.dates.arrival, false ); var check_out_date_string = hotelmap.calendar.getLongPrettyDateString( hotelmap.calendar_item.dates.depart, false ); _("arrival_live").innerHTML = check_in_date_string; _("departure_live").innerHTML = check_out_date_string; if (!this.noHighLight) { this.style.backgroundImage = this.oldBack; } }; } var turnedOn = false; if (hotelmap.calendar_item.isSameDateAndOrigin("arrival", "arrival", item)) { item.turnON(); turnedOn = true; } if ((hotelmap.calendar.showSelection || hotelmap.calendar.isPreDefinedDate) && hotelmap.calendar_item.isSameDateAndOrigin("arrival", "departure", item)){ item.style.backgroundImage = 'url('+attributes.host+'resource/images/gfx_v2/calendar/event_period.jpg)'; } if (hotelmap.calendar_item.isSameDateAndOrigin("departure", "departure", item)) { item.turnON(); turnedOn = true; } } else if ( days_printed ) { /** We are finished with the month.. just go from 1..N until finished **/ //next_month_incrementor++; //item.innerHTML = "
    "+next_month_incrementor+"
    "; } else { /** PRevious month - find NUM days in that month and go back **/ var previous_month_target = targetdate.month - 1; var previous_year_target = targetdate.year; if ( previous_month_target < 1 ) { previous_month_target = 12; previous_year_target--; } var previous_month = new Date(previous_year_target,previous_month_target-1,1); var previous_month_in_days = this.__daysInMonth(previous_month_target,previous_year_target); var today = new Date(attributes.__mp_loc_time*1000) ; // used to ensure we dont show dates in the past. //var this_date = new Date(previous_year_target,previous_month_target,previous_incrementor); var this_date = new Date(previous_year_target,previous_month_target-1,previous_month_in_days-previous_incrementor); item.innerHTML = "
    "+(previous_month_in_days-previous_incrementor)+""+dot_end_calendar+"
    "; previous_incrementor--; item.style.backgroundImage = 'url('+attributes.host+'resource/images/gfx_v2/calendar/pastpresent.jpg)'; var days = this.__getDayName(this_date.getDay()); if (this_date > today) { /** Massive Date data object - can be used later for anything we like.. **/ item.data = {}; item.data.origin = entity_defined; item.data.day_index = this_date.getDay(); item.data.day = this_date.getDate(); item.data.month = this_date.getMonth() + 1; item.data.year = this_date.getFullYear(); item.data.day_short = days[1]; item.data.day_long = days[0]; item.data.month_name = this.__getMonthName(this_date.getMonth() + 1); var t_1 = (item.data.day<10) ? "0"+item.data.day : item.data.day; var t_2 = (item.data.month<10) ? "0"+item.data.month : item.data.month; var t_3 = item.data.year; item.data.comparison = t_3+""+t_2+""+t_1; item.data.format_send = item.data.day + "-" + item.data.month + "-" + item.data.year; item.data.r = r; item.data.c = c; item.data.days_in_month = days_in_month; item.onclick = item.make_selector = function() { if (this.data.origin == "arrival") { hotelmap.calendar_item.dates.arrival.day = this.data.day; hotelmap.calendar_item.dates.arrival.month = this.data.month; hotelmap.calendar_item.dates.arrival.year = this.data.year; } else if (this.data.origin == "departure") { hotelmap.calendar_item.dates.depart.day = this.data.day; hotelmap.calendar_item.dates.depart.month = this.data.month; hotelmap.calendar_item.dates.depart.year = this.data.year; } hotelmap.calendar_item.create_calendars(); }; item.onmouseover = function() { if (!this.noHighLight) { $(this).addClass("calendar_zone_item_hover"); } }; /** Out action **/ item.onmouseout = function() { if (!this.noHighLight) { $(this).removeClass("calendar_zone_item_hover"); } }; } } } } } catch ( loadMonthException ) { //console.log("loadMonthException: " + loadMonthException.message ) ; } }, isSameDateAndOrigin: function(origin, state, item) { return (item.data.origin == origin && hotelmap.search_data.dates[state].day == item.data.day && hotelmap.search_data.dates[state].month == item.data.month && hotelmap.search_data.dates[state].year == item.data.year ) ? true : false; } } /** * HotelMap.com Search Data Object */ hotelmap.search_data = { dates : { arrival : { }, departure : {} }, adults : 1, children : 0, rooms : 1, currency : "", // This can be superseeded by the attributes.currency_pref if it's set. __nights : 1, __rooms: 1, /** * populate_dynamic_date * @param start * @param end * @param rooms * @param configuration [{'adults':0, 'children':0}] */ populate_dynamic_date : function( rooms, configuration ) { // Define the number of rooms hotelmap.search_data.rooms = rooms ; hotelmap.search_data.occupancy = configuration ; hotelmap.calendar_item.dates.arrival.day = attributes.event.date_start.day ; hotelmap.calendar_item.dates.arrival.month = attributes.event.date_start.month ; hotelmap.calendar_item.dates.arrival.year = attributes.event.date_start.year ; hotelmap.calendar_item.dates.depart.day = attributes.event.date_end.day ; hotelmap.calendar_item.dates.depart.month = attributes.event.date_end.month ; hotelmap.calendar_item.dates.depart.year = attributes.event.date_end.year ; hotelmap.search_data.dates.arrival.day = attributes.event.date_start.day ; hotelmap.search_data.dates.arrival.month = attributes.event.date_start.month ; hotelmap.search_data.dates.arrival.year = attributes.event.date_start.year ; hotelmap.search_data.dates.departure.day = attributes.event.date_end.day ; hotelmap.search_data.dates.departure.month = attributes.event.date_end.month ; hotelmap.search_data.dates.departure.year = attributes.event.date_end.year ; // -- // Process to correct dates hotelmap.search_data.dates.arrival = hotelmap.calendar_item.dates.arrival; hotelmap.search_data.dates.departure = hotelmap.calendar_item.dates.depart; // -- // Create YYYMMDD hotelmap.search_data.dates.arrival.yyyymmdd = hotelmap.search_data.dates.arrival.year + "" + ((hotelmap.search_data.dates.arrival.month<10)?"0"+hotelmap.search_data.dates.arrival.month:hotelmap.search_data.dates.arrival.month) + "" + ((hotelmap.search_data.dates.arrival.day<10)?"0"+hotelmap.search_data.dates.arrival.day:hotelmap.search_data.dates.arrival.day) hotelmap.search_data.dates.departure.yyyymmdd = hotelmap.search_data.dates.departure.year + "" + ((hotelmap.search_data.dates.departure.month<10)?"0"+hotelmap.search_data.dates.departure.month:hotelmap.search_data.dates.departure.month) + "" + ((hotelmap.search_data.dates.departure.day<10)?"0"+hotelmap.search_data.dates.departure.day:hotelmap.search_data.dates.departure.day) }, occupancy : [ { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} }, { adults:1,children:0,ages:{child1:0,child2:0,child3:0} } ], populate_calendar_string : function() { //console.log(">>"); hotelmap.search_data.__rooms = hotelmap.search_data.rooms ; hotelmap.search_data.__nights = hotelmap.calendar.getDateDifference(hotelmap.search_data.dates.departure,hotelmap.search_data.dates.arrival); if ( hotelmap.search_data.__nights > 1 ) { $("#W_TCA").show(); } else { $("#W_TCA").hide(); } if ( hotelmap.search_data.__nights > 1 ) { $("#W_APN").show(); } else { $("#W_APN").hide(); } /** We have a map which has been selected for auto APN **/ //console.log("Debugging pre apn test"); if ( attributes.auto_apn_maps && attributes.auto_apn_maps[attributes.map_identity] && hotelmap.search_data.__nights > 1 ) { //console.log("Auto Selecting"); $("#W_APN").attr('selected', true); } if ( hotelmap.search_data.__rooms > 1 ) { $("#W_TCA")[0].innerHTML = translations.LNG_VAR_TCOS; } else { $("#W_TCA")[0].innerHTML = translations.LNG_VAR_TCOS; } var countrooms = hotelmap.search_data.rooms; var countchildren = 0; var countadults = 0; // //console.log("Rooms: " + countrooms); for ( var i = 0 ; i 1 ) ? translations.LNG_ROOMS : translations.LNG_ROOM; _("child_plural").innerHTML = ( countchildren == 1) ? translations.LNG_CHILD : translations.LNG_CHILDR; _("adults_plural").innerHTML = (countadults==1) ? translations.LNG_ADULT:translations.LNG_ADULTS; // //_("CAL_NIGHTS").innerHTML = "POO"; if (attributes.language == "ja_JP") { $(".summary_cal_free").html("大人: "+countadults+"人、子供: "+countchildren+"人 - "+countrooms+"部屋、"+hotelmap.search_data.__nights+"泊"); $(".summary_cal_string").hide(); } }, /* * occupancy : [ {adults : 0, children : 0, ages : []}, {adults : 0, children : 0, ages : []} ] * * */ /** * Populates the upper top itinerary bar */ populate_right_menu_side : function() { // -- // Pretty date formatting var pretty_date = hotelmap.calendar.getPrettyDateString( hotelmap.search_data.dates.arrival); var pretty_date2 = hotelmap.calendar.getPrettyDateString( hotelmap.search_data.dates.departure); // -- // Night calculation var nights = hotelmap.calendar.getDateDifference(hotelmap.search_data.dates.departure,hotelmap.search_data.dates.arrival); var countrooms = hotelmap.search_data.rooms; var countchildren = 0; var countadults = 0; // //console.log("Rooms: " + countrooms); for ( var i = 0 ; i1) ? translations.LNG_NIGHTS : translations.LNG_NIGHT; var rooms_text = (countrooms>1) ? translations.LNG_ROOMS : translations.LNG_ROOM; var child_text = (countchildren!=1) ? translations.LNG_CHILDR : translations.LNG_CHILD; var adults_text = (countadults>1) ? translations.LNG_ADULTS : translations.LNG_ADULT; // -- // Update the itinerary string //hotelmap.heading.date_string.innerHTML = pretty_date + " to " + pretty_date2 + " | " + nights + " "+night_text+" | " + hotelmap.search_data.rooms + " "+rooms_text+" | " + hotelmap.search_data.adults + " "+adults_text+", " + hotelmap.search_data.children + " "+child_text; var comma = ","; if ( attributes.language == "ar_SA" ) comma = "،"; //_("CAL_NIGHTS").innerHTML = "POO"; if (attributes.language == "ja_JP") { var ending = "大人: "+countadults+"人、子供: "+countchildren+"人 - "+countrooms+"部屋、"+nights+"泊"; hotelmap.heading.date_string.innerHTML = "
    "+translations['LNG_RCHITEN']+"
    "+pretty_date + " - " + pretty_date2 + " | " + ending + "
    "; } else { hotelmap.heading.date_string.innerHTML = "
    "+translations['LNG_RCHITEN']+"
    "+pretty_date + " - " + pretty_date2 + " | " + countadults + " " + adults_text +comma+" " + countchildren + " "+child_text+comma+" " + countrooms + " " + rooms_text +comma+" " + nights + " " + night_text + "
    "; } var json = ""; for ( var i =0 ; i < countrooms ; i++ ) { json += "{\"adults\":"+parseInt(hotelmap.search_data.occupancy[i].adults)+",\"children\":"+parseInt(hotelmap.search_data.occupancy[i].children); if ( parseInt(hotelmap.search_data.occupancy[i].children ) > 0 ){ json += ",\"childAges\": ["; for ( var j = 1 ; j <= parseInt(hotelmap.search_data.occupancy[i].children ); j++ ) { var reference = "child"+j; json += hotelmap.search_data.occupancy[i].ages[reference]+""; if ( j < parseInt(hotelmap.search_data.occupancy[i].children ) ) { json += ","; } } json += "]"; } json += "}"; if ( i < (countrooms-1) ){ json += ","; } } hotelmap.criteraJSON = "["+json+"]"; $(".date_boundary").click(function(){ // hotelmap.rhp.push_to_packet("CLICK_CAL_CREATE",attributes.sorting); hotelmap.calendar.init(); }); // console.log(json); } }; /** * ------------------------------------------------------------------------- * HotelMap WorldWide 1.0 * Copyright (C) 2012 - All Rights Reserved - HotelMap.com * ------------------------------------------------------------------------- * Base ID: Hotel Icons * Description: Manages the icons and lozzenges for hotels. * ------------------------------------------------------------------------- * Version : $Id$ * Author : James Holden * Contact : james@hotelmap.com * ------------------------------------------------------------------------- * Notes : * ------------------------------------------------------------------------- */ hotelmap.hotelicon = { right_panel_elements: {}, core_map_items: {}, icons: { 'hotels-zoom-2-medium' : {'width':'47', 'height':'63'}, 'hotels-zoom-2-small' : {'width':'47', 'height':'57'}, 'hotels-zoom-2-large' : {'width':'47', 'height':'68'} }, /*********************************************************************************************************************************/ remove_from_incoming_data_set: function(data_set) { var the_loaded = {}; var in_map = 0; var in_feed = 0; for (var i in hotelmap.properties.shapes.objects) { var child = hotelmap.properties.shapes.objects[i]; the_loaded[child.identity]=1; in_map++; } for (var i=0 ; i