Merge remote-tracking branch 'calcms/master'

* default.js: add parseUrl
* fixup! remove deprecated role model
This commit is contained in:
Milan
2023-03-23 22:20:07 +01:00
4 changed files with 33 additions and 2 deletions

View File

@@ -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"} );

View File

@@ -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){

View File

@@ -83,6 +83,8 @@ function updateEventSelection(resultElemId){
}
var elem=$("#selectEvent").parent();
url = parseUrl(url);
console.log(url);
$(elem).load(url);
}

View File

@@ -36,7 +36,9 @@ function updateSeriesSelection(resultElemId){
url+="&selectProjectStudio=1";
}
url = parseUrl(url);
var elem=$("#selectSeries").parent();
console.log(url);
$(elem).load(url);
}