Replace hardcoded nl include by same ?lang result as overview.
<(common.inc.plp)><:
+our $lang = $get{lang} || 'en';
+our $wordlistbase = "data/wordlist.$lang";
+
if ($Request and $Request =~ m{\A([^/]+)}) {
my $page = "word/$1.plp";
utf8::downgrade($page); # unicode filename breaks contents encoding
}
}
-my $lang = $get{lang} || 'en';
-my $wordlist = "data/wordlist.$lang.inc.pl";
+my $wordlist = "$wordlistbase.inc.pl";
my $limit = $get{v} // (exists $get{v} ? 4 : 3);
Html({
});
}
- constructor() {
- this.dataurl = '/data/wordlist.nl.json';
- fetch(this.dataurl).then(res => res.json()).then(json => {
+ constructor(dataurl) {
+ fetch(dataurl).then(res => res.json()).then(json => {
this.form = document.getElementById('quiz');
this.words = Object.values(json)
.sort(() => {return .5 - Math.random()}) // shuffle
});
}
};
-
-new Quiz();
<(../common.inc.plp)><:
+our $wordlistbase;
+
Html({
raw => <<'EOT',
<script src="/word/put.min.js"></script>
</style>
EOT
});
+
say '<h1 id=quiz>quiz</h1>';
+say "<script>new Quiz('/$wordlistbase.json')</script>";