Remove inline storage
This commit is contained in:
parent
63f49f531d
commit
3c01b7bd0f
11
FILTERS.md
11
FILTERS.md
@ -890,17 +890,6 @@ Filters the intermediate item array of the `fictioneer_render_icon_menu()` funct
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_inline_storage', $attributes )`
|
||||
Filters the intermediate output array (tuples) for the `#inline-storage` data attributes before it is mapped, imploded, and rendered in the `header.php` template. These values are important for several scripts and stored in the `fcn_inlineStorage` JavaScript constant.
|
||||
|
||||
**attributes:**
|
||||
* $permalink (['data-permalink', string]) – Escaped current URL.
|
||||
* $homelink (['data-homelink', string]) – Escaped home URL.
|
||||
* $post_id (['data-post-id', int|null]) – Current post ID. Unsafe since this may be an archive, author, etc.
|
||||
* $story_id (['data-story-id', int|null]) – Current story ID (if story or chapter). Unsafe.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_is_admin', $check, $user_id )`
|
||||
Filters the boolean return value of the `fictioneer_is_admin( $user_id )` function. This may be handy if you want to use custom roles or account for other factors not covered by default capabilities. Beware, the result determines whether the user can perform [administrator](https://wordpress.org/support/article/roles-and-capabilities/#administrator) actions.
|
||||
|
||||
|
111
header.php
111
header.php
@ -29,6 +29,7 @@ global $post;
|
||||
|
||||
$page_id = get_queried_object_id();
|
||||
$post_id = $post ? $post->ID : null;
|
||||
$story_id = null;
|
||||
|
||||
if ( $page_id != $post_id ) {
|
||||
$post_id = $page_id;
|
||||
@ -43,6 +44,66 @@ if ( ( $args['no_index'] ?? 0 ) || FICTIONEER_MU_REGISTRATION ) {
|
||||
add_filter( 'wp_robots', 'wp_robots_no_robots' );
|
||||
}
|
||||
|
||||
// Setup
|
||||
$story_id = null;
|
||||
$post_type = $post_id ? $post->post_type : null;
|
||||
$header_image_source = 'default';
|
||||
$header_image_url = get_header_image();
|
||||
|
||||
// If this is a content page...
|
||||
if ( $post_id ) {
|
||||
// Type?
|
||||
switch ( $post_type ) {
|
||||
case 'fcn_story':
|
||||
$story_id = $post_id;
|
||||
break;
|
||||
case 'fcn_chapter':
|
||||
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
|
||||
break;
|
||||
}
|
||||
|
||||
// Custom header image?
|
||||
if ( get_post_meta( $post_id, 'fictioneer_custom_header_image', true ) ) {
|
||||
$header_image_url = get_post_meta( $post_id, 'fictioneer_custom_header_image', true );
|
||||
$header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' );
|
||||
$header_image_source = 'post';
|
||||
} elseif ( ! empty( $story_id ) && get_post_meta( $story_id, 'fictioneer_custom_header_image', true ) ) {
|
||||
$header_image_url = get_post_meta( $story_id, 'fictioneer_custom_header_image', true );
|
||||
$header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' );
|
||||
$header_image_source = 'story';
|
||||
}
|
||||
}
|
||||
|
||||
// Filter header image
|
||||
if ( ! empty( $post_id ) && $header_image_url ) {
|
||||
$header_image_url = apply_filters( 'fictioneer_filter_header_image', $header_image_url, $post_id );
|
||||
}
|
||||
|
||||
// Action arguments
|
||||
$action_args = array(
|
||||
'post_id' => $post_id,
|
||||
'post_type' => $post_type,
|
||||
'story_id' => $story_id,
|
||||
'header_image_url' => $header_image_url,
|
||||
'header_image_source' => $header_image_source,
|
||||
'header_args' => $args ?? []
|
||||
);
|
||||
|
||||
// Body attributes
|
||||
$body_attributes = array(
|
||||
'data-post-id' => ( $post_id ?: -1 )
|
||||
);
|
||||
|
||||
if ( $story_id ) {
|
||||
$body_attributes['data-story-id'] = $story_id;
|
||||
}
|
||||
|
||||
$body_attributes = array_map(
|
||||
function ( $key, $value ) { return $key . '="' . esc_attr( $value ) . '"'; },
|
||||
array_keys( $body_attributes ),
|
||||
$body_attributes
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
@ -51,54 +112,10 @@ if ( ( $args['no_index'] ?? 0 ) || FICTIONEER_MU_REGISTRATION ) {
|
||||
|
||||
<head><?php wp_head(); ?></head>
|
||||
|
||||
<body <?php body_class( 'site-bg scrolled-to-top' ); ?> data-post-id="<?php echo $post_id ?: -1; ?>">
|
||||
<?php wp_body_open(); ?>
|
||||
|
||||
<body <?php body_class( 'site-bg scrolled-to-top' ); echo implode( ' ', $body_attributes ); ?>>
|
||||
<?php
|
||||
// Setup
|
||||
$story_id = null;
|
||||
$post_type = $post_id ? $post->post_type : null;
|
||||
$header_image_source = 'default';
|
||||
$header_image_url = get_header_image();
|
||||
|
||||
// If this is a content page...
|
||||
if ( $post_id ) {
|
||||
// Type?
|
||||
switch ( $post_type ) {
|
||||
case 'fcn_story':
|
||||
$story_id = $post_id;
|
||||
break;
|
||||
case 'fcn_chapter':
|
||||
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
|
||||
break;
|
||||
}
|
||||
|
||||
// Custom header image?
|
||||
if ( get_post_meta( $post_id, 'fictioneer_custom_header_image', true ) ) {
|
||||
$header_image_url = get_post_meta( $post_id, 'fictioneer_custom_header_image', true );
|
||||
$header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' );
|
||||
$header_image_source = 'post';
|
||||
} elseif ( ! empty( $story_id ) && get_post_meta( $story_id, 'fictioneer_custom_header_image', true ) ) {
|
||||
$header_image_url = get_post_meta( $story_id, 'fictioneer_custom_header_image', true );
|
||||
$header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' );
|
||||
$header_image_source = 'story';
|
||||
}
|
||||
}
|
||||
|
||||
// Filter header image
|
||||
if ( ! empty( $post_id ) && $header_image_url ) {
|
||||
$header_image_url = apply_filters( 'fictioneer_filter_header_image', $header_image_url, $post_id );
|
||||
}
|
||||
|
||||
// Action arguments
|
||||
$action_args = array(
|
||||
'post_id' => $post_id,
|
||||
'post_type' => $post_type,
|
||||
'story_id' => $story_id,
|
||||
'header_image_url' => $header_image_url,
|
||||
'header_image_source' => $header_image_source,
|
||||
'header_args' => $args ?? []
|
||||
);
|
||||
// WP Default action
|
||||
wp_body_open();
|
||||
|
||||
// Includes mobile menu
|
||||
do_action( 'fictioneer_body', $action_args );
|
||||
|
4
js/application.min.js
vendored
4
js/application.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/chapter.min.js
vendored
2
js/chapter.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/checkmarks.min.js
vendored
2
js/checkmarks.min.js
vendored
@ -1 +1 @@
|
||||
var fcn_checkmarks,fcn_userCheckmarksTimeout;function fcn_initializeCheckmarks(a){const e=a.detail.data.checkmarks;!1!==e&&(Array.isArray(e.data)&&0===e.data.length&&(e.data={}),fcn_checkmarks=e,fcn_updateCheckmarksView(),localStorage.removeItem("fcnBookshelfContent"),_$$("button.checkmark").forEach((a=>{a.addEventListener("click",(a=>{fcn_clickCheckmark(a.currentTarget)}))})))}function fcn_toggleCheckmark(a,e,t=null,c=null,s="toggle"){const r=fcn_getUserData();if(fcn_checkmarks&&r.checkmarks){if(localStorage.removeItem("fcnBookshelfContent"),"toggle"===s&&JSON.stringify(fcn_checkmarks.data[a])!==JSON.stringify(r.checkmarks.data[a]))return fcn_checkmarks=r.checkmarks,fcn_showNotification(fictioneer_tl.notification.checkmarksResynchronized),void fcn_updateCheckmarksView();if(fcn_checkmarks.data[a]||(fcn_checkmarks.data[a]=[]),r.checkmarks.data[a]||(r.checkmarks.data[a]=[]),t&&"progress"===e&&!fcn_checkmarks.data[a].includes(t)&&fcn_checkmarks.data[a].push(t),t&&"chapter"===e)if(!fcn_checkmarks.data[a].includes(t)&&"unset"!==s||"set"===s)fcn_checkmarks.data[a].push(t),c&&(c.classList.add("marked"),c.setAttribute("aria-checked",!0));else{fcn_removeItemOnce(fcn_checkmarks.data[a],t),c&&(c.classList.remove("marked"),c.setAttribute("aria-checked",!1)),fcn_removeItemOnce(fcn_checkmarks.data[a],a);const e=_$('button[data-type="story"]');e&&(e.classList.remove("marked"),e.setAttribute("aria-checked",!1))}if("story"===e){const e=(fcn_checkmarks.data[a].includes(a)||"unset"===s)&&"set"!==s;fcn_checkmarks.data[a]=[],e||(_$$("button.checkmark").forEach((e=>{fcn_checkmarks.data[a].push(parseInt(e.dataset.id))})),fcn_checkmarks.data[a].includes(a)||fcn_checkmarks.data[a].push(a))}fcn_checkmarks.data[a]=fcn_checkmarks.data[a].filter(((a,e,t)=>t.indexOf(a)==e)),r.checkmarks.data[a]=fcn_checkmarks.data[a],r.lastLoaded=0,fcn_setUserData(r),fcn_updateCheckmarksView(),clearTimeout(fcn_userCheckmarksTimeout),fcn_userCheckmarksTimeout=setTimeout((()=>{fcn_updateCheckmarks(a,fcn_checkmarks.data[a])}),fictioneer_ajax.post_debounce_rate)}}function fcn_clickCheckmark(a){fcn_toggleCheckmark(parseInt(a.dataset.storyId),a.dataset.type,parseInt(a.dataset.id),a)}function fcn_updateCheckmarks(a,e=null){e=e||fcn_getUserData().checkmarks.data[a],fcn_ajaxPost({action:"fictioneer_ajax_set_checkmark",fcn_fast_ajax:1,story_id:a,update:e.join(" ")}).then((a=>{a.success||(fcn_showNotification(a.data.failure??a.data.error??fictioneer_tl.notification.error,3,"warning"),(a.data.error||a.data.failure)&&console.error("Error:",a.data.error??a.data.failure))})).catch((a=>{a.status&&a.statusText&&fcn_showNotification(`${a.status}: ${a.statusText}`,5,"warning"),console.error(a)}))}function fcn_updateCheckmarksView(){const a=fcn_getUserData(),e=a.checkmarks;if(!e)return;const t=parseInt(fcn_inlineStorage.storyId);if(t){const c=e.data[t]&&e.data[t].includes(t);if(c){let c=!1;_$$("button.checkmark").forEach((a=>{const s=parseInt(a.dataset.id);e.data[t].includes(s)||(e.data[t].push(s),c=!0)})),c&&(a.checkmarks=e,fcn_setUserData(a),fcn_updateCheckmarks(t,e.data[t]))}_$$$("ribbon-read")?.classList.toggle("hidden",!c)}_$$("button.checkmark").forEach((a=>{const t=parseInt(a.dataset.storyId);if(e.data[t]){const c=e.data[t].includes(parseInt(a.dataset.id));a.classList.toggle("marked",c),a.setAttribute("aria-checked",c)}})),_$$(".card").forEach((a=>{const t=parseInt(a.dataset.storyId),c=e.data[t]&&(e.data[t].includes(parseInt(a.dataset.checkId))||e.data[t].includes(t));a.classList.toggle("has-checkmark",1==c)}))}document.addEventListener("fcnUserDataReady",(a=>{fcn_initializeCheckmarks(a)}));
|
||||
var fcn_checkmarks,fcn_userCheckmarksTimeout;function fcn_initializeCheckmarks(a){const e=a.detail.data.checkmarks;!1!==e&&(Array.isArray(e.data)&&0===e.data.length&&(e.data={}),fcn_checkmarks=e,fcn_updateCheckmarksView(),localStorage.removeItem("fcnBookshelfContent"),_$$("button.checkmark").forEach((a=>{a.addEventListener("click",(a=>{fcn_clickCheckmark(a.currentTarget)}))})))}function fcn_toggleCheckmark(a,e,t=null,c=null,s="toggle"){const r=fcn_getUserData();if(fcn_checkmarks&&r.checkmarks){if(localStorage.removeItem("fcnBookshelfContent"),"toggle"===s&&JSON.stringify(fcn_checkmarks.data[a])!==JSON.stringify(r.checkmarks.data[a]))return fcn_checkmarks=r.checkmarks,fcn_showNotification(fictioneer_tl.notification.checkmarksResynchronized),void fcn_updateCheckmarksView();if(fcn_checkmarks.data[a]||(fcn_checkmarks.data[a]=[]),r.checkmarks.data[a]||(r.checkmarks.data[a]=[]),t&&"progress"===e&&!fcn_checkmarks.data[a].includes(t)&&fcn_checkmarks.data[a].push(t),t&&"chapter"===e)if(!fcn_checkmarks.data[a].includes(t)&&"unset"!==s||"set"===s)fcn_checkmarks.data[a].push(t),c&&(c.classList.add("marked"),c.setAttribute("aria-checked",!0));else{fcn_removeItemOnce(fcn_checkmarks.data[a],t),c&&(c.classList.remove("marked"),c.setAttribute("aria-checked",!1)),fcn_removeItemOnce(fcn_checkmarks.data[a],a);const e=_$('button[data-type="story"]');e&&(e.classList.remove("marked"),e.setAttribute("aria-checked",!1))}if("story"===e){const e=(fcn_checkmarks.data[a].includes(a)||"unset"===s)&&"set"!==s;fcn_checkmarks.data[a]=[],e||(_$$("button.checkmark").forEach((e=>{fcn_checkmarks.data[a].push(parseInt(e.dataset.id))})),fcn_checkmarks.data[a].includes(a)||fcn_checkmarks.data[a].push(a))}fcn_checkmarks.data[a]=fcn_checkmarks.data[a].filter(((a,e,t)=>t.indexOf(a)==e)),r.checkmarks.data[a]=fcn_checkmarks.data[a],r.lastLoaded=0,fcn_setUserData(r),fcn_updateCheckmarksView(),clearTimeout(fcn_userCheckmarksTimeout),fcn_userCheckmarksTimeout=setTimeout((()=>{fcn_updateCheckmarks(a,fcn_checkmarks.data[a])}),fictioneer_ajax.post_debounce_rate)}}function fcn_clickCheckmark(a){fcn_toggleCheckmark(parseInt(a.dataset.storyId),a.dataset.type,parseInt(a.dataset.id),a)}function fcn_updateCheckmarks(a,e=null){e=e||fcn_getUserData().checkmarks.data[a],fcn_ajaxPost({action:"fictioneer_ajax_set_checkmark",fcn_fast_ajax:1,story_id:a,update:e.join(" ")}).then((a=>{a.success||(fcn_showNotification(a.data.failure??a.data.error??fictioneer_tl.notification.error,3,"warning"),(a.data.error||a.data.failure)&&console.error("Error:",a.data.error??a.data.failure))})).catch((a=>{a.status&&a.statusText&&fcn_showNotification(`${a.status}: ${a.statusText}`,5,"warning"),console.error(a)}))}function fcn_updateCheckmarksView(){const a=fcn_getUserData(),e=a.checkmarks;if(!e)return;const t=parseInt(fcn_theBody.dataset.storyId);if(t){const c=e.data[t]&&e.data[t].includes(t);if(c){let c=!1;_$$("button.checkmark").forEach((a=>{const s=parseInt(a.dataset.id);e.data[t].includes(s)||(e.data[t].push(s),c=!0)})),c&&(a.checkmarks=e,fcn_setUserData(a),fcn_updateCheckmarks(t,e.data[t]))}_$$$("ribbon-read")?.classList.toggle("hidden",!c)}_$$("button.checkmark").forEach((a=>{const t=parseInt(a.dataset.storyId);if(e.data[t]){const c=e.data[t].includes(parseInt(a.dataset.id));a.classList.toggle("marked",c),a.setAttribute("aria-checked",c)}})),_$$(".card").forEach((a=>{const t=parseInt(a.dataset.storyId),c=e.data[t]&&(e.data[t].includes(parseInt(a.dataset.checkId))||e.data[t].includes(t));a.classList.toggle("has-checkmark",1==c)}))}document.addEventListener("fcnUserDataReady",(a=>{fcn_initializeCheckmarks(a)}));
|
10
js/complete.min.js
vendored
10
js/complete.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/story.min.js
vendored
2
js/story.min.js
vendored
@ -1 +1 @@
|
||||
var fcn_storyCommentPage=1,fcn_storySettings=fcn_getStorySettings();function fcn_cleanUpActions(){_$$(".story__actions > *").forEach((t=>{const e=window.getComputedStyle(t);"none"!==e.display&&"hidden"!==e.visibility||t.remove()}))}function fcn_getStorySettings(){let t=fcn_parseJSON(localStorage.getItem("fcnStorySettings"))??fcn_defaultStorySettings();return t.timestamp<1674770712849&&(t=fcn_defaultStorySettings(),t.timestamp=Date.now()),fcn_setStorySettings(t),t}function fcn_defaultStorySettings(){return{view:"list",order:"asc",timestamp:1674770712849}}function fcn_setStorySettings(t){"object"==typeof t&&(fcn_storySettings=t,localStorage.setItem("fcnStorySettings",JSON.stringify(t)))}function fcn_applyStorySettings(){"object"==typeof fcn_storySettings&&(_$$("[data-view]").forEach((t=>{t.dataset.view="grid"==fcn_storySettings.view?"grid":"list"})),_$$("[data-order]").forEach((t=>{t.dataset.order="desc"==fcn_storySettings.order?"desc":"asc"})))}fcn_theRoot.dataset.ajaxAuth?document.addEventListener("fcnAuthReady",(()=>{fcn_cleanUpActions()})):document.addEventListener("DOMContentLoaded",(()=>{fcn_cleanUpActions()})),fcn_applyStorySettings();var fcn_isToggling=!1;function fcn_toggleStoryTab(t){const e=t.closest(".story");e.querySelectorAll(".story__tab-target._current, .story__tabs ._current").forEach((t=>{t.classList.remove("_current")})),e.querySelectorAll(`[data-finder="${t.dataset.target}"]`).forEach((t=>{t.classList.add("_current")})),e.querySelector(".story__tabs").dataset.current=t.dataset.target,t.classList.add("_current")}function fcn_loadStoryComments(t){let e;_$(".load-more-list-item").remove(),_$(".comments-loading-placeholder").classList.remove("hidden"),fcn_ajaxGet({post_id:t.dataset.storyId??fcn_inlineStorage.postId,page:fcn_storyCommentPage},"get_story_comments").then((t=>{t.success?(_$(".fictioneer-comments__list > ul").innerHTML+=t.data.html,fcn_storyCommentPage++):t.data?.error&&(e=fcn_buildErrorNotice(t.data.error))})).catch((t=>{e=fcn_buildErrorNotice(t)})).then((()=>{_$(".comments-loading-placeholder").remove(),e&&_$(".fictioneer-comments__list > ul").appendChild(e)}))}function fcn_startEpubDownload(t,e=0){e>3?t.classList.remove("ajax-in-progress"):fcn_ajaxGet({action:"fictioneer_ajax_download_epub",story_id:t.dataset.storyId}).then((n=>{n.success?(window.location.href=t.href,setTimeout((()=>{t.classList.remove("ajax-in-progress")}),2e3)):setTimeout((()=>{fcn_startEpubDownload(t,e+1)}),2e3)})).catch((e=>{t.classList.remove("ajax-in-progress"),e.status&&e.statusText&&fcn_showNotification(`${e.status}: ${e.statusText}`,5,"warning")}))}_$$('[data-click-action*="toggle-chapter-order"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.order="asc"===t.currentTarget.dataset.order?"desc":"asc",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$('[data-click-action*="toggle-chapter-view"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.view="list"===t.currentTarget.dataset.view?"grid":"list",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$(".chapter-group__folding-toggle").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-group[data-folded]");e&&(e.dataset.folded="true"==e.dataset.folded?"false":"true")}))})),_$$(".tabs__item").forEach((t=>{t.addEventListener("click",(t=>{fcn_toggleStoryTab(t.currentTarget)}))})),_$(".comment-section")?.addEventListener("click",(t=>{t.target?.classList.contains("load-more-comments-button")&&fcn_loadStoryComments(t.target)})),_$$('[data-action="download-epub"]').forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.currentTarget.classList.contains("ajax-in-progress")||(t.currentTarget.classList.add("ajax-in-progress"),fcn_startEpubDownload(t.currentTarget))}))}));
|
||||
var fcn_storyCommentPage=1,fcn_storySettings=fcn_getStorySettings();function fcn_cleanUpActions(){_$$(".story__actions > *").forEach((t=>{const e=window.getComputedStyle(t);"none"!==e.display&&"hidden"!==e.visibility||t.remove()}))}function fcn_getStorySettings(){let t=fcn_parseJSON(localStorage.getItem("fcnStorySettings"))??fcn_defaultStorySettings();return t.timestamp<1674770712849&&(t=fcn_defaultStorySettings(),t.timestamp=Date.now()),fcn_setStorySettings(t),t}function fcn_defaultStorySettings(){return{view:"list",order:"asc",timestamp:1674770712849}}function fcn_setStorySettings(t){"object"==typeof t&&(fcn_storySettings=t,localStorage.setItem("fcnStorySettings",JSON.stringify(t)))}function fcn_applyStorySettings(){"object"==typeof fcn_storySettings&&(_$$("[data-view]").forEach((t=>{t.dataset.view="grid"==fcn_storySettings.view?"grid":"list"})),_$$("[data-order]").forEach((t=>{t.dataset.order="desc"==fcn_storySettings.order?"desc":"asc"})))}fcn_theRoot.dataset.ajaxAuth?document.addEventListener("fcnAuthReady",(()=>{fcn_cleanUpActions()})):document.addEventListener("DOMContentLoaded",(()=>{fcn_cleanUpActions()})),fcn_applyStorySettings();var fcn_isToggling=!1;function fcn_toggleStoryTab(t){const e=t.closest(".story");e.querySelectorAll(".story__tab-target._current, .story__tabs ._current").forEach((t=>{t.classList.remove("_current")})),e.querySelectorAll(`[data-finder="${t.dataset.target}"]`).forEach((t=>{t.classList.add("_current")})),e.querySelector(".story__tabs").dataset.current=t.dataset.target,t.classList.add("_current")}function fcn_loadStoryComments(t){let e;_$(".load-more-list-item").remove(),_$(".comments-loading-placeholder").classList.remove("hidden"),fcn_ajaxGet({post_id:t.dataset.storyId??fcn_theBody.dataset.postId,page:fcn_storyCommentPage},"get_story_comments").then((t=>{t.success?(_$(".fictioneer-comments__list > ul").innerHTML+=t.data.html,fcn_storyCommentPage++):t.data?.error&&(e=fcn_buildErrorNotice(t.data.error))})).catch((t=>{e=fcn_buildErrorNotice(t)})).then((()=>{_$(".comments-loading-placeholder").remove(),e&&_$(".fictioneer-comments__list > ul").appendChild(e)}))}function fcn_startEpubDownload(t,e=0){e>3?t.classList.remove("ajax-in-progress"):fcn_ajaxGet({action:"fictioneer_ajax_download_epub",story_id:t.dataset.storyId}).then((n=>{n.success?(window.location.href=t.href,setTimeout((()=>{t.classList.remove("ajax-in-progress")}),2e3)):setTimeout((()=>{fcn_startEpubDownload(t,e+1)}),2e3)})).catch((e=>{t.classList.remove("ajax-in-progress"),e.status&&e.statusText&&fcn_showNotification(`${e.status}: ${e.statusText}`,5,"warning")}))}_$$('[data-click-action*="toggle-chapter-order"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.order="asc"===t.currentTarget.dataset.order?"desc":"asc",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$('[data-click-action*="toggle-chapter-view"]').forEach((t=>{t.addEventListener("click",(t=>{fcn_isToggling||(fcn_isToggling=!0,setTimeout((()=>fcn_isToggling=!1),50),fcn_storySettings.view="list"===t.currentTarget.dataset.view?"grid":"list",fcn_setStorySettings(fcn_storySettings),fcn_applyStorySettings())}))})),_$$(".chapter-group__folding-toggle").forEach((t=>{t.addEventListener("click",(t=>{const e=t.currentTarget.closest(".chapter-group[data-folded]");e&&(e.dataset.folded="true"==e.dataset.folded?"false":"true")}))})),_$$(".tabs__item").forEach((t=>{t.addEventListener("click",(t=>{fcn_toggleStoryTab(t.currentTarget)}))})),_$(".comment-section")?.addEventListener("click",(t=>{t.target?.classList.contains("load-more-comments-button")&&fcn_loadStoryComments(t.target)})),_$$('[data-action="download-epub"]').forEach((t=>{t.addEventListener("click",(t=>{t.preventDefault(),t.currentTarget.classList.contains("ajax-in-progress")||(t.currentTarget.classList.add("ajax-in-progress"),fcn_startEpubDownload(t.currentTarget))}))}));
|
@ -5,7 +5,6 @@
|
||||
const /** @const {HTMLElement} */ fcn_theSite = _$$$('site');
|
||||
const /** @const {HTMLElement} */ fcn_theBody = _$('body');
|
||||
const /** @const {HTMLElement} */ fcn_theRoot = document.documentElement;
|
||||
const /** @const {HTMLElement} */ fcn_inlineStorage = _$$$('inline-storage').dataset;
|
||||
const /** @const {Object} */ fcn_urlParams = Object.fromEntries(new URLSearchParams(window.location.search).entries());
|
||||
const /** @const {Number} */ fcn_pageLoadTimestamp = Date.now();
|
||||
const /** @const {Number} */ fcn_ajaxLimitThreshold = Date.now() - parseInt(fictioneer_ajax.ttl); // Default: 60 seconds
|
||||
|
@ -1235,7 +1235,7 @@ function fcn_readingProgress() {
|
||||
|
||||
// If end of chapter has been reached and the user is logged in...
|
||||
if (p >= 100 && !fcn_chapterCheckmarkUpdated && fcn_isLoggedIn) {
|
||||
const storyId = _$$$('inline-storage')?.dataset.storyId;
|
||||
const storyId = fcn_theBody.dataset.storyId;
|
||||
|
||||
// Only do this once per page load
|
||||
fcn_chapterCheckmarkUpdated = true;
|
||||
@ -1246,7 +1246,7 @@ function fcn_readingProgress() {
|
||||
}
|
||||
|
||||
// Mark chapter as read
|
||||
fcn_toggleCheckmark(storyId, 'progress', parseInt(fcn_inlineStorage.postId), null, 'set');
|
||||
fcn_toggleCheckmark(storyId, 'progress', parseInt(fcn_theBody.dataset.postId), null, 'set');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ function fcn_updateCheckmarksView() {
|
||||
}
|
||||
|
||||
// Completed story pages
|
||||
const storyId = parseInt(fcn_inlineStorage.storyId);
|
||||
const storyId = parseInt(fcn_theBody.dataset.storyId);
|
||||
|
||||
if (storyId) {
|
||||
const completed = checkmarks.data[storyId] && checkmarks.data[storyId].includes(storyId);
|
||||
|
@ -247,7 +247,7 @@ function fcn_loadStoryComments(button) {
|
||||
// REST request
|
||||
fcn_ajaxGet(
|
||||
{
|
||||
'post_id': button.dataset.storyId ?? fcn_inlineStorage.postId,
|
||||
'post_id': button.dataset.storyId ?? fcn_theBody.dataset.postId,
|
||||
'page': fcn_storyCommentPage
|
||||
},
|
||||
'get_story_comments'
|
||||
|
Loading…
x
Reference in New Issue
Block a user