User:PetraMagna/story.js: Difference between revisions

From Blue Archive Wiki
Jump to navigation Jump to search
Content deleted Content added
add bgm stop functionality
(No difference)

Revision as of 19:26, 7 January 2024

const story_js = function() {
    // wait for jQuery to become available
    function defer(method) {
        if (window.jQuery) {
            method();
        } else {
            setTimeout(function() { defer(method) }, 50);
        }
    }
    
    // specifies what to do after the user clicks on a sensei reply option
    function bgm_stop_click() {
        $('.story-bgm-container button.vjs-playing').each(function(num, pause_button) {
			pause_button.click();
        });
        
    }
    
    function bgm_init() {
        $(".story-bgm-stop-button").each(function(i, stop_button) {
        	stop_button.onclick = bgm_stop_click;
        });
    }
    
    function bgm_main() {
        $(document).ready(function() {
            bgm_init();
        });
    }
    
    defer(bgm_main);
};

story_js();