Skip to content
Snippets Groups Projects
Commit 4d0dc5e6 authored by Mark M. Florida's avatar Mark M. Florida
Browse files

Minor fixes and updates: strip leading and trailing slashes from custom page...

Minor fixes and updates: strip leading and trailing slashes from custom page name in url hash or query string; removed rogue semicolon; added methods to render and retrieve table HTML using XNAT.table(); added usage comment in 'hello.vm'.
parent f76c3115
No related branches found
No related tags found
No related merge requests found
......@@ -445,7 +445,7 @@ function toNumber( val, strip, force, dec ){
// chop off after 2nd decimal, if present
val = val.split('.');
val = val[0]+ '.' +val[1];
val = (val.length === 1) ? val[0] : val[0]+ '.' +val[1];
}
......
......@@ -12,12 +12,12 @@
else {
return factory(NS);
}
}('XNAT.app.customPage', function(NS, undefined){
}('app.customPage', function(NS, undefined){
// setExtendedObject() hasn't been tested yet
//var customPage = setExtendedObject(XNAT, NS);
// var customPage = setExtendedObject(XNAT, NS);
var customPage = getObject(eval(NS)||{});
var customPage = getObject(eval('XNAT.'+NS)||{});
customPage.getName = function(){
var name = getQueryStringValue('view');
......@@ -45,26 +45,31 @@
url: XNAT.url.rootUrl(path),
dataType: 'html',
success: function(content){
$container.html(content);
$container.html(content)
}
})
}
var setPaths = function(pg, prefixes){
var paths = [];
pg = pg.replace(/^\/+|\/+$/g, ''); // remove leading and trailing slashes
[].concat(prefixes).forEach(function(prefix){
paths.push(prefix + '/' + pg + '/content.jsp');
paths.push(prefix + '/' + pg + '.jsp');
paths.push(prefix + '/' + pg + '/content.html');
paths.push(prefix + '/' + pg + '.html');
// paths.push(prefix + '/' + pg + '/'); // that could be dangerous
});
return paths;
};
pagePaths = setPaths(name, ['/pages']);
pagePaths = setPaths(name, ['/page', '/pages']);
// if we're using a theme, check that theme's folder
if (XNAT.theme){
themePaths = setPaths(name, [
'/themes/' + XNAT.theme,
'/themes/' + XNAT.theme + '/page',
'/themes/' + XNAT.theme + '/pages'
]);
pagePaths = themePaths.concat(pagePaths);
......
......@@ -274,6 +274,17 @@ var XNAT = getObject(XNAT||{});
return this;
};
Table.p.render = function(element){
if (element){
$$(element).empty().append(this.table);
}
return this.table;
};
Table.p.html = function(){
return this.table.outerHTML;
};
table = function(data, opts){
if (!opts){
......
<h1>Hello.</h1>
\ No newline at end of file
## The content of any page in the *templates/pages folder
## will be accessible at /app/template/Page.vm?view=name,
## where the 'name' query string parameter is the name of
## the file without the .vm extension. This is intended
## to be used for page content that relies solely on XNAT's
## REST service for receiving and sending data.
<h1>Hello.</h1>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment