Skip to content

Commit

Permalink
Add reading menu link to show term list.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Jan 22, 2025
1 parent 07ab41a commit bf84d77
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lute/static/js/lute.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,27 @@ let show_translation_for_text = function(text) {
};


// Get all the word ids on the current page, open new tab with just those terms.
function open_term_list_for_current_page() {
const ids = new Set();
$('span.word').each(function () {
ids.add($(this).data("wid"));
});
if (ids.length == 0)
return; // Nothing to do.

const idarray = Array.from(ids);
const idlist = idarray.join('+');

// console.log('passing ids:');
// console.log(idlist);
// let msg = idlist;
// window.alert(msg);
const url = `/term/index?termids=${idlist}`;
window.open(url);
}


/** Show the translation using the next dictionary. */
function handle_translate(span_attribute) {
const tis = get_textitems_spans(span_attribute);
Expand Down
5 changes: 5 additions & 0 deletions lute/templates/read/reading_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
</ul>
</div>
</li>
<li>
<a id="listTermsOnCurrentPage" class="reading-menu-item" href="" onclick="open_term_list_for_current_page(); return false;">
Term list
</a>
</li>
<li>
<!-- mobile users need this link, since they don't have keyboard shortcuts. -->
<a id="translateSentence" class="reading-menu-item" href="" onclick="handle_translate('sentence-id'); return false;">
Expand Down

0 comments on commit bf84d77

Please sign in to comment.