Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
patricaaz22 committed Jul 14, 2020
1 parent 408fc22 commit 16e9a39
Show file tree
Hide file tree
Showing 13 changed files with 354 additions and 315 deletions.
5 changes: 2 additions & 3 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": true,

"semi": true,
"singleQuote": true
}
6 changes: 2 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"skipFiles": ["<node_internals>/**"],
"program": "${file}"
}
]
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true
}
}
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ function checkEnter(e) {
if (e.keyCode === 13) {
// redirect query to packages.html
window.location.href =
'packages.html?query=' + document.getElementById('idx-search').value;
'packages.html?query=' +
document.getElementById('idx-search').value;
}
return false;
}
73 changes: 53 additions & 20 deletions dist/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ var getUrlParameter = function getUrlParameter(sParam) {
var query = getUrlParameter('query') || '';
$.getJSON('./output.json', function (responseObject) {
allPackages = responseObject.Source;
currentPackages = allPackages(document.getElementById('pkg-search')).value = query;
currentPackages = allPackages(
document.getElementById('pkg-search')
).value = query;
searchAndRenderPackages();
});
var renderModalDescription = function (fullDesc) {
Expand All @@ -53,7 +55,10 @@ var renderModalDescription = function (fullDesc) {
var extraDescSpan = parentExtraDescSpan.cloneNode(true);
extraDescSpan.textContent = fullDesc.substring(cutoff);
var moreDescSpan = parentMoreDescSpan.cloneNode(true);
moreDescSpan.addEventListener('click', expandText.bind(this, moreDescSpan, extraDescSpan));
moreDescSpan.addEventListener(
'click',
expandText.bind(this, moreDescSpan, extraDescSpan)
);
moreDescSpan.textContent = ' More...';
descriptionDiv.appendChild(moreDescSpan);
descriptionDiv.appendChild(extraDescSpan);
Expand Down Expand Up @@ -91,12 +96,15 @@ var renderCompability = function (pkg, packageDiv) {
var t = triples_1[_i];
var procStatusDiv = statusDiv.cloneNode(true);
var status = pkg[t];
var simplifiedStatus = status === 'pass' || status === 'fail' ? status : 'unknown';
var simplifiedStatus =
status === 'pass' || status === 'fail' ? status : 'unknown';
procStatusDiv.classList.add(simplifiedStatus);
// hide card if it doesn't pass the compatibility filter
if (packageDiv &&
if (
packageDiv &&
simplifiedStatus === 'fail' &&
compatFilter.indexOf(t) !== -1) {
compatFilter.indexOf(t) !== -1
) {
if (!packageDiv.classList.contains('hide')) {
packageDiv.classList.add('hide');
hiddenCount += 1;
Expand All @@ -105,7 +113,10 @@ var renderCompability = function (pkg, packageDiv) {
var procStatusFrag = document.createDocumentFragment();
var procStatusIconDiv = iconDiv.cloneNode(true);
procStatusIconDiv.setAttribute('alt', simplifiedStatus);
procStatusIconDiv.setAttribute('src', 'assets/' + simplifiedStatus + '.png');
procStatusIconDiv.setAttribute(
'src',
'assets/' + simplifiedStatus + '.png'
);
procStatusFrag.appendChild(procStatusIconDiv);
var procStatusName = document.createElement('span');
procStatusName.textContent = t;
Expand Down Expand Up @@ -161,7 +172,9 @@ parentGitHubCount.style.display = 'block';
var parentVersionDiv = document.createElement('div');
parentVersionDiv.className = 'package-version';
function renderPackageDetails(package, packageDiv, isCard) {
if (isCard === void 0) { isCard = true; }
if (isCard === void 0) {
isCard = true;
}
var detailFrag = document.createDocumentFragment();
if (isCard) {
var cardHeaderDiv = parentCardHeaderDiv.cloneNode(true);
Expand Down Expand Up @@ -208,7 +221,12 @@ function renderPackageDetails(package, packageDiv, isCard) {
btnSpan.appendChild(btnTxtSpan);
fullBtnSpan.appendChild(btnSpan);
var ghCount = parentGitHubCount.cloneNode(true);
ghCount.textContent = package.Stars(ghCount).setAttribute('aria-label', package.Stars)(ghCount).href = homepageURL;
ghCount.textContent = package
.Stars(ghCount)
.setAttribute(
'aria-label',
package.Stars
)(ghCount).href = homepageURL;
fullBtnSpan.appendChild(ghCount);
cardFooterDiv.appendChild(fullBtnSpan);
}
Expand All @@ -217,8 +235,10 @@ function renderPackageDetails(package, packageDiv, isCard) {
return detailFrag;
}
function renderCard(package, mainDiv, oldCancellationToken) {
if (oldCancellationToken !== null &&
oldCancellationToken !== cancellationToken)
if (
oldCancellationToken !== null &&
oldCancellationToken !== cancellationToken
)
return; //don't render old packages
console.log('loading packages');
var totalPackags = document.getElementsByClassName('total-packages')[0];
Expand All @@ -243,12 +263,18 @@ var renderPackages = function () {
// Parent div to hold all the package cards
var mainDiv = document.getElementsByClassName('package-results')[0];
if (currentPackages.length > 0) {
for (var _i = 0, currentPackages_1 = currentPackages; _i < currentPackages_1.length; _i++) {
for (
var _i = 0, currentPackages_1 = currentPackages;
_i < currentPackages_1.length;
_i++
) {
var package = currentPackages_1[_i];
setTimeout(renderCard.bind(this, package, mainDiv, cancellationToken), 0);
setTimeout(
renderCard.bind(this, package, mainDiv, cancellationToken),
0
);
}
}
else {
} else {
var noResultDiv = document.createElement('div');
noResultDiv.className = 'card package-card';
noResultDiv.innerHTML = 'No results for ' + '<b>' + query + '</b>';
Expand All @@ -273,7 +299,11 @@ function searchPackages(query) {
var fuse = new Fuse(allPackages, options);
var searchResult = fuse.search(query);
var newPackagesList = [];
for (var _i = 0, searchResult_1 = searchResult; _i < searchResult_1.length; _i++) {
for (
var _i = 0, searchResult_1 = searchResult;
_i < searchResult_1.length;
_i++
) {
var rslt = searchResult_1[_i];
newPackagesList.push(rslt.item);
}
Expand All @@ -283,8 +313,7 @@ function searchAndRenderPackages() {
query = document.getElementById('pkg-search').value.trim();
if (query === '') {
currentPackages = allPackages;
}
else {
} else {
searchPackages(query);
}
if (document.getElementById('sortBtn').value !== 'Best Match') {
Expand Down Expand Up @@ -317,7 +346,11 @@ function sortPackages() {
}
}
function filterCompat() {
compatFilter = Array.from(document.querySelectorAll(".compat-card input[type='checkbox']:checked")).map(function (e) { return e.value; });
compatFilter = Array.from(
document.querySelectorAll(".compat-card input[type='checkbox']:checked")
).map(function (e) {
return e.value;
});
renderPackages();
}
function updateModal(pkg) {
Expand Down Expand Up @@ -355,7 +388,7 @@ function updateModal(pkg) {
function clickInstallTab(platform) {
var selectedPackage;
var installCode = document.getElementById('install-code');
installCode.setAttribute('readonly', "false");
installCode.setAttribute('readonly', 'false');
var windowsTab = document.getElementById('install-tab-windows');
var unixTab = document.getElementById('install-tab-unix');
switch (platform) {
Expand All @@ -374,5 +407,5 @@ function clickInstallTab(platform) {
default:
console.log('Error: unexpected platform', platform);
}
installCode.setAttribute('readonly', "true");
installCode.setAttribute('readonly', 'true');
}
6 changes: 3 additions & 3 deletions gettingStarted.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<script src="https://www.microsoft.com/onerfstatics/marketingsites-wcus-prod/shell/_scrf/js/themes=default/54-af9f9f/c0-247156/de-099401/e1-a50eee/e7-954872/d8-97d509/f0-251fe2/46-be1318/77-04a268/11-240c7b/63-077520/a4-34de62/1b-c96630/db-bc0148/dc-7e9864/78-4c7d22/e1-c35781/23-c64e70/cd-23d3b0/6d-1e7ed0/b7-cadaa7/ca-40b7b0/4e-ee3a55/3e-f5c39b/c3-6454d7/f9-7592d3/92-10345d/79-499886/7e-cda2d3/14-983080/ab-30f5b9/e0-3c9860/91-97a04f/1f-100dea/33-abe4df/4d-6e4c52?ver=2.0&iife=1"></script>
<script>
$(document).ready(function () {
$('#loadNavBar').load('header.html')
$('#loadFooter').load('footer.html')
})
$('#loadNavBar').load('header.html');
$('#loadFooter').load('footer.html');
});
</script>
</head>
<div id="loadNavBar"></div>
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<script src="https://www.microsoft.com/onerfstatics/marketingsites-wcus-prod/shell/_scrf/js/themes=default/54-af9f9f/c0-247156/de-099401/e1-a50eee/e7-954872/d8-97d509/f0-251fe2/46-be1318/77-04a268/11-240c7b/63-077520/a4-34de62/1b-c96630/db-bc0148/dc-7e9864/78-4c7d22/e1-c35781/23-c64e70/cd-23d3b0/6d-1e7ed0/b7-cadaa7/ca-40b7b0/4e-ee3a55/3e-f5c39b/c3-6454d7/f9-7592d3/92-10345d/79-499886/7e-cda2d3/14-983080/ab-30f5b9/e0-3c9860/91-97a04f/1f-100dea/33-abe4df/4d-6e4c52?ver=2.0&iife=1"></script>
<script>
$(document).ready(function () {
$('#loadNavBar').load('header.html')
$('#loadFooter').load('footer.html')
})
$('#loadNavBar').load('header.html');
$('#loadFooter').load('footer.html');
});
</script>

<script async defer src="https://buttons.github.io/buttons.js"></script>
Expand Down
18 changes: 9 additions & 9 deletions js/common.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
function copyCodePanel(id) {
let temp = document.getElementById(id)
temp.value = temp.textContent
temp.select()
document.execCommand('copy')
clearSelection()
let temp = document.getElementById(id);
temp.value = temp.textContent;
temp.select();
document.execCommand('copy');
clearSelection();
}

// remove the highlight from selected text
function clearSelection() {
if (window.getSelection) {
window.getSelection().removeAllRanges()
window.getSelection().removeAllRanges();
} else if (document.selection) {
document.selection.empty()
document.selection.empty();
}
}

// determine what OS the user is on, used to render corresponding package installation code
// default to Unix unless the user is on a Windows device
function detectOS() {
if (/Win/.test(navigator.platform)) {
return 'windows'
return 'windows';
}
return 'unix'
return 'unix';
}
38 changes: 19 additions & 19 deletions js/gettingStarted.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
let os = detectOS()
let os = detectOS();

$(document).ready(function () {
clickGetStartedTab(os) //initialized to user's current platform
clickGetStartedTab(os); //initialized to user's current platform

$('.gs-copy-btn').click(function () {
var step = $(this).attr('id')
var step = $(this).attr('id');
if (step === 'step5') {
// the code for windows and unix is shared in this case
copyCodePanel('all-' + step)
} else if (os === 'windows') copyCodePanel('windows-' + step)
else copyCodePanel('unix-' + step)
})
copyCodePanel('all-' + step);
} else if (os === 'windows') copyCodePanel('windows-' + step);
else copyCodePanel('unix-' + step);
});

$('.gs-tab-btn').click(function () {
var id = $(this).attr('id')
clickGetStartedTab(id.substring(7))
})
})
var id = $(this).attr('id');
clickGetStartedTab(id.substring(7));
});
});

function clickGetStartedTab(platform) {
os = platform
let elems = document.getElementsByClassName(os)
os = platform;
let elems = document.getElementsByClassName(os);

$('.show').removeClass('show')
$('.selected').removeClass('selected')
$('.show').removeClass('show');
$('.selected').removeClass('selected');

document.getElementById('gs-btn-' + os).classList.add('selected')
document.getElementById('gs-btn-' + os).classList.add('selected');
for (e of elems) {
e.classList.add('show')
e.classList.add('show');
}

if (os === 'linux' || os === 'mac') {
elems = document.getElementsByClassName('unix')
elems = document.getElementsByClassName('unix');
for (e of elems) {
e.classList.add('show')
e.classList.add('show');
}
}
}
6 changes: 3 additions & 3 deletions packages.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
<script src="https://www.microsoft.com/onerfstatics/marketingsites-wcus-prod/shell/_scrf/js/themes=default/54-af9f9f/c0-247156/de-099401/e1-a50eee/e7-954872/d8-97d509/f0-251fe2/46-be1318/77-04a268/11-240c7b/63-077520/a4-34de62/1b-c96630/db-bc0148/dc-7e9864/78-4c7d22/e1-c35781/23-c64e70/cd-23d3b0/6d-1e7ed0/b7-cadaa7/ca-40b7b0/4e-ee3a55/3e-f5c39b/c3-6454d7/f9-7592d3/92-10345d/79-499886/7e-cda2d3/14-983080/ab-30f5b9/e0-3c9860/91-97a04f/1f-100dea/33-abe4df/4d-6e4c52?ver=2.0&iife=1"></script>
<script>
$(document).ready(function () {
$('#loadNavBar').load('header.html')
$('#loadFooter').load('footer.html')
})
$('#loadNavBar').load('header.html');
$('#loadFooter').load('footer.html');
});
</script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
Expand Down
7 changes: 4 additions & 3 deletions ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function start_email() {
window.location.href = 'mailto:[email protected]'
window.location.href = 'mailto:[email protected]';
}

function checkEnter(e) {
if (e.keyCode === 13) {
// redirect query to packages.html
window.location.href =
'packages.html?query=' + (<HTMLInputElement>document.getElementById('idx-search')).value
'packages.html?query=' +
(<HTMLInputElement>document.getElementById('idx-search')).value;
}
return false
return false;
}
Loading

0 comments on commit 16e9a39

Please sign in to comment.