천현우

Merge branch 'python-download' into 'main'

Home: python file download



See merge request !6
...@@ -122,19 +122,11 @@ button:hover{ ...@@ -122,19 +122,11 @@ button:hover{
122 padding:10px; 122 padding:10px;
123 margin:20px; 123 margin:20px;
124 display:flex; 124 display:flex;
125 -<<<<<<< HEAD
126 - padding: 10px;
127 - height:700px;
128 - background-color:rgba(0,0,0,.87);
129 - color:var(--text-color);
130 - font-size:20px;
131 -=======
132 font-size:20px; 125 font-size:20px;
133 height:700px; 126 height:700px;
134 background-color:rgba(0,0,0,.87); 127 background-color:rgba(0,0,0,.87);
135 color:var(--text-color); 128 color:var(--text-color);
136 font-family: 'Raleway', 'Noto Serif KR'; 129 font-family: 'Raleway', 'Noto Serif KR';
137 ->>>>>>> e948ff4325bc9174b01571ab61b4339fdec7cbdf
138 } 130 }
139 #recordButton{ 131 #recordButton{
140 line-height: 22px; 132 line-height: 22px;
......
1 +//download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage
2 +// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
3 +// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
4 +// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support
5 +
6 +// data can be a string, Blob, File, or dataURL
7 +
8 +
9 +
10 +
11 +function download(data, strFileName, strMimeType) {
12 +
13 + var self = window, // this script is only for browsers anyway...
14 + u = "application/octet-stream", // this default mime also triggers iframe downloads
15 + m = strMimeType || u,
16 + x = data,
17 + D = document,
18 + a = D.createElement("a"),
19 + z = function(a){return String(a);},
20 +
21 +
22 + B = self.Blob || self.MozBlob || self.WebKitBlob || z,
23 + BB = self.MSBlobBuilder || self.WebKitBlobBuilder || self.BlobBuilder,
24 + fn = strFileName || "download",
25 + blob,
26 + b,
27 + ua,
28 + fr;
29 +
30 + //if(typeof B.bind === 'function' ){ B=B.bind(self); }
31 +
32 + if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
33 + x=[x, m];
34 + m=x[0];
35 + x=x[1];
36 + }
37 +
38 +
39 +
40 + //go ahead and download dataURLs right away
41 + if(String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)){
42 + return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
43 + navigator.msSaveBlob(d2b(x), fn) :
44 + saver(x) ; // everyone else can save dataURLs un-processed
45 + }//end if dataURL passed?
46 +
47 + try{
48 +
49 + blob = x instanceof B ?
50 + x :
51 + new B([x], {type: m}) ;
52 + }catch(y){
53 + if(BB){
54 + b = new BB();
55 + b.append([x]);
56 + blob = b.getBlob(m); // the blob
57 + }
58 +
59 + }
60 +
61 +
62 +
63 + function d2b(u) {
64 + var p= u.split(/[:;,]/),
65 + t= p[1],
66 + dec= p[2] == "base64" ? atob : decodeURIComponent,
67 + bin= dec(p.pop()),
68 + mx= bin.length,
69 + i= 0,
70 + uia= new Uint8Array(mx);
71 +
72 + for(i;i<mx;++i) uia[i]= bin.charCodeAt(i);
73 +
74 + return new B([uia], {type: t});
75 + }
76 +
77 + function saver(url, winMode){
78 +
79 +
80 + if ('download' in a) { //html5 A[download]
81 + a.href = url;
82 + a.setAttribute("download", fn);
83 + a.innerHTML = "downloading...";
84 + D.body.appendChild(a);
85 + setTimeout(function() {
86 + a.click();
87 + D.body.removeChild(a);
88 + if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(a.href);}, 250 );}
89 + }, 66);
90 + return true;
91 + }
92 +
93 + //do iframe dataURL download (old ch+FF):
94 + var f = D.createElement("iframe");
95 + D.body.appendChild(f);
96 + if(!winMode){ // force a mime that will download:
97 + url="data:"+url.replace(/^data:([\w\/\-\+]+)/, u);
98 + }
99 +
100 +
101 + f.src = url;
102 + setTimeout(function(){ D.body.removeChild(f); }, 333);
103 +
104 + }//end saver
105 +
106 +
107 + if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
108 + return navigator.msSaveBlob(blob, fn);
109 + }
110 +
111 + if(self.URL){ // simple fast and modern way using Blob and URL:
112 + saver(self.URL.createObjectURL(blob), true);
113 + }else{
114 + // handle non-Blob()+non-URL browsers:
115 + if(typeof blob === "string" || blob.constructor===z ){
116 + try{
117 + return saver( "data:" + m + ";base64," + self.btoa(blob) );
118 + }catch(y){
119 + return saver( "data:" + m + "," + encodeURIComponent(blob) );
120 + }
121 + }
122 +
123 + // Blob but not URL:
124 + fr=new FileReader();
125 + fr.onload=function(e){
126 + saver(this.result);
127 + };
128 + fr.readAsDataURL(blob);
129 + }
130 + return true;
131 +} /* end download() */
132 +
File mode changed