|
@@ -0,0 +1,53 @@
|
|
1
|
+/**
|
|
2
|
+ * WHITEBOPHIR
|
|
3
|
+ *********************************************************
|
|
4
|
+ * @licstart The following is the entire license notice for the
|
|
5
|
+ * JavaScript code in this page.
|
|
6
|
+ *
|
|
7
|
+ * Copyright (C) 2020 Ophir LOJKINE
|
|
8
|
+ *
|
|
9
|
+ *
|
|
10
|
+ * The JavaScript code in this page is free software: you can
|
|
11
|
+ * redistribute it and/or modify it under the terms of the GNU
|
|
12
|
+ * General Public License (GNU GPL) as published by the Free Software
|
|
13
|
+ * Foundation, either version 3 of the License, or (at your option)
|
|
14
|
+ * any later version. The code is distributed WITHOUT ANY WARRANTY;
|
|
15
|
+ * without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
16
|
+ * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
|
|
17
|
+ *
|
|
18
|
+ * As additional permission under GNU GPL version 3 section 7, you
|
|
19
|
+ * may distribute non-source (e.g., minimized or compacted) forms of
|
|
20
|
+ * that code without the copy of the GNU GPL normally required by
|
|
21
|
+ * section 4, provided you include this license notice and a URL
|
|
22
|
+ * through which recipients can access the Corresponding Source.
|
|
23
|
+ *
|
|
24
|
+ * @licend
|
|
25
|
+ */
|
|
26
|
+
|
|
27
|
+(function download() { //Code isolation
|
|
28
|
+
|
|
29
|
+ var canvas = document.getElementById('canvas');
|
|
30
|
+ function downloadFile(evt) {
|
|
31
|
+ var styleNode = document.createElement("style");
|
|
32
|
+ styleNode.innerHTML = "rect { fill:none; } path, line {fill: none;stroke-linecap: round; stroke-linejoin: round;}";
|
|
33
|
+ canvas.appendChild(styleNode);
|
|
34
|
+ var element = document.createElement('a');
|
|
35
|
+ element.setAttribute('href', 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(canvas.outerHTML));
|
|
36
|
+ element.setAttribute('download', "file.svg");
|
|
37
|
+ element.style.display = 'none';
|
|
38
|
+ document.body.appendChild(element);
|
|
39
|
+ element.click();
|
|
40
|
+ document.body.removeChild(element);
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ Tools.add({ //The new tool
|
|
44
|
+ "name": "Download",
|
|
45
|
+ "shortcut": "d",
|
|
46
|
+ "listeners": {},
|
|
47
|
+ "icon": "tools/download/download.svg",
|
|
48
|
+ "oneTouch": true,
|
|
49
|
+ "onstart": downloadFile,
|
|
50
|
+ "mouseCursor": "crosshair",
|
|
51
|
+ });
|
|
52
|
+
|
|
53
|
+})(); //End of code isolation
|