in dialogflow-prebuilt-agents/client_side_messenger/airline_support/airline_support.js [20:72]
connectedCallback() {
Promise
.all([
fetch(
'https://storage.googleapis.com/aiestaran-ccai-misc/travel-rich-content/flight-grid.html')
.then((response) => response.text()),
fetch(
'https://storage.googleapis.com/aiestaran-ccai-misc/travel-rich-content/flight-grid-row.html')
.then((response) => response.text()),
fetch(
'https://storage.googleapis.com/aiestaran-ccai-misc/travel-rich-content/flight-grid.css')
.then((response) => response.text()),
])
.then(([tableHtml, rowHtml, css]) => {
console.log({tableHtml, rowHtml, css});
const styles = document.createElement('style');
styles.textContent = css;
this.renderRoot.appendChild(styles);
const template = document.createElement('template');
const preparedHtml =
this.prepareHtml(tableHtml, this.dfPayload.route);
template.innerHTML = preparedHtml;
const content = template.content.cloneNode(true);
window.testcontent = content;
const tbody = content.querySelector('tbody');
const flights = this.dfPayload.flights;
for (const flight of flights) {
const formattedTimes = this.formatTimes(flight);
flight.human_readable_times = formattedTimes.human_readable_times;
flight.date_offset = formattedTimes.date_offset;
flight.stop_count_text = `${flight.stop_count} stops`;
if (flight.stop_count === 0) flight.stop_count_text = 'nonstop';
if (flight.stop_count === 1) flight.stop_count_text = '1 stop';
flight.cost_class = 'standard';
if (flight.cost_tag === 'LOWEST') flight.cost_class = 'lowest';
if (flight.cost_tag === 'HIGHEST') flight.cost_class = 'highest';
flight.formatted_duration =
this.formatMinutesToHoursMinutes(flight.duration);
const row = document.createElement('tr');
const preparedRowHtml = this.prepareHtml(rowHtml, flight);
row.innerHTML = preparedRowHtml;
const rowContent = row.cloneNode(true);
tbody.appendChild(rowContent);
}
this.renderRoot.appendChild(content);
});
};