Skip to content

Commit 4a67d75

Browse files
committed
fix ts example
1 parent be8d39b commit 4a67d75

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.vscode/
1+
.vscode

ghDirList.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -86,36 +86,43 @@ var createListElement = function (linkArray) {
8686
return (listEl.innerHTML += "<li>\n <input type=\"button\" id=\"" + links[0] + "\">\n <label for=\"" + links[0] + "\">\n <a href='/" + links[0] + "'>" + links[0] + "</a>\n </label>\n </li>");
8787
}
8888
else {
89-
var innerLinks_1 = [], templateCollapse_1;
89+
var innerLinks = void 0, templateCollapse_1;
9090
Promise.all(links[1].map(function (url, i) {
9191
return fetch(url + "/README.md", fetchHeaders).then(function (resp) { return resp.text(); });
9292
}))
9393
.then(function (texts) {
94-
innerLinks_1 = links[1].map(function (link, i) {
94+
return links[1].map(function (link, i) {
9595
return "<li><a href=\"" + link + "\">" + converter.makeHtml(texts[i]) + "</a></li>";
9696
});
9797
})
98-
.then(function () {
99-
templateCollapse_1 = "<li><input type=\"checkbox\" id=\"" + links[0] + "\">\n <label for=\"" + links[0] + "\">" + links[0] + "</label>\n <ul class=\"" + links[0] + "\">\n " + innerLinks_1.join(" ") + "\n </ul></li>";
98+
.then(function (thing) {
99+
templateCollapse_1 = "<li><input type=\"checkbox\" id=\"" + links[0] + "\">\n <label for=\"" + links[0] + "\">" + links[0] + "</label>\n <ul class=\"" + links[0] + "\">\n " + thing.join(" ") + "\n </ul></li>";
100100
return (listEl.innerHTML += templateCollapse_1);
101101
});
102102
}
103103
});
104104
var domDoc = document;
105105
var wrapper = domDoc.querySelector(".wrapper");
106106
wrapper.innerHTML = "";
107-
domDoc.append(listEl);
107+
wrapper.append(listEl);
108108
};
109109
findGithubRepoContents("atomize", "atomize.github.io")
110110
.then(function (arr) { return dirFilter(arr, "tree"); })
111111
.then(function (paths) {
112-
paths.map(function (path, fetchedPaths) {
112+
var fetchedPaths = {
113+
rootPaths: {}
114+
};
115+
paths.map(function (path) {
116+
if (/^\./.test(path.path)) {
117+
return;
118+
}
113119
if (!path.path.includes("/")) {
114-
fetchedPaths.rootPaths;
120+
/* fetchedPaths.rootPaths; */
115121
fetchedPaths.rootPaths[path.path] = [];
116122
}
117123
else {
118124
var rootDir = path.path.split("/")[0];
125+
console.log(fetchedPaths.rootPaths[rootDir]);
119126
!fetchedPaths.rootPaths[rootDir]
120127
? (fetchedPaths.rootPaths[rootDir] =
121128
[] &&

ghDirList.ts

+17-14
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function findGithubRepoContents(username: string, repo: string) {
2626
return fullCommitTree.tree;
2727
}
2828

29-
const dirFilter = (response: any, type: string) => {
29+
const dirFilter = (response: string[], type: string) => {
3030
return response.filter((responseItem: any) => {
3131
if (responseItem.type === type) {
3232
return `${responseItem.path}`;
@@ -36,7 +36,7 @@ const dirFilter = (response: any, type: string) => {
3636

3737
const createListElement = (linkArray: any) => {
3838
let listEl = document.createElement("ul");
39-
linkArray.map((links: string[][]) => {
39+
linkArray.map((links: any) => {
4040
if (links[1].length == 0) {
4141
return (listEl.innerHTML += `<li>
4242
<input type="button" id="${links[0]}">
@@ -45,25 +45,24 @@ const createListElement = (linkArray: any) => {
4545
</label>
4646
</li>`);
4747
} else {
48-
let innerLinks: [] = [],
49-
templateCollapse;
48+
let innerLinks: [], templateCollapse;
5049
Promise.all(
5150
links[1].map((url: string, i: number) =>
5251
fetch(url + "/README.md", fetchHeaders).then(resp => resp.text())
5352
)
5453
)
55-
.then((texts: Array) => {
56-
innerLinks = links[1].map((link: string, i: number) => {
54+
.then((texts: any) => {
55+
return links[1].map((link: string, i: number) => {
5756
return `<li><a href="${link}">${converter.makeHtml(
5857
texts[i]
5958
)}</a></li>`;
6059
});
6160
})
62-
.then(() => {
61+
.then((thing: any) => {
6362
templateCollapse = `<li><input type="checkbox" id="${links[0]}">
6463
<label for="${links[0]}">${links[0]}</label>
6564
<ul class="${links[0]}">
66-
${innerLinks.join(" ")}
65+
${thing.join(" ")}
6766
</ul></li>`;
6867
return (listEl.innerHTML += templateCollapse);
6968
});
@@ -72,21 +71,25 @@ const createListElement = (linkArray: any) => {
7271
let domDoc = document;
7372
let wrapper = <Element>domDoc.querySelector(".wrapper");
7473
wrapper.innerHTML = "";
75-
domDoc.append(listEl);
74+
wrapper.append(listEl);
7675
};
7776

7877
findGithubRepoContents("atomize", "atomize.github.io")
7978
.then(arr => dirFilter(arr, "tree"))
8079
.then(paths => {
81-
interface fetchedPaths {
82-
rootPaths: {};
83-
}
84-
paths.map((path: any, fetchedPaths: fetchedPaths) => {
80+
let fetchedPaths = {
81+
rootPaths: <any>{}
82+
};
83+
paths.map((path: any) => {
84+
if (/^\./.test(path.path)) {
85+
return;
86+
}
8587
if (!path.path.includes("/")) {
86-
fetchedPaths.rootPaths;
88+
/* fetchedPaths.rootPaths; */
8789
fetchedPaths.rootPaths[path.path] = [];
8890
} else {
8991
let rootDir = path.path.split("/")[0];
92+
console.log(fetchedPaths.rootPaths[rootDir]);
9093
!fetchedPaths.rootPaths[rootDir]
9194
? (fetchedPaths.rootPaths[rootDir] =
9295
[] &&

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
33
/* Basic Options */
4-
"target": "es2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
4+
"target": "ES3" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
55
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
6-
"lib": ["dom", "es2015"],
6+
"lib": ["dom", "es2017"],
77
// "allowJs": true, /* Allow javascript files to be compiled. */
88
// "checkJs": true, /* Report errors in .js files. */
99
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */

0 commit comments

Comments
 (0)