Total Complexity | 6 |
Complexity/F | 1.5 |
Lines of Code | 23 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /** |
||
11 | inji.Notifications = { |
||
12 | showNotification: function (title, text, action) { |
||
13 | var notification = new Notification(title, { |
||
14 | icon: '/static/system/images/logo-dark.png', |
||
15 | body: text, |
||
16 | }); |
||
17 | if (action) { |
||
18 | notification.onclick = action; |
||
19 | } |
||
20 | } |
||
21 | } |
||
22 | inji.onLoad(function () { |
||
23 | setInterval(function () { |
||
24 | inji.Server.request({ |
||
25 | url: '/notifications/check', |
||
26 | success: function (result) { |
||
27 | for (var key in result) { |
||
|
|||
28 | inji.Notifications.showNotification(result[key].notification_name, result[key].notification_text); |
||
29 | } |
||
30 | } |
||
31 | }); |
||
32 | }, 30 * 1000); |
||
33 | }) |
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: