Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 76 additions & 19 deletions source-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,31 @@
<link rel="stylesheet" href="https://unpkg.com/basscss@7.1.1/css/basscss.min.css" integrity="sha384-/biuPsPEkt10QoeOExIADuWNrpFFXALKPgBhEDkRdKDJdQOPpbNU3uUeFbL/KPJg" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.5.0/hint.base.min.css" integrity="sha256-ODFgZG+Y3V10lzZu+7J8epM4SdW0w3p8qbVmmShNrtk=" crossorigin="anonymous">
<style type="text/css">
ul:nth-child(1) {
list-style-type: none;
position: absolute;
margin: 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these rules should be replaced with the basscss v7 rules. e.g. .m0 is margin: 0.

padding: 0;
overflow: hidden;
background-color: #333333;
position: fixed;
bottom: 0;
width: 100%;
z-index: 10;
}
.navbar li {
float: left;
}
.navbar li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
#content {
margin-top: 75px;
margin-bottom: 100px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using 3 margin rules, just use one with 4 values.

overflow-x: hidden;
}
#logo-text {
Expand Down Expand Up @@ -42,6 +65,7 @@
</style>
</head>
<body class="m2">
<ul class="navbar" id="navbar"></ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the id should suffice unless you have multiple navbars.

<div class="fixed top-0 col-12 py1 mr3 bg-white z1">
<a href="https://apertium.org" target="_blank" rel="noopener" class="mt2 text-decoration-none nowrap"> <!-- apertium.org is slow and hosts a large version -->
<img id="logo" alt="Apertium" height="50" src="data:image/png;base64,iVBORw0KGgoAAAANS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ZzH3vi6cFbH964f8M3d9pfAcMdhrTNp7i/ylj2x4JSBkbdaPcS7BP+EDcR1JNfXtn4d9zCeb7Ms7WXvP0fVkUKEGhETG4AAAAASUVORK5CYII">
Expand All @@ -67,21 +91,21 @@ <h1 id="loading" class="m1 center display-none">⌛</h1>
CACHE_KEY = `${ORGANIZATION}-cache`,
EXPIRY_KEY = `${ORGANIZATION}-expiry`,
EXPIRY_MILLIS = 60000,
TOPICS = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools'].map(topic => ({
LIST = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use entirely unhelpful variables names like list. In fact, this change isn't necessary at all. Just use the previous TOPICS variable for iteration and access the name attribute. e.g. TOPICS[0].name.

TOPICS = LIST.map(topic => ({
topic: `apertium-${topic}`,
name: topic,
repoUrl: `https://github.com/${ORGANIZATION}/apertium-${topic}`,
}));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this spacing change and the others.

async function getReposByTopic(organization) {
const headers = new Headers({ Accept: 'application/vnd.github.mercy-preview+json' });
const cacheStale = !(CACHE_KEY in localStorage) || localStorage[EXPIRY_KEY] < Date.now();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still unnecessary whitespace additions throughout this entire file that should be deleted. Something like 10 of them.

function _fetchRepos(page) {
const url = `https://api.github.com/orgs/${ORGANIZATION}/repos?page=${page}&per_page=100`;
return fetch(url, { headers });
}

let reposByTopic = {};
function _addRepos(repos) {
repos.forEach(repo => {
Expand All @@ -92,30 +116,30 @@ <h1 id="loading" class="m1 center display-none">⌛</h1>
});
});
}

if (cacheStale) {
console.warn('Repository list cache stale, updating.');

const response = await _fetchRepos(1);
_addRepos(await response.json());
const linkHeader = response.headers.get('Link');
const links = linkHeader ? linkHeader.split(',').map(x => x.split('; ')) : [];
const lastPage = links.length ? parseInt(links.find(([_, rel]) => rel === 'rel="last"')[0].match(/page=(\d+)/)[1]) : 1;

const remainingPages = [...Array(lastPage + 1).keys()].slice(2);
const responses = await Promise.all(remainingPages.map(_fetchRepos));
const reposs = await Promise.all(responses.map(response => response.json()));
reposs.forEach(_addRepos);

localStorage[CACHE_KEY] = JSON.stringify(reposByTopic);
localStorage[EXPIRY_KEY] = Date.now() + EXPIRY_MILLIS;
} else {
reposByTopic = JSON.parse(localStorage[CACHE_KEY]);
}

