Skip to content

Commit

Permalink
keypress event now firing
Browse files Browse the repository at this point in the history
  • Loading branch information
mdda committed Feb 13, 2018
1 parent 0fe03d2 commit cafac4a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions notebooks/2-CNN/8-Speech/SpeechAnalysis_Annotation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
" notebook_html('<span id=\"%s\"></span>' % (hsh,)),\n",
" notebook_audio(f, rate=_sample_rate, autoplay=autoplay)\n",
" )\n",
" return '#'+hsh\n",
" return hsh\n",
"\n",
"audio_id=play_audio_samples(audio_samples)\n",
"audio_id"
Expand Down Expand Up @@ -129,7 +129,8 @@
" var tb = $(selector);\n",
" var caretPos = tb[0].selectionStart;\n",
" var textAreaTxt = tb.val();\n",
" tb.val(textAreaTxt.substring(0, caretPos) + txt + textAreaTxt.substring(caretPos) );\n",
" tb.val(textAreaTxt.substring(0, caretPos) \n",
" + txt + textAreaTxt.substring(caretPos) );\n",
"}\n",
"</script>\"\"\")"
]
Expand Down Expand Up @@ -167,12 +168,15 @@
"metadata": {},
"outputs": [],
"source": [
"# https://stackoverflow.com/questions/1064089/inserting-a-text-where-cursor-is-using-javascript-jquery\n",
"# https://stackoverflow.com/questions/1064089/\n",
"# inserting-a-text-where-cursor-is-using-javascript-jquery\n",
"\n",
"notebook_html(\"\"\"<script type=\"text/Javascript\">\n",
"var audio_ele=get_audio_ele('{id}');\n",
"$('{id}_tb').keypress(function(ev){ alert(ev);});\n",
"</script>\"\"\".format(id=audio_id))"
"var audio_ele=get_audio_ele('#%s');\n",
"$('#%s_tb').keypress(function(ev){ \n",
" alert(ev); \n",
"});\n",
"</script>\"\"\" % (audio_id, audio_id, ))"
]
},
{
Expand Down

0 comments on commit cafac4a

Please sign in to comment.