-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/video tags #27 #51
Open
nmpereira
wants to merge
18
commits into
labrocadabro:main
Choose a base branch
from
nmpereira:feat/video-tags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d83c97e
update .env example to add more documentation
nmpereira 4e7ad8c
add tags
nmpereira ddc3a6f
fix styling and add link to query
nmpereira cd5c3a1
add router logic for filtering by tags
nmpereira f7300b6
add filteredLessons page
nmpereira ecc2d26
improve filter page
nmpereira 350b134
added ability to use filter buttons
nmpereira 96dfee4
add count of filter results for each tag
nmpereira af04d41
fix styling on edit class page
nmpereira 7610f44
update the redirect when editing a class
nmpereira 2f27451
add some final styling
nmpereira e0b2961
change endpoint to /filter instead of /tags
nmpereira 7152aa3
whitespace/formatting changes
nmpereira 0eb9bba
remove comment
nmpereira f27de2f
fix bug with crash when there are no tags
nmpereira 10f29e3
changes from self review
nmpereira 4d421ce
revert index.css
nmpereira c56f36e
update to remove login condition for js script
nmpereira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,53 @@ | ||
const title = document.getElementById('video-title'); | ||
const videoId = document.getElementById('video-id'); | ||
const classNo = document.getElementById('number'); | ||
const addTsButton = document.getElementById('add-timestamp'); | ||
let tsIndex = document.querySelectorAll('.timestamp').length; | ||
const title = document.getElementById("video-title"); | ||
const videoId = document.getElementById("video-id"); | ||
const classNo = document.getElementById("number"); | ||
const addTsButton = document.getElementById("add-timestamp"); | ||
let tsIndex = document.querySelectorAll(".timestamp").length; | ||
|
||
title.addEventListener("change", addPermalink); | ||
videoId.addEventListener("change", addThumbnail); | ||
classNo.addEventListener("change", updateSlidesClass); | ||
addTsButton.addEventListener('click', addTimestamp); | ||
addTsButton.addEventListener("click", addTimestamp); | ||
|
||
function addPermalink() { | ||
const permalink = title.value | ||
|
||
.split('') | ||
.map(c => c.toLowerCase()) | ||
.filter(c => { | ||
return (c.charCodeAt(0) >= 97 && c.charCodeAt(0) <= 122) || c.charCodeAt(0) === 32; | ||
}) | ||
.join('') | ||
.replace(/\s/g, "-"); | ||
document.getElementById("permalink").value = permalink; | ||
document.getElementById("permalink").disabled = false; | ||
const permalink = title.value | ||
|
||
.split("") | ||
.map((c) => c.toLowerCase()) | ||
.filter((c) => { | ||
return ( | ||
(c.charCodeAt(0) >= 97 && c.charCodeAt(0) <= 122) || | ||
c.charCodeAt(0) === 32 | ||
); | ||
}) | ||
.join("") | ||
.replace(/\s/g, "-"); | ||
document.getElementById("permalink").value = permalink; | ||
document.getElementById("permalink").disabled = false; | ||
} | ||
|
||
function addThumbnail() { | ||
const thumbnail = `https://i3.ytimg.com/vi/${videoId.value}/maxresdefault.jpg`; | ||
document.getElementById("thumbnail").value = thumbnail; | ||
document.getElementById("thumbnail").disabled = false; | ||
const thumbnail = `https://i3.ytimg.com/vi/${videoId.value}/maxresdefault.jpg`; | ||
document.getElementById("thumbnail").value = thumbnail; | ||
document.getElementById("thumbnail").disabled = false; | ||
} | ||
|
||
function updateSlidesClass() { | ||
document.getElementById("slides-classNo").value = classNo.value; | ||
document.getElementById("slides-classNo").value = classNo.value; | ||
} | ||
|
||
function addTimestamp(e) { | ||
e.preventDefault(); | ||
const newTs = document.createElement('div'); | ||
newTs.classList.add('timestamp'); | ||
newTs.innerHTML = ` | ||
e.preventDefault(); | ||
const newTs = document.createElement("div"); | ||
newTs.classList.add("timestamp"); | ||
newTs.innerHTML = ` | ||
<label for="ts-time-${tsIndex}">Time</label> | ||
<input id="ts-time-${tsIndex}" type="number" name="tsTime"> | ||
<label for="ts-title-${tsIndex}">Title</label> | ||
<input id="ts-title-${tsIndex}" type="text" name="tsTitle"> | ||
`; | ||
tsIndex += 1; | ||
document.getElementById('timestamps').append(newTs); | ||
} | ||
tsIndex += 1; | ||
document.getElementById("timestamps").append(newTs); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const filterTags = document.querySelectorAll(".filter-tag"); | ||
const clearFilterBtn = document.getElementById("filter-tag-clear"); | ||
|
||
// when clicking on a filter tag, add it to the url query string like /class/filter?tags=tag1,tag2 | ||
filterTags.forEach((tag) => { | ||
tag.addEventListener("click", (e) => { | ||
const tag = e.target.value; | ||
|
||
//url encode the tag | ||
const encodedTag = encodeURIComponent(tag); | ||
|
||
const tags = new URLSearchParams(window.location.search).get("tags"); | ||
|
||
// if the tag is already in the query string, remove it | ||
let newTags = ""; | ||
|
||
if (tags) { | ||
const tagArr = tags.split(","); | ||
if (tagArr.includes(tag)) { | ||
tagArr.splice(tagArr.indexOf(tag), 1); | ||
} else { | ||
tagArr.push(encodedTag); | ||
} | ||
newTags = tagArr.join(","); | ||
} else { | ||
newTags = tag; | ||
} | ||
window.location.href = `/class/filter?tags=${newTags}`; | ||
}); | ||
}); | ||
|
||
clearFilterBtn.addEventListener("click", (e) => { | ||
window.location.href = `/class/filter`; | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of extra documentation to help with project setup