From 748a10f120a4e303f5061c7d6d426bddbb8cbb5c Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Tue, 13 Nov 2018 21:00:56 -0800 Subject: [PATCH 01/31] added fixed, edited navbar to source browser --- source-browser.html | 157 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 140 insertions(+), 17 deletions(-) diff --git a/source-browser.html b/source-browser.html index 75cf389..2acaad2 100644 --- a/source-browser.html +++ b/source-browser.html @@ -10,8 +10,37 @@ + + +
@@ -72,16 +111,16 @@

โŒ›

name: topic, repoUrl: `https://github.com/${ORGANIZATION}/apertium-${topic}`, })); - + 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(); - + 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 => { @@ -92,30 +131,30 @@

โŒ›

}); }); } - + 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'); @@ -132,7 +171,7 @@

โŒ›

$('#topics').append( $('
').append( $('
').append( - $('

').text(name), + $('

').text(name), $('๐Ÿ”—', { href: repoUrl, }), @@ -141,7 +180,7 @@

โŒ›

repoList, ), ); - + const repos = reposByTopic[topic] || []; repos .sort((a, b) => a.name.localeCompare(b.name)) @@ -166,34 +205,119 @@

โŒ›

), ); }); - + $('#topics, #loading').toggleClass('display-none'); } - + function refreshTopics() { localStorage.clear(); showTopics(); } - + function showSearchInput() { $('#search') .removeClass('display-none') .focus(); } + + + $(window).scroll(function() { + var top = $(window).scrollTop(); + var bottom = $(window).scrollTop() + $(window).height(); + var langtop = $("#languages").position(); + var trunktop = $("#trunk").position(); + var stagingtop = $("#staging").position(); + var nurserytop = $("#nursery").position(); + var incutop = $("#incubator").position(); + var toolstop = $("#tools").position(); + if(top < toolstop.top && toolstop.top < bottom) + $("#litools").hide(); + else{ + $("#litools").show(); + var $tools = $("#litools"); + if(toolstop.top>bottom){ + $tools.text("toolsโ†“") + } + else + $tools.text("toolsโ†‘") + + } + if(top < incutop.top && incutop.top < bottom) + $("#liincubator").hide(); + else{ + $("#liincubator").show(); + var $incubator = $("#liincubator"); + if(incutop.top>bottom){ + $incubator.text("incubatorโ†“") + } + else + $incubator.text("incubatorโ†‘") + } + if(top < nurserytop.top && nurserytop.top < bottom) + $("#linursery").hide(); + else{ + $("#linursery").show(); + var $nursery = $("#linursery"); + if(nurserytop.top>bottom){ + $nursery.text("nurseryโ†“") + } + else + $nursery.text("nurseryโ†‘") + } + if(top < stagingtop.top && stagingtop.top < bottom) + $("#listaging").hide(); + else{ + $("#listaging").show(); + var $staging = $("#listaging"); + if(stagingtop.top>bottom){ + $staging.text("stagingโ†“") + } + else + $staging.text("stagingโ†‘") + } + if(top < trunktop.top && trunktop.top < bottom) + $("#litrunk").hide(); + else{ + $("#litrunk").show(); + var $trunk = $("#litrunk"); + if(trunktop.top>bottom){ + $trunk.text("trunkโ†“") + } + else + $trunk.text("trunkโ†‘") + } + if(top < langtop.top && langtop.top < bottom) + $("#lilang").hide(); + else{ + $("#lilang").show(); + var $lang = $("#lilang"); + if(langtop.top>bottom){ + $lang.text("languagesโ†“") + } + else + $lang.text("languagesโ†‘") + } + if((top < langtop.top && langtop.top < bottom) && (top < trunktop.top && trunktop.top < bottom) && (top < stagingtop.top && stagingtop.top < bottom) && (top < nurserytop.top && nurserytop.top < bottom) && (top < incutop.top && incutop.top < bottom) && (top < toolstop.top && toolstop.top < bottom)) + $("#navbar").hide(); + else + $("#navbar").show(); + }); $(document).ready(() => { + $('#github-link').attr('href', `https://github.com/${ORGANIZATION}`); $('#refresh').click(({ currentTarget }) => { currentTarget.blur(); refreshTopics(); }); - + $('#search').on('input', showTopics); $(document.body).keypress(({ target, altKey, ctrlKey, metaKey, key }) => { if (target === document.body && !altKey && !ctrlKey && !metaKey) { showSearchInput(); } }); + $(window).keydown(event => { const { keyCode, ctrlKey, metaKey } = event; if (keyCode === 114 || ((ctrlKey || metaKey) && keyCode === 70)) { @@ -201,10 +325,9 @@

โŒ›

showSearchInput(); } }); - setInterval(refreshTopics, EXPIRY_MILLIS * 2); showTopics(); }); - + \ No newline at end of file From 1a44b6b2b4536cb71785b957ed60a1aeb371969b Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Tue, 13 Nov 2018 22:04:55 -0800 Subject: [PATCH 02/31] fixed spacing --- source-browser.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/source-browser.html b/source-browser.html index 2acaad2..7e8609e 100644 --- a/source-browser.html +++ b/source-browser.html @@ -10,7 +10,6 @@ - - - +
@@ -168,13 +156,14 @@

