Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide. diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php index ec68777..719fdc8 100644 --- a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php @@ -149,6 +149,33 @@ final class Linker return null; } + /** + * Get active Linker details + * + * @param bool $setup The setup switch + * + * @return array|null Linker details + * @since 2.0.1 + **/ + public function activeDetails(bool $setup = true): ?array + { + if (($linker = $this->active($setup)) !== null) + { + // check if this is a valid linker (already set) + if (($name = $this->load->value( + ['guid' => $linker, 'published' => 1], + 'name', 'linker' + )) !== null) + { + return ['guid' => $linker, 'name' => $name, 'share' => $this->share()]; + } + + return ['guid' => $linker, 'name' => null, 'share' => null]; + } + + return null; + } + /** * Check if a Linker is valid active linker * @@ -211,6 +238,75 @@ final class Linker return true; } + /** + * Revoke Linker Session + * + * @param string $linker The linker GUID value + * + * @return array|null The success or error details + * @since 2.0.1 + **/ + public function revokeSession(string $linker): ?array + { + // linker not valid GUID + if (!GuidHelper::valid($linker)) + { + // hmm we can log this + return [ + 'error' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + if (($access = $this->session->get('getbible_active_linker_guid', null)) === null + || $access !== $linker) + { + // hmm we can log this + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + $this->session->set('getbible_active_linker_guid', null); + + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + /** + * Set a linker name + * + * @param string $name The linker name + * + * @return array|null Array on success + * @since 2.0.1 + **/ + public function setName(string $name): ?array + { + // make sure the linker has access + if (($linker = $this->get()) === null) + { + return [ + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'access_required' => true + ]; + } + + // set the name of this linker + if (!$this->update->value($name, 'name', $linker, 'guid', 'linker')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_THE_NAME_COULD_NOT_BE_UPDATED') + ]; + } + + return [ + 'guid' => $linker, + 'name' => $name, + 'success' => Text::_('COM_GETBIBLE_THE_NAME_HAS_BEEN_UPDATED') + ]; + } + /** * Set Access * @@ -308,6 +404,41 @@ final class Linker return (array) $_linker; } + /** + * Revoke Access + * + * @param string $linker The linker GUID value + * + * @return array|null The success or error details + * @since 2.0.1 + **/ + public function revoke(string $linker): ?array + { + // linker not valid GUID + if (!GuidHelper::valid($linker)) + { + // hmm we can log this + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + if (($access = $this->session->get("getbible_active_{$linker}", null)) === null + || $access !== 'valid_access') + { + // hmm we can log this + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + + $this->session->set("getbible_active_{$linker}", null); + + return [ + 'success' => Text::_('COM_GETBIBLE_ACCESS_REVOKED') + ]; + } + /** * Has Access * diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php index b51a050..c2932dd 100644 --- a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php @@ -103,7 +103,7 @@ final class Note if (($linker = $this->linker->get()) === null) { return [ - 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), 'access_required' => true ]; } diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php index b2fb49a..61e343a 100644 --- a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php @@ -95,7 +95,7 @@ final class Tag if (($linker = $this->linker->get()) === null) { return [ - 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), 'access_required' => true ]; } diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php index 41f9deb..64416ea 100644 --- a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php @@ -131,7 +131,7 @@ final class Tagged if (($linker = $this->linker->get()) === null) { return [ - 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), 'access_required' => true ]; } @@ -187,7 +187,7 @@ final class Tagged if (($linker = $this->linker->get()) === null) { return [ - 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), 'access_required' => true ]; } diff --git a/script.php b/script.php index 3dc4dc4..731e09f 100644 --- a/script.php +++ b/script.php @@ -1539,7 +1539,7 @@ class com_getbibleInstallerScript echo ' -
Please setup curl on your system, or getbible will not function correctly!
" +COM_GETBIBLE_IF_YOU_SWITCH_FROM_YOUR_ACTIVE_SESSION_TO_A_SHARED_ONE_YOUR_ORIGINAL_SESSION_WILL_BE_PRESERVED_HERE_FOR_EASY_ACCESS="If you switch from your active session to a shared one, your original session will be preserved here for easy access." COM_GETBIBLE_INCORRECT_FAVOURITE_VERSE_SELECTED="Incorrect favourite verse selected." COM_GETBIBLE_INSENSITIVE="Insensitive" COM_GETBIBLE_INSTALL="Install" @@ -76,7 +81,9 @@ COM_GETBIBLE_LABEL="Label" COM_GETBIBLE_LAYOUT="Layout" COM_GETBIBLE_LICENSE="License" COM_GETBIBLE_LINK="Link" -COM_GETBIBLE_LOAD_PREVIOUS_SESSION="Load Previous Session" +COM_GETBIBLE_LOAD="Load" +COM_GETBIBLE_LOADING="Loading" +COM_GETBIBLE_LOAD_PREVIOUS_PERSISTENT_SESSION="Load Previous Persistent Session" COM_GETBIBLE_MARKDOWN="Markdown" COM_GETBIBLE_MATCH="Match" COM_GETBIBLE_MAX_TOKENS="Max Tokens" @@ -111,6 +118,7 @@ COM_GETBIBLE_PARTIAL="Partial" COM_GETBIBLE_PARTIAL_MATCH="Partial Match" COM_GETBIBLE_PASSWORD_TO_SHORT_USE_A_LONGER_PASSWORD="Password to short, use a longer password." COM_GETBIBLE_PERFORMING_MULTIPLE_INSTALLATIONS_WILL_NOT_CAUSE_ANY_DUPLICATES_OR_DATA_CLUTTER_THE_SYSTEM_INTELLIGENTLY_RECOGNIZES_ALREADY_INSTALLED_PARTS_AND_MERELY_REFRESHES_THEM_TO_VERIFY_THAT_THEY_ARE_IN_SYNC_WITH_THE_ORIGINAL_SOURCE="Performing multiple installations will not cause any duplicates or data clutter. The system intelligently recognizes already installed parts and merely refreshes them to verify that they are in sync with the original source." +COM_GETBIBLE_PERSISTENT_SESSION_KEY="Persistent Session Key" COM_GETBIBLE_PER_LINE="Per Line" COM_GETBIBLE_PLAIN_TEXT="Plain Text" COM_GETBIBLE_PLEASE_KEEP_YOUR_FAVOURITE_VERSE_PRIVATE="Please Keep Your Favourite Verse Private" @@ -129,6 +137,7 @@ COM_GETBIBLE_REMOVE="Remove" COM_GETBIBLE_RESEARCH_THIS="Research this" COM_GETBIBLE_RESPONSE="Response" COM_GETBIBLE_RESPONSE_DETAILS="Response Details" +COM_GETBIBLE_REVOKE_EXCLUSIVE_ACCESS_TO_EDIT_YOUR_NOTES_AND_TAGS="Revoke exclusive access to edit your notes and tags." COM_GETBIBLE_SAVE="Save" COM_GETBIBLE_SCRIPTURE="Scripture" COM_GETBIBLE_SEARCH="Search" @@ -137,16 +146,21 @@ COM_GETBIBLE_SEARCH_OPTIONS="Search Options" COM_GETBIBLE_SEARCH_RESULTS="Search Results" COM_GETBIBLE_SELECT="Select" COM_GETBIBLE_SENSITIVE="Sensitive" +COM_GETBIBLE_SESSIONS="Sessions" COM_GETBIBLE_SESSION_KEY="Session Key" COM_GETBIBLE_SESSION_KEY_COULD_NOT_BE_STORED="Session key could not be stored." +COM_GETBIBLE_SESSION_NAME="Session Name" COM_GETBIBLE_SETTINGS="Settings" COM_GETBIBLE_SHARE="Share" COM_GETBIBLE_SHARE_LINK="Share Link" COM_GETBIBLE_SHARE_TEXT="Share Text" +COM_GETBIBLE_SHARE_YOUR_SESSION="Share Your Session" COM_GETBIBLE_SHARING_THE_WORD_OF_GOD_WITH_THE_WORLD="Sharing the Word of God with the world." COM_GETBIBLE_SHOULD_YOU_HAVE_BANOTHER_SESSION_KEYB_FROM_A_PREVIOUS_SESSION="Should you have another session key from a previous session." COM_GETBIBLE_SHOW="Show" COM_GETBIBLE_SOURCE="Source" +COM_GETBIBLE_STYLE="Style" +COM_GETBIBLE_STYLE_GO_HERE="Style go here" COM_GETBIBLE_TAB_NAME_PLACEHOLDERS="Tab Name Placeholders" COM_GETBIBLE_TAG="Tag" COM_GETBIBLE_TAGGED_VERSES="Tagged Verses" @@ -164,24 +178,27 @@ COM_GETBIBLE_THERE_WAS_AN_ERROR_PLEASE_RELOAD_YOUR_PAGE_AND_TRY_AGAIN="There was COM_GETBIBLE_THE_ACTIVE_VERSE_SELECTED_TEXT_SHOULD_LOAD_HERE="The active verse selected text should load here." COM_GETBIBLE_THE_CHAPTERS_OF_BOOKS_WAS_SUCCESSFULLY_INSTALLED_FOR_S_TRANSLATION="The chapter:%s of book:%s was successfully installed for %s translation." COM_GETBIBLE_THE_LINK_WAS_COPIED_TO_YOUR_CLIPBOARD="The link was copied to your clipboard!" +COM_GETBIBLE_THE_NAME_COULD_NOT_BE_UPDATED="The name could not be updated." +COM_GETBIBLE_THE_NAME_HAS_BEEN_UPDATED="The name has been updated." COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_CREATED="The note was successfully created." COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_UPDATED="The note was successfully updated." +COM_GETBIBLE_THE_PERSISTENT_SESSION_KEY_ALLOWS_VIEWING_WHILE_EDITING_IS_ONLY_POSSIBLE_WHEN_THE_CORRECT_FAVOURITE_VERSE_IS_PROVIDED="The persistent session key allows viewing, while editing is only possible when the correct favourite verse is provided." COM_GETBIBLE_THE_SCRIPTURE_WAS_COPIED_TO_YOUR_CLIPBOARD="The scripture was copied to your clipboard!" COM_GETBIBLE_THE_SEARCH_FEATURE_HAS_NOT_BEEN_ACTIVATED_PLEASE_CONTACT_THE_SYSTEM_ADMINISTRATOR_OF_THIS_WEBSITE_TO_RESOLVE_THIS="The search feature has not been activated. Please contact the system administrator of this website to resolve this." COM_GETBIBLE_THE_SESSION_IS_SET="The session is set." -COM_GETBIBLE_THE_SESSION_KEY_ALLOWS_VIEWING_WHILE_EDITING_IS_ONLY_POSSIBLE_WHEN_THE_CORRECT_FAVOURITE_VERSE_IS_PROVIDED="The session key allows viewing, while editing is only possible when the correct favourite verse is provided." COM_GETBIBLE_THE_TAG_SELECTED_IS_NOT_ACTIVE_PLEASE_SELECT_AN_ACTIVE_TAG="The tag selected is not active, please select an active tag." COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED="The tag was successfully removed." COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED_FROM_THE_VERSE="The tag was successfully removed from the verse." COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_SET="The tag was successfully set." COM_GETBIBLE_THE_VERSE_WAS_SUCCESSFULLY_TAGGED="The verse was successfully tagged." COM_GETBIBLE_THE_WORDS_OF_ETERNAL_LIFE="The words of eternal life!" +COM_GETBIBLE_THIS_AREA_DISPLAYS_YOUR_RECENTLY_ACCESSED_SESSIONS="This area displays your recently accessed sessions." COM_GETBIBLE_THIS_INSTALLATION_PROCESS_IS_A_ONETIME_OPERATION_FOR_EACH_TRANSLATION_HOWEVER_YOU_ARE_WELCOME_TO_RUN_THE_PROCESS_A_SECOND_TIME_OR_AS_OFTEN_AS_YOUD_LIKE_TO_VALIDATE_AND_ENSURE_THAT_ALL_CONTENT_WAS_PROPERLY_LOADED_AND_IS_UPTODATE="This installation process is a one-time operation for each translation. However, you are welcome to run the process a second time or as often as you'd like to validate and ensure that all content was properly loaded and is up-to-date." COM_GETBIBLE_THIS_IS_A_GLOBAL_TAG_SET_BY_US_AT_BSB_FOR_YOUR_CONVENIENCE_WE_HOLD_THE_PRIVILEGE_TO_MODIFY_THESE_TAGS_IF_YOU_BELIEVE_ITS_SET_IN_ERROR_KINDLY_INFORM_US="This is a global tag, set by us at %s for your convenience. We hold the privilege to modify these tags. If you believe it's set in error, kindly inform us." COM_GETBIBLE_THIS_IS_CURRENTLY_THE_ACTIVE_SESSION_KEY="This is currently the active session key." COM_GETBIBLE_THIS_IS_NOT_A_VALID_SESSION_KEY="This is not a valid session key." -COM_GETBIBLE_THIS_SESSION_IS_ALREADY_ACTIVE="This session is already active." -COM_GETBIBLE_THIS_SESSION_KEY_DOES_NOT_QUALIFY_FOR_SHARING="This session key does not qualify for sharing." +COM_GETBIBLE_THIS_PERSISTENT_SESSION_IS_ALREADY_ACTIVE="This persistent session is already active." +COM_GETBIBLE_THIS_SESSION_KEY_IS_NOT_YET_ELIGIBLE_FOR_SHARING_AS_NO_ACTIONS_HAVE_BEEN_PERFORMED_WITHIN_IT="This session key is not yet eligible for sharing, as no actions have been performed within it." COM_GETBIBLE_THIS_TAG_COULD_NOT_BE_REMOVED="This tag could not be removed." COM_GETBIBLE_THIS_TAG_CURRENTLY_DOESNT_HAVE_ANY_VERSES_LINKED_TO_IT_PLEASE_SELECT_ANOTHER_TAG_OR_ATTACH_SOME_VERSES_TO_THIS_ONE="This tag currently doesn't have any verses linked to it. Please select another tag, or attach some verses to this one." COM_GETBIBLE_THIS_VERSE_IN_COMBINATION_WITH_YOUR_ISESSION_KEYI_WILL_BE_USED_TO_AUTHENTICATE_YOU_IN_THE_FUTURE="This verse in combination with your session key will be used to authenticate you in the future." @@ -190,10 +207,11 @@ COM_GETBIBLE_TOP_P="Top P" COM_GETBIBLE_TOTALTOKENS="TotalTokens" COM_GETBIBLE_TO_PERFORM_THIS_OPEN_THE_GLOBAL_OPTIONS_SECTION_OF_THE_GETBIBLE_BACKEND_LOCATE_THE_GLOBAL_TAB_AND_SWITCH_SHOW_INSTALL_BUTTON_TO_NO_THIS_STEP_ENSURES_THAT_YOUR_SYSTEM_RESOURCES_ARE_NOT_UTILIZED_UNNECESSARILY_ONCE_YOU_HAVE_SUCCESSFULLY_INSTALLED_ALL_YOUR_DESIRED_BIBLE_TRANSLATIONS="To perform this, open the 'Global Options' section of the getBible backend, locate the 'Global' Tab, and switch 'Show Install Button' to [No]. This step ensures that your system resources are not utilized unnecessarily once you have successfully installed all your desired Bible translations." COM_GETBIBLE_TO_UNTAG_A_VERSE_DRAG_AND_DROP_THE_DESIRED_TAG_FROM_ACTIVE_TO_THE_AVAILABLE_TAGS_AREA="To un-tag a verse, drag and drop the desired tag from active to the available tags area." -COM_GETBIBLE_TO_USE_A_DIFFERENT_SESSION_KEY_SIMPLY_ADD_IT_HERE="To use a different session key, simply add it here." +COM_GETBIBLE_TO_USE_A_DIFFERENT_PERSISTENT_SESSION_KEY_SIMPLY_ADD_IT_ABOVE_AND_CLICK_LOAD="To use a different persistent session key, simply add it above, and click load." COM_GETBIBLE_TRANSLATION="Translation" COM_GETBIBLE_TRANSLATIONS="Translations" COM_GETBIBLE_TYPE_YOUR_SEARCH_PHRASE_INTO_THE_SEARCH_BOX_AND_PRESS_ENTER_TO_SEARCH_THE_BSCRIPTURESB_DAILY="Type your search phrase into the search box and press [ENTER] to search the Scriptures daily!" +COM_GETBIBLE_UPDATE_PERSISTENT_SESSION_NAME="Update Persistent Session Name" COM_GETBIBLE_VALIDATION_HASH_OF_THIS_CHAPTER="Validation Hash of this Chapter" COM_GETBIBLE_VERSE="Verse" COM_GETBIBLE_VERSES="Verses" @@ -202,15 +220,18 @@ COM_GETBIBLE_VIEW_ALL_VERSES_TAGGED="View all verses tagged." COM_GETBIBLE_WERE_SORRY_THE_TRANSLATION_YOU_SELECTED_DOES_NOT_INCLUDE_THE_BOOK_YOU_WERE_IN_PREVIOUSLY_HOWEVER_WE_HAVE_LOCATED_BSB_WHICH_MIGHT_BE_OF_INTEREST_TO_YOU="We're sorry, the translation you selected does not include the book you were in previously. However, we have located %s which might be of interest to you." COM_GETBIBLE_WE_CURRENTLY_HAVE_BSB_VERSES_STORED_IN_THE_DATABASE_FOR_THIS_PARTICULAR_TRANSLATION="We currently have %s verses stored in the database for this particular translation." COM_GETBIBLE_WHAT_IS_THIS_HASH_ALL_ABOUT_CLICK_HERE_TO_READ_MORE="What is this Hash all about? Click here to read more..." -COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION="Without selecting the correct favourite verse, you can't perform the initial action." +COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSEBR_YOU_CANT_PERFORM_THE_INITIAL_ACTION="Without selecting the correct favourite verse,- - -
-' . JText::_('COM_GETBIBLE_SHOULD_YOU_HAVE
// set buttons
$buttons = [
- ['name' => JText::_('COM_GETBIBLE_SELECT'), 'onclick' => "activeLinkerAccess();", 'class' => 'uk-button uk-button-default uk-width-2-3'],
- ['close' => true, 'name' => JText::_('COM_GETBIBLE_CANCEL'), 'class' => 'uk-button uk-button-danger uk-width-1-3']
+ ['id' => 'getbible-select-favourite-verse', 'name' => JText::_('COM_GETBIBLE_SELECT'), 'class' => 'uk-button uk-button-default uk-width-2-3'],
+ ['id' => 'getbible-cancel-favourite-verse', 'close' => true, 'name' => JText::_('COM_GETBIBLE_CANCEL'), 'class' => 'uk-button uk-button-danger uk-width-1-3']
];
@@ -74,37 +74,142 @@ const favouriteBook = document.getElementById('getbible_favourite_book');
const favouriteChapter = document.getElementById('getbible_favourite_chapter');
const favouriteVerse = document.getElementById('getbible_favourite_verse');
const favouriteLinker = document.getElementById('getbible_favourite_linker');
-
+const favouriteSelection = document.getElementById('getbible-select-favourite-verse');
+const cancelFavouriteSelection = document.getElementById('getbible-cancel-favourite-verse');
+params->get('show_settings') == 1): ?>
+const sessionAccessStatusSwitch = document.getElementById('getbible-session-status-switch');
+
+// Helper function to update the UI
+const updateUIAfterSettingFavourite = (linker, pass) => {
+ favouriteError.style.display = 'none';
+ setActiveLinkerOnPage(linker);
+ setLocalMemory('getbible_active_linker_guid', linker);
+ setLocalMemory(linker + '-validated', true);params->get('show_settings') == 1): ?>
+ setSessionStatusAccess();
+ UIkit.modal('#getbible_favourite_verse_selector').hide();
+};
+// Helper function to handle errors
+const handleFavouriteError = (errorMessage) => {
+ favouriteError.style.display = '';
+ favouriteErrorMessage.textContent = errorMessage;
+};
+// two variables to hold the resolve and reject functions of our Promise
+let resolveFavouriteVerseSelection, rejectFavouriteVerseSelection;
// function to try and set the linker access
-const activeLinkerAccess = async () => {
+const setGetBibleFavouriteVerse = () => {
+ UIkit.modal('#getbible_favourite_verse_selector').show();
+ return new Promise((resolve, reject) => {
+ resolveFavouriteVerse = resolve;
+ rejectFavouriteVerse = reject;
+ });
+};
+favouriteSelection.addEventListener('click', async () => {
try {
- // create the pass key
favouriteError.style.display = 'none';
let pass = favouriteBook.value + '_' + favouriteChapter.value + '_' + favouriteVerse.value;
let linker = favouriteLinker.value;
- // Wait for the server to return the response, then parse it as JSON.
const data = await setLinkerAccess(linker, pass);
- // Call another function after the response has been received
if (data.success) {
- // set the linker global
- favouriteError.style.display = 'none';
- setActiveLinkerOnPage(linker);
- setLocalMemory('getbible_active_linker_guid', linker);
- setLocalMemory(linker, pass);
+ updateUIAfterSettingFavourite(linker, pass);
+ resolveFavouriteVerse();
UIkit.modal('#getbible_favourite_verse_selector').hide();
} else if (data.error) {
- // show the error
- favouriteError.style.display = '';
- favouriteErrorMessage.textContent = data.error;
+ handleFavouriteError(data.error);
+ rejectFavouriteVerse(data.error);
} else {
- // Handle any errors
- console.error("Error occurred: ", data);
+ let error = "Unknown error occurred: " + JSON.stringify(data);
+ console.error(error);
+ rejectFavouriteVerse(error);
}
} catch (error) {
- // Handle any errors
console.error("Error occurred: ", error);
+ rejectFavouriteVerse(error);
}
-}
+});
+cancelFavouriteSelection.addEventListener('click', () => {
+ rejectFavouriteVerse('User cancelled the operation');
+ UIkit.modal('#getbible_favourite_verse_selector').hide();
+});
+const setFavouriteVerseForBrowser = async () => {
+ return new Promise(async (resolve, reject) => {
+ try {
+ await setGetBibleFavouriteVerse();
+ resolve();
+ } catch (err) {
+ reject(err);
+ }
+ });
+};
+params->get('show_settings') == 1): ?>
+const removeFavouriteVerseFromBrowser = () => {
+ return new Promise(async (resolve, reject) => {
+ try {
+ let linker = getLocalMemory('getbible_active_linker_guid');
+ if (linker) {
+ let revoked = await revokeLinkerAccess(linker);
+ if (revoked.success) {
+ setLocalMemory(linker + '-validated', false);
+ resolve();
+ } else if (revoked.error) {
+ reject(revoked.error);
+ } else {
+ reject("Unexpected response");
+ }
+ } else {
+ reject("Linker is undefined");
+ }
+ } catch (err) {
+ reject(err);
+ }
+ });
+};
+const lockSessionStatusAccess = async () => {
+ sessionAccessStatusSwitch.setAttribute('uk-icon', 'icon: lock; ratio: 5');
+ sessionAccessStatusSwitch.classList.remove('uk-text-success');
+ sessionAccessStatusSwitch.setAttribute('uk-tooltip', '');
+};
+const unlockSessionStatusAccess = async () => {
+ sessionAccessStatusSwitch.setAttribute('uk-icon', 'icon: unlock; ratio: 6');
+ sessionAccessStatusSwitch.classList.add('uk-text-success');
+ sessionAccessStatusSwitch.setAttribute('uk-tooltip', '');
+};
+const changeSessionStatusSwitch = async () => {
+ var isLocked = sessionAccessStatusSwitch.getAttribute('uk-icon') === "icon: lock; ratio: 5";
+ if(isLocked) {
+ setFavouriteVerseForBrowser().then(() => {
+ unlockSessionStatusAccess();
+ }).catch((error) => {
+ console.error("An error occurred:", error);
+ });
+ } else {
+ removeFavouriteVerseFromBrowser().then(() => {
+ lockSessionStatusAccess()
+ }).catch((error) => {
+ console.error("An error occurred:", error);
+ });
+ }
+};
+const setSessionStatusAccess = async () => {
+ // check if we have an open or closed session
+ let linker = getLocalMemory('getbible_active_linker_guid');
+ if (linker) {
+ let pass = getLocalMemory(linker + '-validated');
+ if (pass) {
+ unlockSessionStatusAccess();
+ } else {
+ lockSessionStatusAccess();
+ }
+ } else {
+ lockSessionStatusAccess();
+ }
+};
+document.addEventListener('DOMContentLoaded', function() {
+ setSessionStatusAccess();
+ sessionAccessStatusSwitch.addEventListener('click', function() {
+ changeSessionStatusSwitch();
+ });
+});
+
diff --git a/site/views/app/tmpl/default_getbiblelinkermanager.php b/site/views/app/tmpl/default_getbiblelinkermanager.php
new file mode 100644
index 0000000..7c11db2
--- /dev/null
+++ b/site/views/app/tmpl/default_getbiblelinkermanager.php
@@ -0,0 +1,61 @@
+
+ @git Get Bible