-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: gitginore db folder and .vscode settings * feat: search phrase highlighting * refactor: highlight function moved to sekizai tag * fix: keyerror for '/browse' with empty parameters * refactor: delete unecessary js block
- Loading branch information
Showing
6 changed files
with
35 additions
and
2 deletions.
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
2 changes: 1 addition & 1 deletion
2
clipping_manager/templates/clipping_manager/partials/clipping_list_item.html
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,4 +1,4 @@ | ||
<div class="mb-5"> | ||
<p><em>{{ clipping.content }}</em></p> | ||
<p class="clipping-content"><em>{{ clipping.content }}</em></p> | ||
<span class="text-secondary">— {{ clipping.book.title }}</span> | ||
</div> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,18 @@ | ||
// Highlights the searched phrase ('Content contains') in clippings | ||
function highlightClippings(wordToHighlight) { | ||
// If empty -> stop the function | ||
if (!wordToHighlight) return; | ||
|
||
// Get all clippings' text | ||
const clippings = document.querySelectorAll('.clipping-content > em'); | ||
|
||
// Highlighs searched-for phrase in each clipping (case-insensitive) | ||
clippings.forEach((clipping) => { | ||
const regex = new RegExp(wordToHighlight, 'gi'); | ||
const highlightedClipping = clipping.innerHTML.replace(regex, (foundWord) => { | ||
return `<span class="highlight">${foundWord}</span>`; | ||
}); | ||
|
||
clipping.innerHTML = highlightedClipping; | ||
}); | ||
} |
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 |
---|---|---|
|
@@ -5,4 +5,8 @@ a { | |
&:hover { | ||
color: $color-secondary; | ||
} | ||
} | ||
|
||
.highlight { | ||
background: #ffc600; | ||
} |