Skip to content

Commit

Permalink
Merge pull request #18 from nspalo/development
Browse files Browse the repository at this point in the history
BWA-Dev-6-Weather-App-Sending-Request-UI-Functionality
  • Loading branch information
nspalo authored Sep 9, 2023
2 parents 735441e + fc40961 commit 36e9f94
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import './bootstrap';

import '../sass/app.scss';


import { sendMessage } from './weather-app.js'

window.sendMessage = sendMessage;
18 changes: 18 additions & 0 deletions src/resources/js/weather-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Simple Javascript to get input and set to url then reload!
*/
const chatInput = document.querySelector('#inputAddress')

export function sendMessage() {
let message = chatInput.value;
let queryParams = new URLSearchParams(window.location.search);

// Set new or modify existing parameter value.
queryParams.set("location", message);

// Replace current querystring with the new one.
history.replaceState(null, null, "?"+queryParams.toString());

window.location.reload()
chatInput.value = message;
}
2 changes: 2 additions & 0 deletions src/resources/views/layouts/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@

@include("layouts.footer")
</div>

@yield('custom-js')
</body>
</html>
8 changes: 6 additions & 2 deletions src/resources/views/weather-app/weather-update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

<form class="row g-3">
<div class="d-flex input-group rounded mb-3">
<input id="inputAddress2" class="form-control rounded" type="search" placeholder="City" aria-label="Search" aria-describedby="search-input">
<button id="search-button" class="btn btn-outline-secondary rounded" type="button">Search</button>
<input id="inputAddress" class="form-control rounded" type="search" placeholder="City" aria-label="Search" aria-describedby="search-input">
<button id="searchButton" class="btn btn-outline-secondary rounded" type="button" onclick="sendMessage()">Search</button>
</div>
</form>
</div><!-- Header: Weather Card -->
Expand Down Expand Up @@ -152,3 +152,7 @@
</div>
</div>
@endsection

@section('custom-js')
@vite(['resources/js/weather-app.js'])
@endsection
1 change: 1 addition & 0 deletions src/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default defineConfig({
laravel([
'resources/sass/app.scss',
'resources/js/app.js',
'resources/js/weather-app.js',
]),
],
resolve: {
Expand Down

0 comments on commit 36e9f94

Please sign in to comment.