โŒ›

$('#topics').append( $('
').append( $('
').append( - $('

').text(name), + $('

').text(name), $('๐Ÿ”—', { href: repoUrl, }), ), $('
'), repoList, + ), ); @@ -217,91 +206,36 @@

โŒ›

.focus(); } - + + var array = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools']; + array.forEach(function(header) { + $("#navbar").append("
  • "+header+"
  • "); + $("#inline-block m0").attr("id", name); + }); $(window).scroll(function() { var top = $(window).scrollTop(); var bottom = $(window).scrollTop() + $(window).height(); - var langtop = $("#languages").position(); - var trunktop = $("#trunk").position(); - var stagingtop = $("#staging").position(); - var nurserytop = $("#nursery").position(); - var incutop = $("#incubator").position(); - var toolstop = $("#tools").position(); - if(top < toolstop.top && toolstop.top < bottom) - $("#litools").hide(); - else{ - $("#litools").show(); - var $tools = $("#litools"); - if(toolstop.top>bottom){ - $tools.text("toolsโ†“") - } - else - $tools.text("toolsโ†‘") - - } - if(top < incutop.top && incutop.top < bottom) - $("#liincubator").hide(); - else{ - $("#liincubator").show(); - var $incubator = $("#liincubator"); - if(incutop.top>bottom){ - $incubator.text("incubatorโ†“") - } - else - $incubator.text("incubatorโ†‘") - } - if(top < nurserytop.top && nurserytop.top < bottom) - $("#linursery").hide(); - else{ - $("#linursery").show(); - var $nursery = $("#linursery"); - if(nurserytop.top>bottom){ - $nursery.text("nurseryโ†“") - } - else - $nursery.text("nurseryโ†‘") - } - if(top < stagingtop.top && stagingtop.top < bottom) - $("#listaging").hide(); - else{ - $("#listaging").show(); - var $staging = $("#listaging"); - if(stagingtop.top>bottom){ - $staging.text("stagingโ†“") - } - else - $staging.text("stagingโ†‘") - } - if(top < trunktop.top && trunktop.top < bottom) - $("#litrunk").hide(); - else{ - $("#litrunk").show(); - var $trunk = $("#litrunk"); - if(trunktop.top>bottom){ - $trunk.text("trunkโ†“") - } - else - $trunk.text("trunkโ†‘") - } - if(top < langtop.top && langtop.top < bottom) - $("#lilang").hide(); - else{ - $("#lilang").show(); - var $lang = $("#lilang"); - if(langtop.top>bottom){ - $lang.text("languagesโ†“") + var titles = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools']; + var i; + for(i = 0; ibottom){ + $tools.text(header+'โ†“') + } + else + $tools.text(header+'โ†‘') + } } - else - $lang.text("languagesโ†‘") - } - if((top < langtop.top && langtop.top < bottom) && (top < trunktop.top && trunktop.top < bottom) && (top < stagingtop.top && stagingtop.top < bottom) && (top < nurserytop.top && nurserytop.top < bottom) && (top < incutop.top && incutop.top < bottom) && (top < toolstop.top && toolstop.top < bottom)) - $("#navbar").hide(); - else - $("#navbar").show(); - }); - + }); + $(document).ready(() => { - $('#github-link').attr('href', `https://github.com/${ORGANIZATION}`); $('#refresh').click(({ currentTarget }) => { currentTarget.blur(); @@ -314,7 +248,6 @@

    โŒ›

    showSearchInput(); } }); - $(window).keydown(event => { const { keyCode, ctrlKey, metaKey } = event; if (keyCode === 114 || ((ctrlKey || metaKey) && keyCode === 70)) { @@ -322,6 +255,7 @@

    โŒ›

    showSearchInput(); } }); + setInterval(refreshTopics, EXPIRY_MILLIS * 2); showTopics(); }); From dd265b870f1323eec669584b20130a505c7f9515 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Wed, 14 Nov 2018 20:15:36 -0800 Subject: [PATCH 05/31] fixed spacing, edited js/jquery and attributes --- source-browser.html | 59 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/source-browser.html b/source-browser.html index 0a487a3..9fc9737 100644 --- a/source-browser.html +++ b/source-browser.html @@ -26,7 +26,7 @@ float: left; } .navbar li a { - display: block; + display: inline-block; color: white; text-align: center; padding: 14px 16px; @@ -65,7 +65,7 @@ - +
    @@ -91,12 +91,12 @@

    โŒ›

    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'], + TOPICS = LIST.map(topic => ({ topic: `apertium-${topic}`, name: topic, repoUrl: `https://github.com/${ORGANIZATION}/apertium-${topic}`, })); - 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(); @@ -156,16 +156,16 @@

    โŒ›

    $('#topics').append( $('
    ').append( $('
    ').append( - $('

    ').text(name), + $('

    ').text(name), $('๐Ÿ”—', { href: repoUrl, }), ), $('
    '), repoList, - ), ); + $("[id=topic]").attr("id", name); const repos = reposByTopic[topic] || []; repos @@ -194,7 +194,7 @@

    โŒ›

    $('#topics, #loading').toggleClass('display-none'); } - + function refreshTopics() { localStorage.clear(); showTopics(); @@ -205,37 +205,40 @@

    โŒ›

    .removeClass('display-none') .focus(); } - - - var array = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools']; - array.forEach(function(header) { - $("#navbar").append("
  • "+header+"
  • "); - $("#inline-block m0").attr("id", name); - }); + $(window).scroll(function() { - var top = $(window).scrollTop(); - var bottom = $(window).scrollTop() + $(window).height(); - var titles = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools']; - var i; - for(i = 0; ibottom){ - $tools.text(header+'โ†“') + $heading.text(heading+'โ†“') } - else - $tools.text(header+'โ†‘') + else { + $heading.text(heading+'โ†‘') + } } } }); - + $(document).ready(() => { + $("#navbar").append('
  • '); + for(let i = 0; i < LIST.length; i++){ + $("#li").append(''); + $("[id=placeholder]").attr({ + '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(); From e778e6921d6b98af15479ce23bfe8df326286da0 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 11:00:36 -0800 Subject: [PATCH 06/31] edited spacing and jquery/js --- source-browser.html | 71 +++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/source-browser.html b/source-browser.html index 9fc9737..d9f2858 100644 --- a/source-browser.html +++ b/source-browser.html @@ -32,6 +32,10 @@ padding: 14px 16px; text-decoration: none; } + h2[class$="inline-block m0"] { + padding-top:75px; + margin-top:-75px; + } #content { margin-top: 75px; margin-bottom: 100px; @@ -91,8 +95,7 @@

    โŒ›

    CACHE_KEY = `${ORGANIZATION}-cache`, EXPIRY_KEY = `${ORGANIZATION}-expiry`, EXPIRY_MILLIS = 60000, - LIST = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools'], - TOPICS = LIST.map(topic => ({ + TOPICS = ['languages', 'trunk', 'staging', 'nursery', 'incubator', 'tools'].map(topic => ({ topic: `apertium-${topic}`, name: topic, repoUrl: `https://github.com/${ORGANIZATION}/apertium-${topic}`, @@ -100,12 +103,10 @@

    โŒ›

    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(); - 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 => { @@ -116,30 +117,24 @@

    โŒ›

    }); }); } - 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'); @@ -156,7 +151,7 @@

    โŒ›

    $('#topics').append( $('
    ').append( $('
    ').append( - $('

    ').text(name), + $('

    ', {id: name}).text(name), $('๐Ÿ”—', { href: repoUrl, }), @@ -165,8 +160,6 @@

    โŒ›

    repoList, ), ); - $("[id=topic]").attr("id", name); - const repos = reposByTopic[topic] || []; repos .sort((a, b) => a.name.localeCompare(b.name)) @@ -191,60 +184,63 @@

    โŒ›

    ), ); }); - $('#topics, #loading').toggleClass('display-none'); } - function refreshTopics() { localStorage.clear(); showTopics(); } - function showSearchInput() { $('#search') .removeClass('display-none') .focus(); } - - $(window).scroll(function() { + + function createNavbar(item) { + $('#li').append( + $('', { + id: 'li' + item, + href: '#' + item, + }).text(item), + ); + } + + $(window).scroll(() => { 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(); + for(let i = 0; i < TOPICS.length; i++){ + let heading = TOPICS[i].name; + let vartop = $('#' + heading).position(); if(top < vartop.top && vartop.top < bottom){ - $('#li'+heading).hide(); + $('#li' + heading).hide(); } else{ - $('#li'+heading).show(); - let $heading = $('#li'+heading); + $('#li' + heading).show(); + let $heading = $('#li' + heading); if(vartop.top>bottom){ - $heading.text(heading+'โ†“') + $heading.text(heading + 'โ†“') } else { - $heading.text(heading+'โ†‘') + $heading.text(heading + 'โ†‘') } } } }); - + $(document).ready(() => { + let list = []; $("#navbar").append('
  • '); - for(let i = 0; i < LIST.length; i++){ - $("#li").append('
    '); - $("[id=placeholder]").attr({ - 'href': '#' + LIST[i], - 'id': 'li' + LIST[i], - }); - $("[id=placeholder]").text(LIST[i]); - } + for(let i = 0; i < TOPICS.length; i++){ + let heading = TOPICS[i].name; + list.push(heading); + } + list.forEach(createNavbar); $('#github-link').attr('href', `https://github.com/${ORGANIZATION}`); $('#refresh').click(({ currentTarget }) => { currentTarget.blur(); refreshTopics(); }); - $('#search').on('input', showTopics); $(document.body).keypress(({ target, altKey, ctrlKey, metaKey, key }) => { if (target === document.body && !altKey && !ctrlKey && !metaKey) { @@ -258,10 +254,9 @@

    โŒ›

    showSearchInput(); } }); - setInterval(refreshTopics, EXPIRY_MILLIS * 2); showTopics(); }); - \ No newline at end of file + From 4103dfb41f5890ae1e19210e14cd8e5b67043c52 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 14:15:41 -0800 Subject: [PATCH 07/31] edited spacing, css --- source-browser.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source-browser.html b/source-browser.html index d9f2858..38b44e9 100644 --- a/source-browser.html +++ b/source-browser.html @@ -32,7 +32,7 @@ padding: 14px 16px; text-decoration: none; } - h2[class$="inline-block m0"] { + h2[class="inline-block m0"] { padding-top:75px; margin-top:-75px; } @@ -195,7 +195,6 @@

    โŒ›

    .removeClass('display-none') .focus(); } - function createNavbar(item) { $('#li').append( $('', { @@ -204,7 +203,6 @@

    โŒ›

    }).text(item), ); } - $(window).scroll(() => { let top = $(window).scrollTop(); let bottom = $(window).scrollTop() + $(window).height(); @@ -217,7 +215,7 @@

    โŒ›

    else{ $('#li' + heading).show(); let $heading = $('#li' + heading); - if(vartop.top>bottom){ + if(vartop.top > bottom){ $heading.text(heading + 'โ†“') } else { From ab7d0a979d02afc36e4f3f6ac2bc0569a3a3112d Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 14:23:53 -0800 Subject: [PATCH 08/31] fixed spacing, reverted spacing changes --- source-browser.html | 54 +++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/source-browser.html b/source-browser.html index 38b44e9..cabac2d 100644 --- a/source-browser.html +++ b/source-browser.html @@ -100,13 +100,16 @@

    โŒ›

    name: topic, repoUrl: `https://github.com/${ORGANIZATION}/apertium-${topic}`, })); + 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(); + 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 => { @@ -117,24 +120,30 @@

    โŒ›

    }); }); } + 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'); @@ -160,6 +169,7 @@

    โŒ›

    repoList, ), ); + const repos = reposByTopic[topic] || []; repos .sort((a, b) => a.name.localeCompare(b.name)) @@ -184,17 +194,21 @@

    โŒ›

    ), ); }); + $('#topics, #loading').toggleClass('display-none'); } + function refreshTopics() { localStorage.clear(); showTopics(); } + function showSearchInput() { $('#search') .removeClass('display-none') .focus(); } + function createNavbar(item) { $('#li').append( $('
    ', { @@ -203,28 +217,29 @@

    โŒ›

    }).text(item), ); } - $(window).scroll(() => { - let top = $(window).scrollTop(); - let bottom = $(window).scrollTop() + $(window).height(); - for(let i = 0; i < TOPICS.length; i++){ - let heading = TOPICS[i].name; - let vartop = $('#' + heading).position(); - if(top < vartop.top && vartop.top < bottom){ - $('#li' + heading).hide(); - } - else{ - $('#li' + heading).show(); - let $heading = $('#li' + heading); - if(vartop.top > bottom){ - $heading.text(heading + 'โ†“') - } - else { - $heading.text(heading + 'โ†‘') + + $(window).scroll(() => { + let top = $(window).scrollTop(); + let bottom = $(window).scrollTop() + $(window).height(); + for(let i = 0; i < TOPICS.length; i++){ + let heading = TOPICS[i].name; + let vartop = $('#' + heading).position(); + if(top < vartop.top && vartop.top < bottom){ + $('#li' + heading).hide(); + } + else{ + $('#li' + heading).show(); + let $heading = $('#li' + heading); + if(vartop.top > bottom){ + $heading.text(heading + 'โ†“') } + else { + $heading.text(heading + 'โ†‘') } } - }); - + } + }); + $(document).ready(() => { let list = []; $("#navbar").append('
  • '); @@ -252,6 +267,7 @@

    โŒ›

    showSearchInput(); } }); + setInterval(refreshTopics, EXPIRY_MILLIS * 2); showTopics(); }); From c6fb817a6eba54de8568ae40e5347f1a0ab15bd4 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 14:36:57 -0800 Subject: [PATCH 09/31] edited css --- source-browser.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-browser.html b/source-browser.html index cabac2d..b01034f 100644 --- a/source-browser.html +++ b/source-browser.html @@ -32,7 +32,7 @@ padding: 14px 16px; text-decoration: none; } - h2[class="inline-block m0"] { + .inline-block.m0 { padding-top:75px; margin-top:-75px; } From e9e36e522baa6591d68a8b3afc556d6fbaa428e9 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 14:43:01 -0800 Subject: [PATCH 10/31] removed extra trailing spaces --- source-browser.html | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/source-browser.html b/source-browser.html index b01034f..7f4c2c9 100644 --- a/source-browser.html +++ b/source-browser.html @@ -34,7 +34,7 @@ } .inline-block.m0 { padding-top:75px; - margin-top:-75px; + margin-top:-75px; } #content { margin-top: 75px; @@ -100,16 +100,16 @@

    โŒ›

    name: topic, repoUrl: `https://github.com/${ORGANIZATION}/apertium-${topic}`, })); - + 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(); - + 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 => { @@ -120,30 +120,30 @@

    โŒ›

    }); }); } - + 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'); @@ -169,7 +169,7 @@

    โŒ›

    repoList, ), ); - + const repos = reposByTopic[topic] || []; repos .sort((a, b) => a.name.localeCompare(b.name)) @@ -194,30 +194,30 @@

    โŒ›

    ), ); }); - + $('#topics, #loading').toggleClass('display-none'); } - + function refreshTopics() { localStorage.clear(); showTopics(); } - + function showSearchInput() { $('#search') .removeClass('display-none') .focus(); } - + function createNavbar(item) { $('#li').append( $('
    ', { id: 'li' + item, href: '#' + item, - }).text(item), + }).text(item), ); } - + $(window).scroll(() => { let top = $(window).scrollTop(); let bottom = $(window).scrollTop() + $(window).height(); @@ -238,7 +238,7 @@

    โŒ›

    } } } - }); + }); $(document).ready(() => { let list = []; @@ -248,7 +248,7 @@

    โŒ›

    list.push(heading); } list.forEach(createNavbar); - + $('#github-link').attr('href', `https://github.com/${ORGANIZATION}`); $('#refresh').click(({ currentTarget }) => { currentTarget.blur(); @@ -267,7 +267,7 @@

    โŒ›

    showSearchInput(); } }); - + setInterval(refreshTopics, EXPIRY_MILLIS * 2); showTopics(); }); From 80d03512d2038a0dc59cb9c48ec686c9fd120670 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 18:01:12 -0800 Subject: [PATCH 11/31] edited spacing, ran through Prettier, edited JS/JQuery --- source-browser.html | 65 +++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/source-browser.html b/source-browser.html index 7f4c2c9..4d5931f 100644 --- a/source-browser.html +++ b/source-browser.html @@ -209,44 +209,44 @@

    โŒ›

    .focus(); } - function createNavbar(item) { - $('#li').append( - $('
    ', { - id: 'li' + item, - href: '#' + item, - }).text(item), - ); + function createNavbar(topic) { + $('.li').append( + $('', { + id: `li${topic}`, + href: `#${topic}` + }).text(topic) + ); } + let list = []; + $(document).ready(() => { + TOPICS.forEach(item =>{ + let heading = item.name; + list.push(heading); + }); + }); + $(window).scroll(() => { - let top = $(window).scrollTop(); - let bottom = $(window).scrollTop() + $(window).height(); - for(let i = 0; i < TOPICS.length; i++){ - let heading = TOPICS[i].name; - let vartop = $('#' + heading).position(); - if(top < vartop.top && vartop.top < bottom){ - $('#li' + heading).hide(); + let top = $(window).scrollTop(); + let bottom = $(window).scrollTop() + $(window).height(); + list.forEach(heading => { + let vartop = $(`#${heading}`).position(); + if (top < vartop.top && vartop.top < bottom) { + $(`#li${heading}`).hide(); + } else { + $(`#li${heading}`).show(); + let $heading = $(`#li${heading}`); + if (vartop.top > bottom) { + $heading.text(`${heading}โ†“`); + } else { + $heading.text(`${heading}โ†‘`); } - else{ - $('#li' + heading).show(); - let $heading = $('#li' + heading); - if(vartop.top > bottom){ - $heading.text(heading + 'โ†“') - } - else { - $heading.text(heading + 'โ†‘') - } - } - } - }); + } + }); + }); $(document).ready(() => { - let list = []; - $("#navbar").append('
  • '); - for(let i = 0; i < TOPICS.length; i++){ - let heading = TOPICS[i].name; - list.push(heading); - } + $('#navbar').append('
  • '); list.forEach(createNavbar); $('#github-link').attr('href', `https://github.com/${ORGANIZATION}`); @@ -254,6 +254,7 @@

    โŒ›

    currentTarget.blur(); refreshTopics(); }); + $('#search').on('input', showTopics); $(document.body).keypress(({ target, altKey, ctrlKey, metaKey, key }) => { if (target === document.body && !altKey && !ctrlKey && !metaKey) { From 4a8f35fc8ee2cddc15c14e8eda5669ee5d76cf66 Mon Sep 17 00:00:00 2001 From: Nathan Chi Date: Fri, 16 Nov 2018 18:04:26 -0800 Subject: [PATCH 12/31] edited spacing, script, ran through Prettier --- source-browser.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-browser.html b/source-browser.html index 4d5931f..bbba657 100644 --- a/source-browser.html +++ b/source-browser.html @@ -220,7 +220,7 @@

    โŒ›

    let list = []; $(document).ready(() => { - TOPICS.forEach(item =>{ + TOPICS.forEach(item => { let heading = item.name; list.push(heading); }); From a9e5cfea3afbe4541c330fb0b9aa63b0d41d4afb Mon Sep 17 00:00:00 2001 From: Andrew Chi Date: Sat, 17 Nov 2018 13:00:00 -0800 Subject: [PATCH 13/31] edited script --- source-browser.html | 88 +++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 59 deletions(-) diff --git a/source-browser.html b/source-browser.html index bbba657..802016d 100644 --- a/source-browser.html +++ b/source-browser.html @@ -10,29 +10,10 @@ - +
    @@ -160,7 +143,7 @@

    โŒ›

    $('#topics').append( $('
    ').append( $('
    ').append( - $('

    ', {id: name}).text(name), + $('

    ', {id: name}).text(name), $('๐Ÿ”—', { href: repoUrl, }), @@ -209,45 +192,32 @@

    โŒ›

    .focus(); } - function createNavbar(topic) { - $('.li').append( - $('', { - id: `li${topic}`, - href: `#${topic}` - }).text(topic) - ); - } - - let list = []; $(document).ready(() => { - TOPICS.forEach(item => { - let heading = item.name; - list.push(heading); - }); - }); + $(window).on('scroll resize', function(){ + const top = $(window).scrollTop(); + const bottom = $(window).scrollTop() + $(window).height(); + TOPICS.forEach(heading => { + heading = heading.name; + let heading_position = $(`#${heading}`).position(); + if (top < heading_position.top && heading_position.top < bottom) { + $(`#${heading}-nav-link`).hide(); + } else { + $(`#${heading}-nav-link`).show(); + $(`#${heading}-nav-link`).text(`${heading} ${heading_position.top > bottom ? 'โ†“' : 'โ†‘'}`); + } + }); + }); - $(window).scroll(() => { - let top = $(window).scrollTop(); - let bottom = $(window).scrollTop() + $(window).height(); - list.forEach(heading => { - let vartop = $(`#${heading}`).position(); - if (top < vartop.top && vartop.top < bottom) { - $(`#li${heading}`).hide(); - } else { - $(`#li${heading}`).show(); - let $heading = $(`#li${heading}`); - if (vartop.top > bottom) { - $heading.text(`${heading}โ†“`); - } else { - $heading.text(`${heading}โ†‘`); - } - } + TOPICS.forEach(topic => { + topic = topic.name; + $('.li').append( + $('', { + class: `inline-block white center btn:hover`, + id: `${topic}-nav-link`, + href: `#${topic}` + }).text(topic) + ); }); - }); - - $(document).ready(() => { - $('#navbar').append('
  • '); - list.forEach(createNavbar); $('#github-link').attr('href', `https://github.com/${ORGANIZATION}`); $('#refresh').click(({ currentTarget }) => { From 6377cb95eadc8ddb5220d3b7064e334f16194e87 Mon Sep 17 00:00:00 2001 From: Andrew Chi Date: Sat, 17 Nov 2018 23:19:46 -0800 Subject: [PATCH 14/31] fixed script --- source-browser.html | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/source-browser.html b/source-browser.html index 802016d..a752db7 100644 --- a/source-browser.html +++ b/source-browser.html @@ -14,8 +14,8 @@ padding: 14px 16px; } .topic { - padding-top:75px; - margin-top:-75px; + padding-top: 75px; + margin-top: -75px; } #content { margin-top: 75px; @@ -195,27 +195,24 @@

    โŒ›

    $(document).ready(() => { $(window).on('scroll resize', function(){ const top = $(window).scrollTop(); - const bottom = $(window).scrollTop() + $(window).height(); - TOPICS.forEach(heading => { - heading = heading.name; - let heading_position = $(`#${heading}`).position(); - if (top < heading_position.top && heading_position.top < bottom) { - $(`#${heading}-nav-link`).hide(); + const bottom = top + $(window).height(); + TOPICS.forEach(topic => { + let {name} = topic; + const name_position = $(`#${name}`).position().top; + if (top < name_position && name_position < bottom) { + $(`#${name}-nav-link`).hide(); } else { - $(`#${heading}-nav-link`).show(); - $(`#${heading}-nav-link`).text(`${heading} ${heading_position.top > bottom ? 'โ†“' : 'โ†‘'}`); + $(`#${name}-nav-link`).text(`${name} ${name_position > bottom ? 'โ†“' : 'โ†‘'}`).show(); } }); }); - TOPICS.forEach(topic => { - topic = topic.name; + let {name} = topic; $('.li').append( - $('
    ', { - class: `inline-block white center btn:hover`, - id: `${topic}-nav-link`, - href: `#${topic}` - }).text(topic) + $('', { + id: `${name}-nav-link`, + href: `#${name}` + }).text(name) ); }); From 6aed63a61ca486ff780f9b70d1428cabf074423d Mon Sep 17 00:00:00 2001 From: Square Snow Date: Sun, 18 Nov 2018 21:28:17 -0800 Subject: [PATCH 15/31] ran through prettier to fix styling, edited script --- source-browser.html | 75 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/source-browser.html b/source-browser.html index a752db7..391a2f0 100644 --- a/source-browser.html +++ b/source-browser.html @@ -14,7 +14,7 @@ padding: 14px 16px; } .topic { - padding-top: 75px; + padding-top: 75px; margin-top: -75px; } #content { @@ -51,7 +51,6 @@ ๐Ÿ”„ - +