65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
/** Agenten Plattform
|
|
(c) 2024 Magnus Bender
|
|
Institute of Humanities-Centered Artificial Intelligence (CHAI)
|
|
Universitaet Hamburg
|
|
https://www.chai.uni-hamburg.de/~bender
|
|
source code released under the terms of GNU Public License Version 3
|
|
https://www.gnu.org/licenses/gpl-3.0.txt
|
|
**/
|
|
|
|
function pagination_link(name, value){
|
|
let link_args = db_args;
|
|
if (name && value){
|
|
link_args[name] = value;
|
|
}
|
|
else if(name){
|
|
delete link_args[name];
|
|
}
|
|
return '?' + $.param( link_args );
|
|
}
|
|
$(".value_filter").change((e)=>{
|
|
window.location = pagination_link($(e.target).attr('name').substr('filter_'.length), $(e.target).val())
|
|
});
|
|
|
|
function enable_auto_refresh(){
|
|
setInterval( () => {
|
|
if($('#autoRefresh').prop('checked')){
|
|
$.get(
|
|
'/app/table/total' + pagination_link(),
|
|
(v) => {
|
|
if( v != db_total ){
|
|
window.location = pagination_link()
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}, 1000);
|
|
sessionStorage.setItem('auto_refresh', $('#autoRefresh').prop('checked'));
|
|
}
|
|
$("#autoRefresh").click(enable_auto_refresh);
|
|
if(sessionStorage.hasOwnProperty('auto_refresh') && sessionStorage.getItem('auto_refresh') === 'true'){
|
|
$("#autoRefresh").prop('checked', true);
|
|
enable_auto_refresh()
|
|
}
|
|
|
|
function send_json_message(json_str){
|
|
$.ajax(
|
|
"/message",
|
|
{
|
|
contentType : 'application/json',
|
|
type : 'POST',
|
|
data: json_str,
|
|
},
|
|
).then((d) => {
|
|
$("#message_sent .modal-title").text("Message Sent");
|
|
$("#message_sent .modal-body").html('<pre>'+JSON.stringify(d, null, 2)+'</pre>');
|
|
new bootstrap.Modal('#message_sent').show();
|
|
}).fail((d)=>{
|
|
$("#message_sent .modal-title").text("Error Sending Message");
|
|
$("#message_sent .modal-body").html('<pre>'+JSON.stringify(d, null, 2)+'</pre>');
|
|
new bootstrap.Modal('#message_sent').show();
|
|
});
|
|
}
|
|
$(".send_message_again").click(
|
|
(e) => send_json_message( $("pre#row_message_raw_"+$(e.target).attr('idx')).text() )
|
|
); |