Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
chore: pr cleanup, notice
Browse files Browse the repository at this point in the history
  • Loading branch information
zacanger committed Sep 10, 2023
1 parent 9c08e9b commit 82fcdee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

A [ProleSoft](https://prolesoft.github.io) project.

### Abandoned

Please feel free to fork, use the db in your own project, or do whatever you
want; I'm archiving this because I don't have the time to maintain it.

## Adding Resources

First please search `db.yml` to make sure what you want to add isn't already in
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h1>marxist.space</h1>
This project is <a href="https://github.com/prolesoft/marxist.space" target="_blank" rel="noopener nofollow noreferrer">free and open source</a> under the
<a href="https://github.com/prolesoft/marxist.space/blob/master/LICENSE.md" target="_blank" rel="noopener nofollow noreferrer">LGPL-3.0</a> license.
<br/>

<a href="https://github.com/prolesoft/marxist.space/blob/master/.github/CONTRIBUTING.md" target="_blank" rel="noopener nofollow noreferrer">Contributions</a> are welcome.
</div>
</header>
Expand Down
37 changes: 13 additions & 24 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
return uniq([...pluralized, ...possibleAliases])
}

const enrichResources = (resources) => (
const enrichResources = (resources) => (
resources.map((a) =>
({ ...a, extraTags: addTagAliases(a.tags) }))
)
Expand All @@ -72,65 +72,55 @@

const fetchy = (resources) => {
// enrich resource with plurals and tag aliases from functions above
const enrichedResources = enrichResources(resList)
const enrichedResources = enrichResources(resources)

const fuse = new window.Fuse(enrichResources(resList), fuseOptions)
const fuse = new window.Fuse(enrichedResources, fuseOptions)

// set up filtering code
const addListFilter = () => {
const filterButton = $('#filter')
const ul = $(document.body).find('ul')

// actual filtering function
const filterRows = (e) => {
//console.log("I wanna show all of it!")

var completeList = itemsList.concat(items)
//console.log(completeList)
const filterRows = () => {
const completeList = items

$('ul').html(completeList)
addListFilter()

const query = document.getElementById("query").value.trim()
//const query = e.target.value.trim()
// show all items if no query
if (query === '') {
ul.find('li').show()
} else {

const fuseResults = fuse.search(query)
.map((a) => a.item)
.map((a) => a.href)
const allLis = ul.find('li')
// assume nothing found, then just show found rows
// this should be refactored
ul.find('li').hide()
allLis.filter((i, element) => {
allLis.filter((_i, element) => {
const href = $(element).find('a').attr('href')
return fuseResults.find((l) => l === href)
}).show()
}
}

$('#filter').on('click', filterRows)
$('#query').on('keyup', (e) => {
if (e.keyCode === 13) {
filterRows()
}
})
}

// build the elements from the resources, and flip it since new
// links are added to the end of the yaml file
const items = enrichedResources.map(buildResourceItem).reverse()

const itemsList = items.splice(0,15)

// append all the items and add the filter
$('ul').html(itemsList)
$('ul').html(items)
addListFilter()

window.onscroll = function(e) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
itemsList.push(...items.splice(0,15))

$('ul').html(itemsList.concat(resList.splice(0,15)))
}
}
}

// get the db, convert to js
Expand All @@ -139,7 +129,6 @@
.then((text) => jsyaml.load(text))
.then((obj) => obj.resources)
.then((resources) => {
resList = resources
fetchy(resources)
})
})(jQuery);
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ noscript {

#scroll-top:hover {
background-color: #b14848;
}
}

0 comments on commit 82fcdee

Please sign in to comment.