質問編集履歴
1
軌道修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,27 +4,97 @@
|
|
4
4
|
|
5
5
|
```javascript
|
6
6
|
|
7
|
-
|
7
|
+
// a要素を生成し、href属性に値を付与
|
8
8
|
|
9
|
-
var
|
9
|
+
var a = document.createElement('a');
|
10
10
|
|
11
|
-
var n
|
11
|
+
var domain = "https://example.com";
|
12
12
|
|
13
|
-
var a
|
13
|
+
var aid = json.XXXXXXXXXX + "/";
|
14
14
|
|
15
|
-
|
15
|
+
a.setAttribute("href", domain + aid);
|
16
16
|
|
17
|
-
top.className = "top-of-plugin";
|
18
17
|
|
19
|
-
bottom.className = "bottom-of-plugin";
|
20
18
|
|
21
|
-
|
19
|
+
// img要素を生成し、src属性に値を付与
|
22
20
|
|
23
|
-
ar
|
21
|
+
var img = document.createElement('img');
|
24
22
|
|
25
|
-
|
23
|
+
var imgUrl = json.AcmList[0].ImageUrl;
|
26
24
|
|
25
|
+
img.setAttribute("src", imgUrl);
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
// 他のDOMも生成
|
30
|
+
|
31
|
+
var top = document.createElement('div');
|
32
|
+
|
33
|
+
var name = document.createElement('h3');
|
34
|
+
|
35
|
+
var area = document.createElement('p');
|
36
|
+
|
37
|
+
var button = document.createElement('button');
|
38
|
+
|
39
|
+
var bottom = document.createElement('div');
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
// 各要素にクラスを付与
|
44
|
+
|
45
|
+
a.className = "a-of-plugin";
|
46
|
+
|
47
|
+
top.className = "top-of-plugin";
|
48
|
+
|
49
|
+
img.className = "img-of-plugin";
|
50
|
+
|
51
|
+
name.className = "name-of-plugin";
|
52
|
+
|
53
|
+
area.className = "area-of-plugin";
|
54
|
+
|
55
|
+
button.className = "button-of-plugin";
|
56
|
+
|
57
|
+
bottom.className = "bottom-of-plugin";
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
// 文字を挿入
|
62
|
+
|
63
|
+
name.innerHTML = json.XXXXXXXXXX;
|
64
|
+
|
65
|
+
area.innerHTML = json.XXXXXXXXXX;
|
66
|
+
|
67
|
+
button.innerHTML = "サンプルテキスト";
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
//親子関係
|
72
|
+
|
73
|
+
top.appendChild(img);
|
74
|
+
|
75
|
+
bottom.appendChild(name);
|
76
|
+
|
77
|
+
bottom.appendChild(area);
|
78
|
+
|
79
|
+
bottom.appendChild(button);
|
80
|
+
|
81
|
+
a.appendChild(top);
|
82
|
+
|
83
|
+
a.appendChild(bottom);
|
84
|
+
|
85
|
+
document.getElementsByTagName("body")[0].appendChild(a);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
// 配置
|
90
|
+
|
91
|
+
plugin.parentNode.insertBefore(button, plugin.nextSibling);
|
92
|
+
|
93
|
+
plugin.parentNode.insertBefore(area, plugin.nextSibling);
|
94
|
+
|
27
|
-
plugin.parentNode.insertBefore(name, plugin.nextSibling);
|
95
|
+
plugin.parentNode.insertBefore(name, plugin.nextSibling);
|
96
|
+
|
97
|
+
plugin.parentNode.insertBefore(img, plugin.nextSibling);
|
28
98
|
|
29
99
|
```
|
30
100
|
|
@@ -34,30 +104,24 @@
|
|
34
104
|
|
35
105
|
```html
|
36
106
|
|
37
|
-
<a
|
107
|
+
<a class="a-of-plugin">
|
38
108
|
|
39
|
-
<div class="top-of-plugin">
|
109
|
+
<div class="top-of-plugin">
|
40
110
|
|
41
|
-
<img />
|
111
|
+
<img class="img-of-plugin" />
|
42
112
|
|
43
|
-
</div>
|
113
|
+
</div>
|
44
114
|
|
45
|
-
<div class="bottom-of-plugin">
|
115
|
+
<div class="bottom-of-plugin">
|
46
116
|
|
47
|
-
<h3>
|
117
|
+
<h3 class="name-of-plugin"></h3>
|
48
118
|
|
49
|
-
|
119
|
+
<p class="area-of-plugin"></p>
|
50
120
|
|
51
|
-
</
|
121
|
+
<button class="button-of-plugin">サンプルテキスト</button>
|
52
122
|
|
53
|
-
<
|
123
|
+
</div>
|
54
124
|
|
55
|
-
area
|
56
|
-
|
57
|
-
</p>
|
58
|
-
|
59
|
-
</div>
|
60
|
-
|
61
|
-
</a>
|
125
|
+
</a>
|
62
126
|
|
63
127
|
```
|