Ophir LOJKINE 4 anni fa
parent
commit
259486b855
1 ha cambiato i file con 13 aggiunte e 10 eliminazioni
  1. 13
    10
      client-data/tools/download/download.js

+ 13
- 10
client-data/tools/download/download.js Vedi File

33
         // Copy the stylesheets from the whiteboard to the exported SVG
33
         // Copy the stylesheets from the whiteboard to the exported SVG
34
         styleNode.innerHTML = Array.from(document.styleSheets)
34
         styleNode.innerHTML = Array.from(document.styleSheets)
35
             .filter(function (stylesheet) {
35
             .filter(function (stylesheet) {
36
-                if(stylesheet.href && (stylesheet.href.match(/boards\/tools\/.*\.css/)
36
+                if (stylesheet.href && (stylesheet.href.match(/boards\/tools\/.*\.css/)
37
                     || stylesheet.href.match(/board\.css/))) {
37
                     || stylesheet.href.match(/board\.css/))) {
38
                     // This is a Stylesheet from a Tool or the Board itself, so we should include it
38
                     // This is a Stylesheet from a Tool or the Board itself, so we should include it
39
                     return true;
39
                     return true;
45
                 return Array.from(stylesheet.cssRules).map(
45
                 return Array.from(stylesheet.cssRules).map(
46
                     function (rule) {
46
                     function (rule) {
47
                         return rule.cssText
47
                         return rule.cssText
48
-                }
49
-            )}
50
-        ).join("\n")
48
+                    }
49
+                )
50
+            }
51
+            ).join("\n")
51
 
52
 
52
         canvasCopy.appendChild(styleNode);
53
         canvasCopy.appendChild(styleNode);
53
-        downloadContent(new Blob([canvasCopy.outerHTML || new XMLSerializer().serializeToString(canvasCopy)], { type: 'image/svg+xml;charset=utf-8' }), Tools.boardName + ".svg")
54
+        var outerHTML = canvasCopy.outerHTML || new XMLSerializer().serializeToString(canvasCopy);
55
+        var blob = new Blob([outerHTML], { type: 'image/svg+xml;charset=utf-8' });
56
+        downloadContent(blob, Tools.boardName + ".svg");
54
     }
57
     }
55
 
58
 
56
-    function downloadContent(blob, filename){
57
-        if (window.navigator.msSaveBlob) {
59
+    function downloadContent(blob, filename) {
60
+        if (window.navigator.msSaveBlob) { // Internet Explorer
58
             window.navigator.msSaveBlob(blob, filename);
61
             window.navigator.msSaveBlob(blob, filename);
59
-          } else {
62
+        } else {
60
             const url = URL.createObjectURL(blob);
63
             const url = URL.createObjectURL(blob);
61
             var element = document.createElement('a');
64
             var element = document.createElement('a');
62
             element.setAttribute('href', url);
65
             element.setAttribute('href', url);
63
-            element.setAttribute('download',  filename);
66
+            element.setAttribute('download', filename);
64
             element.style.display = 'none';
67
             element.style.display = 'none';
65
             document.body.appendChild(element);
68
             document.body.appendChild(element);
66
             element.click();
69
             element.click();
67
             document.body.removeChild(element);
70
             document.body.removeChild(element);
68
             window.URL.revokeObjectURL(url);
71
             window.URL.revokeObjectURL(url);
69
-          }
72
+        }
70
     }
73
     }
71
 
74
 
72
     Tools.add({ //The new tool
75
     Tools.add({ //The new tool

Loading…
Annulla
Salva