Skip to content

Commit

Permalink
Lecture 30 - Creating the weather cards
Browse files Browse the repository at this point in the history
  • Loading branch information
nibblebits committed Mar 16, 2024
1 parent c56d674 commit 494565d
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions WeatherAssistant/resources/views/weather/home.blade.php
Expand Up @@ -78,6 +78,32 @@
$('.typing-indicator-box').hide();
function applyWeatherCard(response) {
var allWeatherData = response.function_calls.filter(call => call.function_name == "handle_weather");
allWeatherData.forEach(weatherData => {
var city = weatherData.function_arguments.location;
var temperature = weatherData.function_arguments.celcius;
var weatherDescription = 'The weather description';
var iconUrl = 'images/chat/icons/weather/clouds.png';
var weatherCardHtml = '<div class="weather-card">' +
'<div class="weather-content">' +
'<div class="weather-card-header">' +
'<span class="city-name">' + city + '</span>' +
'</div>' +
'<div class="weather-card-body">' +
'<p class="temperature">Temperature: ' + temperature + 'C</p>' +
'<p class="weather-description">' + weatherDescription + '</p>' +
'</div>' +
'</div>' +
'<div class="weather-icon">' +
'<img src="' + iconUrl + '" alt="Weather icon" />' +
'</div>' +
'</div>';
$('.weather-data').append(weatherCardHtml);
});
}
function scrollToBottom() {
var chatMessages = $('.chat-messages');
chatMessages.scrollTop(chatMessages.prop("scrollHeight"));
Expand Down Expand Up @@ -121,8 +147,7 @@ function sendMessage()
$('.chat-card .chat-messages').append(replyHtml);
$('.typing-indicator-box').hide();
// Create weather icons and append TODO
// TODO....
applyWeatherCard(response);
scrollToBottom();
save_data_string = response.save_data_string;
Expand Down

0 comments on commit 494565d

Please sign in to comment.