Currently in the process of developing a fun little script to help me organize and rate the movies in my personal collection. Among my list are a number of different movie titles that desperately need to be organized. The plan is to implement a merge-sort-like recursive algorithm to arrange the movies according to their ratings. During each comparison, I want to dynamically update a form on the page. The user's task will be to choose between two movie titles, marking the better one as either A or B, then proceeding by clicking a "continue" button. This input will guide the sorting process. By the end of the algorithm, the user should have answered a series of binary comparison questions, resulting in an ordered list of the movies.
One major hurdle I've encountered is figuring out how to pause the recursive algorithm at each step to await user input from the form. While using something like confirm()
would allow the code to halt until input is received, page elements themselves are unable to provide this functionality. Is there a workaround that involves a timed function? Perhaps utilizing a global closure? Ideally, I would like the "continue" button to trigger a callback function named continueRecursion(), though I am unsure how to implement this.
If anyone has any advice or strategies to tackle this challenge, please share your suggestions!