Skip to content

Commit bf84d77

Browse files
committed
Add reading menu link to show term list.
1 parent 07ab41a commit bf84d77

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lute/static/js/lute.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,27 @@ let show_translation_for_text = function(text) {
825825
};
826826

827827

828+
// Get all the word ids on the current page, open new tab with just those terms.
829+
function open_term_list_for_current_page() {
830+
const ids = new Set();
831+
$('span.word').each(function () {
832+
ids.add($(this).data("wid"));
833+
});
834+
if (ids.length == 0)
835+
return; // Nothing to do.
836+
837+
const idarray = Array.from(ids);
838+
const idlist = idarray.join('+');
839+
840+
// console.log('passing ids:');
841+
// console.log(idlist);
842+
// let msg = idlist;
843+
// window.alert(msg);
844+
const url = `/term/index?termids=${idlist}`;
845+
window.open(url);
846+
}
847+
848+
828849
/** Show the translation using the next dictionary. */
829850
function handle_translate(span_attribute) {
830851
const tis = get_textitems_spans(span_attribute);

lute/templates/read/reading_menu.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
</ul>
9292
</div>
9393
</li>
94+
<li>
95+
<a id="listTermsOnCurrentPage" class="reading-menu-item" href="" onclick="open_term_list_for_current_page(); return false;">
96+
Term list
97+
</a>
98+
</li>
9499
<li>
95100
<!-- mobile users need this link, since they don't have keyboard shortcuts. -->
96101
<a id="translateSentence" class="reading-menu-item" href="" onclick="handle_translate('sentence-id'); return false;">

0 commit comments

Comments
 (0)