Fix UI "clear" button to clear URL state

This commit is contained in:
Brandon Thomas committed 2016-10-30 03:04:57 -04:00
1 parent 0ea02db27f
commit 32248e9e36
2 files changed
+9 -1

No files matched your search

+2 -1
View File
@@ -8,7 +8,7 @@ declare var $: any;
import { setup_animation } from "./animation";
import Audio from "./audio";
import { decode_url_hash, get_audio_api_url, set_url_hash } from "./url";
import { clear_url_hash, decode_url_hash, get_audio_api_url, set_url_hash } from "./url";
import { RawSentence, FilteredSentence } from "./sentence";
const INPUT = 'input#jungle';
@@ -75,6 +75,7 @@ function install_events() {
$('button#clear').on('click', function(ev: any): any {
$(INPUT).val(''); // ESC key.
(<any>window).audio.stop();
clear_url_hash();
ev.preventDefault();
return false;
});
+7
View File
@@ -13,6 +13,13 @@ export function get_audio_api_url(sentence: FilteredSentence) : string {
return `/speak?v=trump&vol=3&s=${encoded}`;
}
/**
* Reset the URL.
*/
export function clear_url_hash() {
window.history.replaceState(null, null, '/');
}
/**
* Sentence -> Persistent URL hash
*/