Skip to content

Commit 5c28fb9

Browse files
committed
More NovaCast work
1 parent 5344397 commit 5c28fb9

File tree

3 files changed

+21
-35
lines changed

3 files changed

+21
-35
lines changed

index.html

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
<script type="module" src="script.js"></script>
336336
<script type="module" src="libraries/foxywm.js"></script>
337337
<div class="cur"></div>
338+
<script src="libraries/ht2canvas.js"></script>
338339
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
339340
</body>
340341

libraries/ht2canvas.js

+3-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/novacast.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import './ht2canvas.js'
21
window.novacast = {
3-
test: function(){
4-
html2canvas(document.body).then(canvas => {
5-
let canvasUrl = canvas.toDataURL();
6-
console.log(canvasUrl);
7-
let createEl = document.createElement('a');
8-
createEl.href = canvasUrl;
9-
10-
// This is the name of our downloaded file
11-
createEl.download = "download-this-canvas";
12-
13-
// Click the download button, causing a download, and then remove it
14-
createEl.click();
15-
createEl.remove();
16-
});
2+
test: function () {
3+
alert()
4+
domtoimage.toPng(document.body.parentElement)
5+
.then(function (dataUrl) {
6+
let createEl = document.createElement('a');
7+
createEl.href = dataUrl;
8+
9+
// This is the name of our downloaded file
10+
createEl.download = "download-this-canvas";
11+
12+
// Click the download button, causing a download, and then remove it
13+
createEl.click();
14+
createEl.remove();
15+
})
16+
.catch(function (error) {
17+
console.error('oops, something went wrong!', error);
18+
});
1719
}
1820
}

0 commit comments

Comments
 (0)