summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-08-15 18:21:40 +0200
committerYorhel <git@yorhel.nl>2019-08-15 18:21:40 +0200
commita118b8550098e96c0c96ac9bd6567692156f8145 (patch)
tree390213454db867e34ee45834be406232821bda2a
parent5a173c85c30acd3c5d80f9a0b6dd250efb61ad81 (diff)
Add engine autocompletion to release filtersHEADmaster
-rw-r--r--data/js/filter.js16
-rw-r--r--lib/VNDB/Handler/Releases.pm24
2 files changed, 39 insertions, 1 deletions
diff --git a/data/js/filter.js b/data/js/filter.js
index 1258afc6..58105a84 100644
--- a/data/js/filter.js
+++ b/data/js/filter.js
@@ -397,6 +397,20 @@ function filFInput(c, n) {
]
}
+function filFEngine(c, n) {
+ var input = tag('input', {type: 'text', 'class': 'text', onfocus: selectField, onchange: serialize});
+ dsInit(input, '/xml/engines.xml?q=',
+ function(item, tr) { tr.appendChild(tag('td', shorten(item.firstChild.nodeValue, 40))); },
+ function(item, obj) { return item.firstChild.nodeValue; },
+ function(o) { selectField(o) }
+ );
+ return [ c, n, input,
+ function (c) { return [c.value] },
+ function (c, f) { c.value = f }
+ ]
+}
+
+
function filFOptions(c, n, opts) {
var p = tag('p', {'class':'opts', fil_val:opts[0][0]});
var sel = function (e) {
@@ -628,7 +642,7 @@ function filReleases() {
filFSelect('voiced', 'Voiced', 5, VARS.voiced),
filFSelect('ani_story', 'Story animation', 5, VARS.animated),
filFSelect('ani_ero', 'Ero animation', 5, VARS.animated),
- filFInput('engine', 'Engine')
+ filFEngine('engine', 'Engine')
]
];
}
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 0c649cc4..60de9fb5 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -15,6 +15,7 @@ TUWF::register(
=> \&edit,
qr{r/engines} => \&engines,
qr{xml/releases.xml} => \&relxml,
+ qr{xml/engines.xml} => \&enginexml,
);
@@ -707,5 +708,28 @@ sub relxml {
}
+sub enginexml {
+ my $self = shift;
+
+ # The list of engines happens to be small enough for this to make sense, and
+ # fetching all unique engines from the releases table also happens to be fast
+ # enough right now, but this may need a separate cache or index in the future.
+ my $lst = $self->dbReleaseEngines();
+
+ my $f = $self->formValidate(
+ { get => 'q', required => 1, maxlength => 500 },
+ );
+ return $self->resNotFound if $f->{_err};
+
+ $self->resHeader('Content-type' => 'text/xml; charset=UTF-8');
+ xml;
+ tag 'engines';
+ for(grep $_->{engine} =~ /\Q$f->{q}\E/i, @$lst) {
+ tag 'item', count => $_->{cnt}, $_->{engine};
+ }
+ end;
+}
+
+
1;