Design for Pages that starts for Different Purposes

At my company, we have different pages for different purposes and some of those pages has multiple starting points. According to that points, pages opens with different types. For examle: When clicked on a record for open details page, it opens that page with necessary information and enabled and editable fields filled with those information, but when selected from another list for approvement, it opens page with same but slightly different information with non-editable fileds. And for starting purposes, pages could include another partial pages inside some ‘div’s.

One of those pages has +10000 lines of spaghetti code and it is my duty to develop and maintain that page. Everytime i need to add something to that code, i find myself reading and try to understand it and try to figure it out where should i put my code.

So, what is the elegant way to handle these types of pages. Is there any design patternish thing that i can implement?

PS: We use a special framework that is written 8 years ago, before me. It uses Java for handling events and uses HTML/CSS/JS to render page.