mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 08:28:18 +00:00
Fix UI "clear" button to clear URL state
This commit is contained in:
1 parent
0ea02db27f
commit
32248e9e36
2 files changed
+9
-1
No files matched your search
+2
-1
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user