forked from microsoft/pxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcertificates.html
More file actions
104 lines (87 loc) · 2.8 KB
/
certificates.html
File metadata and controls
104 lines (87 loc) · 2.8 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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta charset="UTF-8">
<title>Certificate</title>
<meta name="Description" content="Certificate" />
<!-- @include meta.html -->
<link rel="stylesheet" data-rtl="/doccdn/rtlsemantic.css" href="/doccdn/semantic.css">
<link ref="stylesheet" href="/doccdn/style.css" />
<script src="/doccdn/jquery.js"></script>
<style>
#template {
max-width: 20rem;
}
.certificate {
width: 100%;
}
.certificate canvas {
width: 100%;
}
@media only print {
.hideprint {
display: none !important;
}
}
</style>
</head>
<script>
function printCertificates() {
var cw = 1754;
var ch = 1235;
var $certs = $('#certificates');
$certs.empty();
var img = $('#template')[0];
$('#names').val().split(/\r?\n/).forEach(function (m) {
if (!m) return;
var cvs = document.createElement("canvas");
var ctx = cvs.getContext("2d");
cvs.width = cw;
cvs.height = ch;
ctx.textAlign = "center";
ctx.textBaseline = "center";
ctx.fillStyle = 'black';
ctx.font = '200px monospace';
ctx.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, 0, 0, cw, ch);
ctx.fillText(m, cw / 2, ch / 2);
var div = $(`<div class="certificate"></div>`);
div.append(cvs);
$certs.append(div);
})
try {
window.print();
} catch (e) { }
}
$(function () {
$('#print').click(printCertificates);
if (/^#name:/.test(window.location.hash)) {
$('#names').val(window.location.hash.substr("#name:".length));
printCertificates();
}
})
</script>
<body id='root' class='root'>
<div class="main ui container mainbody hideprint">
<h1>Microsoft MakeCode Certificate</h1>
<img id="template" class="ui medium image" src="/static/certificate.png" />
<div id="inputs" class="ui segment">
<div class="ui form">
<div class="field">
<label>Enter names</label>
<textarea id="names" rows="2"></textarea>
</div>
<div class="field">
<button id="print" class="ui primary button">
Print certificates
</button>
</div>
</div>
</div>
<p></p>
</div>
<div id="certificates">
</div>
<!-- @include footer.html -->
<!-- @include tracking.html -->
</body>
</html>