質問編集履歴

3

インデント

2018/06/27 07:59

投稿

yu-smc
yu-smc

スコア610

test CHANGED
File without changes
test CHANGED
@@ -14,53 +14,53 @@
14
14
 
15
15
  var id = $('.messages .message:last-child').data('messageId'); //1
16
16
 
17
- var interval = setInterval(function(){ //2
17
+ var interval = setInterval(function(){ //2
18
18
 
19
- var insertHTML = '';
19
+ var insertHTML = '';
20
20
 
21
- if (window.location.href.match(//groups/\d+/messages/)) {
21
+ if (window.location.href.match(//groups/\d+/messages/)) {
22
22
 
23
- $.ajax({
23
+ $.ajax({
24
24
 
25
- url: location.href,
25
+ url: location.href,
26
26
 
27
- dataType: 'json',
27
+ dataType: 'json',
28
28
 
29
- })
29
+ })
30
30
 
31
- .done(function(data){
31
+ .done(function(data){
32
32
 
33
- data.forEach(function(message){ //3
33
+ data.forEach(function(message){ //3
34
34
 
35
- if (message.id > id) {
35
+ if (message.id > id) {
36
36
 
37
- console.log(id)
37
+ console.log(id)
38
38
 
39
- console.log(message.id)
39
+ console.log(message.id)
40
40
 
41
- insertHTML += buildHTML(message);
41
+ insertHTML += buildHTML(message);
42
42
 
43
- }
43
+ }
44
44
 
45
- });
45
+ });
46
46
 
47
- $('.messages').append(insertHTML);
47
+ $('.messages').append(insertHTML);
48
48
 
49
- scrollToNewest();
49
+ scrollToNewest();
50
50
 
51
- })
51
+ })
52
52
 
53
- .fail(function(data){
53
+ .fail(function(data){
54
54
 
55
- alert('自動更新できません。更新するにはページを再度読み込んでください。');
55
+ alert('自動更新できません。更新するにはページを再度読み込んでください。');
56
56
 
57
- });
57
+ });
58
58
 
59
- } else {
59
+ } else {
60
60
 
61
- clearInterval(interval);
61
+ clearInterval(interval);
62
62
 
63
- }
63
+ }
64
64
 
65
65
  id = $('.messages .message:last-child').data('messageId');
66
66
 

2

いんでんと

2018/06/27 07:59

投稿

yu-smc
yu-smc

スコア610

test CHANGED
File without changes
test CHANGED
@@ -10,59 +10,57 @@
10
10
 
11
11
  以下JSコードです。
12
12
 
13
- ```
13
+ ```js
14
-
15
- js
16
14
 
17
15
  var id = $('.messages .message:last-child').data('messageId'); //1
18
16
 
19
17
  var interval = setInterval(function(){ //2
20
18
 
21
- var insertHTML = '';
19
+ var insertHTML = '';
22
20
 
23
- if (window.location.href.match(//groups/\d+/messages/)) {
21
+ if (window.location.href.match(//groups/\d+/messages/)) {
24
22
 
25
- $.ajax({
23
+ $.ajax({
26
24
 
27
- url: location.href,
25
+ url: location.href,
28
26
 
29
- dataType: 'json',
27
+ dataType: 'json',
30
28
 
31
- })
29
+ })
32
30
 
33
- .done(function(data){
31
+ .done(function(data){
34
32
 
35
- data.forEach(function(message){ //3
33
+ data.forEach(function(message){ //3
36
34
 
37
- if (message.id > id) {
35
+ if (message.id > id) {
38
36
 
39
- console.log(id)
37
+ console.log(id)
40
38
 
41
- console.log(message.id)
39
+ console.log(message.id)
42
40
 
43
- insertHTML += buildHTML(message);
41
+ insertHTML += buildHTML(message);
44
42
 
45
- }
43
+ }
46
44
 
47
- });
45
+ });
48
46
 
49
- $('.messages').append(insertHTML);
47
+ $('.messages').append(insertHTML);
50
48
 
51
- scrollToNewest();
49
+ scrollToNewest();
52
50
 
53
- })
51
+ })
54
52
 
55
- .fail(function(data){
53
+ .fail(function(data){
56
54
 
57
- alert('自動更新できません。更新するにはページを再度読み込んでください。');
55
+ alert('自動更新できません。更新するにはページを再度読み込んでください。');
58
56
 
59
- });
57
+ });
60
58
 
61
- } else {
59
+ } else {
62
60
 
63
- clearInterval(interval);
61
+ clearInterval(interval);
64
62
 
65
- }
63
+ }
66
64
 
67
65
  id = $('.messages .message:last-child').data('messageId');
68
66
 

1

誤字

2018/06/27 07:52

投稿

yu-smc
yu-smc

スコア610

test CHANGED
File without changes
test CHANGED
File without changes