Skip to content
Permalink
Browse files

Implemented support for showing selected verses also when verses for …

…multiple books are shown (tagged verse lists or search)
  • Loading branch information
tobias-klein committed Sep 7, 2019
1 parent ac96d1a commit 30909b21c5f994d10a40af9f76cf06c801b2cf30
Showing with 118 additions and 80 deletions.
  1. +43 −10 app/tags/tags_controller.js
  2. +5 −0 models/biblebook.js
  3. +69 −69 models/bibletranslation.js
  4. +1 −1 templates/verse_list.pug
@@ -1379,7 +1379,7 @@ function TagsController() {
return selected_verse_ids;
};

this.update_tags_view_after_verse_selection = function(force) {
this.update_tags_view_after_verse_selection = async function(force) {
//console.time('update_tags_view_after_verse_selection');
if (tags_controller.verse_selection_blocked && force !== true) {
return;
@@ -1441,18 +1441,51 @@ function TagsController() {
//$('#clippy-box').empty();
var currentBook = bible_browser_controller.tab_controller.getCurrentTabBook();

if (currentBook != null && tags_controller.selected_verse_references.length > 0) {
var currentBookName = bible_browser_controller.get_book_long_title(currentBook);
var formatted_verse_list = tags_controller.format_verse_list_for_view(tags_controller.selected_verse_references, true);
selected_verses_content = currentBookName + ' ' + formatted_verse_list;
$('#tags-header').find('#selected-verses').html(selected_verses_content);
var selectedBooks = [];
for (var i = 0; i < tags_controller.selected_verse_boxes.length; i++) {
var currentVerseBox = $(tags_controller.selected_verse_boxes[i]);
var currentBibleBookId = currentVerseBox.find('.verse-bible-book-id').text();
var currentBookShortName = await models.BibleBook.getShortTitleById(currentBibleBookId);

if (!selectedBooks.includes(currentBookShortName)) {
selectedBooks.push(currentBookShortName);
}
}

// PORTING disabled
/*if (tags_controller.selected_verse_references.length > 0) {
var selected_verses_content = [];
for (var i = 0; i < selectedBooks.length; i++) {
var currentBookShortName = selectedBooks[i];
var currentBookLongTitle = bible_browser_controller.get_book_long_title(currentBookShortName);
var currentBookName = i18nHelper.getSwordTranslation(currentBookLongTitle);

var currentBookVerseReferences = [];
for (var j = 0; j < tags_controller.selected_verse_boxes.length; j++) {
var currentVerseBox = $(tags_controller.selected_verse_boxes[j]);
var currentVerseBibleBookId = currentVerseBox.find('.verse-bible-book-id').text();
var currentVerseBibleBookShortName = await models.BibleBook.getShortTitleById(currentVerseBibleBookId);

if (currentVerseBibleBookShortName == currentBookShortName) {
var currentVerseReference = currentVerseBox.find('a:first').attr('name');
currentBookVerseReferences.push(currentVerseReference);
}
}

var formatted_verse_list = tags_controller.format_verse_list_for_view(currentBookVerseReferences, true);
var currentBookVerseReferenceDisplay = currentBookName + ' ' + formatted_verse_list;
selected_verses_content.push(currentBookVerseReferenceDisplay);
}

$('#tags-header').find('#selected-verses').html(selected_verses_content.join('; '));

// PORTING disabled
/*
if (currentBook != null && tags_controller.selected_verse_references.length > 0) {
if (tags_controller.selected_verse_references.length > 0) {
var verse_text = tags_controller.get_selected_verse_text() + $('#tags-header').find('#selected-verses').text();
tags_controller.update_text_for_clipboard(escape(verse_text));
}*/
}
}
}*/
//console.timeEnd('update_tags_view_after_verse_selection');
};

@@ -119,5 +119,10 @@ module.exports = (sequelize, DataTypes) => {
return sequelize.query(query, { model: models.BibleBook });
}

BibleBook.getShortTitleById = async function(id) {
var bibleBook = await BibleBook.findByPk(id);
return bibleBook.shortTitle;
}

return BibleBook;
};
@@ -18,6 +18,75 @@

const NodeSwordInterface = require('node-sword-interface');

