From 311c3fc06eb4f1a6bd0e4cd235fb35c7a4c2ece9 Mon Sep 17 00:00:00 2001 From: Kai Labusch Date: Thu, 22 Aug 2019 17:26:12 +0200 Subject: [PATCH] add demo url text parameter --- qurator/sbb_ner/webapp/static/js/ner-demo.js | 36 ++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/qurator/sbb_ner/webapp/static/js/ner-demo.js b/qurator/sbb_ner/webapp/static/js/ner-demo.js index a08c391..3e97dc8 100644 --- a/qurator/sbb_ner/webapp/static/js/ner-demo.js +++ b/qurator/sbb_ner/webapp/static/js/ner-demo.js @@ -4,11 +4,7 @@ $(document).ready(function(){ function(e){ e.preventDefault(); - var task = $('#task').val(); - var model_id = $('#model').val(); - var input_text = $('#inputtext').val() - - do_task(task, model_id, input_text); + update(); } ); @@ -27,8 +23,34 @@ $(document).ready(function(){ tmp += '' }); $('#model').html(tmp); + + var url_params = new URLSearchParams(window.location.search); + + var do_update=false; + + if (url_params.has('text')) { + + var text = url_params.get('text') + + $('#inputtext').val(text); + + do_update = true; + + window.history.replaceState({}, '', `${location.pathname}`); + } + + task_select() + + if (do_update) update(); } ); - - task_select() }); + +function update() { + + var task = $('#task').val(); + var model_id = $('#model').val(); + var input_text = $('#inputtext').val() + + do_task(task, model_id, input_text); +} \ No newline at end of file