summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-08-10 01:05:25 +0200
committerYorhel <git@yorhel.nl>2015-08-10 01:05:25 +0200
commiteabd513285a111442a11f7e62a53a48eb8931054 (patch)
tree41950c48bcf503cf30c3da3ad5dc2d15f9a03b8b /util
parent8447ba51583f6ac061688fd17ca78e3b77c6d76e (diff)
Split script.js into multiple smaller files
First part of a Javascript cleanup.
Diffstat (limited to 'util')
-rwxr-xr-xutil/jsgen.pl16
1 files changed, 13 insertions, 3 deletions
diff --git a/util/jsgen.pl b/util/jsgen.pl
index eb7d2a8a..1a003aea 100755
--- a/util/jsgen.pl
+++ b/util/jsgen.pl
@@ -97,6 +97,18 @@ sub resolutions {
}
+# Reads main.js and any included files.
+sub readjs {
+ my $f = shift || 'main.js';
+ open my $JS, '<:utf8', "$ROOT/data/js/$f" or die $!;
+ local $/ = undef;
+ local $_ = <$JS>;
+ close $JS;
+ s{^//include (.+)$}{readjs($1)}meg;
+ $_;
+}
+
+
sub jsgen {
l10n_load();
my $common = '';
@@ -119,9 +131,7 @@ sub jsgen {
sprintf('["%s","%s"]', $_, $lang{$_}{"_lang_$_"}||$lang{en}{"_lang_$_"}),
VNDB::L10N::languages());
- open my $JS, '<:utf8', "$ROOT/data/script.js" or die $!;
- my $js .= join '', <$JS>;
- close $JS;
+ my $js = readjs 'main.js';
for my $l (VNDB::L10N::languages()) {
my($head, $body) = l10n($l, $js);