mirror of
https://github.com/qurator-spk/sbb_ner.git
synced 2025-06-09 20:30:01 +02:00
add url parameters
This commit is contained in:
parent
23d4aa39b8
commit
a1aff8e229
2 changed files with 73 additions and 27 deletions
|
@ -5,30 +5,7 @@ $(document).ready(function(){
|
|||
function(e){
|
||||
e.preventDefault();
|
||||
|
||||
var task = $('#task').val();
|
||||
var model_id = $('#model').val();
|
||||
|
||||
var spinner_html =
|
||||
`<div class="d-flex justify-content-center">
|
||||
<div class="spinner-border align-center" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
var ppn = $('#ppn').val()
|
||||
|
||||
$("#resultregion").html(spinner_html);
|
||||
|
||||
$.get( "/digisam-fulltext/" + ppn)
|
||||
.done(function( data ) {
|
||||
|
||||
do_task(task, model_id, data.text)
|
||||
})
|
||||
.fail(
|
||||
function() {
|
||||
console.log('Failed.');
|
||||
$("#resultregion").html('Failed.');
|
||||
});
|
||||
update();
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -47,6 +24,41 @@ $(document).ready(function(){
|
|||
tmp += '<option value="' + item.id + '" ' + selected + ' >' + item.name + '</option>'
|
||||
});
|
||||
$('#model').html(tmp);
|
||||
|
||||
var url_params = new URLSearchParams(window.location.search);
|
||||
|
||||
var do_update=false;
|
||||
|
||||
if (url_params.has('ppn')) {
|
||||
|
||||
var ppn = url_params.get('ppn')
|
||||
|
||||
$('#ppn').val(ppn);
|
||||
|
||||
do_update = true;
|
||||
}
|
||||
|
||||
if (url_params.has('model_id')) {
|
||||
|
||||
var model_id = url_params.get('model_id')
|
||||
|
||||
$('#model').val(model_id);
|
||||
|
||||
do_update = true;
|
||||
}
|
||||
|
||||
if (url_params.has('task')) {
|
||||
|
||||
var task = url_params.get('task')
|
||||
|
||||
$('#task').val(task);
|
||||
|
||||
do_update = true;
|
||||
}
|
||||
|
||||
task_select()
|
||||
|
||||
if (do_update) update();
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -62,6 +74,40 @@ $(document).ready(function(){
|
|||
$('#ppnexamples').html(tmp);
|
||||
}
|
||||
);
|
||||
|
||||
task_select()
|
||||
});
|
||||
|
||||
|
||||
function update() {
|
||||
|
||||
var spinner_html =
|
||||
`<div class="d-flex justify-content-center">
|
||||
<div class="spinner-border align-center" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
var task = $('#task').val();
|
||||
var model_id = $('#model').val();
|
||||
var ppn = $('#ppn').val();
|
||||
|
||||
var url_params = new URLSearchParams(window.location.search);
|
||||
|
||||
url_params.set('ppn', ppn)
|
||||
url_params.set('model_id', model_id)
|
||||
url_params.set('task', task)
|
||||
|
||||
window.history.replaceState({}, '', `${location.pathname}?${url_params}`);
|
||||
|
||||
$("#resultregion").html(spinner_html);
|
||||
|
||||
$.get( "/digisam-fulltext/" + ppn)
|
||||
.done(function( data ) {
|
||||
|
||||
do_task(task, model_id, data.text)
|
||||
})
|
||||
.fail(
|
||||
function() {
|
||||
console.log('Failed.');
|
||||
$("#resultregion").html('Failed.');
|
||||
});
|
||||
}
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<div class="form-group row ml-2">
|
||||
<label for="ppn" class="col-sm-2 col-form-label">PPN:</label>
|
||||
<input id="ppn" list="ppnexamples" class="col-sm-8" type="text"/>
|
||||
<input id="ppn" list="ppnexamples" class="col-sm-8" type="text" required/>
|
||||
<datalist id="ppnexamples">
|
||||
</datalist>
|
||||
<button class="btn btn-primary" type="submit">Go</button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue