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

js/sharing/sharing.js (25 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
 * @author Sebastian Doell <[email protected]>
9
 * @copyright 2016-2019 Marcel Scherello
10
 * @copyright 2015 Sebastian Doell
11
 */
12
13
'use strict';
0 ignored issues
show
Use the function form of "use strict".
Loading history...
14
15
$(document).ready(function () {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
16
    if ($('#header').hasClass('share-file')) {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
17
        var mime_array = ['audio/mpeg', 'audio/mp4', 'audio/m4b', 'audio/ogg', 'audio/wav', 'audio/flac'];
18
        var mimeType = $('#mimetype').val();
0 ignored issues
show
$ does not seem to be defined.
Loading history...
19
        var sharingToken = $('#sharingToken');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
20
21
        var token = (sharingToken.val() !== undefined) ? sharingToken.val() : '';
22
        if (mime_array.indexOf(mimeType) !== -1) {
23
24
            var imgFrame = $('#imgframe');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
25
            imgFrame.css({'max-width': '450px'});
26
27
            if (imgFrame.find('audio').length === 0) {
28
                var downloadURL = $('#downloadURL').val();
0 ignored issues
show
$ does not seem to be defined.
Loading history...
29
                var audioTag = '<audio tabindex="0" controls preload="none" style="width: 100%;"> <source src="' + downloadURL + '" type="' + mimeType + '"/> </audio>';
30
                imgFrame.append(audioTag);
31
            }
32
33
            imgFrame.after($('<div/>').attr('id', 'id3'));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
34
            var ajaxurl = OC.generateUrl('apps/audioplayer/getpublicaudioinfo?token={token}', {'token': token}, {escape: false});
35
36
            $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
37
                type: 'GET',
38
                url: ajaxurl,
39
                success: function (jsondata) {
40
                    if (jsondata.status === 'success') {
41
                        var $id3 = $('#id3');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
42
                        if (jsondata.data.title !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Title') + ': ')).append($('<span/>').text(jsondata.data.title)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
43
                        if (jsondata.data.subtitle !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Subtitle') + ': ')).append($('<span/>').text(jsondata.data.subtitle)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
44
                        if (jsondata.data.artist !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Artist') + ': ')).append($('<span/>').text(jsondata.data.artist)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
45
                        if (jsondata.data.albumartist !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Album Artist') + ': ')).append($('<span/>').text(jsondata.data.albumartist)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
46
                        if (jsondata.data.composer !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Composer') + ': ')).append($('<span/>').text(jsondata.data.composer)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
47
                        if (jsondata.data.album !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Album') + ': ')).append($('<span/>').text(jsondata.data.album)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
48
                        if (jsondata.data.genre !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Genre') + ': ')).append($('<span/>').text(jsondata.data.genre)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
49
                        if (jsondata.data.year !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Year') + ': ')).append($('<span/>').text(jsondata.data.year)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
50
                        if (jsondata.data.number !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Disc') + '-' + t('audioplayer', 'Track') + ': ')).append($('<span/>').text(jsondata.data.disc + '-' + jsondata.data.number)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
51
                        if (jsondata.data.length !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Length') + ': ')).append($('<span/>').text(jsondata.data.length)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
52
                        if (jsondata.data.bitrate !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Bitrate') + ': ')).append($('<span/>').text(jsondata.data.bitrate + ' kbps')));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
53
                        if (jsondata.data.mimetype !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'MIME type') + ': ')).append($('<span/>').text(jsondata.data.mimetype)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
54
                        if (jsondata.data.isrc !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'ISRC') + ': ')).append($('<span/>').text(jsondata.data.isrc)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
55
                        if (jsondata.data.copyright !== '') $id3.append($('<div/>').append($('<span/>').text(t('audioplayer', 'Copyright') + ' © ')).append($('<span/>').text(jsondata.data.copyright)));
0 ignored issues
show
$ does not seem to be defined.
Loading history...
There were too many errors found in this file; checking aborted after 85%.

If JSHint finds too many errors in a file, it aborts checking altogether because it suspects a configuration issue.

Further Reading:

Loading history...
56
                        $('.directDownload').css({'padding-top':'20px'});
57
                        $('.publicpreview').css({'padding-top': '20px'});
58
                    }
59
                }
60
            });
61
        }
62
    }
63
});
64