Page 1 of 1

Warning when closing the Subsonic Website?!

PostPosted: Fri Dec 30, 2011 12:26 pm
by Pcace
Hi,

is it possible to implement a warning when closing the Subsonic Website? like Grooveshark?
Here it happens very often, that i simply close the website...


Possible?


Pcace

Re: Warning when closing the Subsonic Website?!

PostPosted: Thu Jan 19, 2012 8:45 pm
by ytechie
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.

Re: Warning when closing the Subsonic Website?!

PostPosted: Fri Jan 20, 2012 1:32 am
by ytechie
Check out the full mod:

viewtopic.php?f=8&t=8804

Re: Warning when closing the Subsonic Website?!

PostPosted: Tue Jun 05, 2012 8:39 pm
by Pcace
Thanks!!! Simply Great!