/** Microsoft.Com.SyndicationDemo.Core.js: shared functionality for widgets **/ // Namespace definition : All Widget Classes should be created in this namespace // if (!window.Microsoft) window.Microsoft = {}; if (!Microsoft.Com) Microsoft.Com = {}; if (!Microsoft.Com.SyndicationDemo) Microsoft.Com.SyndicationDemo = {}; // Widget Core Constructor // Microsoft.Com.SyndicationDemo.Core = function() { // Write out Parent Div where script is placed // Widget content can then be attached to this div through the DOM this.parentDivId = 'rs-iuqb'; document.write('
'); // Widget Path is replaced at runtime // Used to attach scripts and stylesheets from Host server this.widgetPath = 'https://v3.reservation-system.net/'; } // Widget Core Class Definition // Microsoft.Com.SyndicationDemo.Core.prototype = { // Create any HTML element // createTag: function(tagName, innerHtml, cssClass, tagType, tagID) { var tag = $c(tagName); if (tagType) { this.setTagType(tag, tagType); } if (tagID) { this.setTagID(tag, tagID); } if (cssClass) { this.setCssClass(tag, cssClass); } if (innerHtml) { tag.innerHTML = innerHtml; } return tag; }, createButton: function(tagID, tagValue, cssClass, onClickFunction) { var tag = $c('input'); this.setTagType(tag, 'button'); if (tagID) { this.setTagID(tag, tagID); } if (tagValue) { tag.value = tagValue; } if (cssClass) { this.setCssClass(tag, cssClass); } // Attach onclick event handlers if (onClickFunction) { tag.onclick = onClickFunction; if (tag.addEventListener) { tag.addEventListener('click', function() { eval(onClickFunction); }, false); } else if (tag.attachEvent) { var onClickHandler = new Function(tag.onclick); tag.attachEvent('onclick', onClickHandler); } } return tag; }, // Create a hyperlink and attach event handlers if needed // createHyperlink: function(hyperlinkId, text, href, onClickFunction, cssClass, target) { hyperlink = $c('a'); if (hyperlinkId) { hyperlink.id = hyperlinkId; hyperlink.name = hyperlinkId; } hyperlink.title = text; hyperlink.appendChild(document.createTextNode(text)); if (href) { hyperlink.href = href; } if (cssClass != null && cssClass != '') { this.setCssClass(hyperlink, cssClass); } if (target) { hyperlink.setAttribute("target", target); } // Attach onclick event handlers if (onClickFunction) { hyperlink.onclick = onClickFunction; if (hyperlink.addEventListener) { hyperlink.addEventListener('click', function() { eval(onClickFunction); }, false); //hyperlink.addEventListener('click', onClickHandler, false); } else if (hyperlink.attachEvent) { var onClickHandler = new Function(hyperlink.onclick); hyperlink.attachEvent('onclick', onClickHandler); } } return hyperlink; }, // Add Type to any element // setTagType: function(elem, tagType) { elem.setAttribute('type', tagType); }, // Add ID to any element // setTagID: function(elem, tagID) { elem.setAttribute('id', tagID); elem.setAttribute('name', tagID); }, // Adds CSS Class to any element // setCssClass: function(elem, cls) { elem.setAttribute('class', cls); elem.setAttribute('className', cls); }, // Attach a Stylesheet to document // attachStyleSheet: function(path, linkId) { var doc = document.getElementsByTagName('head').item(0); var link = $c('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = path; link.id = linkId; doc.appendChild(link); return false; }, // Attach Style rule // attachStyleRule: function(selector, declaration) { if (!document.getElementsByTagName || !(document.createElement || document.createElementNS)) return; var agt = navigator.userAgent.toLowerCase(); var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); var is_iewin = (is_ie && (agt.indexOf("win") != -1)); var is_iemac = (is_ie && (agt.indexOf("mac") != -1)); if (is_iemac) return; // script doesn't work properly in IE/Mac var head = document.getElementsByTagName("head")[0]; var style = (typeof document.createElementNS != "undefined") ? document.createElementNS("http://www.w3.org/1999/xhtml", "style") : document.createElement("style"); if (!is_iewin) { var styleRule = document.createTextNode(selector + " {" + declaration + "}"); style.appendChild(styleRule); // bugs in IE/Win } style.setAttribute("type", "text/css"); style.setAttribute("media", "screen"); head.appendChild(style); if (is_iewin && document.styleSheets && document.styleSheets.length > 0) { var lastStyle = document.styleSheets[document.styleSheets.length - 1]; if (typeof lastStyle.addRule == "object" || typeof lastStyle.addRule == "function") { lastStyle.addRule(selector, declaration); } } }, // Attach a Stylesheet to document // attachJavascript: function(path, linkId) { var doc = document.getElementsByTagName('head').item(0); var jsTag = $c('script'); jsTag.type = 'text/javascript' jsTag.language = 'javascript' if (path) { jsTag.src = path; } if (linkId) { jsTag.id = linkId; } doc.appendChild(jsTag); return false; }, //Load javascript until loaded and callback function loadScript: function(url, callback) { var head = document.getElementsByTagName("head")[0]; var script = $c("script"); if (url == "jquery") url = "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"; script.src = url; // Attach handlers for all browsers var done = false; script.onload = script.onreadystatechange = function() { if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { done = true; // Continue your code callback(); // Handle memory leak in IE script.onload = script.onreadystatechange = null; head.removeChild(script); } }; head.appendChild(script); }, // Attach a new script, useful for simulating postbacks // attachScript: function(path, scriptId) { script = $c('script'); script.src = path; script.type = 'text/javascript'; script.id = scriptId; this.parentDiv.appendChild(script); return false; } } // Shortcut for GetElementsById // function $g(elem) { return document.getElementById(elem); } // Shortcut for CreateElement // function $c(elem) { return document.createElement(elem); } // Construct a new core object var core = new Microsoft.Com.SyndicationDemo.Core(); var jsonData = {"BackgroundColor":"#C69946","CaptionAdult":"Adults per room","CaptionCheckIn":"Check-in","CaptionCheckOut":"Check-out","CaptionChild":"Children per room","CaptionPromo":"Promo Code","CaptionRetrieve":"Retrieve","CaptionRoom":"Rooms","CaptionSearch":"Search","CoBrandCd":"","Color":"#333333","DefaultLOS":1,"DisplayAdult":true,"DisplayChild":true,"DisplayPromo":true,"DisplayRoom":true,"ErrorMessage":"","FontFamily":"Arial","HotelCd":"HT12004940","HotelDateTime":"4\/28\/2024","HtlCcCode":"","HypertextColor":"#AB1B2A","HypertextHoverColor":"#AB1B2A","IsHorizontal":false,"LangCd":"en","MaxAdult":3,"MaxChild":2,"MaxRoom":10,"MsgValidStayingDate":"Please enter valid staying date","OpenNewWindow":false,"PromoCd":""}; var idTxtCheckIn = 'rs-dtCheckIn'; var idTxtCheckOut = 'rs-dtCheckOut'; var idDdlRoom = 'rs-intRoom'; var idDdlAdult = 'rs-intAdult'; var idDdlChild = 'rs-intChild'; var idDdlOption = 'rs-ddloption'; var idTxtOption = 'rs-txtoption'; /** Microsoft.Com.SyndicationDemo.EventsWidget.js: renders list of dev events **/ // Events Widget Constructor // Microsoft.Com.SyndicationDemo.EventsWidget = function() { // Get reference to main div. All widget content will be children of this div this.parentDiv = document.getElementById(core.parentDivId); this.eventData = jsonData; //this.hotelCd = { temp: placeholder }; } // Events Widget : Core Class Definition // Microsoft.Com.SyndicationDemo.EventsWidget.prototype = { // Main function for Events Widget : Handles rendering the widget to the consuming site // render: function() { // Attach Javascript to Page this.initJS(this.eventData); // Attach Stylesheet to Page core.attachStyleSheet(core.widgetPath + 'Css/Widget/WidgetClass.css', 'rs-styleWidget'); core.attachStyleSheet(core.widgetPath + 'Css/jQuery/Redmont/jquery-ui-1.7.2.custom.css', 'rs-styleUI'); // Rewrite Style this.rewriteStyle(this.eventData); var contentDiv = ""; if (this.eventData.ErrorMessage == "") { contentDiv = this.createContent(); } else { contentDiv = core.createTag('div', '', 'rs-eventWrapper width' + (this.eventData.IsHorizontal ? 400 : 200)); contentDiv.appendChild(core.createTag('div', this.eventData.ErrorMessage)); } this.parentDiv.appendChild(contentDiv); }, initJS: function(eventData) { if (eventData.ErrorMessage == "") { if (typeof jQuery == "undefined") { core.loadScript('jquery', function() { core.loadScript(core.widgetPath + 'Js/jquery-ui-1.7.2.custom.min.js', function() { core.attachJavascript(core.widgetPath + 'Js/Widget/WidgetHotelIuserQB_load.js', 'rs-WidgetHotelIuserQB_load'); } ); } ); } else { core.loadScript(core.widgetPath + 'Js/jquery-ui-1.7.2.custom.min.js', function() { core.attachJavascript(core.widgetPath + 'Js/Widget/WidgetHotelIuserQB_load.js', 'rs-WidgetHotelIuserQB_load'); } ); } } }, rewriteStyle: function(eventData) { core.attachStyleRule('#rs-iuqb', 'color: ' + eventData.Color + ';font-family: ' + eventData.FontFamily + ';font-size:11px'); core.attachStyleRule('#rs-iuqb a:link', 'text-decoration:none;color: ' + eventData.HypertextColor); core.attachStyleRule('#rs-iuqb a:visited', 'text-decoration:none;color: ' + eventData.HypertextColor); core.attachStyleRule('#rs-iuqb a:hover', 'text-decoration:none;color: ' + eventData.HypertextHoverColor); core.attachStyleRule('#rs-iuqb a:active', 'text-decoration:none;color: ' + eventData.HypertextColor); core.attachStyleRule('#rs-iuqb input', 'font-family: ' + eventData.FontFamily); core.attachStyleRule('#rs-iuqb select', 'font-family: ' + eventData.FontFamily); core.attachStyleRule('#rs-iuqb .rs-eventWrapper', 'background-color: ' + eventData.BackgroundColor + ';'); }, createContent: function() { var result; var divCiCo; var divRoom; var divAdult; var divChild; var divOption; result = core.createTag('div', '', 'rs-eventWrapper width' + (this.eventData.IsHorizontal ? 400 : 200)); //Check-In Check-Out divCiCo = this.createCiCo(this.eventData.IsHorizontal); result.appendChild(divCiCo); result.appendChild(core.createTag('br')); //Adult Child Room if (this.eventData.DisplayRoom || this.eventData.DisplayAdult || this.eventData.DisplayChild) { if (this.eventData.DisplayRoom) { divRoom = this.createDropDownNumeric(this.eventData.IsHorizontal, idDdlRoom, this.eventData.CaptionRoom, (this.eventData.IsHorizontal ? 70 : 50), 1, this.eventData.MaxRoom, ''); result.appendChild(divRoom); result.appendChild(core.createTag('div', '', 'inlinebox width10')); } if (this.eventData.DisplayAdult) { divAdult = this.createDropDownNumeric(this.eventData.IsHorizontal, idDdlAdult, this.eventData.CaptionAdult, (this.eventData.IsHorizontal ? 90 : 50), 1, this.eventData.MaxAdult, (this.eventData.IsHorizontal ? '' : 'aligncenter')); result.appendChild(divAdult); result.appendChild(core.createTag('div', '', 'inlinebox width10')); } if (this.eventData.DisplayChild) { divChild = this.createDropDownNumeric(this.eventData.IsHorizontal, idDdlChild, this.eventData.CaptionChild, (this.eventData.IsHorizontal ? 90 : 60), 0, this.eventData.MaxChild, (this.eventData.IsHorizontal ? '' : 'aligncenter')); result.appendChild(divChild); } result.appendChild(core.createTag('br')); } //Promo if (this.eventData.DisplayPromo) { divOption = this.createInput(true, idTxtOption, this.eventData.CaptionPromo, (this.eventData.IsHorizontal ? 70 : 90), ''); result.appendChild(divOption); if (this.eventData.IsHorizontal) result.appendChild(core.createTag('div', '', 'inlinebox width5')); else result.appendChild(core.createTag('br')); } //Buttons result.appendChild(core.createButton('rs-xSubmit', this.eventData.CaptionSearch, 'button inlinebox buttonsize60', 'rs_fSubmit()')); result.appendChild(core.createTag('div', '', 'inlinebox width20')); result.appendChild(core.createHyperlink('rs-xRetrieve', this.eventData.CaptionRetrieve, '#', 'rs_fRetrieve()', 'inlinebox')); return result; }, createCiCo: function(isHorizontal) { var result = core.createTag('div', '', 'inlinebox'); result.appendChild(this.createCiCoDetail(isHorizontal, idTxtCheckIn, this.eventData.CaptionCheckIn)); if (isHorizontal) { result.appendChild(core.createTag('div', '', 'inlinebox width30')); } else { result.appendChild(core.createTag('div', '', 'inlinebox width10')); } result.appendChild(this.createCiCoDetail(isHorizontal, idTxtCheckOut, this.eventData.CaptionCheckOut)); return result; }, createCiCoDetail: function(isHorizontal, tagID, innerText) { var result = core.createTag('div', '', 'inlinebox'); result.appendChild(core.createTag('div', '' + innerText + '', 'inlinebox width70')); if (!isHorizontal) { result.appendChild(core.createTag('br')); } result.appendChild(core.createTag('input', '', 'input inlinebox width80', 'text', tagID)); return result; }, createDropDownNumeric: function(isHorizontal, tagID, innerText, intWidth, intStart, intEnd, cssClass) { var result = core.createTag('div', '', 'inlinebox ' + cssClass); var select; result.appendChild(core.createTag('div', innerText, 'inlinebox width' + intWidth)); if (!isHorizontal) { result.appendChild(core.createTag('br')); } var select = core.createTag('select', '', 'select inlinebox width40', '', tagID); this.createDropDownNumericDetail(select, intStart, intEnd); result.appendChild(select); return result; }, createDropDownNumericDetail: function(elem, intStart, intEnd) { var opt; for (var i = intStart; i <= intEnd; i++) { opt = document.createElement('option'); opt.setAttribute('value', i); opt.appendChild(document.createTextNode(i)); elem.appendChild(opt); } }, createInput: function(isHorizontal, tagID, innerText, intWidth, cssClass) { var result = core.createTag('div', '', 'inlinebox ' + cssClass); result.appendChild(core.createTag('div', innerText, 'inlinebox width' + intWidth)); if (!isHorizontal) { result.appendChild(core.createTag('br')); } result.appendChild(core.createTag('input', '', 'input inlinebox width80', 'text', tagID)); return result; } } // Create Events Widget Object var ev_w = new Microsoft.Com.SyndicationDemo.EventsWidget(); ev_w.render();