$('#tracker_form').addClass('hidden');
update_tracker();
var xhr = new XMLHttpRequest();
- xhr.open('GET', '/us/' + user);
- xhr.setRequestHeader('Accept', 'application/json');
+ xhr.open('GET', '/us/' + user + '?format=json');
xhr.onload = function () {
localStorage.setItem('tracker_data', this.responseText);
update_tracker();
response_filter { return shift }
},
- sub () {
+ sub (?:format~) {
+ my $format = lc $_{format} // '';
response_filter {
my ($r) = @_;
return $r if ref $r ne 'Plack::App::Gruntmaster::Response';
- return [200, ['Content-Type' => 'application/json', 'X-Forever' => 1], [encode_json $r->{params}]] if $env->{HTTP_ACCEPT} =~ m,^\s*application/json\s*$,g;
+ return [200, ['Content-Type' => 'application/json', 'X-Forever' => 1], [encode_json $r->{params}]] if $format eq 'json';
my $ret = render $r->{template}, 'en', title => $r->{title}, %{$r->{params}};
[200, ['Content-Type' => 'text/html'], [encode 'UTF-8', $ret]]
},