summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7e9a114)
Only json loading from multichoice to start with.
+class WordMemory extends WordQuiz {
turn(click) {
let target = click.currentTarget;
if (!target.classList.contains('turn')) {
turn(click) {
let target = click.currentTarget;
if (!target.classList.contains('turn')) {
.forEach(card => put(card, '!.turn!.bad'));
}
.forEach(card => put(card, '!.turn!.bad'));
}
this.dataurl = '/data/wordpairs.json';
fetch(this.dataurl).then(res => res.json()).then(pairs => {
this.turned = [];
this.dataurl = '/data/wordpairs.json';
fetch(this.dataurl).then(res => res.json()).then(pairs => {
this.turned = [];
Html({
raw => <<'EOT',
<script src="/word/put.min.js"></script>
Html({
raw => <<'EOT',
<script src="/word/put.min.js"></script>
+<script src="/word/quiz.js"></script>
<script src="/word/memory.js"></script>
<style>
/* cards */
<script src="/word/memory.js"></script>
<style>
/* cards */
EOT
});
say '<h1>memory</h1><p id="quiz"></p>';
EOT
});
say '<h1>memory</h1><p id="quiz"></p>';
+say "<script>new WordMemory()</script>";
+class WordMultiChoice extends WordQuiz {
next() {
let word = this.words.shift();
let form = put(this.form,
next() {
let word = this.words.shift();
let form = put(this.form,
- 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
- this.next();
- });
+ setup() {
+ this.form = document.getElementById('quiz');
+ this.next();
Html({
raw => <<'EOT',
<script src="/word/put.min.js"></script>
Html({
raw => <<'EOT',
<script src="/word/put.min.js"></script>
+<script src="/word/quiz.js"></script>
<script src="/word/multichoice.js"></script>
<style>
img {
<script src="/word/multichoice.js"></script>
<style>
img {
});
say '<h1 id=quiz>quiz</h1>';
});
say '<h1 id=quiz>quiz</h1>';
-say "<script>new Quiz('/$wordlistbase.json')</script>";
+say "<script>new WordMultiChoice('/$wordlistbase.json')</script>";
--- /dev/null
+class WordQuiz {
+ dataselect(json) {
+ let rows = Object.values(json);
+ return rows.sort(() => {return .5 - Math.random()}) // shuffle
+ }
+
+ load(dataurl) {
+ fetch(dataurl).then(res => res.json()).then(json => {
+ this.words = this.dataselect(json)
+ this.setup();
+ });
+ }
+
+ constructor(dataurl) {
+ this.load(dataurl);
+ }
+}