diff --git a/lib/calcms/template.pm b/lib/calcms/template.pm index 8b3f668..14c00e0 100644 --- a/lib/calcms/template.pm +++ b/lib/calcms/template.pm @@ -44,6 +44,19 @@ sub process($$$$) { $params->{user} = $ENV{REMOTE_USER} unless defined $params->{user}; + if ( ( $filename =~ /json\-p/ ) || (params::isJson) ) { + my $header = "Content-type:application/json; charset=utf-8\n\n"; + my $json = JSON->new->pretty(1)->canonical()->encode($params); + + $json = $header . $params->{json_callback} . $json; + if ( ( defined $_[1] ) && ( $_[1] eq 'print' ) ) { + print $json. "\n"; + } else { + $_[1] = $json . "\n"; + } + return; + } + unless ( -r $filename ) { log::error( $config, qq{template "$filename" does not exist} ) unless -e $filename; log::error( $config, qq{missing permissions to read "$filename"} ); diff --git a/website/agenda/planung/js/default.js b/website/agenda/planung/js/default.js index c8c05bf..3cc64d7 100644 --- a/website/agenda/planung/js/default.js +++ b/website/agenda/planung/js/default.js @@ -78,14 +78,28 @@ function contains(s,t){ } function updateContainer(id, url, callback){ - //alert(id+":"+url); if (id==null) return; if ($("#"+id).length==0) return; + url = parseUrl(url); $("#"+id).load(url, callback); } function load(url){ - window.location=url; + window.location = parseUrl(url); +} + +function parseUrl(uri){ + if (uri.startsWith("/")) { + uri = window.location.origin + uri; + } else if (!uri.startsWith("http")) { + var path = window.location.pathname.replace(/\/$/, ""); + path = path.split("/"); + path.pop(); + uri = window.location.origin + path.join("/") + "/" + uri; + } + var url = new URL(uri); + url.searchParams.append("_", Date.now()); + return url.toString(); } function postContainer(url, parameters, callback){ diff --git a/website/agenda/planung/js/select-event.js b/website/agenda/planung/js/select-event.js index 388d7a7..fae2eaa 100644 --- a/website/agenda/planung/js/select-event.js +++ b/website/agenda/planung/js/select-event.js @@ -83,6 +83,8 @@ function updateEventSelection(resultElemId){ } var elem=$("#selectEvent").parent(); + url = parseUrl(url); + console.log(url); $(elem).load(url); } diff --git a/website/agenda/planung/js/select-series.js b/website/agenda/planung/js/select-series.js index 9e130c1..f1b4fb8 100644 --- a/website/agenda/planung/js/select-series.js +++ b/website/agenda/planung/js/select-series.js @@ -36,7 +36,9 @@ function updateSeriesSelection(resultElemId){ url+="&selectProjectStudio=1"; } + url = parseUrl(url); var elem=$("#selectSeries").parent(); + console.log(url); $(elem).load(url); }