-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
105 lines (105 loc) · 6.85 KB
/
index.html
File metadata and controls
105 lines (105 loc) · 6.85 KB
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
<html>
<head>
<title>Worker Server</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico?bypass=1">
<script src="mime.js?bypass=1"></script>
<script src="jszip.js?bypass=1"></script>
<script src="utils.js?bypass=1"></script>
<script src="index.js?bypass=1"></script>
</head>
<body>
<noscript>This project requires javascript to work!</noscript>
<div style="padding: 20px;" id="main">
Choose Directory: <input type="file" webkitdirectory multiple id="files"><br><br>
Choose Zip: <input type="file" id="zip"><br>
<p><a href="/git.html?bypass=1">Git Clone Manager</a></p>
<input type="checkbox" id="index" name="index">
<label for="index"> Auto render index.html</label><br>
<input type="checkbox" id="noDotHtml" name="noDotHtml">
<label for="noDotHtml"> Exclude .html extension</label><br>
<input type="checkbox" id="put" name="put">
<label for="put"> Allow PUT request</label><br>
<div style="margin-left:20px;display:none;">
<input type="checkbox" id="overWrite" name="overWrite">
<label for="overWrite"> Allow overwriting existing files</label><br>
</div>
<input type="checkbox" id="delete" name="delete">
<label for="delete"> Allow DELETE request</label><br>
<input type="checkbox" id="noDirectoryListing" name="noDirectoryListing">
<label for="noDirectoryListing"> No directory listing</label><br>
<input type="checkbox" id="spa" name="spa">
<label for="spa"> Single Page App</label><br>
<input type="checkbox" id="renderMarkdown" name="renderMarkdown" checked>
<label for="renderMarkdown"> Render Markdown Files</label><br>
<div style="margin-left:20px;display:none;">
<label for="rewriteTo"> Rewrite To (for spa)</label>
<input type="text" id="rewriteTo" name="rewriteTo" value="/index.html" autocomplete="off"><br>
<label for="rewriteRegex"> Rewrite Regex</label>
<input type="text" id="rewriteRegex" name="rewriteRegex" value=".*\.[\d\w]+$" autocomplete="off"><br>
</div>
<input type="checkbox" id="deleteExisting" name="deleteExisting">
<label for="deleteExisting"> Do not delete existing files</label><br>
<input type="checkbox" id="baseFolder" name="baseFolder">
<label for="baseFolder"> Put all files in base folder</label><br>
<br>
<button id="submit">Submit</button><br><br>
<button id="dlAllFiles">Download all Files</button>
<p>No files will be uploaded to the server. All files are kept locally.</p>
<p id="message">Loading...</p>
<p id="size">Loading...</p>
<button id="clear">Clear storage</button><br><br>
<a href="/">Go to site</a><br><br>
<a href="/editor.html?bypass=1">Go to code editor</a>
</div>
<p style="margin-left: 20px;"><a href="https://github.com/ethanaobrien/worker-server">Worker Server</a> Version 3.7</p>
<script>
(async function() {
const msg = document.getElementById('message');
if (!("serviceWorker" in navigator)) {
document.getElementById('main').innerHTML = '<p>Service workers not available (are you on an https page?)</p>';
return;
}
if (!window.indexedDB) {
document.getElementById('main').innerHTML = '<p>IndexedDB not available. What browser are you using? Chrome 5?</p>';
return;
}
navigator.serviceWorker.register("worker.js?bypass=1");
navigator.serviceWorker.addEventListener('message', function(e) {
var data = e.data;
msg.innerHTML = data;
})
var registration = await navigator.serviceWorker.ready;
document.getElementById('submit').addEventListener('click', function(e) {
registration.active.postMessage('Processing files');
submitPressed(document.getElementById('files').files, document.getElementById('zip').files[0], isChecked('deleteExisting'), isChecked('baseFolder'));
})
registration.active.postMessage('Service worker ready');
var urlParams = new URLSearchParams(window.location.search);
var zip = urlParams.get('zip');
if (zip) {
registration.active.postMessage('Downloading zip');
zip = decodeURIComponent(zip);
try {
var res = await fetchZip(zip+'?bypass=1');
await submitPressed([], res, urlParams.has('deleteExisting'), urlParams.has('baseFolder'));
await put('opts?', {
index: (urlParams.has('index') && urlParams.get('index').toString() === 'true') || isChecked('index') || false,
noDotHtml: (urlParams.has('noDotHtml') && urlParams.get('noDotHtml').toString() === 'true') || isChecked('noDotHtml') || false,
put: (urlParams.has('put') && urlParams.get('put').toString() === 'true') || isChecked('put') || false,
overWrite: (urlParams.has('overWrite') && urlParams.get('overWrite').toString() === 'true') || isChecked('overWrite') || false,
delete: (urlParams.has('delete') && urlParams.get('delete').toString() === 'true') || isChecked('delete') || false,
spa: (urlParams.has('spa') && urlParams.get('spa').toString() === 'true') || isChecked('spa') || false,
noDirectoryListing: (urlParams.has('noDirectoryListing') && urlParams.get('noDirectoryListing').toString() === 'true') || isChecked('noDirectoryListing') || false,
rewriteTo: (urlParams.has('rewriteTo')&&decodeURIComponent(urlParams.get('rewriteTo'))) || document.getElementById('rewriteTo').value || '/index.html',
rewriteRegex: (urlParams.has('rewriteRegex')&&decodeURIComponent(urlParams.get('rewriteRegex'))) || document.getElementById('rewriteRegex').value || '.*\\.[\d\\w]+$',
renderMarkdown: (urlParams.has('renderMarkdown') && urlParams.get('renderMarkdown').toString() === 'true') || isChecked('renderMarkdown') || false
})
} catch(e) {
console.warn(e);
registration.active.postMessage('Error downloading zip (does the resource have cors headers?)');
}
}
})();
</script>
</body>
</html>