1 | $(document).ready(function () { |
||
2 | function getCurrentDateStr() { |
||
3 | var month = d.getMonth() + 1; |
||
4 | var day = d.getDate(); |
||
5 | return d.getFullYear() + '-' + |
||
6 | (month < 10 ? '0' : '') + month + '-' + |
||
7 | (day < 10 ? '0' : '') + day; |
||
8 | } |
||
9 | |||
10 | function getCurrentTimeStr() { |
||
11 | return d.getHours() + ":" + d.getMinutes(); |
||
12 | } |
||
13 | |||
14 | function scrollToNearReport() { |
||
15 | var scrollTo = null; |
||
16 | var current_report = null; |
||
17 | var prev_report = null; |
||
18 | var now_time = getCurrentTimeStr(); |
||
19 | |||
20 | $('.program-body__td--time').each(function (index, value) { |
||
0 ignored issues
–
show
|
|||
21 | if (current_report !== null) { |
||
22 | prev_report = current_report; |
||
23 | } |
||
24 | current_report = $(this); |
||
25 | if (now_time < current_report.text()) { |
||
0 ignored issues
–
show
There is no return statement if
now_time < current_report.text() is false . Are you sure this is correct? If so, consider adding return; explicitly.
This check looks for functions where a Consider this little piece of code function isBig(a) {
if (a > 5000) {
return "yes";
}
}
console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined
The function This behaviour may not be what you had intended. In any case, you can add a
![]() |
|||
26 | if (prev_report !== null) { |
||
27 | scrollTo = prev_report; |
||
28 | } else { |
||
29 | scrollTo = current_report; |
||
30 | } |
||
31 | return false; |
||
32 | } |
||
33 | }); |
||
34 | if (scrollTo !== null) { |
||
35 | $('body,html').animate({ |
||
36 | scrollTop: scrollTo.offset().top - 125 |
||
37 | }, 600); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | var event_header_date_element = $('.event-header__date'); |
||
42 | if (event_header_date_element.length) { |
||
43 | var d = new Date(); |
||
44 | var now_date = getCurrentDateStr(); |
||
45 | var event_date = event_header_date_element.attr('datetime'); |
||
46 | |||
47 | if ('scrollRestoration' in history) { |
||
0 ignored issues
–
show
The variable
history seems to be never declared. If this is a global, consider adding a /** global: history */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
48 | history.scrollRestoration = event_date === now_date ? 'manual' : 'auto'; |
||
49 | } |
||
50 | if (event_date === now_date) { |
||
51 | scrollToNearReport(); |
||
52 | } |
||
53 | } |
||
54 | }); |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.