PageSourceSearch

http://www.prosperomoran.com/wp-content/plugins/soundy-audio-playlist/js/front-end.js

js prosperomoran.com collected 2026-09-25 19:10:38 UTC 60,223 bytes, 1,596 lines download raw bytes

1function war_SoundyAudioPlaylistFrontEnd( args )
2{
3	var _this = this;
4
5	_this.soundtracks_list         = args.soundtracks;
6	_this.autoplay                 = args.autoplay;
7	_this.play_mode                = args.play_mode;
8	_this.audio_loop               = args.audio_loop;
9	_this.pp_code                  = args.pp_code;
10	_this.yellow_select_id         = args.yellow_select_id;
11	_this.preview                  = args.preview;
12	_this.button_url_play_normal   = args.button_url_play;
13	_this.button_url_pause_normal  = args.button_url_pause;
14	_this.button_url_play_hover    = args.hover_url_play;
15	_this.button_url_pause_hover   = args.hover_url_pause;
16	_this.is_autoplay_agent        = args.is_autoplay_agent;
17    _this.is_safari                = args.is_safari;
18
19    _this.is_safari_on_ios = _this.is_safari && ! _this.is_autoplay_agent;
20
21	jQuery.noConflict();
22
23    _this.autoplay = ( _this.autoplay == 'yes' && _this.is_autoplay_agent );
24	_this.audio_loop = ( _this.audio_loop == 'yes' );
25
26    _this.is_preview              = _this.preview != 'false';
27	_this.hovering                = false;
28	_this.jquery_li_selected      = null;
29	_this.is_playlist_shortcode   = false;
30	_this.is_playing              = _this.autoplay;
31    _this.is_audio_mode_logic     = true;
32
33	jQuery( document ).ready( function() 
34	{
35		if( _this.pp_code )
36		{
37			jQuery( 'body' ).append( _this.pp_code );
38		}
39
40        switch( war_sdy_pl_button_corner )
41        {
42            case 'upper_right':
43            default:
44                var prop_x = 'right';
45                var prop_y = 'top';
46                break;
47            case 'upper_left':
48                var prop_x = 'left';
49                var prop_y = 'top';
50                break;
51            case 'bottom_right':
52                var prop_x = 'right';
53                var prop_y = 'bottom';
54                break;
55            case 'bottom_left':
56                var prop_x = 'left';
57                var prop_y = 'bottom';
58                break;
59        }
60
61        var jquery_corner_button = jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' );
62        if( jquery_corner_button.length )
63        {
64            _this.button_offset_x = jquery_corner_button.css( prop_x );
65            _this.button_offset_x = _this.button_offset_x.replace( 'px', '' );
66            _this.button_offset_y = jquery_corner_button.css( prop_y );
67            _this.button_offset_y = _this.button_offset_y.replace( 'px', '' );
68        }
69
70        _this.audio_player_element = new Audio();
71        _this.audio_player = jQuery( _this.audio_player_element );
72
73        _this.audio_control = jQuery( '.war_sdy_pl_audio_control' );
74
75        _this.column_ordered_names = sdy_pl_column_ordered_names_string.split( ',' );
76        var jquery_playlist = jQuery( '#war_sdy_pl_playlist' );
77        if( jquery_playlist.length )
78        {
79            _this.is_playlist_shortcode = true;
80            _this.jquery_playlist = jquery_playlist;
81        }
82        else
83        {
84            _this.is_playlist_shortcode = false;
85            jQuery( 'body' ).append( '<ul id="war_sdy_pl_playlist" class="war_hidden"></ul>' );
86            _this.jquery_playlist = jQuery( '#war_sdy_pl_playlist' );
87            _this.jquery_playlist.append( _this.soundtracks_list );
88        }
89
90        _this.initPlaylist();
91        _this.initShortcodePlaceholders();
92
93		if( _this.is_preview )
94		{
95            _this.initPreview();
96        }
97
98		_this.setEventHandlersForPlayPauseButtons();
99		_this.setEventHandlersForAudioPlayer();
100        _this.initPlayMode();
101        if( _this.is_playlist_shortcode )
102            _this.initPlaylistColumns();
103
104        if( ! sdy_pl_css_use_only && _this.is_playlist_shortcode )
105        {
106            _this.initPlaylistCSS();
107        }
108
109        var audio_control_has_been_loaded = false;
110        _this.audio_control.load( function()
111        {
112            if( audio_control_has_been_loaded ) return;
113            audio_control_has_been_loaded = true;
114
115            _this.button_width = this.width;
116            _this.button_height = this.height;
117
118            _this.button_aspect_ratio = _this.button_height / _this.button_width;
119
120            var jquery_picture = jQuery( 'img.war_sdy_pl_playlist_picture');
121            if( jquery_picture.length )
122            {
123                jquery_picture.load( function()
124                {
125                    _this.makePlaylistResponsive();
126                } );
127            }
128
129            _this.makePlaylistResponsive();
130
131            jQuery( window ).resize( function()
132            {
133                _this.makePlaylistResponsive();
134            } );
135        } );
136	} );
137}
138
139war_SoundyAudioPlaylistFrontEnd.prototype.initPlayMode = function()
140{
141    var _this = this;
142
143    var soundtracks = _this.jquery_playlist.children();
144    var first_soundtrack = null;
145    switch( _this.play_mode )
146    {
147        case 'seq_from_first':
148        case 'seq_from_selected':
149            if( _this.play_mode == 'seq_from_first' )
150            {
151                first_soundtrack = soundtracks.first();
152            }
153            else //if( _this.play_mode == 'seq_from_selected' )
154            {
155                if( _this.yellow_select_id )
156                {
157                    var soundtrack = _this.getSoundtrackById( _this.yellow_select_id );
158                    first_soundtrack = ( soundtrack && soundtrack.length ) ? soundtrack : soundtracks.first();
159                }
160                else
161                {
162                    first_soundtrack = soundtracks.first();
163                }
164            }
165            _this.current_soundtrack = first_soundtrack;
166            if( _this.autoplay )
167            {
168                _this.loadAudioPlayer( 'play' );
169            }
170            else
171            {
172                _this.loadAudioPlayer( 'pause' );
173            }
174
175            _this.audio_player.bind( 'ended.audio_mode_logic' , function()
176            {
177                var next_soundtrack = _this.current_soundtrack.next();
178                if( next_soundtrack.length )
179                {
180                    _this.current_soundtrack = next_soundtrack;
181                }
182                else
183                {
184                    _this.current_soundtrack = soundtracks.first();
185                }
186                if( _this.current_soundtrack.get( 0 ) !== first_soundtrack.get( 0 ) )
187                {
188                    _this.loadAudioPlayer( 'play' );
189                }
190                else if( _this.current_soundtrack.get( 0 ) === first_soundtrack.get( 0 ) && _this.audio_loop )
191                {
192                    _this.loadAudioPlayer( 'play' );
193                }
194                else //if( _this.current_soundtrack.get( 0 ) === first_soundtrack.get( 0 ) && ! _this.audio_loop )
195                {
196                    _this.loadAudioPlayer( 'pause' );
197                }
198            } );
199            break;
200    
201        case 'random_one':
202            if( soundtracks.length == 1 )
203            {
204                _this.current_soundtrack = soundtracks.first();
205                if( _this.autoplay )
206                {
207                    _this.loadAudioPlayer( 'play', _this.audio_loop );
208                }
209                else
210                {
211                    _this.loadAudioPlayer( 'pause', _this.audio_loop );
212                }
213            }
214            else
215            {
216                var index_last = sessionStorage.getItem( 'war_sdy_pl_soundtrack_index' );
217                var index_random = Math.floor( Math.random() * soundtracks.length );
218                if( index_last )
219                {
220                    index_last--;
221                    while( index_random == index_last )
222                    {
223                        index_random = Math.floor( Math.random() * soundtracks.length );
224                    }
225                }
226                sessionStorage.setItem( 'war_sdy_pl_soundtrack_index', index_random + 1 );
227                var index_selector = ':eq(' + index_random + ')';
228                _this.current_soundtrack = soundtracks.filter( index_selector );
229                if( _this.autoplay )
230                {
231                    _this.loadAudioPlayer( 'play', _this.audio_loop );
232                }
233                else
234                {
235                    _this.loadAudioPlayer( 'pause', _this.audio_loop );
236                }
237            }
238            break;
239    
240        case 'random_all':
241            if( soundtracks.length == 1 )
242            {
243                _this.current_soundtrack = soundtracks.first();
244                if( _this.autoplay )
245                {
246                    _this.loadAudioPlayer( 'play', _this.audio_loop );
247                }
248                else
249                {
250                    _this.loadAudioPlayer( 'pause', _this.audio_loop );
251                }
252            }
253            else
254            {
255                var indexes = new Array();
256                var index_random = Math.floor( Math.random() * soundtracks.length );
257                var index_last = sessionStorage.getItem( 'war_sdy_pl_soundtrack_index' );
258                var there_is_index_last = false;
259                if( index_last )
260                {
261                    there_is_index_last = true;
262                    index_last--;
263                    indexes[ index_last ] = true;
264                    while( index_random == index_last )
265                    {
266                        index_random = Math.floor( Math.random() * soundtracks.length );
267                    }
268                }
269                sessionStorage.setItem( 'war_sdy_pl_soundtrack_index', index_random + 1 );
270                indexes[ index_random ] = true;
271                var index_selector = ':eq(' + index_random + ')';
272                _this.current_soundtrack = soundtracks.filter( index_selector );
273                if( _this.autoplay )
274                {
275                    _this.loadAudioPlayer( 'play' );
276                }
277                else
278                {
279                    _this.loadAudioPlayer( 'pause' );
280                }
281    
282                _this.number_of_playings = 0;
283    
284                _this.audio_player.bind( 'ended.audio_mode_logic' , function()
285                {
286                    if( _this.arrayLength( indexes ) < soundtracks.length )
287                    {
288                        do
289                        {
290                            var index_random = Math.floor( Math.random() * soundtracks.length );
291                        }
292                        while( index_random in indexes );
293                        indexes[ index_random ] = true;
294                        var index_selector = ':eq(' + index_random + ')';
295                        _this.current_soundtrack = soundtracks.filter( index_selector );
296                        if( _this.number_of_playings && ! _this.audio_loop )
297                        {
298                            _this.loadAudioPlayer( 'pause' );
299                            _this.number_of_playings = 0;
300                        }
301                        else
302                        {
303                            _this.loadAudioPlayer( 'play' );
304                        }
305                    }
306                    else
307                    {
308                        if( there_is_index_last )
309                        {
310                            var index_selector = ':eq(' + index_last + ')';
311                            var soundtrack = soundtracks.filter( index_selector );
312                            if( soundtrack.length )
313                            {
314                                _this.current_soundtrack = soundtrack;
315                                _this.loadAudioPlayer( 'play' );
316                            }
317                        }
318                        indexes = new Array();
319                        indexes[ index_last ] = true;
320                        _this.number_of_playings++;
321                    }
322                } );
323            }
324            break;
325    
326        case 'selected':
327            var soundtrack = _this.getSoundtrackById( _this.yellow_select_id );
328            _this.current_soundtrack = ( soundtrack && soundtrack.length ) ? soundtrack : soundtracks.first();
329            if( _this.autoplay )
330            {
331                _this.loadAudioPlayer( 'play', _this.audio_loop );
332            }
333            else
334            {
335                _this.loadAudioPlayer( 'pause', _this.audio_loop );
336            }
337            break;
338    }
339}
340
341war_SoundyAudioPlaylistFrontEnd.prototype.arrayLength = function( arr )
342{
343	var _this = this;
344	
345	var length = 0;
346	for( var index in arr )
347	{
348		if ( ! isNaN( index ) ) length++;
349	}
350	
351	return length;
352}
353
354war_SoundyAudioPlaylistFrontEnd.prototype.getSoundtrackById = function( id )
355{
356	var _this = this;
357	
358	var found_soundtrack = null;
359	
360	_this.jquery_playlist.children().each( function( index, li )
361	{
362		var jquery_li = jQuery( li );
363		var jquery_id = jquery_li.children( '.war_soundtrack_id' );
364		if( jquery_id.html() == id )
365		{
366			found_soundtrack = jquery_li;
367			return false;
368		}
369	} );
370	
371	return found_soundtrack;
372}
373
374war_SoundyAudioPlaylistFrontEnd.prototype.loadAudioPlayer = function( mode, audio_loop, origin )
375{
376	var _this = this;
377
378	var audio_index       = _this.current_soundtrack.index() + 1;
379	var audio_id          = _this.current_soundtrack.children( '.war_soundtrack_id' ).html();
380	var audio_url         = _this.current_soundtrack.children( '.war_soundtrack_url' ).html();
381	var audio_type        = _this.current_soundtrack.children( '.war_soundtrack_type' ).html();
382	var audio_duration    = _this.current_soundtrack.children( '.war_soundtrack_time' ).html();
383	var audio_title       = _this.current_soundtrack.children( '.war_soundtrack_title' ).html();
384	var audio_artist      = _this.current_soundtrack.children( '.war_soundtrack_artist' ).html();
385	var audio_composer    = _this.current_soundtrack.children( '.war_soundtrack_composer' ).html();
386    var audio_volume      = parseInt( _this.current_soundtrack.children( '.war_soundtrack_volume' ).html() );
387
388    // Removes any HTML tag like: <span class="skimlinks-unlinked">...</span> in URL
389    var audio_url = audio_url.replace( /<[^>]+\>/g, '' );
390
391    _this.audio_control.attr( 'title', audio_title );
392
393    // Because of Safari Caprices:
394    if( _this.is_safari )
395    {
396        _this.audio_player_element.autoplay = true;
397        _this.audio_player_element.src      = audio_url;
398        _this.audio_player_element.type     = audio_type;
399        _this.audio_player_element.volume   = audio_volume / 100;
400        _this.audio_player_element.loop     = audio_loop;
401        _this.audio_player_element.preload  = _this.is_safari_on_ios ? 'auto' : 'none';
402    }
403
404	_this.audio_player_element.src      = audio_url;
405	_this.audio_player_element.type     = audio_type;
406	_this.audio_player_element.volume   = audio_volume / 100;
407	_this.audio_player_element.loop     = audio_loop;
408    _this.audio_player_element.preload  = _this.is_autoplay_agent ? 'auto' : 'none';
409
410	if( mode == 'auto' )
411	{
412		mode = _this.is_playing ? 'play' : 'pause';
413	}
414	
415	if( mode == 'play' )
416	{
417		_this.audio_player_element.autoplay = true;		
418		_this.audio_control.attr( 'src', _this.button_url_pause_normal );
419	}
420	else //if( mode == 'pause' )
421	{
422		_this.audio_player_element.autoplay = false;		
423		_this.audio_control.attr( 'src', _this.button_url_play_normal );
424	}
425
426    // highlight soundtrack in displayed playlist if playlist is displayed
427	if( _this.is_playlist_shortcode && typeof origin == 'undefined' )
428	{
429		_this.selectSoundtrack( _this.current_soundtrack, 'noload' );
430	}
431
432    if( _this.playlist_volume_slider.length )
433    {
434        _this.playlist_volume_slider.slider( 'value', audio_volume );
435    }
436
437	if( _this.jquery_placeholder_soundtrack_current_index.length )
438	{
439		_this.jquery_placeholder_soundtrack_current_index.html( audio_index );
440	}
441	
442	if( _this.jquery_placeholder_soundtrack_current_id.length )
443	{
444		_this.jquery_placeholder_soundtrack_current_id.html( audio_id );
445	}
446	
447	if( _this.jquery_placeholder_soundtrack_current_url.length )
448	{
449		_this.jquery_placeholder_soundtrack_current_url.html( audio_url );
450	}
451	
452	if( _this.jquery_placeholder_soundtrack_current_type.length )
453	{
454		_this.jquery_placeholder_soundtrack_current_type.html( audio_type );
455	}
456	
457	if( _this.jquery_placeholder_soundtrack_current_volume.length )
458	{
459		_this.jquery_placeholder_soundtrack_current_volume.html( audio_volume );
460	}
461
462    if( _this.jquery_placeholder_soundtrack_current_time )
463    {
464        _this.jquery_placeholder_soundtrack_current_time.html( '0:00' );
465    }
466
467	if( _this.jquery_placeholder_soundtrack_current_duration.length )
468	{
469		_this.jquery_placeholder_soundtrack_current_duration.html( audio_duration );
470	}
471	
472	if( _this.jquery_placeholder_soundtrack_current_title.length )
473	{
474		_this.jquery_placeholder_soundtrack_current_title.html( audio_title );
475	}
476	
477	if( _this.jquery_placeholder_soundtrack_current_artist.length )
478	{
479		_this.jquery_placeholder_soundtrack_current_artist.html( audio_artist );
480	}
481	
482	if( _this.jquery_placeholder_soundtrack_current_composer.length )
483	{
484		_this.jquery_placeholder_soundtrack_current_composer.html( audio_composer );
485	}
486	
487	if( _this.jquery_placeholder_playlist_current_status.length )
488	{
489		_this.jquery_placeholder_playlist_current_status.html( _this.is_playing ? 'Playing' : 'Paused' );
490	}
491
492    if( _this.jquery_placeholder_soundtrack_current_download.length )
493    {
494        _this.jquery_placeholder_soundtrack_current_download.attr( 'href', audio_url );
495    }
496}
497
498war_SoundyAudioPlaylistFrontEnd.prototype.setEventHandlersForPlayPauseButtons = function()
499{
500	var _this = this;
501	
502	if( _this.audio_control.length )
503	{
504		_this.audio_control.click( 
505			function() 
506			{ 
507				if( _this.audio_player_element.paused )
508				{
509					_this.audio_player_element.play();
510					_this.audio_control.attr( 'src', _this.button_url_pause_hover );
511				}
512				else
513				{
514					_this.audio_player_element.pause();
515					_this.audio_control.attr( 'src', _this.button_url_play_hover );
516				}
517			}
518        );
519			
520		_this.audio_control.hover( 
521			function() 
522			{ 
523				_this.hovering = true;
524				if( _this.audio_player_element.paused )
525				{
526					_this.audio_control.attr( 'src', _this.button_url_play_hover );
527				}
528				else
529				{
530					_this.audio_control.attr( 'src', _this.button_url_pause_hover );
531				}
532			},
533			function() 
534			{ 
535				_this.hovering = false;
536				if( _this.audio_player_element.paused )
537				{
538					_this.audio_control.attr( 'src', _this.button_url_play_normal );
539				}
540				else
541				{
542					_this.audio_control.attr( 'src', _this.button_url_pause_normal );
543				}
544			}
545		);
546			
547		_this.audio_player.bind( 'ended' , function()
548		{
549			if( _this.hovering )
550			{
551				_this.audio_control.attr( 'src', _this.button_url_play_hover );
552			}
553			else
554			{
555				_this.audio_control.attr( 'src', _this.button_url_play_normal );
556			}
557		} );
558
559		_this.audio_player.bind( 'play' , function()
560	    {
561			if( _this.hovering )
562			{
563				_this.audio_control.attr( 'src', _this.button_url_pause_hover );
564			}
565			else
566			{
567				_this.audio_control.attr( 'src', _this.button_url_pause_normal );
568			}
569		} );
570
571		_this.audio_player.bind( 'pause' , function()
572	    {
573			if( _this.hovering )
574			{
575				_this.audio_control.attr( 'src', _this.button_url_play_hover );
576			}
577			else
578			{
579				_this.audio_control.attr( 'src', _this.button_url_play_normal );
580			}
581		} );
582	}
583}
584
585war_SoundyAudioPlaylistFrontEnd.prototype.setEventHandlersForAudioPlayer = function()
586{
587	var _this = this;
588		
589	_this.audio_player.bind( 'ended' , function()
590	{
591		_this.is_playing = false;
592		
593		if( _this.jquery_placeholder_playlist_current_status.length )
594		{
595			_this.jquery_placeholder_playlist_current_status.html( 'Paused' );
596		}
597	} );
598
599	_this.audio_player.bind( 'play' , function()
600  {
601		_this.is_playing = true;
602		
603		if( _this.jquery_placeholder_playlist_current_status.length )
604		{
605			_this.jquery_placeholder_playlist_current_status.html( 'Playing' );
606		}
607	} );
608
609	_this.audio_player.bind( 'pause' , function()
610    {
611		_this.is_playing = false;
612		
613		if( _this.jquery_placeholder_playlist_current_status.length )
614		{
615			_this.jquery_placeholder_playlist_current_status.html( 'Paused' );
616		}
617	} );
618	
619	if( _this.playlist_time_slider.length )
620	{
621        _this.audio_player.bind( 'durationchange', function()
622        {
623            var duration_str = _this.current_soundtrack.children( '.war_soundtrack_time' ).html();
624            if( duration_str == '∞' )
625            {
626                _this.playlist_time_slider.slider( 'option', 'max', '' );
627                return;
628            }
629
630            if( _this.is_safari && duration_str != '' )
631            {
632                // For Safari Duration Bug in first soundtrack of list
633                var dur = duration_str.split( ':' );
634                var duration = parseInt( dur[ 0 ] ) * 60 + parseInt( dur[ 1 ] );
635            }
636            else
637            {
638                var duration = Math.round( this.duration );
639            }
640
641            if( duration_str == '' )
642            {
643                duration_str = _this.secondsToHms( duration );
644                if( _this.jquery_placeholder_soundtrack_current_duration.length )
645                {
646                    _this.jquery_placeholder_soundtrack_current_duration.html( duration_str );
647                }
648                _this.current_soundtrack.children( '.war_soundtrack_time' ).html( duration_str );
649            }
650
651            _this.playlist_time_slider.slider( 'option', 'max', duration );
652        } );
653	}
654}
655
656war_SoundyAudioPlaylistFrontEnd.prototype.setFooter = function()
657{
658    var _this = this;
659
660    if( war_sdy_pl_display_footer )
661    {
662        var strings = new Array();
663
664        if( war_sdy_pl_string_copyright_notice )
665            strings.push( war_sdy_pl_string_copyright_notice );
666
667        if( war_sdy_pl_display_number_of_tracks )
668            strings.push( war_sdy_pl_string_number_of_tracks );
669
670        if( war_sdy_pl_string_arrow_keys )
671            strings.push( war_sdy_pl_string_arrow_keys );
672
673        if( war_sdy_pl_string_double_click )
674            strings.push( war_sdy_pl_string_double_click );
675
676        if( war_sdy_pl_enable_scrolling )
677            strings.push( war_sdy_pl_string_scrolling );
678
679        var content_string = '';
680        for( var i = 0; i < strings.length; i++ )
681        {
682            content_string += strings[ i ];
683            if( i != strings.length - 1 ) content_string += '&nbsp;&nbsp;•&nbsp;&nbsp;';
684        }
685
686        jQuery( '.war_sdy_pl_playlist_row_footer_div' ).html( content_string );
687    }
688    else
689    {
690        jQuery( '#war_sdy_playlist_footer' ).hide();
691    }
692}
693
694war_SoundyAudioPlaylistFrontEnd.prototype.initPlaylist = function()
695{
696	var _this = this;
697
698    var jquery_playlist = jQuery( '#war_sdy_pl_playlist' );
699
700    if( _this.is_playlist_shortcode )
701    {
702        if( ! war_sdy_pl_display_column_headings )
703        {
704            jQuery( '#war_sdy_playlist_column_headings' ).hide();
705        }
706
707        _this.setFooter();
708    }
709
710    jquery_playlist.children().each( function( index, li )
711    {
712        var jquery_li = jQuery( li );
713
714        var jquery_time = jquery_li.children( '.war_soundtrack_time' );
715        var soundtrack_time = jquery_time.html();
716        // Removes Invalid Soundtrack Time
717        var reg_invalid_time = /[^0-9:]/;
718        if( reg_invalid_time.test( soundtrack_time ) )
719        {
720            jquery_time.html( '&infin;' );
721        }
722    } );
723
724	if( jquery_playlist.length )
725	{
726        jquery_playlist.on( 'click', 'li', function()
727		{
728			_this.selectSoundtrack( this, 'load' );
729		} );
730
731
732        if( war_sdy_pl_enable_double_click )
733        {
734            //disable text selection when double-clicking
735            jquery_playlist.disableSelection();
736
737            jquery_playlist.on('dblclick', 'li', function (event)
738            {
739                if (_this.is_playing) {
740                    _this.audio_player_element.pause();
741                    _this.is_playing = false;
742                }
743                else {
744                    _this.audio_player_element.play();
745                    _this.is_playing = true;
746                }
747                event.preventDefault();
748            } );
749        }
750
751        jQuery( '.war_sdy_pl_button_previous' ).on( 'click', function( event )
752        {
753            _this.selectSoundtrack( 'up', 'load' );
754            event.preventDefault();
755            return false;
756        } );
757
758        jQuery( '.war_sdy_pl_button_next' ).on( 'click', function( event )
759        {
760            _this.selectSoundtrack( 'down', 'load' );
761            event.preventDefault();
762            return false;
763        } );
764
765
766        if( war_sdy_pl_enable_arrow_keys )
767        {
768            function setArrowKeys(event)
769            {
770                if (event.keyCode == 38 || event.keyCode == 37) {
771                    _this.selectSoundtrack('up', 'load');
772                    return false;
773                }
774                else if (event.keyCode == 40 || event.keyCode == 39) {
775                    _this.selectSoundtrack('down', 'load');
776                    return false;
777                }
778            }
779
780            jQuery(document).bind('keydown', setArrowKeys);
781
782            jQuery('textarea, input').focus(function (event) {
783                jQuery(document).unbind('keydown');
784            });
785
786            jQuery('textarea, input').blur(function (event) {
787                jQuery(document).bind('keydown', setArrowKeys);
788            });
789        }
790	}
791}
792
793war_SoundyAudioPlaylistFrontEnd.prototype.initPlaylistColumns = function()
794{
795    var _this = this;
796
797    var jquery_playlist        = jQuery( '#war_sdy_pl_playlist' );
798    var jquery_column_captions = jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' ).children();
799    var jquery_columns         = jquery_playlist.children().children();
800
801    for( var index in _this.column_ordered_names )
802    {
803        var column_name        = _this.column_ordered_names[ index ];
804        var column_do_display  = sdy_pl_column_do_display[ column_name ];
805        var column_width_value = sdy_pl_column_width_value[ column_name ];
806        var column_width_unit  = sdy_pl_column_width_unit[ column_name ];
807
808        var jquery_playlist_column_caption = jquery_column_captions.filter( '.war_soundtrack_' + column_name );
809        var jquery_playlist_column         = jquery_columns.filter( '.war_soundtrack_' + column_name );
810        jquery_playlist_column_caption.css( 'width', column_width_value + column_width_unit );
811        jquery_playlist_column.css( 'width', column_width_value + column_width_unit );
812        if( column_do_display == 'no' )
813        {
814            jquery_playlist_column_caption.hide();
815            jquery_playlist_column.hide();
816        }
817    }
818
819    _this.orderColumns();
820}
821
822war_SoundyAudioPlaylistFrontEnd.prototype.orderColumns = function()
823{
824    var _this = this;
825
826    var jquery_column_captions_row = jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' );
827    var jquery_column_captions     = jquery_column_captions_row.children();
828
829    for( var index in _this.column_ordered_names )
830    {
831        var column_name = _this.column_ordered_names[ index ];
832
833        var jquery_column_caption = jquery_column_captions.filter( '.war_soundtrack_' + column_name );
834        jquery_column_caption.detach();
835        jquery_column_captions_row.append( jquery_column_caption );
836    }
837
838    var jquery_soundtracks_list = jQuery( '#war_sdy_pl_playlist' );
839
840    jquery_soundtracks_list.children().each
841    (
842        function( index, li )
843        {
844            var jquery_li = jQuery( li );
845
846            for( var i in _this.column_ordered_names )
847            {
848                var column_name = _this.column_ordered_names[ i ];
849
850                var jquery_column = jquery_li.children().filter( '.war_soundtrack_' + column_name );
851                jquery_column.detach();
852                jquery_li.append( jquery_column );
853            }
854        }
855    );
856}
857
858war_SoundyAudioPlaylistFrontEnd.prototype.makePlaylistResponsive = function()
859{
860    var _this = this;
861
862    var jquery_header_container = jQuery( 'div.war_sdy_pl_playlist_header_container' );
863    var jquery_picture          = jQuery( 'img.war_sdy_pl_playlist_picture' );
864    var jquery_title            = jQuery( 'div.war_sdy_pl_playlist_title_global' );
865
866    if( jquery_picture.length && _this.is_picture_width_and_height_set == null )
867    {
868        _this.picture_width  = jquery_picture.prop( 'width' );
869        if( _this.picture_width == 0 ) return;
870
871        _this.picture_height = jquery_picture.prop( 'height' );
872        _this.picture_aspect_ratio = _this.picture_height / _this.picture_width;
873
874        _this.is_picture_width_and_height_set = true;
875    }
876
877    _this.makePlayPauseButtonResponsive();
878
879    var picture_is_above = false;
880
881    if( jquery_picture.length )
882    {
883        var header_container_width = jquery_header_container.width();
884        var picture_width = jquery_picture.prop( 'width' );
885
886        header_container_width = header_container_width - picture_width;
887
888        if( header_container_width < 260 )
889        {
890            jquery_picture.css( 'float', 'none' );
891
892            picture_is_above = true;
893        }
894        else
895        {
896            jquery_picture.css( 'float', 'left' );
897        }
898    }
899
900    header_container_width = jquery_header_container.width();
901
902    var width_slider_volume = Math.min( Math.round( 0.40 * header_container_width ), 250 );
903    var width_slider_time   = Math.min( Math.round( 0.55 * header_container_width ), 350 );
904    var width_title         = Math.min( Math.round( 0.75 * header_container_width ), 500 );
905
906    jQuery( 'div.war_sdy_pl_playlist_volume_slider' ).css( 'width', width_slider_volume );
907    jQuery( 'div.war_sdy_pl_playlist_time_slider' ).css( 'width', width_slider_time );
908    jQuery( 'div.war_sdy_pl_playlist_header_soundtrack_title_and_artist' ).css( 'width', width_slider_time );
909
910    jquery_title.css( 'width', width_title );
911
912    if( picture_is_above )
913    {
914        jquery_title.css( 'marginTop', '1.0em' );
915    }
916}
917
918war_SoundyAudioPlaylistFrontEnd.prototype.initPlaylistCSS = function()
919{
920    var _this = this;
921
922    var jquery_header           = jQuery( 'li.war_sdy_pl_playlist_row_header' );
923    var jquery_footer           = jQuery( 'li.war_sdy_pl_playlist_row_footer' );
924    var jquery_captions         = jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' );
925
926    jquery_header.css(   'background-color', sdy_pl_css_color_bg_header_footer );
927    jquery_captions.css( 'background-color', sdy_pl_css_color_bg_header_footer );
928    jquery_footer.css(   'background-color', sdy_pl_css_color_bg_header_footer );
929
930    jquery_header.css(   'color', sdy_pl_css_color_txt_header_footer );
931    jquery_captions.css( 'color', sdy_pl_css_color_txt_header_footer );
932    jquery_footer.css(   'color', sdy_pl_css_color_txt_header_footer );
933
934    var jquery_previous_next = jQuery( '.war_sdy_pl_icon_previous_next_graphic' );
935    if( _this.jquery_playlist.children().length == 1 )
936    {
937        jquery_previous_next.hide();
938    }
939    else
940    {
941        jquery_previous_next.css( 'fill',   sdy_pl_css_color_txt_header_footer );
942        jquery_previous_next.css( 'stroke', sdy_pl_css_color_txt_header_footer );
943    }
944
945    var jquery_speaker_icon_1 = jQuery( '.war_sdy_pl_icon_speaker_graphic_1' );
946    var jquery_speaker_icon_2 = jQuery( '.war_sdy_pl_icon_speaker_graphic_2' );
947    jquery_speaker_icon_1.css( 'fill',   sdy_pl_css_color_txt_header_footer );
948    jquery_speaker_icon_2.css( 'stroke', sdy_pl_css_color_txt_header_footer );
949
950    var jquery_slider_bar_volume = jQuery( '.war_sdy_pl_playlist_volume_slider' );
951    var jquery_slider_bar_time   = jQuery( '.war_sdy_pl_playlist_time_slider' );
952    jquery_slider_bar_volume.css( 'background', sdy_pl_css_color_slider_bar );
953    jquery_slider_bar_time.css(   'background', sdy_pl_css_color_slider_bar );
954
955    var jquery_slider_range_volume = jQuery( '.war_sdy_pl_playlist_volume_slider .ui-slider-range' );
956    var jquery_slider_range_time   = jQuery( '.war_sdy_pl_playlist_time_slider .ui-slider-range' );
957    jquery_slider_range_volume.css( 'background', sdy_pl_css_color_slider_range );
958    jquery_slider_range_time.css(   'background', sdy_pl_css_color_slider_range );
959
960    var jquery_slider_handle_volume = jQuery( '.war_sdy_pl_playlist_volume_slider .ui-slider-handle' );
961    var jquery_slider_handle_time   = jQuery( '.war_sdy_pl_playlist_time_slider .ui-slider-handle' );
962    jquery_slider_handle_volume.css( 'background', sdy_pl_css_color_slider_handle );
963    jquery_slider_handle_time.css(   'background', sdy_pl_css_color_slider_handle );
964
965    jQuery( '.war_sdy_pl_playlist_outer_box' ).css( 'background-color', sdy_pl_css_color_bg_outer_box );
966    var val = sdy_pl_css_outer_box_width_unit == '%' ? 0.98 * sdy_pl_css_outer_box_width_value : sdy_pl_css_outer_box_width_value;
967    jQuery( 'div.war_sdy_pl_playlist_outer_box' ).css( 'width', val + sdy_pl_css_outer_box_width_unit );
968    jQuery( 'div.war_sdy_pl_playlist_outer_box' ).css( 'font-size', sdy_pl_css_font_size_value + sdy_pl_css_font_size_unit );
969
970    jQuery( '#war_sdy_pl_playlist li' ).css(                  'background-color', sdy_pl_css_color_bg_even_soundtrack );
971    jQuery( '#war_sdy_pl_playlist li:nth-child( odd )' ).css( 'background-color', sdy_pl_css_color_bg_odd_soundtrack );
972    jQuery( '#war_sdy_pl_playlist li' ).css(                  'color',            sdy_pl_css_color_txt_soundtrack );
973
974    _this.jquery_li_selected.css( 'background-color', sdy_pl_css_color_bg_soundtrack_selected );
975    _this.jquery_li_selected.css( 'color',            sdy_pl_css_color_txt_soundtrack_selected );
976
977    jQuery( 'div.war_sdy_pl_playlist_outer_box' ).css(                     'border-color', sdy_pl_css_color_outline );
978    jQuery( 'img.war_sdy_pl_playlist_picture' ).css(                       'border-color', sdy_pl_css_color_outline );
979    jQuery( 'li.war_sdy_pl_playlist_row_header' ).css(                     'border-color', sdy_pl_css_color_outline );
980    jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' ).css(            'border-color', sdy_pl_css_color_outline );
981    jQuery( '#war_sdy_pl_playlist li' ).css(                               'border-color', sdy_pl_css_color_outline );
982    jQuery( 'li.war_sdy_pl_playlist_row_footer' ).css(                     'border-color', sdy_pl_css_color_outline );
983    jQuery( '.war_sdy_pl_playlist_volume_slider' ).css(                    'border-color', sdy_pl_css_color_outline );
984    jQuery( '.war_sdy_pl_playlist_time_slider' ).css(                      'border-color', sdy_pl_css_color_outline );
985    jQuery( '.war_sdy_pl_playlist_volume_slider .ui-slider-handle' ).css(  'border-color', sdy_pl_css_color_outline );
986    jQuery( '.war_sdy_pl_playlist_time_slider .ui-slider-handle' ).css(    'border-color', sdy_pl_css_color_outline );
987
988    jQuery( 'ul#war_sdy_pl_playlist li' ).css(                     'border-top-width',      sdy_pl_css_pixel_soundtrack_separator_width );
989    jQuery( 'ul#war_sdy_pl_playlist li' ).css(                     'border-bottom-width',   sdy_pl_css_pixel_soundtrack_separator_width );
990    jQuery( 'ul#war_sdy_pl_playlist li' ).css(                     'padding-top',           sdy_pl_css_pixel_soundtrack_vertical_padding );
991    jQuery( 'ul#war_sdy_pl_playlist li' ).css(                     'padding-bottom',        sdy_pl_css_pixel_soundtrack_vertical_padding );
992    jQuery( 'ul#war_sdy_pl_playlist' ).children().first().css(     'border-top-width',      sdy_pl_css_pixel_outline_width );
993    jQuery( 'ul#war_sdy_pl_playlist' ).children().last().css(      'border-bottom-width',   sdy_pl_css_pixel_outline_width );
994
995    jQuery( 'div.war_sdy_pl_playlist_outer_box' ).css(             'border-width',          sdy_pl_css_pixel_outline_width );
996    jQuery( 'img.war_sdy_pl_playlist_picture' ).css(               'border-width',          sdy_pl_css_pixel_outline_width );
997    jQuery( 'li.war_sdy_pl_playlist_row_header' ).css(             'border-width',          sdy_pl_css_pixel_outline_width );
998    jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' ).css(    'border-width',          sdy_pl_css_pixel_outline_width );
999    jQuery( 'ul#war_sdy_pl_playlist li' ).css(                     'border-left-width',     sdy_pl_css_pixel_outline_width );
1000    jQuery( 'ul#war_sdy_pl_playlist li' ).css(                     'border-right-width',    sdy_pl_css_pixel_outline_width );
1001    jQuery( 'li.war_sdy_pl_playlist_row_footer' ).css(             'border-width',          sdy_pl_css_pixel_outline_width );
1002
1003    jQuery( 'div.war_sdy_pl_playlist_outer_box' ).css(              'border-radius',                sdy_pl_css_pixel_outer_box_corner_rounding );
1004    jQuery( 'img.war_sdy_pl_playlist_picture' ).css(                'border-radius',                sdy_pl_css_pixel_inner_box_corner_rounding );
1005    jQuery( 'li.war_sdy_pl_playlist_row_header' ).css(              'border-radius',                sdy_pl_css_pixel_inner_box_corner_rounding );
1006    jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' ).css(     'border-radius',                sdy_pl_css_pixel_inner_box_corner_rounding );
1007    jQuery( 'ul#war_sdy_pl_playlist').children().first().css(       'border-top-left-radius',       sdy_pl_css_pixel_inner_box_corner_rounding );
1008    jQuery( 'ul#war_sdy_pl_playlist').children().first().css(       'border-top-right-radius',      sdy_pl_css_pixel_inner_box_corner_rounding );
1009    jQuery( 'ul#war_sdy_pl_playlist').children().last().css(        'border-bottom-left-radius',    sdy_pl_css_pixel_inner_box_corner_rounding );
1010    jQuery( 'ul#war_sdy_pl_playlist').children().last().css(        'border-bottom-right-radius',   sdy_pl_css_pixel_inner_box_corner_rounding );
1011    jQuery( 'li.war_sdy_pl_playlist_row_footer' ).css(              'border-radius',                sdy_pl_css_pixel_inner_box_corner_rounding );
1012
1013    jQuery( 'div.war_sdy_pl_playlist_outer_box' ).css( 'padding', sdy_pl_css_pixel_outer_box_padding );
1014
1015    jQuery( 'li.war_sdy_pl_playlist_row_header' ).css(          'margin-bottom',    sdy_pl_css_pixel_inner_box_margin );
1016    jQuery( 'li.war_sdy_pl_playlist_columns_caption_row' ).css( 'margin-bottom',    sdy_pl_css_pixel_inner_box_margin );
1017    jQuery( 'li.war_sdy_pl_playlist_row_footer' ).css(          'margin-top',       sdy_pl_css_pixel_inner_box_margin );
1018
1019    if( sdy_pl_css_scrolling_enable == 'yes' )
1020    {
1021        var border_height = jQuery( '#war_sdy_pl_playlist').children().first().css( 'border-top-width' );
1022        border_height = border_height.replace( 'px', '' );
1023        var row_height = jQuery( '#war_sdy_pl_playlist').children().first().outerHeight();
1024        row_height -= border_height;
1025        var rows = sdy_pl_css_scrolling_height;
1026        var height = rows * row_height;
1027        jQuery( '#war_sdy_pl_playlist' ).css( 'overflow-y', 'auto' );
1028        jQuery( '#war_sdy_pl_playlist' ).css( 'height', height );
1029    }
1030}
1031
1032war_SoundyAudioPlaylistFrontEnd.prototype.initShortcodePlaceholders = function()
1033{
1034    var _this = this;
1035
1036    _this.jquery_placeholder_soundtrack_current_index     = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_index' );
1037    _this.jquery_placeholder_soundtrack_current_id        = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_id' );
1038    _this.jquery_placeholder_soundtrack_current_url       = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_url' );
1039    _this.jquery_placeholder_soundtrack_current_type      = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_type' );
1040    _this.jquery_placeholder_soundtrack_current_volume    = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_volume' );
1041    _this.jquery_placeholder_soundtrack_current_time      = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_time' );
1042    _this.jquery_placeholder_soundtrack_current_duration  = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_duration' );
1043    _this.jquery_placeholder_soundtrack_current_title     = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_title' );
1044    _this.jquery_placeholder_soundtrack_current_artist    = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_artist' );
1045    _this.jquery_placeholder_soundtrack_current_composer  = jQuery( '.war_sdy_pl_placeholder_soundtrack_current_composer' );
1046    _this.jquery_placeholder_soundtrack_current_download  = jQuery( '.war_sdy_pl_placeholder_soundtrack_download' );
1047    _this.jquery_placeholder_playlist_current_status      = jQuery( '.war_sdy_pl_placeholder_playlist_current_status' );
1048
1049    _this.playlist_time_slider = jQuery( '.war_sdy_pl_playlist_time_slider' );
1050    if( _this.playlist_time_slider.length )
1051    {
1052        _this.playlist_time_slider.slider
1053        (
1054            {
1055                min:     0,
1056                value:   0,
1057                range:   'min',
1058                slide:   function( event, ui )
1059                {
1060                    _this.audio_player_element.currentTime = ui.value;
1061                },
1062                start:   function( event, ui )
1063                {
1064                    _this.playlist_time_slider_is_sliding = true;
1065                },
1066                stop:    function( event, ui )
1067                {
1068                    _this.playlist_time_slider_is_sliding = false;
1069                }
1070            }
1071        );
1072
1073        function permanentUpdateCurrentTime_1()
1074        {
1075            if( _this.audio_player_element.readyState > 1 )
1076            {
1077                var current_time = Math.round( _this.audio_player_element.currentTime );
1078                _this.jquery_placeholder_soundtrack_current_time.html( _this.secondsToHms( current_time ) );
1079                if( ! _this.playlist_time_slider_is_sliding )
1080                {
1081                    _this.playlist_time_slider.slider( 'value', current_time );
1082                }
1083            }
1084
1085            setTimeout( permanentUpdateCurrentTime_1, 1000 );
1086        }
1087        permanentUpdateCurrentTime_1();
1088    }
1089    else if( _this.jquery_placeholder_soundtrack_current_time.length )
1090    {
1091        function permanentUpdateCurrentTime_2()
1092        {
1093            if( _this.audio_player_element.readyState > 1 )
1094            {
1095                _this.jquery_placeholder_soundtrack_current_time.html( _this.secondsToHms( Math.round( _this.audio_player_element.currentTime ) ) );
1096            }
1097
1098            setTimeout( permanentUpdateCurrentTime_2, 1000 );
1099        }
1100        permanentUpdateCurrentTime_2();
1101    }
1102
1103    _this.playlist_volume_slider = jQuery( '.war_sdy_pl_playlist_volume_slider' );
1104    if( _this.playlist_volume_slider.length )
1105    {
1106        _this.playlist_volume_slider.slider
1107        (
1108            {
1109                min:     0,
1110                max:     100,
1111                value:   80,
1112                range:   'min',
1113                slide:   function( event, ui )
1114                {
1115                    _this.audio_player_element.volume = ui.value / 100;
1116                }
1117            }
1118        );
1119    }
1120}
1121
1122war_SoundyAudioPlaylistFrontEnd.prototype.initPreview = function()
1123{
1124    var _this = this;
1125
1126    // Workaround for the preview player hanging:
1127    var opener_player = window.opener.jQuery( '#war_sdy_pl_audio_player' )[ 0 ];
1128    opener_player.play();
1129    opener_player.pause();
1130
1131    if( _this.preview == 'position' )
1132    {
1133        var pp_images_to_use = window.opener.jQuery( 'input[name=war_sdy_pl_pp_images_to_use]:checked' ).val();
1134
1135        if( pp_images_to_use == 'none' )
1136        {
1137            _this.preview = 'default';
1138        }
1139        else
1140        {
1141            _this.preview = pp_images_to_use;
1142        }
1143    }
1144
1145    if( _this.preview == 'designer' )
1146    {
1147        _this.button_url_play_normal  = window.opener.war_design_pp.img_data_play_normal;
1148        _this.button_url_pause_normal = window.opener.war_design_pp.img_data_pause_normal;
1149        _this.button_url_play_hover   = window.opener.war_design_pp.img_data_play_hover;
1150        _this.button_url_pause_hover  = window.opener.war_design_pp.img_data_pause_hover;
1151    }
1152    else if( _this.preview == 'default' )
1153    {
1154        _this.button_url_play_normal  = window.opener.jQuery( '#war_sdy_pl_url_play_button' ).val();
1155        _this.button_url_pause_normal = window.opener.jQuery( '#war_sdy_pl_url_pause_button' ).val();
1156        _this.button_url_play_hover   = window.opener.jQuery( '#war_sdy_pl_url_play_hover' ).val();
1157        _this.button_url_pause_hover  = window.opener.jQuery( '#war_sdy_pl_url_pause_hover' ).val();
1158    }
1159
1160    var position = window.opener.jQuery( '#war_sdy_pl_pp_position' ).children( 'option:selected' ).val();
1161    if( position == 'document' )
1162    {
1163        _this.audio_control.css( 'position', 'absolute' );
1164    }
1165    else
1166    {
1167        _this.audio_control.css( 'position', 'fixed' );
1168    }
1169
1170    var pp_corner = window.opener.jQuery( '#war_sdy_pl_pp_corner' ).children( 'option:selected' ).val();
1171    var offset_x  = window.opener.jQuery( '#war_sdy_pl_offset_x' ).val() + window.opener.jQuery( '#war_sdy_pl_offset_x_unit' ).val();
1172    var offset_y  = window.opener.jQuery( '#war_sdy_pl_offset_y' ).val() + window.opener.jQuery( '#war_sdy_pl_offset_y_unit' ).val();
1173    switch( pp_corner )
1174    {
1175        case 'upper_right':
1176            _this.audio_control.css( 'top',    offset_y );
1177            _this.audio_control.css( 'right',  offset_x );
1178            _this.audio_control.css( 'bottom', '' );
1179            _this.audio_control.css( 'left',   '' );
1180            break;
1181        case 'upper_left':
1182            _this.audio_control.css( 'top',    offset_y );
1183            _this.audio_control.css( 'right',  '' );
1184            _this.audio_control.css( 'bottom', '' );
1185            _this.audio_control.css( 'left',   offset_x );
1186            break;
1187        case 'bottom_right':
1188            _this.audio_control.css( 'top',    '' );
1189            _this.audio_control.css( 'right',  offset_x );
1190            _this.audio_control.css( 'bottom', offset_y );
1191            _this.audio_control.css( 'left',   '' );
1192            break;
1193        case 'bottom_left':
1194            _this.audio_control.css( 'top',    '' );
1195            _this.audio_control.css( 'right',  '' );
1196            _this.audio_control.css( 'bottom', offset_y );
1197            _this.audio_control.css( 'left',   offset_x );
1198            break;
1199    }
1200}
1201
1202
1203war_SoundyAudioPlaylistFrontEnd.prototype.numberSoundtracksWhileSorting = function( index_item, index_placeholder )
1204{
1205	var _this = this;
1206	
1207	index_item++; index_placeholder++;
1208	
1209	var jquery_soundtracks_list = jQuery( '#war_sdy_pl_playlist' );
1210	jquery_soundtracks_list.children().each( function( index, li )
1211	{
1212		index++;
1213		var jquery_li = jQuery( li );
1214		if( index == index_item )
1215		{
1216			if( index_item < index_placeholder )
1217			{
1218				index = index_placeholder - 1;		
1219			}
1220			else
1221			{
1222				index = index_placeholder;		
1223			}
1224		}
1225		else if( index > index_item )
1226		{
1227			index--;		
1228		}
1229		
1230		index = ( ( index < 10 ) ? ( '0' + index ) : index ) + '.';
1231		jquery_li.children( '.war_soundtrack_index' ).html( index );
1232	} );
1233}
1234
1235war_SoundyAudioPlaylistFrontEnd.prototype.selectSoundtrack = function( li_selected, soundtrack_action )
1236{
1237	var _this = this;
1238
1239    var jquery_li_selected;
1240	
1241	if( li_selected instanceof jQuery )
1242	{
1243		jquery_li_selected = li_selected;
1244		li_selected = jquery_li_selected.get( 0 );
1245	}
1246	else if( li_selected == 'up' )
1247	{
1248		if( _this.jquery_li_selected )
1249		{
1250			var jquery_li_selected = _this.jquery_li_selected.prev();
1251			if( jquery_li_selected.length )
1252			{
1253				li_selected = jquery_li_selected.get( 0 );
1254			}
1255			else
1256			{
1257                jquery_li_selected = _this.jquery_li_selected.parent().children().last();
1258                if( jquery_li_selected.length )
1259                {
1260                    li_selected = jquery_li_selected.get( 0 );
1261                }
1262                else
1263                {
1264                    return;
1265                }
1266			}
1267		}
1268		else
1269		{
1270			return;			
1271		}
1272	}
1273	else if( li_selected == 'down' )
1274	{
1275		if( _this.jquery_li_selected )
1276		{
1277			var jquery_li_selected = _this.jquery_li_selected.next();
1278			if( jquery_li_selected.length )
1279			{
1280				li_selected = jquery_li_selected.get( 0 );
1281			}
1282			else
1283			{
1284                jquery_li_selected = _this.jquery_li_selected.parent().children().first();
1285                if( jquery_li_selected.length )
1286                {
1287                    li_selected = jquery_li_selected.get( 0 );
1288                }
1289                else
1290                {
1291                    return;
1292                }
1293			}
1294		}
1295		else
1296		{
1297			return;			
1298		}
1299	}
1300	else if( typeof li_selected == 'string' )
1301	{
1302	}
1303	else
1304	{
1305		jquery_li_selected = jQuery( li_selected );
1306	}
1307	
1308	if( _this.jquery_li_selected )
1309	{
1310		var li_current = _this.jquery_li_selected.get( 0 );
1311		if( li_selected === li_current )
1312		{
1313			return;
1314		}
1315	}
1316	
1317	function isOutOfViewport( jquery_ul, jquery_li )
1318	{
1319        var top = jquery_ul.scrollTop();
1320        var bottom = top + jquery_ul.height();
1321
1322        var ul_offset = jquery_ul.offset();
1323        var li_offset = jquery_li.offset();
1324        var li_top = li_offset.top - ul_offset.top + top + 1;
1325        var li_bottom = li_top + jquery_li.outerHeight();
1326
1327        return ( top > li_bottom || bottom < ( li_top + 5 ) );
1328	};
1329	
1330	var jquery_soundtracks_list = jQuery( '#war_sdy_pl_playlist' );
1331	if( isOutOfViewport( jquery_soundtracks_list, jquery_li_selected ) )
1332	{
1333		var ul = jquery_soundtracks_list.get( 0 );
1334		var offset = li_selected.offsetTop - ul.offsetTop;
1335		ul.scrollTop = offset;
1336	}
1337
1338	if( _this.jquery_li_selected )
1339	{
1340        if( sdy_pl_css_use_only )
1341        {
1342            _this.jquery_li_selected.removeClass( 'war_soundtrack_selected' );
1343        }
1344        else
1345        {
1346            var is_odd = _this.jquery_li_selected.index() % 2 == 0;
1347            _this.jquery_li_selected.css( 'background-color', is_odd ? sdy_pl_css_color_bg_odd_soundtrack : sdy_pl_css_color_bg_even_soundtrack );
1348            _this.jquery_li_selected.css( 'color',  sdy_pl_css_color_txt_soundtrack );
1349        }
1350	}
1351    _this.jquery_li_selected = jquery_li_selected;
1352
1353    if( sdy_pl_css_use_only )
1354    {
1355        jquery_li_selected.addClass( 'war_soundtrack_selected' );
1356    }
1357    else
1358    {
1359        _this.jquery_li_selected.css( 'background-color', sdy_pl_css_color_bg_soundtrack_selected );
1360        _this.jquery_li_selected.css( 'color',            sdy_pl_css_color_txt_soundtrack_selected );
1361    }
1362
1363	if( soundtrack_action == 'load' )
1364	{
1365		//stop audio mode logic because of user action:
1366        if( _this.is_audio_mode_logic )
1367        {
1368            _this.audio_player.unbind( 'ended.audio_mode_logic' );
1369            _this.is_audio_mode_logic = false;
1370            _this.setAudioModeSequential();
1371        }
1372
1373		_this.current_soundtrack = _this.jquery_li_selected;
1374		var audio_loop = false;
1375		_this.loadAudioPlayer( 'auto', audio_loop, 'select' );
1376	}
1377}
1378
1379war_SoundyAudioPlaylistFrontEnd.prototype.setAudioModeSequential = function()
1380{
1381    var _this = this;
1382
1383    _this.audio_player.bind( 'ended' , function()
1384    {
1385        var soundtracks = _this.jquery_playlist.children();
1386
1387        var next_soundtrack = _this.current_soundtrack.next();
1388        if( next_soundtrack.length )
1389        {
1390            _this.current_soundtrack = next_soundtrack;
1391        }
1392        else
1393        {
1394            _this.current_soundtrack = soundtracks.first();
1395        }
1396        if( _this.current_soundtrack.length )
1397        {
1398            _this.loadAudioPlayer( 'play' );
1399        }
1400    } );
1401}
1402
1403war_SoundyAudioPlaylistFrontEnd.prototype.secondsToHms = function( d )
1404{
1405	d = Number( d );
1406	var h = Math.floor( d / 3600 );
1407	var m = Math.floor( d % 3600 / 60 );
1408	var s = Math.floor( d % 3600 % 60 );
1409	return ( ( h > 0 ? h + ':' : '' ) + ( m > 0 ? ( h > 0 && m < 10 ? '0' : '' ) + m + ':' : '0:' ) + ( s < 10 ? '0' : '' ) + s ); 
1410}
1411
1412war_SoundyAudioPlaylistFrontEnd.prototype.makePlayPauseButtonResponsive = function()
1413{
1414    var _this = this;
1415
1416    if( war_sdy_pl_responsive_mode != 'none' )
1417    {
1418        if( war_sdy_pl_responsive_include_player_button )
1419        {
1420            var audio_control_selector = '.war_sdy_pl_audio_control';
1421        }
1422        else
1423        {
1424            var audio_control_selector = '.war_sdy_pl_audio_control.war_sdy_pl_no_player, .war_sdy_pl_audio_control.war_sdy_pl_pp_corner';
1425        }
1426
1427        var jquery_picture = jQuery( 'img.war_sdy_pl_playlist_picture' );
1428
1429        var window_width = jQuery( window ).width();
1430
1431        switch( war_sdy_pl_button_corner )
1432        {
1433            case 'upper_right':
1434            default:
1435                var prop_x = 'right';
1436                var prop_y = 'top';
1437                break;
1438            case 'upper_left':
1439                var prop_x = 'left';
1440                var prop_y = 'top';
1441                break;
1442            case 'bottom_right':
1443                var prop_x = 'right';
1444                var prop_y = 'bottom';
1445                break;
1446            case 'bottom_left':
1447                var prop_x = 'left';
1448                var prop_y = 'bottom';
1449                break;
1450        }
1451
1452        if( war_sdy_pl_responsive_mode == 'table' )
1453        {
1454            for( var index in war_sdy_pl_responsive_table_rows )
1455            {
1456                var row = war_sdy_pl_responsive_table_rows[ index ];
1457
1458                if( row.button_width != -1 )
1459                {
1460                    if( row.window_width_min != -1 && row.window_width_max != -1 )
1461                    {
1462                        if( row.window_width_min <= window_width && window_width <= row.window_width_max )
1463                        {
1464                            var width = row.button_width;
1465                            var height = Math.round( _this.button_aspect_ratio * width );
1466                            jQuery( audio_control_selector ).css( 'width', width );
1467                            jQuery( audio_control_selector ).css( 'height', height );
1468                        }
1469                    }
1470                    else if( row.window_width_min != -1 )
1471                    {
1472                        if( row.window_width_min <= window_width )
1473                        {
1474                            var width = row.button_width;
1475                            var height = Math.round( _this.button_aspect_ratio * width );
1476                            jQuery( audio_control_selector ).css( 'width', width );
1477                            jQuery( audio_control_selector ).css( 'height', height );
1478                        }
1479                    }
1480                    else if( row.window_width_max != -1 )
1481                    {
1482                        if( window_width <= row.window_width_max )
1483                        {
1484                            var width = row.button_width;
1485                            var height = Math.round( _this.button_aspect_ratio * width );
1486                            jQuery( audio_control_selector ).css( 'width', width );
1487                            jQuery( audio_control_selector ).css( 'height', height );
1488                        }
1489                    }
1490                }
1491
1492                if( war_sdy_pl_responsive_include_player_picture && jquery_picture.length && row.picture_width != -1 )
1493                {
1494                    if( row.window_width_min != -1 && row.window_width_max != -1 )
1495                    {
1496                        if( row.window_width_min <= window_width && window_width <= row.window_width_max )
1497                        {
1498                            var width = row.picture_width;
1499                            var height = Math.round( _this.picture_aspect_ratio * width );
1500                            jquery_picture.css( 'width', width );
1501                            jquery_picture.css( 'height', height );
1502                        }
1503                    }
1504                    else if( row.window_width_min != -1 )
1505                    {
1506                        if( row.window_width_min <= window_width )
1507                        {
1508                            var width = row.picture_width;
1509                            var height = Math.round( _this.picture_aspect_ratio * width );
1510                            jquery_picture.css( 'width', width );
1511                            jquery_picture.css( 'height', height );
1512                        }
1513                    }
1514                    else if( row.window_width_max != -1 )
1515                    {
1516                        if( window_width <= row.window_width_max )
1517                        {
1518                            var width = row.picture_width;
1519                            var height = Math.round( _this.picture_aspect_ratio * width );
1520                            jquery_picture.css( 'width', width );
1521                            jquery_picture.css( 'height', height );
1522                        }
1523                    }
1524                }
1525            }
1526
1527            if( jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).length )
1528            {
1529                for( var index in war_sdy_pl_responsive_table_rows )
1530                {
1531                    var row = war_sdy_pl_responsive_table_rows[ index ];
1532                    if( row.offset_x != -1 || row.offset_y != -1 )
1533                    {
1534                        if( row.window_width_min != -1 && row.window_width_max != -1 )
1535                        {
1536                            if( row.window_width_min <= window_width && window_width <= row.window_width_max )
1537                            {
1538                                if( row.offset_x != -1 ) jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( prop_x, row.offset_x );
1539                                if( row.offset_y != -1 ) jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( prop_y, row.offset_y );
1540                            }
1541                        }
1542                        else if( row.window_width_min != -1 )
1543                        {
1544                            if( row.window_width_min <= window_width )
1545                            {
1546                                if( row.offset_x != -1 ) jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( prop_x, row.offset_x );
1547                                if( row.offset_y != -1 ) jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( prop_y, row.offset_y );
1548                            }
1549                        }
1550                        else if( row.window_width_max != -1 )
1551                        {
1552                            if( window_width <= row.window_width_max )
1553                            {
1554                                if( row.offset_x != -1 ) jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( prop_x, row.offset_x );
1555                                if( row.offset_y != -1 ) jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( prop_y, row.offset_y );
1556                            }
1557                        }
1558                    }
1559                }
1560            }
1561        }
1562        else // if( war_sdy_pl_responsive_mode == 'scale' )
1563        {
1564            var scale_factor = ( window_width * 0.7 / war_sdy_pl_responsive_reference_window_width ) + 0.3;
1565
1566            if( war_sdy_pl_responsive_include_player_picture )
1567            {
1568                var picture_width = _this.picture_width;
1569
1570                var responsive_picture_width = Math.round( picture_width * scale_factor );
1571                var responsive_picture_height = Math.round( _this.picture_aspect_ratio * responsive_picture_width );
1572                jquery_picture.css( 'width', responsive_picture_width );
1573                jquery_picture.css( 'height', responsive_picture_height );
1574            }
1575
1576            var button_width = _this.button_width;
1577
1578            var responsive_button_width = Math.round( button_width * scale_factor );
1579            var responsive_button_height = Math.round( _this.button_aspect_ratio * responsive_button_width );
1580            jQuery( audio_control_selector ).css( 'width', responsive_button_width );
1581            jQuery( audio_control_selector ).css( 'height', responsive_button_height );
1582            jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( 'width', responsive_button_width );
1583            jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' ).css( 'height', responsive_button_height );
1584
1585            var jquery_corner_button = jQuery( '.war_sdy_pl_audio_control.war_sdy_pl_pp_corner' );
1586            if( jquery_corner_button.length )
1587            {
1588                var responsive_offset_x = Math.round( _this.button_offset_x * scale_factor );
1589                var responsive_offset_y = Math.round( _this.button_offset_y * scale_factor );
1590
1591                jquery_corner_button.css( prop_x, responsive_offset_x );
1592                jquery_corner_button.css( prop_y, responsive_offset_y );
1593            }
1594        }
1595    }
1596}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.