mirror of https://github.com/shadowfacts/type.git
Show previous repo/file lists
This commit is contained in:
parent
b2fac20cc6
commit
3650355593
38
css/main.css
38
css/main.css
|
@ -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 {
|
.invalid {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
color: white !important;
|
color: white !important;
|
||||||
|
@ -13,11 +24,24 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
/* Index */
|
||||||
border: 1px solid red;
|
.prev-list {
|
||||||
border-radius: 3px;
|
padding: 0px;
|
||||||
background-color: rgba(255, 0, 0, 0.5);
|
margin: 0px;
|
||||||
padding: 5px;
|
}
|
||||||
font-size: 2em;
|
|
||||||
font-family: "Helvetica", Arial, sans-serif;
|
.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;
|
||||||
}
|
}
|
||||||
|
|
10
index.html
10
index.html
|
@ -13,7 +13,14 @@
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
</noscript>
|
</noscript>
|
||||||
|
|
||||||
|
<h2>Previous Repos</h2>
|
||||||
|
<div>
|
||||||
|
<ul class="prev-list" id="prev-repos"></ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>New Repo</h2>
|
||||||
<form id="form">
|
<form id="form">
|
||||||
<input type="text" id="repo" placeholder="owner/repo" required="true">
|
<input type="text" id="repo" placeholder="owner/repo" required="true">
|
||||||
<br>
|
<br>
|
||||||
|
@ -21,10 +28,11 @@
|
||||||
<br>
|
<br>
|
||||||
<input type="text" id="file" placeholder="path/to/file.js" required="true">
|
<input type="text" id="file" placeholder="path/to/file.js" required="true">
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" id="type" value="Type">
|
<input type="submit" value="Type">
|
||||||
</form>
|
</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/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>
|
<script src="/js/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
24
js/index.js
24
js/index.js
|
@ -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) => {
|
$("#form").submit((event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
|
|
@ -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}`;
|
||||||
|
});
|
|
@ -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>
|
Loading…
Reference in New Issue