Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add direct twitter result link #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
let links = [];
let previouslySearched = LocalStorage.getItem(STORAGE_KEY.generated_links, []);
let popularCityLinks = [];
let twitterSearchUrl = '';

$: alsoSearchFor, inputs, checkboxes, excludeKeywords, generateLinks();
$: alsoSearchFor, inputs, checkboxes, excludeKeywords, generatePopularCityLinks();
Expand Down Expand Up @@ -185,6 +186,10 @@
LocalStorage.setItem(STORAGE_KEY.generated_links, links);
}

function createTwitterLink() {
twitterSearchUrl = generateLinkForCity(inputs.cities.split(',')[0]);
}

function clearSavedLinks() {
previouslySearched = [];

Expand Down Expand Up @@ -260,6 +265,10 @@
#generate-button-container {
margin-top: 24px;
}

#live-twitter-url {
padding: 16px 0px;
}
</style>

<main>
Expand All @@ -283,11 +292,11 @@
<div>
<h2>Search</h2>

<form on:submit|preventDefault={generate}>
<form on:change={createTwitterLink} on:submit|preventDefault={generate}>
<div>
<label for="cities">Name of city</label>
<br />
<input type="text" bind:value={inputs.cities} id="cities" placeholder="Enter city name here" />
<input on:keyup={createTwitterLink} type="text" bind:value={inputs.cities} id="cities" placeholder="Enter city name here" />
</div>

<div class="split-three-two checkbox-fields">
Expand All @@ -308,6 +317,11 @@
<button>Generate Links</button>
</div>

{#if twitterSearchUrl && inputs.cities && inputs.cities.split(',').length === 1}
<div id="live-twitter-url">
<a target="_blank" href={twitterSearchUrl}>Open Twitter Results for {inputs.cities.split(',')[0]}</a>
</div>
{/if}
<hr />

<div id="options">
Expand Down