Skip to content

Commit

Permalink
Show table only after extra data is done loading
Browse files Browse the repository at this point in the history
Prevents the user from seeing the table load first, then extra information come in.
Also move the link from the version to the dependency name
  • Loading branch information
BrainMaestro committed Feb 19, 2017
1 parent c9a9fd2 commit 59e4cdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions src/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function display(deps, devDeps, config) {
addDependencies(body, devDeps, config.registry, true);

header.textContent = 'Dependencies (' + config.name + ')';
header.style.display = 'none';
table.style.display = 'none';
tableHeaders.forEach(addTableHeader);
table.appendChild(body);

Expand All @@ -30,13 +32,15 @@ function addDependencies(body, deps, registry, dev) {
body.appendChild(subHeader(dev))
}

for (dep in deps) {
for (depName in deps) {
var row = document.createElement('tr');
row.appendChild(textData(dep));
row.appendChild(versionData(deps[dep]));
addName(row, depName);
addVersion(row, deps[depName]);
addVersion(row, '-');
row.appendChild(document.createElement('td')); // description
body.appendChild(row);

registry(dep, addExtraData.bind(row));
registry(depName, addExtraData.bind(row));
}
}

Expand All @@ -53,34 +57,30 @@ function subHeader(dev) {
return row;
}

function textData(text) {
function addName(row, name) {
var td = document.createElement('td');
td.textContent = text;

return td;
var anchor = document.createElement('a');
anchor.textContent = name;
td.appendChild(anchor);
row.appendChild(td);
}

function versionData(version, link) {
function addVersion(row, version) {
var td = document.createElement('td');
var code = document.createElement('code');

if (link) {
var anchor = document.createElement('a');
anchor.textContent = version;
anchor.setAttribute('href', link);
code.appendChild(anchor);
} else {
code.textContent = version;
}

code.textContent = version;
td.appendChild(code);

return td;
row.appendChild(td);
}

function addExtraData(latestVersion, description, homepage) {
this.appendChild(versionData(latestVersion, homepage));
this.appendChild(textData(description));
data = this.getElementsByTagName('td');
data[0].children[0].setAttribute('href', homepage);
data[2].children[0].textContent = latestVersion;
data[3].textContent = description;

this.parentNode.parentNode.style.display = 'block';
this.parentNode.parentNode.previousSibling.style.display = 'block';
}

window.display = display;
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Package Hub",
"version": "0.0.1",
"version": "0.1.0",
"manifest_version": 2,
"description": "Display dependencies for many package managers on GitHub",
"author": "Ezinwa Okpoechi",
Expand Down

0 comments on commit 59e4cdb

Please sign in to comment.