-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkids_mult_worksheet.html
More file actions
199 lines (183 loc) ยท 7.36 KB
/
kids_mult_worksheet.html
File metadata and controls
199 lines (183 loc) ยท 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animal Math Worksheet</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Emoji&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.worksheet {
display: flex;
justify-content: space-between;
}
.column {
width: 48%;
}
.problem {
margin-bottom: 30px;
}
.emoji-line {
font-size: 24px;
line-height: 1.5;
text-align: right;
}
.answer-line {
border-top: 1px solid #000;
height: 30px;
}
.printable .emoji-line {
font-family: 'Noto Emoji', sans-serif;
}
#controls {
margin-bottom: 20px;
}
.problem-line {
display: flex;
justify-content: space-between;
}
@media print {
#controls {
display: none;
}
}
</style>
</head>
<body>
<div id="controls">
<h1>Kids Multiplication Worksheet</h1>
<button onclick="generateWorksheet()">Generate New Worksheet</button>
<label>
<input type="checkbox" id="printable" onchange="togglePrintable()"> Printable
</label>
<button onclick="generatePDF()">Download as PDF</button>
</div>
<div id="worksheet-container">
<div class="worksheet" id="worksheet"></div>
</div>
<script>
const pairs = [
["๐", "car", "๐งณ", "suitcases"],
["๐", "car", "๐ฆ", "boys"],
["๐", "car", "๐ง", "girls"],
["๐", "car", "๐ฆ๐ฝ", "boys"],
["๐", "car", "๐ง๐พ", "girls"],
["๐ ", "house", "๐ท", "flowers"],
["๐ ", "house", "๐ช", "windows"],
["๐ ", "house", "๐ช", "doors"],
["๐ฎ", "cow", "๐ผ", "milk bottles", 'makes'],
["๐", "backpack", "๐", "books"],
["๐", "chicken", "๐ฅ", "eggs", 'makes'],
["๐ช", "cookie", "๐ซ", "chocolate chips"],
["๐", "pizza", "๐
", "tomatoes"],
["๐ณ", "lemon tree", "๐", "lemons"],
["๐ณ", "orange tree", "๐", "oranges"],
["๐ด", "coconut tree", "๐ฅฅ", "coconuts"],
["๐ฃ", "fishing rod", "๐", "fish", "catches"],
["๐จ", "art palette", "๐", "brushes"],
["๐", "tractor", "๐ฝ", "corn ears", 'makes'],
["๐", "dog", "๐ฆด", "bones"],
["๐ช", "tent", "๐", "tickets"],
["๐ช", "tent", "๐คก", "clowns"],
["๐ฆ", "bird", "๐ชถ", "feathers"],
["๐ชด", "plant", "๐ธ", "flowers"],
["๐", "rocket", "๐ช", "planets"],
[ "๐", "mouse", "๐ง", "cheese blocks", 'eats'],
["๐ธ", "guitar", "๐ถ", "music notes"],
["โบ", "campsite", "๐ฅ", "campfires"],
["๐", "monkey", "๐", "bananas"],
["๐", "tractor", "๐พ", "bales of hay"],
["๐", "dog", "๐พ", "paw prints", 'makes'],
["๐ข", "ship", "โ", "anchors"],
// ["๐", "roosters", "๐", "dawns"],
["๐", "cow", "๐ง", "cheese blocks", 'makes'],
["๐", "sheep", "๐งถ", "balls of wool"],
["๐", "elephant", "๐ด", "palm trees", 'eats'],
["๐ผ", "panda", "๐", "bamboo", 'eats'],
["๐", "lake", "๐ฆข", "swans"],
["๐", "hen", "๐ฃ", "eggs"],
["๐", "wave", "๐", "shells"],
["๐ ", "fish", "๐ซง", "bubbles", 'makes'],
["๐", "mushroom", "๐ธ", "frogs"],
["๐ท", "camera", "๐", "photos", 'takes'],
["๐", "pumpkin", "๐ฌ", "candies"],
["๐", "train", "๐", "carriages"]
];
function getRandomAnimal() {
return pairs[Math.floor(Math.random() * pairs.length)];
}
function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generateProblem() {
const pair = getRandomAnimal();
const em1 = pair[0];
const name1 = pair[1];
const em2 = pair[2];
const name2 = pair[3];
const verb = pair[4] || 'has';
const line1Count = getRandomNumber(2, 7);
const line2Count = getRandomNumber(2, 7);
return `
<div class="problem">
<p>Each <span class="emoji-line">${em1}</span> ${name1} ${verb} <span class="emoji-line">${em2}</span> ${name2}. How many <span class="emoji-line">${em2}</span> ${name2} are there?</p>
<div class="problem-line">
<div style="font-size: 2em"> ___</div><div class="emoji-line">${em1.repeat(line1Count)}</div>
</div>
<div class="problem-line">
<div style="font-size: 2em">X ___</div><div class="emoji-line">${em2.repeat(line2Count)}</div>
</div>
<div class="answer-line"></div>
</div>
`;
}
function generateWorksheet() {
const worksheet = document.getElementById('worksheet');
worksheet.innerHTML = '';
for (let col = 0; col < 2; col++) {
const column = document.createElement('div');
column.className = 'column';
for (let prob = 0; prob < 4; prob++) {
column.innerHTML += generateProblem();
}
worksheet.appendChild(column);
}
}
function togglePrintable() {
const isPrintable = document.getElementById('printable').checked;
document.body.classList.toggle('printable', isPrintable);
}
function generatePDF() {
const element = document.getElementById('worksheet-container');
const opt = {
margin: 10,
filename: 'kids_multiplication_worksheet.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
// Temporarily hide controls
document.getElementById('controls').style.display = 'none';
// Add title to the worksheet for PDF
const title = document.createElement('h1');
title.textContent = 'Kids Multiplication Worksheet';
element.insertBefore(title, element.firstChild);
html2pdf().set(opt).from(element).save().then(() => {
// Restore controls and remove title
document.getElementById('controls').style.display = 'block';
element.removeChild(title);
});
}
// Generate the initial worksheet
generateWorksheet();
</script>
</body>
</html>