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

js/sharing/sharing.js (1 issue)

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';
14
15
$(document).ready(function () {
16
    if ($('#header').hasClass('share-file')) {
17
        var mime_array = ['audio/mpeg', 'audio/mp4', 'audio/m4b', 'audio/ogg', 'audio/wav', 'audio/flac'];
18
        var mimeType = $('#mimetype').val();
19
        var sharingToken = $('#sharingToken');
20
21
        var token = (sharingToken.val() !== undefined) ? sharingToken.val() : '';
22
        if (mime_array.indexOf(mimeType) !== -1) {
23
24
            var imgFrame = $('#imgframe');
25
            imgFrame.css({'max-width': '450px'});
26
27
            if (imgFrame.find('audio').length === 0) {
28
                var downloadURL = $('#downloadURL').val();
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'));
34
            var ajaxurl = OC.generateUrl('apps/audioplayer/getpublicaudioinfo?token={token}', {'token': token}, {escape: false});
35
36
            $.ajax({
37
                type: 'GET',
38
                url: ajaxurl,
39
                success: function (jsondata) {
40
                    if (jsondata.status === 'success') {
41
                        var $id3 = $('#id3');
42
                        if (jsondata.data.title !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Title') + ': ')).append($('<span/>').text(jsondata.data.title)));
43
                        if (jsondata.data.subtitle !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Subtitle') + ': ')).append($('<span/>').text(jsondata.data.subtitle)));
44
                        if (jsondata.data.artist !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Artist') + ': ')).append($('<span/>').text(jsondata.data.artist)));
45
                        if (jsondata.data.albumartist !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Album Artist') + ': ')).append($('<span/>').text(jsondata.data.albumartist)));
46
                        if (jsondata.data.composer !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Composer') + ': ')).append($('<span/>').text(jsondata.data.composer)));
47
                        if (jsondata.data.album !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Album') + ': ')).append($('<span/>').text(jsondata.data.album)));
48
                        if (jsondata.data.genre !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Genre') + ': ')).append($('<span/>').text(jsondata.data.genre)));
49
                        if (jsondata.data.year !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Year') + ': ')).append($('<span/>').text(jsondata.data.year)));
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)));
51
                        if (jsondata.data.length !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Length') + ': ')).append($('<span/>').text(jsondata.data.length)));
52
                        if (jsondata.data.bitrate !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'Bitrate') + ': ')).append($('<span/>').text(jsondata.data.bitrate + ' kbps')));
53
                        if (jsondata.data.mimetype !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'MIME type') + ': ')).append($('<span/>').text(jsondata.data.mimetype)));
54
                        if (jsondata.data.isrc !== '') $id3.append($('<div/>').append($('<b/>').text(t('audioplayer', 'ISRC') + ': ')).append($('<span/>').text(jsondata.data.isrc)));
55
                        if (jsondata.data.copyright !== '') $id3.append($('<div/>').append($('<span/>').text(t('audioplayer', 'Copyright') + ' © ')).append($('<span/>').text(jsondata.data.copyright)));
0 ignored issues
show
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