-
Notifications
You must be signed in to change notification settings - Fork 93
/
example.html
executable file
·48 lines (43 loc) · 1.34 KB
/
example.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GitZip Example</title>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/FileSaver.min.js"></script>
<script type="text/javascript" src="js/jszip.min.js"></script>
<script type="text/javascript" src="js/API.js"></script>
</head>
<body>
<script>
'use strict';
// call GitZip.zipRepo(url) with your url path to your github folder
// such as GitZip.zipRepo('https://github.com/kennethgoodman/gitzip/tree/gh-pages/js')
var exampleRx = /^\s*GitZip\.zipRepo\("([^"]+)"\);$/gm;
var createButtons = function (urls) {
urls.forEach(function (url) {
var button = document.createElement('button');
button.textContent = url;
button.addEventListener('click', function () {
GitZip.zipRepo(url);
});
document.body.appendChild(button);
document.body.appendChild(document.createElement('br'));
});
};
// fetches example URLs from the README
var req = new XMLHttpRequest();
req.open('GET', 'README.md');
req.overrideMimeType('text/plain');
req.onload = function (ev) {
var examples = [];
var match;
while (match = exampleRx.exec(this.responseText)) {
examples.push(match[1]);
}
createButtons(examples);
};
req.send();
</script>
</body>
</html>