teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

意図的に内容を抹消する行為にあたるため

2021/10/11 05:18

投稿

退会済みユーザー
answer CHANGED
@@ -1,3 +1,54 @@
1
+ こんなんで、どないでっか?
1
- (都合により削除)
2
+ ```diff
2
-
3
+ //CSV書き出し
4
+ function readCsv(data) {
5
+ var csv = $.csv.toArrays(data);
6
+ - var insert_1 = '';
7
+ - var insert_2 = '';
8
+ - var insert_3 = '';
9
+ - $(csv).each(function() {
10
+ - if (this.length > 0 && this[0] === 'カテゴリ1') {
11
+ - insert_1 += '<li>';
12
+ - insert_1 += '<div>' + this[0] + '</div>';
13
+ - insert_1 += '<div>' + this[1] + '</div>';
14
+ - insert_1 += '<div>' + this[2] + '</div>';
15
+ - insert_1 += '<div>' + this[3] + '</div>';
16
+ - insert_1 += '<div>' + this[4] + '</div>';
17
+ - insert_1 += '<div>' + this[5] + '</div>';
18
+ - insert_1 += '</li>';
19
+ - } else if (this.length > 0 && this[0] === 'カテゴリ2') {
20
+ - insert_2 += '<li>';
21
+ - insert_2 += '<div>' + this[0] + '</div>';
22
+ - insert_2 += '<div>' + this[1] + '</div>';
23
+ - insert_2 += '<div>' + this[2] + '</div>';
24
+ - insert_2 += '<div>' + this[3] + '</div>';
25
+ - insert_2 += '<div>' + this[4] + '</div>';
26
+ - insert_2 += '<div>' + this[5] + '</div>';
27
+ - insert_2 += '</li>';
28
+ - } else if (this.length > 0 && this[0] === 'カテゴリ3') {
29
+ - insert_3 += '<li>';
30
+ - insert_3 += '<div>' + this[0] + '</div>';
31
+ - insert_3 += '<div>' + this[1] + '</div>';
32
+ - insert_3 += '<div>' + this[2] + '</div>';
33
+ - insert_3 += '<div>' + this[3] + '</div>';
34
+ - insert_3 += '<div>' + this[4] + '</div>';
35
+ - insert_3 += '<div>' + this[5] + '</div>';
36
+ - insert_3 += '</li>';
37
+ - } else{
38
+ - return false;
39
+ - }
40
+ - });
41
+ - $('#slick_1 .slider').append(insert_1);
42
+ - $('#slick_2 .slider').append(insert_2);
43
+ - $('#slick_3 .slider').append(insert_3);
3
- ![イメージ説明](d7a9931f678708d658e2f6c057c6e6c7.png)
44
+ + $('.slick_box').each(function() {
45
+ + const categoryId = $(this).attr('id').replace('slick_', '');
46
+ + const rows = csv.filter(([category]) => category === `カテゴリ${categoryId}`);
47
+ + const items = rows.map(values =>
48
+ + $('<li>').append(values.map(v => $('<div>').text(v)))
49
+ + );
50
+ + $('.slider', this).append(items);
51
+ + });
52
+ sliderInit();
53
+ }
54
+ ```

1

テキスト追加

2021/10/11 05:18

投稿

退会済みユーザー
answer CHANGED
@@ -1,56 +1,3 @@
1
- こんなんで、どないでっか?
1
+ (都合により削除)
2
2
 
3
- ```diff
4
- //CSV書き出し
5
- function readCsv(data) {
6
- var csv = $.csv.toArrays(data);
7
- - var insert_1 = '';
8
- - var insert_2 = '';
9
- - var insert_3 = '';
10
- - $(csv).each(function() {
11
- - if (this.length > 0 && this[0] === 'カテゴリ1') {
12
- - insert_1 += '<li>';
13
- - insert_1 += '<div>' + this[0] + '</div>';
14
- - insert_1 += '<div>' + this[1] + '</div>';
15
- - insert_1 += '<div>' + this[2] + '</div>';
16
- - insert_1 += '<div>' + this[3] + '</div>';
17
- - insert_1 += '<div>' + this[4] + '</div>';
18
- - insert_1 += '<div>' + this[5] + '</div>';
19
- - insert_1 += '</li>';
20
- - } else if (this.length > 0 && this[0] === 'カテゴリ2') {
21
- - insert_2 += '<li>';
22
- - insert_2 += '<div>' + this[0] + '</div>';
23
- - insert_2 += '<div>' + this[1] + '</div>';
24
- - insert_2 += '<div>' + this[2] + '</div>';
25
- - insert_2 += '<div>' + this[3] + '</div>';
26
- - insert_2 += '<div>' + this[4] + '</div>';
27
- - insert_2 += '<div>' + this[5] + '</div>';
28
- - insert_2 += '</li>';
29
- - } else if (this.length > 0 && this[0] === 'カテゴリ3') {
30
- - insert_3 += '<li>';
31
- - insert_3 += '<div>' + this[0] + '</div>';
32
- - insert_3 += '<div>' + this[1] + '</div>';
33
- - insert_3 += '<div>' + this[2] + '</div>';
34
- - insert_3 += '<div>' + this[3] + '</div>';
35
- - insert_3 += '<div>' + this[4] + '</div>';
36
- - insert_3 += '<div>' + this[5] + '</div>';
37
- - insert_3 += '</li>';
38
- - } else{
39
- - return false;
40
- - }
41
- - });
42
- - $('#slick_1 .slider').append(insert_1);
43
- - $('#slick_2 .slider').append(insert_2);
44
- - $('#slick_3 .slider').append(insert_3);
45
- + $('.slick_box').each(function() {
3
+ ![イメージ説明](d7a9931f678708d658e2f6c057c6e6c7.png)
46
- + const categoryId = $(this).attr('id').replace('slick_', '');
47
- + const rows = csv.filter(([category]) => category === `カテゴリ${categoryId}`);
48
- + const items = rows.map(values =>
49
- + $('<li>').append(values.map(v => $('<div>').text(v)))
50
- + );
51
- + $('.slider', this).append(items);
52
- + });
53
- sliderInit();
54
- }
55
-
56
- ```