{"id":1096,"date":"2012-06-14T19:05:28","date_gmt":"2012-06-14T23:05:28","guid":{"rendered":"http:\/\/www.a2life.info\/w\/?p=1096"},"modified":"2015-08-08T12:42:32","modified_gmt":"2015-08-08T16:42:32","slug":"%e5%b0%86%e6%a3%8b%e7%9b%a4%e3%81%ab%e6%88%bb%e3%81%97%e3%83%9c%e3%82%bf%e3%83%b3%e3%82%92%e3%81%a4%e3%81%91%e3%81%a6%e3%81%bf%e3%82%8bjavascript","status":"publish","type":"post","link":"https:\/\/www.a2life.info\/w\/?p=1096","title":{"rendered":"\u5c06\u68cb\u76e4\u306b\u623b\u3057\u30dc\u30bf\u30f3\u3092\u3064\u3051\u3066\u307f\u308b(JavaScript)"},"content":{"rendered":"<div>\u5c06\u68cb\u76e4\u306e\u4e0a\u306e\u99d2\u304c\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3054\u3068\u306b\u4e00\u624b\u3065\u3064\u3046\u3054\u304f\u3088\u3046\u306b\u306a\u3063\u3066\u559c\u3093\u3060\u306e\u3082\u3064\u304b\u306e\u9593\u3001\u624b\u3092\u623b\u3059\u30dc\u30bf\u30f3\u304c\u306a\u3044\u306e\u304c\u3072\u3069\u304f\u554f\u984c\u306b\u898b\u3048\u3066\u304d\u305f\u3002\u3000\u3053\u308c\u306f\u6a5f\u80fd\u3092\u8ffd\u52a0\u305b\u306d\u3070\u3001\u3068\u8003\u3048\u305f\u306e\u3060\u304c\u3001\u6700\u521d\u306e\u8a2d\u8a08\u6642\u70b9\u3067\u5c65\u6b74\u3092\u3068\u308b\u3088\u3046\u306a\u69cb\u60f3\u306f\u4e00\u5207\u306a\u304b\u3063\u305f\u306e\u3067\u306f\u305f\u3068\u56f0\u3063\u305f\u3002\u52d5\u304d\u3092\u9006\u306b\u306a\u305e\u3063\u3066\u307f\u3066\u3082\u3001\u99d2\u3092\u53d6\u308b\u3001\u3068\u3044\u3046\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u30c7\u30fc\u30bf\u69cb\u9020\u4e0a\u660e\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3082\u3068\u306b\u623b\u3059\u306e\u304c\u7121\u7406\u306a\u3093\u3067\u3042\u308b\u3002\u3000\u4f55\u304b\u65b9\u6cd5\u304c\u3042\u308b\u306f\u305a\u3060\u3068\u601d\u3044\u3064\u30642\uff5e3\u65e5\u3001\u307b\u304a\u3063\u3066\u304a\u3044\u305f\u3002<\/p>\n<div>\u3044\u3063\u305d\u306e\u3053\u3068\u3001\u4e00\u624b\u3054\u3068\u306b\u5c06\u68cb\u76e4\u5168\u90e8\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3092\u53d6\u3063\u3066\u305d\u308c\u3092\u5909\u6570\u914d\u5217\u306b\u683c\u7d0d\u3057\u3066\u306f\u3069\u3046\u3060\u308d\u3046\u3068\u8003\u3048\u3064\u3044\u305f\u3002\u3000\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3068\u306f\u8a00\u3063\u3066\u3082\u3001\u753b\u50cf\u30c7\u30fc\u30bf\u3092\u30b3\u30d4\u30fc\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001JavaScript\u304c\u7cbe\u88fd\u3057\u305fhtml\u306e\u30c4\u30ea\u30fc\u69cb\u9020\u3092\u305d\u306e\u307e\u307e\u5909\u6570\u306b\u30b3\u30d4\u30fc\u3057\u3066\u3057\u307e\u304a\u3046\u3068\u3044\u3046\u308f\u3051\u3060\u3002JavaScript \u3067\u306finnerHTML\u3068\u3044\u30bf\u30b0\u5185\u306e\u6587\u5b57\u5217\u3092\u305d\u3063\u304f\u308a\u30b3\u30d4\u30fc\u3067\u304d\u308b\u95a2\u6570\u304c\u3042\u308b\u3002JQuery\u3067\u306f.html()\u30e1\u30bd\u30c3\u30c9\u306b\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u4f7f\u3048\u3070\u306a\u3093\u3068\u304b\u306a\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u5b9f\u9a13\u3057\u3066\u307f\u305f\u3089\u3042\u3063\u3055\u308a\u52d5\u3044\u3066\u3057\u307e\u3063\u305f\u3002<\/div>\n<div><\/div>\n<div>\u3061\u306a\u307f\u306b40\u679a\u99d2\u3092\u4e26\u3079\u305f\u5c06\u68cb\u76e4\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306f\u6587\u5b57\u5217\u306e\u5927\u304d\u3055\u30675\u30ad\u30ed\u30d0\u30a4\u30c8\u7a0b\u5ea6\u3060\u3063\u305f\u3002\u3000\u3053\u308c\u306a\u3089200\u624b\u52d5\u304b\u3057\u3066\u3082\u3067\u30821\u30e1\u30ac\u30d0\u30a4\u30c8\u3067\u53ce\u307e\u308b\u3002\u3000Z80\u3067\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3057\u3066\u3044\u308b\u6642\u4ee3\u306a\u3089\u30015\u30ad\u30ed\u30d0\u30a4\u30c8\u3068\u308f\u304b\u3063\u305f\u6642\u70b9\u3067\u3001\u9593\u629c\u3051\u6271\u3044\u3060\u3063\u305f\u304c\u3001\u6642\u4ee3\u306f\u5909\u308f\u3063\u305f\u306e\u3060\u3002\u3053\u308c\u3067\u3044\u3044\u306e\u3060\u3068\u81ea\u5206\u3092\u7d0d\u5f97\u3055\u305b\u308b\u3002\u3000\u30d6\u30e9\u30a6\u30b6\u4e0a\u306e\u3000JavaScript \u3067\u52d5\u3044\u3066\u3044\u308b\u308f\u3051\u3060\u304b\u3089\u3001\u30c7\u30fc\u30bf\u304c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u79fb\u52d5\u3059\u308b\u308f\u3051\u3067\u3082\u306a\u304f\u3001\u5358\u306b\u30d6\u30e9\u30a6\u30b6\u306e\u4f7f\u7528\u30e1\u30e2\u30ea\u30fc\u304c\u305d\u308c\u3060\u3051\u5897\u3048\u308b\u3060\u3051\u3001\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\u3002<\/div>\n<div>\u307e\u305a\u306f\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u914d\u5217\u5909\u6570\u3092\u7528\u610f\u3059\u308b\u3002<\/div>\n<\/div>\n<pre>\r\nvar board {\r\n.\r\n.\r\nhistory:[],\r\n}\r\n<\/pre>\n<div>\u3068\u3044\u3046\u5177\u5408\u306bGloval variable \u306b\u3000Array \u3068\u3057\u3066history[]\u3092\u5b9a\u7fa9\u3057\u3066\u304a\u304d\u3001\u6b21\u306b&lt;div id=&#8221;snapshot&#8221;&gt;&#8230;&lt;\/div&gt; \u5185\u306ehtml\u69cb\u6587\u3092board.history[]\u306b\u30bb\u30fc\u30d6\u3059\u308b\u95a2\u6570\u3000takesnapshot()\u3092\u5b9a\u7fa9\u3059\u308b\u3002<\/div>\n<pre>\r\nfunction takeSnapshot(i){\r\nboard.history[i]=$('.forSnapshot').html();\r\n}\r\n<\/pre>\n<div>\u6b21\u306b\u3001\u3053\u306eboard.history[]\u914d\u5217\u304b\u3089\u73fe\u72b6\u306e&lt;div id=&#8221;forsnapshot&#8221;&gt;&#8230;&lt;\/div&gt;\u5185\u306b\u5185\u5bb9\u3092\u30ed\u30fc\u30c9\u3059\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u3002\u3000\u540c\u6642\u306b\u201d\u4e00\u624b\u9032\u3081\u308b\u30dc\u30bf\u30f3\u201d\u304c\u7121\u52b9\u5316\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u305d\u308c\u3092\u6709\u52b9\u306b\u3059\u308b\u4f5c\u696d\u3082\u884c\u3046\u3002\n<\/div>\n<pre>\r\nfunction setBoardToHistory(i){\r\n$('#aButton').removeAttr(\"disabled\");\r\n$('.forSnapshot').empty().html(board.history[i]);\r\n}\r\n<\/pre>\n<p>><\/p>\n<div>\n\u6b21\u306b\u4e0a\u8a18\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u3066\u3001\u4e00\u624b\u3060\u3051\u623b\u308b\u95a2\u6570\u3000stepback()\u3092\u5b9a\u7fa9\u3059\u308b\u3002\u3053\u3053\u3067\u306f\u4e00\u5fdcboard.index \u304c\uff10\u4ee5\u4e0b\u306b\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u3044\u308b\u3002<\/div>\n<pre>\r\nfunction stepback(){\r\nif(board.index&gt;0)\r\nsetBoardToHistory(--board.index);\r\n}\r\n<\/pre>\n<div>\u305d\u3057\u3066\u3001animateBoard() function \u306b\u592a\u5b57\u90e8\u5206\u3092\u8ffd\u52a0\u3002<\/div>\n<pre>\r\nfunction animateBoard(){\r\nvar zAction=board.moves[board.index];\r\n<strong>takeSnapshot(board.index);<\/strong>\r\nparseAction(zAction);\r\nboard.index+=1;\r\nif (board.moves[board.index].charAt(0)=='x') $('#aButton').attr(\"disabled\",\"disabled\")\r\n;\r\n\r\n}\r\n<\/pre>\n<div>\u30dc\u30bf\u30f3\u6a5f\u80fd\u3092\u8ffd\u52a0<\/div>\n<pre>\r\nfunction setupButton() {\r\n$(\"#aButton\").click(function () {animateBoard()}).attr(\"value\",\"Forward for solution\");\r\n<strong>$(\"&lt;input type='button'&gt;\").click(function() {stepback()}).attr('value','Step back').appendTo('#buttonBar');<\/strong>\r\n}\r\n\r\n&nbsp;<\/pre>\n<div>\n\u4e0a\u306e\u30eb\u30fc\u30c1\u30f3\u3067\u3001<\/p>\n<pre>\r\n&lt;div id='buttonBar'&gt;\r\n&lt;input \u00a0type=\"button\" \u00a0id=\"aButton\" value=\"Javascript did not load\" \/&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>\u3068\u3044\u3046\u30a8\u30ec\u30e1\u30f3\u30c8\u306bStep back \u3068\u3044\u3046\u30dc\u30bf\u30f3\u304c\u52d5\u7684\u306b\u8ffd\u52a0\u3055\u308c\u308b\u3002\uff08aButton \u306e\u307b\u3046\u3082\u540c\u3058\u3088\u3046\u306b\u52d5\u7684\u306b\u8ffd\u52a0\u3057\u305f\u307b\u3046\u304c\u30b3\u30fc\u30c9\u304c\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u306a\u308a\u305d\u3046\u3060\uff09<\/p>\n<p>\u3053\u308c\u3067\u3082\u3068\u306b\u623b\u308b\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u3002\u3000\u30c7\u30e2\u306f<a href=\"http:\/\/www.shogishack.net\/opus1\/shogiboard-with-stepback-button.html\">\u3053\u3061\u3089<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06\u68cb\u76e4\u306e\u4e0a\u306e\u99d2\u304c\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3054\u3068\u306b\u4e00\u624b\u3065\u3064\u3046\u3054\u304f\u3088\u3046\u306b\u306a\u3063\u3066\u559c\u3093\u3060\u306e\u3082\u3064\u304b\u306e\u9593\u3001\u624b\u3092\u623b\u3059\u30dc\u30bf\u30f3\u304c\u306a\u3044\u306e\u304c\u3072\u3069\u304f\u554f\u984c\u306b\u898b\u3048\u3066\u304d\u305f\u3002\u3000\u3053\u308c\u306f\u6a5f\u80fd\u3092\u8ffd\u52a0\u305b\u306d\u3070\u3001\u3068\u8003\u3048\u305f\u306e\u3060\u304c\u3001\u6700\u521d\u306e\u8a2d\u8a08\u6642\u70b9\u3067\u5c65\u6b74\u3092\u3068\u308b\u3088\u3046\u306a\u69cb\u60f3\u306f\u4e00\u5207\u306a\u304b\u3063\u305f\u306e\u3067\u306f\u305f\u3068\u56f0\u3063\u305f <a href=\"https:\/\/www.a2life.info\/w\/?p=1096\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,3,16],"tags":[37,38,33],"class_list":["post-1096","post","type-post","status-publish","format-standard","hentry","category-web-design-study","category-web-making","category-16","tag-css","tag-javascript","tag-jquery"],"_links":{"self":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts\/1096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1096"}],"version-history":[{"count":11,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts\/1096\/revisions"}],"predecessor-version":[{"id":1630,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=\/wp\/v2\/posts\/1096\/revisions\/1630"}],"wp:attachment":[{"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.a2life.info\/w\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}