Warning when closing the Subsonic Website?!

Third-party modifications and add-ons, Apps and Clients

Moderator: moderators

Re: Warning when closing the Subsonic Website?!

Postby ytechie » Thu Jan 19, 2012 8:45 pm

Here is how to add a confirm box before exiting subsonic.

We are going to edit playlist.jsp. Here is the part we are going to edit:

Code: Select all
<script type="text/javascript" language="javascript">
    var player = null;
    var songs = null;
    var currentAlbumUrl = null;
    var currentStreamUrl = null;
    var startPlayer = false;
    var repeatEnabled = false;
    var slider = null;

    function init() {
        dwr.engine.setErrorHandler(null);
        startTimer();

    <c:choose>
    <c:when test="${model.player.web}">
        createPlayer();
    </c:when>
    <c:otherwise>
        getPlaylist();
    </c:otherwise>
    </c:choose>
    }


we are going to add "window.onbeforeunload = askConfirm;" right under "startTimer();".

Now we are going to add this function:

Code: Select all
function askConfirm() {
   return "Are you sure you want to exit?";
}


Hope this helps! :D

Note: Some browsers, including Google Chrome have a default message that will appear underneath your custom message, so feel free to remove the quoted text after "return" (and remove the quotes).

This mod is better when many other things are added, and I plan to post the full version of the exit warning mod soon.
On my instance of subsonic, if a song is playing, the warning will come up with the name and artist of the currently playing song.
When playing videos there is a similar warning replaced with the title of the video.
However, when clicking the back link or new window link or changing the time or bitrate, the warnings don't appear.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Warning when closing the Subsonic Website?!

Postby ytechie » Fri Jan 20, 2012 1:32 am

Check out the full mod:

viewtopic.php?f=8&t=8804
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York


Return to Mods, Apps and Clients

Who is online

Users browsing this forum: No registered users and 7 guests