回答編集履歴

1

解説を詳細化

2018/03/09 10:58

投稿

defghi1977
defghi1977

スコア4756

test CHANGED
@@ -17,3 +17,43 @@
17
17
  var $=jQuery;$("#hpick .shutter_wrap").css("min-height",$(window).height()),$("#shutter_post_header").html($("#hpick").html()).removeClass("hidden"),$("#hpick").remove(),$(window).resize(function(){$("#shutter_post_header .shutter_wrap").css("min-height",$(window).height())}),$("time").map(function(){var e=$(this).attr("data-pub"),t=["","January","February","March","April","May","June","July","August","September","October","November","December"][+(e=(e=e.split("T"))[0].split("-"))[1]]+" "+e[2]+", "+e[0];$(this).after(t),$(this).remove()});
18
18
 
19
19
  ```
20
+
21
+
22
+
23
+ ---
24
+
25
+ ワンライナーコードを解すとしくじっている部分がよく判ります.
26
+
27
+
28
+
29
+ ```HTML
30
+
31
+ <time data-pub='2018-03-09T15:24:00+09:00'></time>
32
+
33
+ ```
34
+
35
+ ```JavaScript
36
+
37
+ $("time").map(
38
+
39
+ function(){
40
+
41
+ var e=$(this).attr("data-pub");
42
+
43
+ var months = ["","January","February","March","April","May","June","July","August","September","October","November","December"];
44
+
45
+ e=e.split("T");
46
+
47
+ e=e[0].split("-");
48
+
49
+ t=months[e[1]]+" "+e[2]+", "+e[0];//←インデックスがNumberじゃない!
50
+
51
+ $(this).after(t);
52
+
53
+ $(this).remove();
54
+
55
+ }
56
+
57
+ );
58
+
59
+ ```