Skip to content

Commit b9b092c

Browse files
save file
1 parent dd7a4f5 commit b9b092c

File tree

1 file changed

+40
-102
lines changed

1 file changed

+40
-102
lines changed

utils/webrtc/file-transfer/file-transfer.html

Lines changed: 40 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,48 @@
55
<head>
66

77
<title>file-transfer</title>
8-
<base href='https://javascript-2020.github.io/utils/webrtc/file-transfer/file-transfer.html'>
8+
9+
<base href='https://ext-code.com/utils/webrtc/file-transfer/'>
10+
<base href='https://javascript-2020.github.io/utils/webrtc/file-transfer/'>
11+
912
<link rel=icon type='image/png' href='image/file-transfer-30.png'>
1013

1114

15+
<script src='https://libs.ext-code.com/js/dom/component/component.js?{mod}'></script>
16+
1217
<script init>
1318
console.clear();
19+
console.log('webrtc-file-transfer.html');
20+
console.log();
1421
console.json=v=>console.log(JSON.stringify(v,null,4));
15-
var mod = {};
22+
var df=true,did='webrtc-file-transfer'
23+
;
1624

1725
var ext;
1826
var $;
1927
var datatype;
2028
var menumod;
2129
var keydown;
2230

31+
var menu;
32+
2333
var filemod;
2434
var log;
2535

2636

37+
//:
38+
39+
40+
mod.stack.add = init;
41+
2742
async function init(){
28-
debug('init',version);
43+
2944

3045
//keydown = keydown();
3146
menu = menumod();
32-
filemod = mod.filemod();
33-
log = mod.log();
47+
48+
filemod = mod.filemod;
49+
log = mod.log;
3450

3551
filemod.initmod({ext,$,menumod,menu,complete});
3652

@@ -49,10 +65,6 @@
4965

5066

5167

52-
init.complete();
53-
54-
55-
//:
5668

5769

5870
await initdom(document.body);
@@ -66,94 +78,33 @@
6678
}//init
6779

6880

69-
init.stack = [];
70-
init.stack.ct = 0;
71-
init.stack.total = 1;
72-
init.stack.mode = '';
73-
init.stack.complete = false;
74-
Object.defineProperty(init.stack,'add',{get:()=>{
75-
init.stack.total++;
76-
init.stack.mode && console[init.stack.mode]('add',init.stack.ct,init.stack.total);
77-
}});
78-
Object.defineProperty(init.stack,'complete',{get:()=>{
79-
init.stack.ct++;
80-
init.stack.mode && console[init.stack.mode]('complete',init.stack.ct,init.stack.total);
81-
init.stack.ct>=init.stack.total && init();
82-
}});
83-
84-
// (typeof init!='undefined' && init?.stack && init.stack.add)
85-
// (typeof init!='undefined' && init?.stack && init.stack.complete)
86-
87-
88-
init.complete = function(){
89-
90-
init.complete.stack.forEach(fn=>fn());
91-
92-
}//complete
93-
94-
init.complete.stack = [];
95-
init.complete.add = fn=>init.complete.stack.push(fn);
96-
97-
98-
9981
(async()=>{
100-
101-
init.stack.add;
102-
103-
104-
var url;
105-
var headers;
106-
var token = localStorage['github-token'];
107-
if(token){
108-
url = 'https://api.github.com/repos/javascript-2020/ext-code/contents/ext-loader.js';
109-
headers = {accept:'application/vnd.github.raw',authorization:`bearer ${token}`};
110-
}else{
111-
url = 'https://raw.githubusercontent.com/javascript-2020/ext-code/main/ext-loader.js';
112-
}
113-
114-
var res = await fetch(url,{headers});
115-
var txt = await res.text();
11682

117-
if(res.headers.get('content-type').includes('json')){
118-
console.log('*** ext : json');
119-
var json = JSON.parse(txt);
120-
var b64 = json.content;
121-
txt = atob(b64);
122-
}else{
123-
console.log('*** ext : text');
124-
}
83+
mod.stack.add;
12584

126-
ext = eval(txt);
127-
128-
85+
({ext} = await import('https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js'));
86+
12987
var promise = ext.load.libs(
13088
'js/dom/$.js',
13189
'js/core/datatype.js',
13290
'js/dom/menumod/menumod.js',
13391
'js/dom/keydown/keydown.js',
13492
);
135-
[$,datatype,menumod,keydown,encrypt] = await promise;
136-
137-
138-
init.stack.complete;
139-
93+
[$,datatype,menumod,keydown] = await promise;
94+
95+
mod.stack.complete;
96+
14097
})();
14198

99+
142100

143101
</script init>
144102

145103

146-
147-
148-
</head>
149-
150-
151-
<body>
152-
153104
<style id=page-inline>
154105

155106
html
156-
{height:100%}
107+
{height:100%;font-family:arial}
157108

158109
body
159110
{height:calc(100% - 40px);margin:20px;display:flex;flex-direction:column;gap:10px}
@@ -233,6 +184,13 @@
233184
}
234185

235186
</style>
187+
188+
189+
</head>
190+
191+
192+
<body>
193+
236194

237195

238196
<!--
@@ -259,9 +217,7 @@
259217
</div>
260218

261219

262-
<filemod-api>
263-
<script src='https://html-loader-1024713184986.us-central1.run.app/'></script>
264-
</filemod-api>
220+
<filemod component v2.0></filemod>
265221

266222

267223
<div id=message>
@@ -314,9 +270,7 @@
314270

315271

316272

317-
<log api>
318-
<script src='https://html-loader-1024713184986.us-central1.run.app/'></script>
319-
</log>
273+
<log component v2.0></log>
320274

321275

322276

@@ -326,11 +280,6 @@
326280

327281
<script>
328282

329-
var version = 'v1.0.0';
330-
331-
var df = true;
332-
333-
var menu;
334283

335284

336285
var img = {};
@@ -1149,26 +1098,15 @@
11491098

11501099
if(!df)return;
11511100
var str = [...arguments].join(' ');
1152-
console.log('[ file-transfer ]',str);
1101+
console.log(`[ ${did} ]`,str);
11531102

11541103
}//debug
11551104

11561105

1157-
debug.log = function(){
1158-
1159-
if(!df)return;
1160-
console.log.apply(console,arguments);
1161-
console.trace();
1162-
1163-
}//log
11641106

11651107

1166-
//:
11671108

11681109

1169-
init.stack.complete;
1170-
1171-
11721110
</script>
11731111

11741112

0 commit comments

Comments
 (0)