forked from steveseguin/vdo.ninja
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileshare.html
167 lines (145 loc) · 3.67 KB
/
fileshare.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
<!DOCTYPE html>
<html>
<head>
<title>WebRTC File Sharing</title>
<style>
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
background-color: #f7f7f7;
}
/* Container Styles */
.container {
margin: 0 auto;
max-width: 600px;
padding: 20px;
background-color: #ffffff;
border-radius: 5px;
box-shadow: 0px 0px 5px rgba(0,0,0,0.1);
}
/* Header Styles */
h1 {
margin: 0;
text-align: center;
font-weight: normal;
font-size: 36px;
color: #333333;
margin-bottom: 20px;
}
/* File Selector Styles */
#file-selector {
display: flex;
flex-direction: column;
align-items: center;
margin: 20px;
}
#file-selector label {
font-size: 20px;
margin-bottom: 10px;
}
#file-selector input[type="file"] {
display: none;
}
#file-selector button {
font-size: 16px;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
#file-selector button:hover {
background-color: #3e8e41;
}
/* Progress Container Styles */
#progress-container {
display: none;
flex-direction: column;
align-items: center;
margin: 20px;
}
#progress-bar {
width: 100%;
height: 30px;
background-color: #f1f1f1;
border-radius: 5px;
overflow: hidden;
margin-bottom: 10px;
}
#progress-bar-inner {
height: 100%;
background-color: #4CAF50;
text-align: center;
line-height: 30px;
color: white;
transition: width 0.3s ease;
}
#status {
font-size: 16px;
margin-bottom: 10px;
}
#connections {
font-size: 14px;
color: #999999;
}
/* Input Styles */
input[type="file"] {
padding: 10px;
border-radius: 5px;
border: 1px solid #dddddd;
margin-bottom: 10px;
}
/* Button Styles */
button {
font-size: 16px;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<h1>WebRTC File Sharing</h1>
<div id="file-selector">
<label for="file-input">Select a file:</label>
<input type="file" id="file-input" />
<button id="share-button">Share</button>
</div>
<div id="progress-container" style="display:none">
<div id="progress-bar">
<div id="progress-bar-inner"></div>
</div>
<div id="status">Connecting...</div>
<div id="connections">0 connections</div>
</div>
<script>
var fileInput = document.getElementById("file-input");
var shareButton = document.getElementById("share-button");
var progressContainer = document.getElementById("progress-container");
var progressBarInner = document.getElementById("progress-bar-inner");
var status = document.getElementById("status");
var connections = document.getElementById("connections");
var connectionCount = 0;
shareButton.addEventListener("click", function() {
if (fileInput.files.length > 0) {
// Display progress bar and status message
progressContainer.style.display = "block";
status.innerText = "Connecting...";
// TODO: Use WebRTC to share the file with other users
// Update progress bar and status messages
progressBarInner.style.width = "100%";
status.innerText = "File shared successfully.";
}
});
// TODO: Use WebRTC to display the number of connections, progress, and speed
</script>
</body>
</html>