var bookMap = {
"Gen" : 1,
"Exod" : 2,
"Lev" : 3,
"Num" : 4,
"Deut" : 5,
"Josh" : 6,
"Judg" : 7,
"Ruth" : 8,
"1Sam" : 9,
"2Sam" : 10,
"1Kgs" : 11,
"2Kgs" : 12,
"1Chr" : 13,
"2Chr" : 14,
"Ezra" : 15,
"Neh" : 16,
"Esth" : 17,
"Job" : 18,
"Ps" : 19,
"Prov" : 20,
"Eccl" : 21,
"Song" : 22,
"Isa" : 23,
"Jer" : 24,
"Lam" : 25,
"Ezek" : 26,
"Dan" : 27,
"Hos" : 28,
"Joel" : 29,
"Amos" : 30,
"Obad" : 31,
"Jonah" : 32,
"Mic" : 33,
"Nah" : 34,
"Hab" : 35,
"Zeph" : 36,
"Hag" : 37,
"Zech" : 38,
"Mal" : 39,
"Matt" : 40,
"Mark" : 41,
"Luke" : 42,
"John" : 43,
"Acts" : 44,
"Rom" : 45,
"1Cor" : 46,
"2Cor" : 47,
"Gal" : 48,
"Eph" : 49,
"Phil" : 50,
"Col" : 51,
"1Thess" : 52,
"2Thess" : 53,
"1Tim" : 54,
"2Tim" : 55,
"Titus" : 56,
"Phlm" : 57,
"Heb" : 58,
"Jas" : 59,
"1Pet" : 60,
"2Pet" : 61,
"1John" : 62,
"2John" : 63,
"3John" : 64,
"Jude" : 65,
"Rev" : 66
};

'use strict';
module.exports = (sequelize, DataTypes) => {
var BibleTranslation = sequelize.define('BibleTranslation', {
@@ -147,75 +216,6 @@ module.exports = (sequelize, DataTypes) => {
};

BibleTranslation.swordBooktoEzraBook = function(swordBook) {
var bookMap = {
"Gen" : 1,
"Exod" : 2,
"Lev" : 3,
"Num" : 4,
"Deut" : 5,
"Josh" : 6,
"Judg" : 7,
"Ruth" : 8,
"1Sam" : 9,
"2Sam" : 10,
"1Kgs" : 11,
"2Kgs" : 12,
"1Chr" : 13,
"2Chr" : 14,
"Ezra" : 15,
"Neh" : 16,
"Esth" : 17,
"Job" : 18,
"Ps" : 19,
"Prov" : 20,
"Eccl" : 21,
"Song" : 22,
"Isa" : 23,
"Jer" : 24,
"Lam" : 25,
"Ezek" : 26,
"Dan" : 27,
"Hos" : 28,
"Joel" : 29,
"Amos" : 30,
"Obad" : 31,
"Jonah" : 32,
"Mic" : 33,
"Nah" : 34,
"Hab" : 35,
"Zeph" : 36,
"Hag" : 37,
"Zech" : 38,
"Mal" : 39,
"Matt" : 40,
"Mark" : 41,
"Luke" : 42,
"John" : 43,
"Acts" : 44,
"Rom" : 45,
"1Cor" : 46,
"2Cor" : 47,
"Gal" : 48,
"Eph" : 49,
"Phil" : 50,
"Col" : 51,
"1Thess" : 52,
"2Thess" : 53,
"1Tim" : 54,
"2Tim" : 55,
"Titus" : 56,
"Phlm" : 57,
"Heb" : 58,
"Jas" : 59,
"1Pet" : 60,
"2Pet" : 61,
"1John" : 62,
"2John" : 63,
"3John" : 64,
"Jude" : 65,
"Rev" : 66
};

return bookMap[swordBook];
};

@@ -39,7 +39,7 @@ each bibleBook in bibleBooks
div.verse-id #{verse.id}
div.verse-reference-id #{verse.verseReferenceId}
div.abs-verse-nr #{verse.absoluteVerseNr}
div.verse-bible-book-short #{verse.bibleBookShortTitle}
div.verse-bible-book-id #{verse.bibleBookId}
div.verse-reference
if renderVerseMetaInfo == true
//- div.notes-info N

0 comments on commit 30909b2

Please sign in to comment.
You can’t perform that action at this time.