Passed
Push — master ( 998e10...1efe83 )
by Marcel
06:10
created

js/settings/personal.js (46 issues)

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
Use the function form of "use strict".
Loading history...
12
13
$(document).ready(function () {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
document does not seem to be defined.
Loading history...
14
    $('#cyrillic_user').on('click', function () {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
15
        var user_value;
16
        if ($('#cyrillic_user').prop('checked')) {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
17
            user_value = 'checked';
18
        }
19
        else {
20
            user_value = '';
21
        }
22
        $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
23
            type: 'GET',
24
            url: OC.generateUrl('apps/audioplayer/setvalue'),
0 ignored issues
show
OC does not seem to be defined.
Loading history...
25
            data: {
26
                'type': 'cyrillic',
27
                'value': user_value
28
            },
29
            success: function () {
30
                OC.Notification.showTemporary(t('audioplayer', 'saved'));
0 ignored issues
show
OC does not seem to be defined.
Loading history...
t does not seem to be defined.
Loading history...
31
            }
32
        });
33
    });
34
35
    $('#sonos').on('click', function () {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
36
        var user_value;
37
        if ($('#sonos').prop('checked')) {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
38
            user_value = 'checked';
39
        }
40
        else {
41
            user_value = '';
42
        }
43
        $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
44
            type: 'GET',
45
            url: OC.generateUrl('apps/audioplayer/setvalue'),
0 ignored issues
show
OC does not seem to be defined.
Loading history...
46
            data: {
47
                'type': 'sonos',
48
                'value': user_value
49
            },
50
            success: function () {
51
                OC.Notification.showTemporary(t('audioplayer', 'saved'));
0 ignored issues
show
OC does not seem to be defined.
Loading history...
t does not seem to be defined.
Loading history...
52
            }
53
        });
54
    });
55
56
    $('#sonos_controller_submit').on('click', function () {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
57
        var user_value = $('#sonos_controller').val();
0 ignored issues
show
$ does not seem to be defined.
Loading history...
58
        $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
59
            type: 'GET',
60
            url: OC.generateUrl('apps/audioplayer/setvalue'),
0 ignored issues
show
OC does not seem to be defined.
Loading history...
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
OC does not seem to be defined.
Loading history...
t does not seem to be defined.
Loading history...
67
            }
68
        });
69
    });
70
71
    $('#sonos_smb_path_submit').on('click', function () {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
72
        var user_value = $('#sonos_smb_path').val();
0 ignored issues
show
$ does not seem to be defined.
Loading history...
73
        $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
74
            type: 'GET',
75
            url: OC.generateUrl('apps/audioplayer/setvalue'),
0 ignored issues
show
OC does not seem to be defined.
Loading history...
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
OC does not seem to be defined.
Loading history...
t does not seem to be defined.
Loading history...
82
            }
83
        });
84
    });
85
86
    /*
87
 * Collection path
88
 */
89
    var $path = $('#audio-path');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
90
    $path.on('click', function () {
91
        OC.dialogs.filepicker(
0 ignored issues
show
OC does not seem to be defined.
Loading history...
92
            t('audioplayer', 'Select a single folder with audio files'),
0 ignored issues
show
t does not seem to be defined.
Loading history...
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
$ does not seem to be defined.
Loading history...
OC does not seem to be defined.
Loading history...
97
                        if (!data.success) {
98
                            OC.Notification.showTemporary(t('audioplayer', 'Invalid path!'));
0 ignored issues
show
OC does not seem to be defined.
Loading history...
t does not seem to be defined.
Loading history...
99
                        } else {
100
                            OC.Notification.showTemporary(t('audioplayer', 'saved'));
0 ignored issues
show
OC does not seem to be defined.
Loading history...
t does not seem to be defined.
Loading history...
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
soundManager does not seem to be defined.
Loading history...
113
        onready: function () {
114
            audioPlayer.player = soundManager.createSound({});
0 ignored issues
show
soundManager does not seem to be defined.
Loading history...
115
            var can_play = soundManager.html5;
0 ignored issues
show
soundManager does not seem to be defined.
Loading history...
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
$ does not seem to be defined.
Loading history...
130
            $('#browser_no').html(nsupported_types);
0 ignored issues
show
$ does not seem to be defined.
Loading history...
131
        }
132
    });
133
134
    $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
135
        type: 'POST',
136
        url: OC.generateUrl('apps/audioplayer/sonosdevices'),
0 ignored issues
show
OC does not seem to be defined.
Loading history...
137
        data: {},
138
        success: function (jsondata) {
139
            $(jsondata).each(function (i, el) {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
140
                $('#sonos_controller').append($('<option>', {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
141
                    value: el[0],
142
                    text: el[2][0]
143
                }));
144
            });
145
            $('#sonos_controller').val($('#sonos_current').val());
0 ignored issues
show
$ does not seem to be defined.
Loading history...
146
        }
147
    });
148
149
150
});