use Carp qw(confess);
use utf8;
use JSON;
+use POSIX qw(strftime);
use lib '/srv/koha_ffzg';
use C4::Context;
}
sub html_end {
- return qq|</body>\n</html>\n|;
+ return
+ qq|<small style="color:gray">Zadnji puta osvježeno: |,
+ strftime("%Y-%m-%d %H:%M:%S\n", localtime()),
+ qq|</body>\n</html>\n|;
}
mkdir 'html' unless -d 'html';
my $path = "html/$row->{authid}";
open(my $fh, '>:encoding(utf-8)', "$path.new");
print $fh html_title($row->{full_name}, "bibliografija");
- print $fh qq|<h1>$row->{full_name} - bibliografija</h1>|;
+ print $fh qq|<h1>$row->{full_name} - bibliografija</h1>\n|;
my $years = count_author_years( $row->{authid} );
- print $fh qq|<span id="years">Godine:|;
+ print $fh qq|<span id="years">Godine:\n|;
my $type_cat_count = {};
foreach my $year ( sort { $b <=> $a } keys %$years ) {
- print $fh qq|<label><input type=checkbox onClick="toggle_year($year, this)" checked>$year</label> \n|;
+ print $fh qq|<label><input name="year_selection" value="$year" type=checkbox onClick="toggle_year($year, this)" checked="checked">$year</label> \n|;
foreach my $type_cat ( keys %{ $years->{$year} } ) {
$type_cat_count->{ $type_cat } += $years->{$year}->{$type_cat};
}
}
+
+ print $fh qq|
+<input type=button value="all" onClick="all_years(1)">
+<input type=button value="none" onClick="all_years(0)">
+ |;
+
print $fh qq|</span>|;
print $fh q|
var type_cat_count = |, encode_json($type_cat_count), q|;
+function year_show(year) {
+ $('.y'+year).show();
+ console.debug('show', year);
+ for(var type_cat in years[year]) {
+ if ( ( type_cat_count[ type_cat ] += years[year][type_cat] ) == years[year][type_cat]) {
+ $('a[name="'+type_cat+'"]').show();
+ console.debug(type_cat, 'show');
+ }
+ }
+}
+
+function year_hide(year) {
+ $('.y'+year).hide();
+ console.debug('hide', year);
+ for(var type_cat in years[year]) {
+ if ( ( type_cat_count[ type_cat ] -= years[year][type_cat] ) == 0 ) {
+ $('a[name="'+type_cat+'"]').hide();
+ console.debug(type_cat, 'hide');
+ }
+ }
+}
+
function toggle_year(year, el) {
if ( el.checked ) {
- $('.y'+year).show();
- console.debug('show', year, el.checked);
- for(var type_cat in years[year]) {
- if ( ( type_cat_count[ type_cat ] += years[year][type_cat] ) == years[year][type_cat]) {
- $('a[name="'+type_cat+'"]').show();
- console.debug(type_cat, 'show');
- }
- }
+ year_show(year);
} else {
- $('.y'+year).hide();
- console.debug('hide', year, el.checked);
- for(var type_cat in years[year]) {
- if ( ( type_cat_count[ type_cat ] -= years[year][type_cat] ) == 0 ) {
- $('a[name="'+type_cat+'"]').hide();
- console.debug(type_cat, 'hide');
+ year_hide(year);
+ }
+}
+
+function all_years( turn_on ) {
+ $('input[name=year_selection]').each( function(i,el) {
+ if ( turn_on ) {
+ if ( ! el.checked ) {
+ el.checked = true;
+ year_show( el.value );
+ }
+ } else {
+ if ( el.checked ) {
+ el.checked = false;
+ year_hide( el.value );
}
}
- }
+ } );
}
+
+$(document).ready( function() {
+ console.info('ready');
+
+ $('input[name=year_selection]').each( function(i, el) {
+ var year = el.value;
+ console.debug( 'on load', year, el.checked );
+ if (! el.checked) year_hide(year);
+ });
+
+});
</script>
|;