-
Notifications
You must be signed in to change notification settings - Fork 23
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
Implemented Bookmark Functionality. #195
base: main
Are you sure you want to change the base?
Implemented Bookmark Functionality. #195
Conversation
Updating Repo!
Updating main!
updating main!
updating main!
updating main!
…browser into secrashi-patch-19
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.
Hi @secrashi
It's a big task your started ! So please do not take badly the numerous comments. There is still work to be done, but what have already been done allows to raise new questions which is a good thing.
@@ -64,6 +64,30 @@ window.onload = function() { | |||
}else{ | |||
browser.current_branch(branch); | |||
} | |||
let keys = Object.keys(sessionStorage); | |||
if (keys != "IsThisFirstTime_Log_From_LiveServer") { |
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.
I removed all IsThisFirstTime_Log_From_LiveServer
and the code still works, why adding it ? if it works without it, It generally means that we do not need it (unless it prevents error in the specific scenario)
for (let key of keys) { | ||
if (key != "IsThisFirstTime_Log_From_LiveServer") { | ||
$(".bookmarks").append( | ||
`<button id="bookClick">${key}</button>` |
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.
Element ID should/must be unique, we indeed can create multiple element with the same id, but it can have strange behavior. Use classes here : ${key}`
browser | ||
.interactive_tree() | ||
.cmd() | ||
.selectElement(`${sessionStorage.getItem(button.innerHTML)}`, true); |
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.
I'm also new to sessionStorage vs localStorage, you should read for example https://krishankantsinghal.medium.com/local-storage-vs-session-storage-vs-cookie-22655ff75a8 In our case we want to data to be saved after the tab is closed, so we should use local storage.
@@ -232,6 +233,9 @@ function interactive_edam_browser(){ | |||
details += '</div>'; | |||
details=$(details); | |||
details.find(".term-name-heading").text(d.data.text); | |||
details.find("#bookmark").click(function () { | |||
bookmark(d.data.text, d.data.data.uri); |
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.
the method bookmark
ask for the branch, not the text of the node.
@@ -754,3 +758,30 @@ function toggleFullscreen(){ | |||
$('#go-fullscreen').show(); | |||
} | |||
} | |||
function bookmark(branch, uri) { |
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.
I think this method should be reworked, we should not store independently each bookmark, but an array/list/dict of all bookmarked elements for the current branch.
Also, adding a third attribut indicating if we want to add or remove the bookmark would be useful.
} | ||
for (let key of keys) { | ||
if (key != "IsThisFirstTime_Log_From_LiveServer") { | ||
$(".bookmarks").append( |
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.
will become $("#bookmarks")
@@ -222,6 +222,7 @@ function interactive_edam_browser(){ | |||
details += '<span>'; | |||
details += '<a title="edit this term" type="button" class="btn btn-default btn-xs pull-right" target="_blank" href="edit.html?term='+uri+'&branch='+current_branch+'"><span class="glyphicon glyphicon-pencil"></span></a>'; | |||
details += '<a title="add a child to this term" type="button" class="btn btn-default btn-xs pull-right" target="_blank" href="edit.html?parent='+uri+'&branch='+current_branch+'"><span class="glyphicon glyphicon-plus"></span></a>'; | |||
details += `<a title="bookmark this term" type="button" class="btn btn-default btn-xs pull-right" id="bookmark" target="_blank"><span class="glyphicon glyphicon-bookmark"></span></a>`; |
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.
The status of bookmarked or not should be rendered. Maybe with a gold color, or maybe by toggling between
glyphicon glyphicon-star
and glyphicon glyphicon-star-empty
sessionStorage.setItem(branch, uri); | ||
let keys = Object.keys(sessionStorage); | ||
for (const key of keys) { | ||
$("#bookClick").remove(); |
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.
Removing them all to re-add them is not very elegant, but as we don't not have hundreds of them it is no big deal
@@ -754,3 +758,30 @@ function toggleFullscreen(){ | |||
$('#go-fullscreen').show(); | |||
} | |||
} | |||
function bookmark(branch, uri) { | |||
sessionStorage.setItem(branch, uri); | |||
let keys = Object.keys(sessionStorage); |
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.
Sorting them could also be useful.
@@ -215,4 +215,25 @@ body { | |||
.flex-column{ | |||
flex-direction: column; | |||
} | |||
#bookClick{ |
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.
The aspect of the bookClick should be reworked. I woulsd sugest smaller and more un the aspect of what is currently done for "previously seen" entries. Also the aspect should allow to un-bookmark an item.
Hello @bryan-brancotte, would it be okay if I take upon this PR now and complete the task? |
Checklist
Issue
fix #91
Details
Features Implemented:
width<=600px
.Shortcomings:
Future Scope Of Improvement:
Implementing this feature took me a while since I used some concepts which are relatively new to me. If @bryan-brancotte @matuskalas @hmenager or anyone from the contributors has any suggestions to overcome the shortcomings or other improvements or even code-reduction, please let me know.