<%doc> This is part of the YARRG website. YARRG is a tool and website for assisting players of Yohoho Puzzle Pirates. Copyright (C) 2009 Ian Jackson Copyright (C) 2009 Clare Boothby YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later). The YARRG website is covered by the GNU Affero GPL v3 or later, which basically means that every installation of the website will let you download the source. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Yohoho and Puzzle Pirates are probably trademarks of Three Rings and are used without permission. This program is not endorsed or sponsored by Three Rings. This Mason component generates the core of the `data age' query. <%args> $quri $dbh <%once> <%perl> my $now= time; my $row; my $sth= $dbh->prepare("SELECT archipelago, islandid, islandname, timestamp FROM uploads NATURAL JOIN islands ORDER BY archipelago, islandid"); $sth->execute(); <&| script &> da_pageload= Date.now();

Market data age

% my %da_ages; % my %ts_sortkeys; % $da_ages{'id_loaded'}= 0; % my $rowix= 0; % while ($row=$sth->fetchrow_hashref) { % my $rowid= "id_$row->{'islandid'}"; % my $cellid= "c$rowid"; % my $age= $now - $row->{'timestamp'}; % $ts_sortkeys{'0'}{$rowid}= $row->{'archipelago'}; % $ts_sortkeys{'1'}{$rowid}= $row->{'islandname'}; % $da_ages{$rowid}= $age; class="<% 'datarow'.($rowix & 1) %>" > % $rowix++; % }
Archipelago Island Age
<% $row->{'archipelago'} |h %> <% $row->{'islandname'} |h %> <% prettyprint_age($age) %>
<& SELF:dataages, id2age => \%da_ages, elemidprefix => "'c'+" &> <%method dataages> <%args> $id2age $elemidprefix => '' <&| script &> function da_Refresh() { var now= Date.now(); debug('updating now='+now); for (var ageid in da_ages) { var oldage= da_ages[ageid]; var el= document.getElementById(<% $elemidprefix %>ageid); var age= oldage + (now - da_pageload) / 1000; var newhtml= <% meta_prettyprint_age('age','Math.floor','+') %>; el.innerHTML= newhtml; } } da_ages= <% to_json_protecttags($id2age) %>; window.setInterval(da_Refresh, 10000); register_onload(da_Refresh); <&| tabsort, table => 'ts_table', rowclass => 'datarow', cols => [ {}, {}, { DoReverse => 1, Numeric => 1, SortKey => "da_ages[rowid]" }] &> ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;

Time since this page loaded: (not known; times above not updating)

<& "lookup:formhidden", ours => sub { 0; } &>
<%init> use POSIX; use CommodsWeb;