-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
87 lines (73 loc) · 2.39 KB
/
Copy pathscript.js
File metadata and controls
87 lines (73 loc) · 2.39 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
//window.addEventListener("load", ()=>{ if (screen.width < 900) { alert('הממשק נתמך רק במחשב ולא במובייל.. /-:'); } });
const setValue = (value, target, property) => {
document.querySelector(target).style[property] = value;
}
const setText = (value, target) => {
document.querySelector(target).innerText = value;
}
const setImge = (element, target, type) => {
if (type=='bgi'){
document.querySelector(target).style.backgroundImage = element.style.backgroundImage;
}
else {
document.querySelector(target).src = element.style.backgroundImage.split('url(\"')[1].split('\")')[0];
}
}
const createImge = (element) => {
element.style.display = 'none';
let node = document.querySelector('.container');
domtoimage.toPng(node)
.then(function (dataUrl) {
printCard(dataUrl);
element.style.display = 'inline-block';
})
.catch(function (error) {
console.error('oops, something went wrong!', error);
element.style.display = 'inline-block';
});
}
const printCard = (src) => {
let style = `
<style>
p {
font-family: arial;
text-align: center;
color: silver;
}
.print-table {
width: 100%;
}
.print-table td {
height: 140px;
text-align: center;
overflow: visible;
}
.print-table td img {
width: 110%;
}
button {
display: block;
margin: auto;
padding: 10px 20px;
}
@media print {
button { display: none; }
}
</style>
`;
let result = '<button onclick="print()">הדפס</button><p>לעילוי נשמת שמואל בן בוקא</p><table class="print-table">';
for (let index = 0; index < 6; index++) {
result += '<tr><td><img src="'+ src +'"></td><td><img src="'+ src +'"></tr>'
}
result += "</table>";
let printWindow = window.open("", "פורים שמח להדפסה", "_blank");
printWindow.document.write(style + result);
}
const openImge = (element) => {
element.style.display = 'none';
domtoimage.toBlob(document.querySelector('.container'))
.then(function (blob) {
window.saveAs(blob, 'פורים שמח.png');
element.style.display = 'inline-block';
});
}