Show previous repo/file lists

This commit is contained in:
Shadowfacts 2016-10-02 10:34:57 -04:00
parent b2fac20cc6
commit 3650355593
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
5 changed files with 124 additions and 8 deletions

View File

@ -1,3 +1,14 @@
/* General */
.error {
border: 1px solid red;
border-radius: 3px;
background-color: rgba(255, 0, 0, 0.5);
padding: 5px;
font-size: 2em;
font-family: "Helvetica", Arial, sans-serif;
}
/* Editor */
.invalid {
background-color: red;
color: white !important;
@ -13,11 +24,24 @@
height: 100%;
}
.error {
border: 1px solid red;
border-radius: 3px;
background-color: rgba(255, 0, 0, 0.5);
padding: 5px;
font-size: 2em;
font-family: "Helvetica", Arial, sans-serif;
/* Index */
.prev-list {
padding: 0px;
margin: 0px;
}
.prev-list > li {
display: inline-block;
width: 30%;
list-style: none;
margin: 5px;
padding: 5px;
border: #CCC 1px solid;
border-radius: 3px;
}
.prev-list > li > a,
.prev-list > li > a:visited {
text-decoration: none;
color: blue;
}

View File

@ -13,7 +13,14 @@
</div>
<br>
</noscript>
<h2>Previous Repos</h2>
<div>
<ul class="prev-list" id="prev-repos"></ul>
</div>
<h2>New Repo</h2>
<form id="form">
<input type="text" id="repo" placeholder="owner/repo" required="true">
<br>
@ -21,10 +28,11 @@
<br>
<input type="text" id="file" placeholder="path/to/file.js" required="true">
<br>
<input type="submit" id="type" value="Type">
<input type="submit" value="Type">
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.4.2/localforage.min.js"></script>
<script src="/js/index.js"></script>
</body>
</html>

View File

@ -1,3 +1,27 @@
let prevRepoList = $("#prev-repos");
localforage.keys()
.then((keys) => {
return keys.filter((el) => {
return el != "theme";
});
})
.then((repos) => {
repos.forEach((el) => {
let li = $("<li></li>");
let a = $("<a></a>");
a.attr("href", `/repo.html#${el}`);
let div = $("<div></div>");
div.text(el);
a.append(div);
li.append(a);
prevRepoList.append(li);
});
})
.catch((e) => {
throw e;
});
$("#form").submit((event) => {
event.preventDefault();

25
js/repo.js Normal file
View File

@ -0,0 +1,25 @@
let repo = window.location.hash.substring(1);
localforage.getItem(repo)
.then((val) => {
for (var f in val) {
let li = $("<li></li>");
let a = $("<a></a>");
a.attr("href", `/type.html#${repo}/${f}`);
let div = $("<div></div>");
div.text(f);
a.append(div);
li.append(a);
$("#prev-files").append(li);
}
})
.catch((e) => {
throw e;
});
$("#form").submit((event) => {
event.preventDefault();
let file = $("#file").val();
window.location.href = `/type.html#${repo}/${file}`;
});

35
repo.html Normal file
View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Type</title>
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<noscript>
<div class="error">
JavaScript must be enabled.
</div>
<br>
</noscript>
<h1 id="repo"></h1>
<h2>Previous Files</h2>
<div>
<ul class="prev-list" id="prev-files"></ul>
</div>
<h2>New File</h2>
<form id="form">
<input type="text" id="file" placeholder="path/to/file.js" required="true">
<br>
<input type="submit" value="Type">
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.4.2/localforage.min.js"></script>
<script src="/js/repo.js"></script>
</body>
</html>