1 | /** |
||
2 | * Audio Player |
||
3 | * |
||
4 | * This file is licensed under the Affero General Public License version 3 or |
||
5 | * later. See the LICENSE.md file. |
||
6 | * |
||
7 | * @author Marcel Scherello <[email protected]> |
||
8 | * @copyright 2016-2019 Marcel Scherello |
||
9 | */ |
||
10 | |||
11 | 'use strict'; |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
12 | |||
13 | $(document).ready(function () { |
||
0 ignored issues
–
show
|
|||
14 | $('#cyrillic_user').on('click', function () { |
||
0 ignored issues
–
show
|
|||
15 | var user_value; |
||
16 | if ($('#cyrillic_user').prop('checked')) { |
||
0 ignored issues
–
show
|
|||
17 | user_value = 'checked'; |
||
18 | } |
||
19 | else { |
||
20 | user_value = ''; |
||
21 | } |
||
22 | $.ajax({ |
||
0 ignored issues
–
show
|
|||
23 | type: 'GET', |
||
24 | url: OC.generateUrl('apps/audioplayer/setvalue'), |
||
0 ignored issues
–
show
|
|||
25 | data: { |
||
26 | 'type': 'cyrillic', |
||
27 | 'value': user_value |
||
28 | }, |
||
29 | success: function () { |
||
30 | OC.Notification.showTemporary(t('audioplayer', 'saved')); |
||
0 ignored issues
–
show
|
|||
31 | } |
||
32 | }); |
||
33 | }); |
||
34 | |||
35 | $('#sonos').on('click', function () { |
||
0 ignored issues
–
show
|
|||
36 | var user_value; |
||
37 | if ($('#sonos').prop('checked')) { |
||
0 ignored issues
–
show
|
|||
38 | user_value = 'checked'; |
||
39 | } |
||
40 | else { |
||
41 | user_value = ''; |
||
42 | } |
||
43 | $.ajax({ |
||
0 ignored issues
–
show
|
|||
44 | type: 'GET', |
||
45 | url: OC.generateUrl('apps/audioplayer/setvalue'), |
||
0 ignored issues
–
show
|
|||
46 | data: { |
||
47 | 'type': 'sonos', |
||
48 | 'value': user_value |
||
49 | }, |
||
50 | success: function () { |
||
51 | OC.Notification.showTemporary(t('audioplayer', 'saved')); |
||
0 ignored issues
–
show
|
|||
52 | } |
||
53 | }); |
||
54 | }); |
||
55 | |||
56 | $('#sonos_controller_submit').on('click', function () { |
||
0 ignored issues
–
show
|
|||
57 | var user_value = $('#sonos_controller').val(); |
||
0 ignored issues
–
show
|
|||
58 | $.ajax({ |
||
0 ignored issues
–
show
|
|||
59 | type: 'GET', |
||
60 | url: OC.generateUrl('apps/audioplayer/setvalue'), |
||
0 ignored issues
–
show
|
|||
61 | data: { |
||
62 | 'type': 'sonos_controller', |
||
63 | 'value': user_value |
||
64 | }, |
||
65 | success: function () { |
||
66 | OC.Notification.showTemporary(t('audioplayer', 'saved')); |
||
0 ignored issues
–
show
|
|||
67 | } |
||
68 | }); |
||
69 | }); |
||
70 | |||
71 | $('#sonos_smb_path_submit').on('click', function () { |
||
0 ignored issues
–
show
|
|||
72 | var user_value = $('#sonos_smb_path').val(); |
||
0 ignored issues
–
show
|
|||
73 | $.ajax({ |
||
0 ignored issues
–
show
|
|||
74 | type: 'GET', |
||
75 | url: OC.generateUrl('apps/audioplayer/setvalue'), |
||
0 ignored issues
–
show
|
|||
76 | data: { |
||
77 | 'type': 'sonos_smb_path', |
||
78 | 'value': user_value |
||
79 | }, |
||
80 | success: function () { |
||
81 | OC.Notification.showTemporary(t('audioplayer', 'saved')); |
||
0 ignored issues
–
show
|
|||
82 | } |
||
83 | }); |
||
84 | }); |
||
85 | |||
86 | /* |
||
87 | * Collection path |
||
88 | */ |
||
89 | var $path = $('#audio-path'); |
||
0 ignored issues
–
show
|
|||
90 | $path.on('click', function () { |
||
91 | OC.dialogs.filepicker( |
||
0 ignored issues
–
show
|
|||
92 | t('audioplayer', 'Select a single folder with audio files'), |
||
0 ignored issues
–
show
|
|||
93 | function (path) { |
||
94 | if ($path.val() !== path) { |
||
95 | $path.val(path); |
||
96 | $.post(OC.generateUrl('apps/audioplayer/userpath'), {value: path}, function (data) { |
||
0 ignored issues
–
show
|
|||
97 | if (!data.success) { |
||
98 | OC.Notification.showTemporary(t('audioplayer', 'Invalid path!')); |
||
0 ignored issues
–
show
|
|||
99 | } else { |
||
100 | OC.Notification.showTemporary(t('audioplayer', 'saved')); |
||
0 ignored issues
–
show
|
|||
101 | } |
||
102 | }); |
||
103 | } |
||
104 | }, |
||
105 | false, |
||
106 | 'httpd/unix-directory', |
||
107 | true |
||
108 | ); |
||
109 | }); |
||
110 | |||
111 | var audioPlayer = {}; |
||
112 | soundManager.setup({ |
||
0 ignored issues
–
show
|
|||
113 | onready: function () { |
||
114 | audioPlayer.player = soundManager.createSound({}); |
||
0 ignored issues
–
show
|
|||
115 | var can_play = soundManager.html5; |
||
0 ignored issues
–
show
|
|||
116 | var supported_types = ''; |
||
117 | var nsupported_types = ''; |
||
118 | for (var mtype in can_play) { |
||
119 | var mtype_check = can_play[mtype]; |
||
120 | if (mtype.substring(5, 6) !== '/' && mtype !== 'usingFlash' && mtype !== 'canPlayType') { |
||
121 | |||
122 | if (mtype_check === true) { |
||
123 | supported_types = supported_types + mtype + ', '; |
||
124 | } else { |
||
125 | nsupported_types = nsupported_types + mtype + ', '; |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | $('#browser_yes').html(supported_types); |
||
0 ignored issues
–
show
|
|||
130 | $('#browser_no').html(nsupported_types); |
||
0 ignored issues
–
show
|
|||
131 | } |
||
132 | }); |
||
133 | |||
134 | $.ajax({ |
||
0 ignored issues
–
show
|
|||
135 | type: 'POST', |
||
136 | url: OC.generateUrl('apps/audioplayer/sonosdevices'), |
||
0 ignored issues
–
show
|
|||
137 | data: {}, |
||
138 | success: function (jsondata) { |
||
139 | $(jsondata).each(function (i, el) { |
||
0 ignored issues
–
show
|
|||
140 | $('#sonos_controller').append($('<option>', { |
||
0 ignored issues
–
show
|
|||
141 | value: el[0], |
||
142 | text: el[2][0] |
||
143 | })); |
||
144 | }); |
||
145 | $('#sonos_controller').val($('#sonos_current').val()); |
||
0 ignored issues
–
show
|
|||
146 | } |
||
147 | }); |
||
148 | |||
149 | |||
150 | }); |