fictioneer/js/story.min.js
2023-01-26 23:34:02 +01:00

1 line
1.7 KiB
JavaScript

var fcn_storyCommentPage=1,fcn_storySettings=fcn_getStorySettings();function fcn_getStorySettings(){let t=localStorage.getItem("fcnStorySettings");return t=t&&fcn_isValidJSONString(t)?JSON.parse(t):fcn_defaultStorySettings(),(!t.hasOwnProperty("timestamp")||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&&(_$$$("toggle-view").checked="grid"==fcn_storySettings.view,_$$$("toggle-order").checked="desc"==fcn_storySettings.order)}function fcn_loadStoryComments(){let t;_$(".load-more-list-item").remove(),_$(".comments-loading-placeholder").classList.remove("hidden");let e={action:"fictioneer_request_story_comments",post_id:fcn_inlineStorage.postId,page:fcn_storyCommentPage};fcn_ajaxGet(e).then((e=>{e.success?(_$(".fictioneer-comments__list > ul").innerHTML+=e.data.html,fcn_storyCommentPage++):e.data?.error&&(t=fcn_buildErrorNotice(e.data.error))})).catch((e=>{t=fcn_buildErrorNotice(e)})).then((()=>{_$(".comments-loading-placeholder").remove(),t&&_$(".fictioneer-comments__list > ul").appendChild(t)}))}fcn_applyStorySettings(),_$$$("toggle-order")?.addEventListener("change",(t=>{fcn_storySettings.order=t.currentTarget.checked?"desc":"asc",fcn_setStorySettings(fcn_storySettings)})),_$$$("toggle-view")?.addEventListener("change",(t=>{fcn_storySettings.view=t.currentTarget.checked?"grid":"list",fcn_setStorySettings(fcn_storySettings)}));