-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbookOGbackup.html
108 lines (95 loc) · 3.76 KB
/
bookOGbackup.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
<!DOCTYPE html>
<!-- Original books.html -->
<head>
<title>ATC Books</title>
<link href="main.css" type="text/css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
</head>
<body>
<div class="nav-wrapper">
<div class="left-nav">
<div class="nav-link-wrapper">
<a href="index.html">Home</a>
</div>
<div class="nav-link-wrapper ">
<a href="games.html">Games</a>
</div>
<div class="nav-link-wrapper active-nav-link">
<a href="books.html">Books</a>
</div>
<div class="nav-link-wrapper">
<a href="projects.html">Projects</a>
</div>
</div>
<div class="right-nav">
<div class="brand">
<div>ATC Game Center</div>
</div>
</div>
</div>
<div class="books-container" id="books-container">
<h2>ATC Books</h2>
</div>
<script>
docsURL = "https://docs.google.com/presentation/d/"; //only for presentations!!!!
ID_fileURL = "https://coding-girl314.github.io/AT-RedGreenGame/book_ID.txt"; //ID file on github
names_fileURL = "https://coding-girl314.github.io/AT-RedGreenGame/book_names.txt"; //Names file on github
async function* makeTextFileLineIterator(fileURL) {
const utf8Decoder = new TextDecoder('utf-8');
const response = await fetch(fileURL); //, {mode: 'no-cors'});
const reader = response.body.getReader();
let { value: chunk, done: readerDone } = await reader.read();
chunk = chunk ? utf8Decoder.decode(chunk) : '';
const re = /\n|\r|\r\n/gm;
let startIndex = 0;
let result;
for (;;) {
let result = re.exec(chunk);
if (!result) {
if (readerDone) {
break;
}
let remainder = chunk.substr(startIndex);
({ value: chunk, done: readerDone } = await reader.read());
chunk = remainder + (chunk ? utf8Decoder.decode(chunk) : '');
startIndex = re.lastIndex = 0;
continue;
}
yield chunk.substring(startIndex, result.index);
startIndex = re.lastIndex;
}
if (startIndex < chunk.length) {
// last line didn't end in a newline char
yield chunk.substr(startIndex);
}
}
var IDs = [];
var names = [];
async function run() {
for await (let line of makeTextFileLineIterator(ID_fileURL)) {
console.log(line);
IDs.push(line);
}
for await (let line of makeTextFileLineIterator(names_fileURL)) {
console.log(line);
names.push(line);
}
for (var i = 0; i < IDs.length; i++) {
if(names[i] == "Instructions to upload a book onto the atc website"){
i = i+1;
console.log('true')
}
//this is showing the book on our website - we can update it
var books_container = document.getElementById('books-container');
console.log(docsURL + IDs[i]);
var a1 = document.createElement('a');
a1.setAttribute('href', docsURL + IDs[i]);
a1.innerHTML = names[i];
books_container.appendChild(a1);
}
}
run();
</script>
</div>
</body>