431e9b791e6fe5bb80bad605219c2ab1ebf8f160
[MojoFacets.git] / templates / actions / index.html.ep
1 % layout 'ui';
2 <h2>Latest actions</h2>
3
4 <form class=action_filter>
5 <input type=submit value="Filter">
6 <ul>
7 % foreach my $type ( sort keys %$stats ) {
8 <li><label>
9 <input type=checkbox name=action_filter value="<%= $type %>">
10 <%= $type %><span class=count><%= $stats->{$type} %></span>
11 </label>
12 % }
13 </ul>
14 <input type=submit value="Filter">
15 </form>
16
17 <table>
18 <tr><th>action</th><th>timestamp</th></tr>
19 % foreach my $action ( @$actions ) {
20 <tr><td>
21 <a class="view" href="<%= url_for( controller => 'actions', action => 'view' )->query( uid => $action->{uid} ) %>"><%= $action->{action} %></a>
22 </td><td>
23 <tt class=ts><%= $action->{t} %></tt>
24 </td></tr>
25 % }
26 </table>
27
28 % my $more = ( $#$actions ) * 10;
29 Show <a href="<%= url_for( controller => 'actions', action => 'index' )->query( max => $more ) %>"><%= $more %> actions</a>
30
31 <script type="text/javascript" src="/js/date_pretty.js"></script>
32 <script type="text/javascript">
33 $(document).ready( function(){
34         console.debug('convert timestamps');
35         $('tt.ts').each( function(){
36                 $(this).text( date_pretty( new Date(this.textContent * 1000) ) );
37         });
38
39         $('a.view').live( 'click', function() {
40                 console.debug(this.href);
41                 var e = $(this).parent();
42                 var link_html = e.html();
43                 $.ajax({
44                         url: this.href,
45                         success: function(data){
46                                 var form = $(data).filter('form');
47                                 console.debug('ajax',e,form);
48                                 e.html( form )
49                                 .addClass( 'action_box' )
50                                 .append(
51                                         $('<input type=button value=hide>').click( function() {
52 console.debug(this,link_html);
53                                         e.html( link_html ).removeClass( 'action_box' ).addClass( 'action_viewed' );
54                                         })
55                                 )
56                                 ;
57                         }
58                 })
59                 return false;
60         });
61
62         $('form input[name=_master]').live( 'click', function(){
63                 var master = this.value;
64                 console.debug('replication master', master);
65
66                 $(this).closest('form').attr('action', function() {
67                         return master + this.action;
68                 }).css({ 'background': '#ffe' });
69         });
70
71 });
72 </script>