return Promise.resolve(reposByTopic);
}

async function showTopics() {
$('#topics, #loading').toggleClass('display-none');

Expand All @@ -132,7 +156,7 @@ <h1 id="loading" class="m1 center display-none">⌛</h1>
$('#topics').append(
$('<div class="topic flex-auto">').append(
$('<div>').append(
$('<h2 class="inline-block m0">').text(name),
$('<h2 class="inline-block m0" id="topic" style="padding-top:75px; margin-top:-75px;">').text(name),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use inline styling. Instead, style the associated class. Furthermore, this creates multiple elements with the same id, i.e. topic. This is illegal HTML. Instead, something like topic-languages etc. might work for your purposes.

$('<a class="ml1 text-decoration-none" target="_blank" rel="noopener">🔗</a>', {
href: repoUrl,
}),
Expand All @@ -141,7 +165,8 @@ <h1 id="loading" class="m1 center display-none">⌛</h1>
repoList,
),
);

$("[id=topic]").attr("id", name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment.


const repos = reposByTopic[topic] || [];
repos
.sort((a, b) => a.name.localeCompare(b.name))
Expand All @@ -166,28 +191,60 @@ <h1 id="loading" class="m1 center display-none">⌛</h1>
),
);
});

$('#topics, #loading').toggleClass('display-none');
}

function refreshTopics() {
localStorage.clear();
showTopics();
}

function showSearchInput() {
$('#search')
.removeClass('display-none')
.focus();
}


$(window).scroll(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use only arrow functions for anonymous functions.

let top = $(window).scrollTop();
let bottom = $(window).scrollTop() + $(window).height();
for(let i = 0; i < LIST.length; i++){
let heading = LIST[i];
let vartop = $('#'+heading).position();
if(top < vartop.top && vartop.top < bottom){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please emulate spacing in the rest of this code.

$('#li'+heading).hide();
}
else{
$('#li'+heading).show();
let $heading = $('#li'+heading);
if(vartop.top>bottom){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing between binary operations here and throughout should be consistent with existing code.

$heading.text(heading+'↓')
}
else {
$heading.text(heading+'↑')
}
}
}
});

$(document).ready(() => {
$("#navbar").append('<li id="li"></li>');
for(let i = 0; i < LIST.length; i++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of stylistic consistency, use forEach here. It might even be nicer with a map to create the elements and then appending the entire list to the container.

$("#li").append('<a id="placeholder"></a>');
$("[id=placeholder]").attr({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an anti-pattern. Use the way that multiple attributes are added to an element throughout the existing code, i.e. an object containing the attributes is passed as the second argument to $(...) when creating the element.

'href': '#' + LIST[i],
'id': 'li' + LIST[i],
});
$("[id=placeholder]").text(LIST[i]);
}

$('#github-link').attr('href', `https://github.com/${ORGANIZATION}`);
$('#refresh').click(({ currentTarget }) => {
currentTarget.blur();
refreshTopics();
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert spacing change here.

$('#search').on('input', showTopics);
$(document.body).keypress(({ target, altKey, ctrlKey, metaKey, key }) => {
if (target === document.body && !altKey && !ctrlKey && !metaKey) {
Expand All @@ -201,10 +258,10 @@ <h1 id="loading" class="m1 center display-none">⌛</h1>
showSearchInput();
}
});

setInterval(refreshTopics, EXPIRY_MILLIS * 2);
showTopics();
});
</script>
</body>
</html>
</html>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert your changes that deleted the final blank line in this file.