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

js/widgets/audioplayer.js (19 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
(function () {
14
15
    /**
16
     * @constructs Widget
17
     */
18
    var Widget = function () {
19
20
        var widget = {
21
22
            divClock: null,
23
24
            init: function () {
25
                widget.divClock = $('#widget-audioplayer');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
26
27
                var PlaylistId = 'X3';
28
                var title = $('<div>/').text('Recently Played:').addClass('widget-audioplayer-header');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
29
                var html = widget.getTitles(PlaylistId);
30
                widget.divClock.append(title);
31
32
                //var PlaylistId = 'X2';
33
                //title = $('<div>/').text('Recently Added:').addClass('widget-audioplayer-header');
34
                //var html = widget.getTitles(PlaylistId);
35
                //widget.divClock.append(title);
36
            },
37
38
            getTitles: function (PlaylistId) {
39
40
                widget.divClock = $('#widget-audioplayer');
0 ignored issues
show
$ does not seem to be defined.
Loading history...
41
                var category = 'Playlist';
42
                $.ajax({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
43
                    type: 'GET',
44
                    url: OC.generateUrl('apps/audioplayer/getcategoryitems'),
0 ignored issues
show
OC does not seem to be defined.
Loading history...
45
                    data: {category: category, categoryId: PlaylistId},
46
                    success: function (jsondata) {
47
                        var $html;
48
                        if (jsondata.status === 'success') {
49
                            $(jsondata.data).each(function (i, el) {
0 ignored issues
show
$ does not seem to be defined.
Loading history...
50
                                var li = $('<li/>').attr({
0 ignored issues
show
$ does not seem to be defined.
Loading history...
51
                                    'data-trackid': el.id,
52
                                    'data-mimetype': el.mim,
53
                                    'mimetype': el.mim,
54
                                    'data-title': el.cl1,
55
                                    'data-artist': el.cl2,
56
                                    'data-album': el.cl3,
57
                                    'data-cover': el.cid,
58
                                    'data-path': el.lin,
59
                                    'class': 'dragable'
60
                                }).addClass('widget-audioplayer-item');
61
                                var spanTitle = $('<span/>').attr({'class': 'widget-audioplayer-title'}).html(el.cl1);
0 ignored issues
show
$ does not seem to be defined.
Loading history...
62
63
                                var coverID = el.cid;
64
                                var getcoverUrl = OC.generateUrl('apps/audioplayer/getcover/');
0 ignored issues
show
OC does not seem to be defined.
Loading history...
65
                                if (coverID === '') {
66
                                    var addCss = 'background-color: #D3D3D3;color: #333333;';
67
                                    var addDescr = el.cl1.substring(0, 1);
68
                                } else {
69
                                    addDescr = '';
0 ignored issues
show
The variable addDescr seems to be used out of scope.

This error can usually be fixed by declaring the variable in the scope where it is used:

function someFunction() {
    (function() {
        var i = 0;
    })();

    // i is not defined.
    alert(i);
}

// This can be fixed by moving the var statement to the outer scope.

function someFunction() {
    var i;
    (function() {
        i = 1;
    })();

    alert(i);
};
Loading history...
70
                                    addCss = 'background-image:url(' + getcoverUrl + coverID + ');-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;';
0 ignored issues
show
The variable addCss seems to be used out of scope.

This error can usually be fixed by declaring the variable in the scope where it is used:

function someFunction() {
    (function() {
        var i = 0;
    })();

    // i is not defined.
    alert(i);
}

// This can be fixed by moving the var statement to the outer scope.

function someFunction() {
    var i;
    (function() {
        i = 1;
    })();

    alert(i);
};
Loading history...
71
                                }
72
                                if (i === 0) $('.sm2-playlist-cover').attr({'style': addCss}).text(addDescr);
0 ignored issues
show
The variable addDescr seems to be used out of scope.

This error can usually be fixed by declaring the variable in the scope where it is used:

function someFunction() {
    (function() {
        var i = 0;
    })();

    // i is not defined.
    alert(i);
}

// This can be fixed by moving the var statement to the outer scope.

function someFunction() {
    var i;
    (function() {
        i = 1;
    })();

    alert(i);
};
Loading history...
The variable addCss seems to be used out of scope.

This error can usually be fixed by declaring the variable in the scope where it is used:

function someFunction() {
    (function() {
        var i = 0;
    })();

    // i is not defined.
    alert(i);
}

// This can be fixed by moving the var statement to the outer scope.

function someFunction() {
    var i;
    (function() {
        i = 1;
    })();

    alert(i);
};
Loading history...
$ does not seem to be defined.
Loading history...
73
74
                                var spanInterpret = $('<span>').attr({'class': 'widget-audioplayer-interpret'});
0 ignored issues
show
$ does not seem to be defined.
Loading history...
75
                                spanInterpret = spanInterpret.html('&nbsp;-&nbsp;'+el.cl2);
76
77
                                li.append(spanTitle);
78
                                li.append(spanInterpret);
79
                                widget.divClock.append(li);
80
                            }); // end each loop
81
                        }
82
83
                    }
84
                });
85
            }
86
87
        };
88
89
        $.extend(Widget.prototype, widget);
0 ignored issues
show
$ does not seem to be defined.
Loading history...
90
    };
91
92
    OCA.DashBoard.Widget = Widget;
0 ignored issues
show
OCA does not seem to be defined.
Loading history...
93
    OCA.DashBoard.widget = new Widget();
0 ignored issues
show
OCA does not seem to be defined.
Loading history...
94
95
})();