-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
190 lines (172 loc) · 6.39 KB
/
index.html
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta name="description" content="front_screenshot">
<meta name="author" content="Felipe Figueroa">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/test/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.21/c3.min.css">
<style>
.transparent {
opacity: 0;
}
#c3graph {
height: 300px;
}
</style>
<script src="test/vendor/bluebird.js"></script>
<script src="test/vendor/cash.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.21/c3.js"></script>
<script src="dist/ig_screenshot.js"></script>
<script src="test/c3_demo.js"></script>
<script>
window.globalvars = {
timeStart: Date.now()
};
console.zdebug = console.info.bind(console, '%cDEBUG:', "color:#A39;font-weight:bold;");
Object.defineProperty(console, "timerInfo", {
get: function () {
return Function.prototype.bind.call(
console.log,
console,
'%c' + parseInt((Date.now() - globalvars.timeStart) / 100, 10) / 10 + ' Timer:',
"color:#03C;font-weight:bold;"
);
}
});
$(document).ready(function () {
drawgraph();
screenShooter.html2canvas($('#text_container'), {
logging: true,
imageTimeout: 15000
}).then(function (the_canvas) {
$('#text_container').closest('tr').find('.transparent').removeClass('transparent');
document.getElementById('canvas_container1').appendChild(the_canvas);
});
screenShooter.svgToImg($('#svg_container1'), {
hideSVG: false
}).then(function (the_img) {
$('#svg_container1').closest('tr').find('.transparent').removeClass('transparent');
document.getElementById('image_container2').appendChild(the_img);
});
screenShooter.svgToCanvas($('#svg_container2'), {
hideSVG: false
}).then(function (the_canvas) {
$('#svg_container2').closest('tr').find('.transparent').removeClass('transparent');
document.getElementById('canvas_container3').appendChild(the_canvas);
});
screenShooter.svgToCanvas($('#c3graph'), {
hideSVG: false
}).then(function (the_canvas) {
document.getElementById('canvas_container4').appendChild(the_canvas);
});
screenShooter.svgToImg($('#c3graph'), {
hideSVG: false
}).then(function (the_img) {
document.getElementById('img_container4').appendChild(the_img);
});
$('#take_screenshot').removeClass('invisible').on('click', function () {
$('#downloadpng').remove();
screenShooter.html2canvas($('#container'), {
logging: true,
imageTimeout: 45000,
onclone: function (clone) {
console.log('onclone', clone);
}
}).then(function (canvas) {
var link = document.createElement('a');
link.target = '_blank';
link.id = 'downloadpng';
link.download = 'screenshot_' + Date.now() + '.png';
link.href = canvas.toDataURL("image/png");
link.textContent = 'downloading';
document.getElementById('buttoncontainer').appendChild(link);
link.click();
});
});
});
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div class="container" id="title">
<div class="row">
<div class="col col-sm-6">
<h4>Examples of Front Screenshot</h4> Dealing with text and SVG elements
</div>
<div class="col col-sm-5" id="buttoncontainer">
<div class="btn btn-info invisible" id="take_screenshot">Download Screenshot</div>
</div>
</div>
</div>
<div class="container" id="container">
<table class="table table-striped">
<tr class="row">
<td class="">
A text character
</td>
<td id="text_parent">
<div id="text_container" style="width:10px;height:12px;color:blue;font-size:10px;">A</div>
</td>
<td class="transparent">Is converted to the canvas to the right</td>
<td>
<div id="canvas_container1" style="width:30px;height:30px;"></div>
</td>
</tr>
<tr class="row">
<td class="">
An SVG element
</td>
<td class="">
<div id="svg_container1" style="width:10px;height:10px;">
<svg height="10" width="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="0" y="0" height="10" width="10" style="stroke:#ff0000; fill: #0000ff" />
</svg>
</div>
</td>
<td class="transparent">Is converted to the image to the right</td>
<td>
<div id="image_container2" style="width:10px;height:10px;"></div>
</td>
</tr>
<tr class="row">
<td>
Another SVG element
</td>
<td>
<div id="svg_container2" style="width:10px;height:10px;">
<svg height="10" width="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="0" y="0" height="10" width="10" style="stroke:#ff0000; fill: #0000ff" />
</svg>
</div>
</td>
<td class="transparent">Is converted to the canvas to the right</td>
<td>
<div id="canvas_container3" style="width:10px;height:10px;"></div>
</td>
</tr>
</table>
<div class="row">
<div class="col-sm-4">
A complex C3 graph
</div>
<div class="col-sm-4">
Can be converted to a canvas element
</div>
<div class="col-sm-4">
Or an image with a dataURI
</div>
<div class="col-sm-4" id="c3graph">
</div>
<div class="col-sm-4" id="canvas_container4">
</div>
<div class="col-sm-4" id="img_container4">
</div>
</div>
</div>
</body>
</html>