package Templar;
use DBI;
use Dancer2;
#use Dancer2::Plugin::Ajax;
use Dancer2::Plugin::Database;
use Template;
use HTML::Escape qw/escape_html/;
use Crypt::SaltedHash;
use Data::Dumper;
our $VERSION = '0.1';
hook before => sub {
if (!session('logged_in') && request->dispatch_path !~ m{^/login}) {
return forward '/login', { requested_path => request->dispatch_path };
}
};
#ajax '/p_details' => sub { "ajax test" };
get '/p_details' => sub { "ajax test" };
####
Partner Details
The partner details function is still in development and is not yet ready to be used.
##
##
function partner_details(catagory)
{
if (! xmlHttpObj) { init_ajax(); }
if (xmlHttpObj)
{
var url = '/p_details';
xmlHttpObj.open('GET', url, true);
xmlHttpObj.onreadystatechange = partner_tab(catagory);
xmlHttpObj.send(null);
}
}
function partner_tab(tab)
{
var details = {
general: "tab1",
qualifier: "tab2",
certificates: "tab3",
contact: "tab4",
notes: "tab5"
};
//alert(details[tab]);
// status is always 0
//alert('response status:' + xmlHttpObj.status);
// xmlHttpObj.responseText is always empty
//document.getElementById('folder').innerHTML = xmlHttpObj.responseText;
// this updates the div as expected
//document.getElementById('folder').innerHTML = "";
if (xmlHttpObj.readyState == 4 && xmlHttpObj.status == 200)
{
// we never reach this point
alert(details[tab]);
document.getElementById('folder').innerHTML = xmlHttpObj.responseText;
//document.getElementById('folder').innerHTML="";
}
}