if (!CeetizPlaceWidget) { var CeetizPlaceWidget = function (widgetId, params) { this.dataHost = 'https://widgets.ceetiz.com'; this.cssUrl = this.dataHost + '/css/routard.css'; this.dataUrl = this.dataHost + '/routard/places/' + params.place + '.js?widgetId=' + params.id; this.container = document.getElementById(widgetId); this.template = '' + '
' + '
' + ' ' + ' <% imageAlt %>' + ' ' + '
' + '
' + '
<% title %>
' + '

<% activityTitle %>

' + ' ' + ' <% buttonTitle %>' + ' ' + '
' + '
'; }; CeetizPlaceWidget.prototype.load = function() { var head = document.getElementsByTagName("head")[0]; // Load data var script = document.createElement("script"); script.type = "text/javascript"; script.src = this.dataUrl; head.appendChild(script); // Load styles var link = document.createElement("link"); link.rel = "stylesheet"; link.media = "all"; link.href = this.cssUrl; head.appendChild(link); }; CeetizPlaceWidget.prototype.setData = function(data) { this.data = data; this.draw(); }; CeetizPlaceWidget.prototype.draw = function() { if (this.container) { this.container.innerHTML = this.template .replace(/<% imageUrl %>/g, this.data.image.url) .replace(/<% imageAlt %>/g, this.data.image.alt) .replace(/<% title %>/g, this.data.title) .replace(/<% activityTitle %>/g, this.data.activity.title) .replace(/<% activityUrl %>/g, this.data.activity.url) .replace(/<% buttonTitle %>/g, this.data.button.title) ; } } } if (!CeetizPlaceWidgetManager) { var CeetizPlaceWidgetManager = (function() { var widgets = {}; return { createWidget: createWidget, setWidgetData: setWidgetData }; function createWidget(params) { var widgetId = params.id; widgets[widgetId] = new CeetizPlaceWidget(widgetId, params); return widgets[widgetId]; } function setWidgetData(widgetId, data) { if (widgets[widgetId]) { widgets[widgetId].setData(data); } } })(); } if (typeof CeetizPlaceWidgetParams === 'object') { CeetizPlaceWidgetManager .createWidget(CeetizPlaceWidgetParams) .load(); }