chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a4e2383
)
New onload arrangments; make tabsort take script argument
author
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Wed, 26 Aug 2009 01:46:27 +0000
(
02:46
+0100)
committer
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Wed, 26 Aug 2009 01:46:57 +0000
(
02:46
+0100)
yarrg/TODO
patch
|
blob
|
history
yarrg/web/lookup
patch
|
blob
|
history
yarrg/web/qtextstring
patch
|
blob
|
history
yarrg/web/query_age
patch
|
blob
|
history
yarrg/web/query_commod
patch
|
blob
|
history
yarrg/web/routetrade
patch
|
blob
|
history
yarrg/web/tabsort
patch
|
blob
|
history
diff --git
a/yarrg/TODO
b/yarrg/TODO
index 8a2208830f793b95c4042088cd34fb18429d2e47..e6d969e91648011f9866514d17651030c043e397 100644
(file)
--- a/
yarrg/TODO
+++ b/
yarrg/TODO
@@
-23,8
+23,6
@@
commodity mass/volume in live database
WEBSITE
-------
WEBSITE
-------
-onload thing broken, need proper framework
-
dropdowns are broken sometimes
initial/final stocks feature
dropdowns are broken sometimes
initial/final stocks feature
diff --git
a/yarrg/web/lookup
b/yarrg/web/lookup
index 1453a372145ee2989261f757481aee295e052fb1..4dbd7558e68a8161ad3394f669bb54d5d161c4b8 100755
(executable)
--- a/
yarrg/web/lookup
+++ b/
yarrg/web/lookup
@@
-127,6
+127,15
@@
body {
tr.datarow0 { background: #ffffff; }
tr.datarow1 { background: #e3e3e3; }
</style>
tr.datarow0 { background: #ffffff; }
tr.datarow1 { background: #e3e3e3; }
</style>
+<&| script &>
+ function register_onload(f) {
+ var previous_onload= window.onload;
+ window.onload= function() {
+ if (previous_onload) previous_onload();
+ f();
+ };
+ }
+</&script>
</head><body>
<a href="<% $m->current_comp()->name() |u %>">YARRG</a> -
</head><body>
<a href="<% $m->current_comp()->name() |u %>">YARRG</a> -
diff --git
a/yarrg/web/qtextstring
b/yarrg/web/qtextstring
index 16aa372bd6794caad89992d6d7b2f2a976d519c2..84564df55205125a2bbad3deac5611b256167582 100644
(file)
--- a/
yarrg/web/qtextstring
+++ b/
yarrg/web/qtextstring
@@
-87,7
+87,7
@@
function ts_Ready() {
ts_request= false;
ts_Request();
}
ts_request= false;
ts_Request();
}
-
window.onload= ts_Needed
;
+
register_onload(ts_Needed)
;
</&script>
<input type="text" <% $m->content %>
</&script>
<input type="text" <% $m->content %>
diff --git
a/yarrg/web/query_age
b/yarrg/web/query_age
index 88bc7ea16b73fa686bb30628761a725c4bd242c3..a02187eae01d1b85988382f3e82bc538c6ba010f 100644
(file)
--- a/
yarrg/web/query_age
+++ b/
yarrg/web/query_age
@@
-85,29
+85,13
@@
$sth->execute();
% }
</table>
% }
</table>
-<& tabsort, table => 'ts_table', rowclass => 'datarow', cols => [
- {}, {},
- { DoReverse => 1,
- Numeric => 1,
- SortKey => "da_ages[rowid]" }]
- &>
-
-<p>
-Time since this page loaded:
-<span id="cid_loaded">(not known; times above not updating)</span>
-
-<form action="lookup" method="get">
-<input type=submit name=submit value="Reload">
-<& "lookup:formhidden", ours => sub { 0; } &>
-</form>
-
+<& SELF:dataages, id2age => \%da_ages, elemidprefix => "'c'+" &>
<%method dataages>
<%args>
$id2age
$elemidprefix => ''
</%args>
<&| script &>
<%method dataages>
<%args>
$id2age
$elemidprefix => ''
</%args>
<&| script &>
- da_ages= <% to_json_protecttags($id2age) %>;
function da_Refresh() {
var now= Date.now();
debug('updating now='+now);
function da_Refresh() {
var now= Date.now();
debug('updating now='+now);
@@
-119,21
+103,29
@@
Time since this page loaded:
el.innerHTML= newhtml;
}
}
el.innerHTML= newhtml;
}
}
+ da_ages= <% to_json_protecttags($id2age) %>;
window.setInterval(da_Refresh, 10000);
window.setInterval(da_Refresh, 10000);
+ register_onload(da_Refresh);
</&>
</%method>
</&>
</%method>
-<& SELF:dataages, id2age => \%da_ages, elemidprefix => "'c'+" &>
-
-<&| script &>
+<&| tabsort, table => 'ts_table', rowclass => 'datarow', cols => [
+ {}, {},
+ { DoReverse => 1,
+ Numeric => 1,
+ SortKey => "da_ages[rowid]" }]
+ &>
ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
+</&tabsort>
- function all_onload() {
- ts_onload__ts_table();
- da_Refresh();
- }
- window.onload= all_onload;
-</&script>
+<p>
+Time since this page loaded:
+<span id="cid_loaded">(not known; times above not updating)</span>
+
+<form action="lookup" method="get">
+<input type=submit name=submit value="Reload">
+<& "lookup:formhidden", ours => sub { 0; } &>
+</form>
<%init>
use POSIX;
<%init>
use POSIX;
diff --git
a/yarrg/web/query_commod
b/yarrg/web/query_commod
index 34b1347f20f5034315a1821d535cd6de40f8f8e2..3c2049ca3a509af276a9c28b9c59dbdf463667f5 100644
(file)
--- a/
yarrg/web/query_commod
+++ b/
yarrg/web/query_commod
@@
-89,8
+89,6
@@
$someresults->();
#---------- actually compute the results and print them ----------
#---------- actually compute the results and print them ----------
-my $onloads= "";
-
foreach my $bs (split /_/, $ARGS{BuySell}) {
$bs =~ m/^(buy|sell)$/ or die;
$bs= $1;
foreach my $bs (split /_/, $ARGS{BuySell}) {
$bs =~ m/^(buy|sell)$/ or die;
$bs= $1;
@@
-197,7
+195,7
@@
foreach my $bs (split /_/, $ARGS{BuySell}) {
% }
</table>
% }
</table>
-<&
tabsort,
table => "${bs}_table", sortkeys => "${bs}_sortkeys",
+<&
| tabsort,
table => "${bs}_table", sortkeys => "${bs}_sortkeys",
throw => "${bs}_table_thr", rowclass => 'datarow', cols => [
{}, {},
{ DoReverse => 1 },
throw => "${bs}_table_thr", rowclass => 'datarow', cols => [
{}, {},
{ DoReverse => 1 },
@@
-207,22
+205,13
@@
foreach my $bs (split /_/, $ARGS{BuySell}) {
{ DoReverse => 1, Numeric => 1 },
{ DoReverse => 1, Numeric => 1 },
] &>
{ DoReverse => 1, Numeric => 1 },
{ DoReverse => 1, Numeric => 1 },
] &>
-<&| script &>
<% $bs %>_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
function ts_Pricemap_<% $bs %>(price) {
if (price=='-') { return <% $bs eq 'buy' ? '-1' : '99999999' %>; }
return price;
}
<% $bs %>_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
function ts_Pricemap_<% $bs %>(price) {
if (price=='-') { return <% $bs eq 'buy' ? '-1' : '99999999' %>; }
return price;
}
-</&>
-% $onloads .= " ts_onload__${bs}_table();\n";
+</&tabsort>
<%perl>
}
</%perl>
<%perl>
}
</%perl>
-
-<&| script &>
- function all_onload() {
-<% $onloads %>
- }
- window.onload= all_onload;
-</&>
diff --git
a/yarrg/web/routetrade
b/yarrg/web/routetrade
index 80fc2b13d5e8cf78f5ba1c61d0310e5de0280318..ce91b48726c40f4a59da3f5d8ad40f2204fb1e12 100644
(file)
--- a/
yarrg/web/routetrade
+++ b/
yarrg/web/routetrade
@@
-542,15
+542,10
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
% }
</table>
% }
</table>
-<& tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow',
+<&
|
tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow',
throw => 'trades_sort', tbrow => 'trades_total' &>
throw => 'trades_sort', tbrow => 'trades_total' &>
-<&| script &>
ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
- function all_onload() {
- ts_onload__trades();
- }
- window.onload= all_onload;
-</&script>
+</&tabsort>
<input type=submit name=update value="Update">
<input type=submit name=update value="Update">
diff --git
a/yarrg/web/tabsort
b/yarrg/web/tabsort
index 444bfb56b15f6e1b01e6e2ff74a29c1140209bb8..e114319a0254f4780bfcaa6071093d39f016f23f 100644
(file)
--- a/
yarrg/web/tabsort
+++ b/
yarrg/web/tabsort
@@
-54,6
+54,8
@@
$cols
<&| script &>
<&| script &>
+% print $m->content();
+
% my $sortfn= "ts_sort__$table";
function <% $sortfn %>(compar) {
debug('sorting compar='+compar);
% my $sortfn= "ts_sort__$table";
function <% $sortfn %>(compar) {
debug('sorting compar='+compar);
@@
-168,4
+170,6
@@
function ts_onload__<% $table %>() {
thlist.item(cix).innerHTML += ah;
}
}
thlist.item(cix).innerHTML += ah;
}
}
+
+register_onload(ts_onload__<% $table %>);
</&>
</&>