{"action":"created","comment":{"url":"https://api.github.com/repos/hws-wao/core/pulls/comments/32896259","id":32896259,"diff_hunk":"@@ -0,0 +1,286 @@\n+/**\n+ * @fileoverview HTMLにJSONをバインド処理するjQueryプラグインです。\n+ * jQueryをrequireしたNode.js上でも動作することを念頭に作成しています。\n+ * @author m_kimura@headwaters.co.jp(Kimura,Manabu)\n+ */\n+\"use strict\";\n+(function($) {\n+  /**\n+   * WAOバインド。HTMLにJSONをバインド処理します。\n+   * @param\n+   * @return {jQuery}\n+   */\n+  $.fn.wao_bind = function(options) {\n+    /**\n+     * WAOバインドに必要なデータと、バインド時に利用するiterator情報を保持します。\n+     * @type {Object} オプション指定（バインドするデータ、iteratorの状態）\n+     */\n+    var settings = $.extend({\n+      'bindData': {\n+        '_DB': {},\n+        '_FILE': {},\n+        '_USR': {}\n+      },\n+      'iterators': {},\n+      'tagStack': []\n+    }, options);\n+\n+    /**\n+     * 指定の変数名を持つコア変数を探して返却します。\n+     * @param {string}\n+     */\n+    var searchCore = function(varName) {\n+      var props = Object.keys(settings.bindData);\n+      for (var idx in props) {\n+        if (props[idx] == varName) {\n+          return settings.bindData;\n+        } else if (settings.bindData[props[idx]][varName]) {\n+          return settings.bindData[props[idx]];\n+        }\n+      }\n+      throw \"Bind or Iterator data is not found. Variable name:=\" + varName;\n+    }\n+\n+    // -------------------------------------\n+    // ピリオドで分割した変数名のうち指定された順番の変数名を返す\n+    // -------------------------------------\n+    var getVarName = function(varPath, index) {\n+      var varName = varPath.split(\".\");\n+      if (varName.length < index) {\n+        throw \"Index Out Of Bounds. Variable Path's Count:=\" + varName.length +\n+          \", Index:=\" + index + \", Variable name:=\" + varPath;\n+      }\n+      return varName[index];\n+    }\n+\n+    // -------------------------------------\n+    // bind指定値を変数に変換する\n+    // -------------------------------------\n+    var getVar = function(varPath, org) {\n+      var firstVarName = getVarName(varPath, 0);\n+      var root = searchCore(firstVarName)[firstVarName];\n+      if (root) {\n+        var ret = root;\n+        var paths = varPath.split(\".\");\n+        var iteratorPath = firstVarName;\n+        // 先頭はfirstVarName→rootで処理済みなので開始番号は1から\n+        for (var i = 1; i < paths.length; i++) {\n+          var trg = paths[i].split('|');\n+          var wrapper;\n+          if (trg.length > 1) {\n+            trg = trg[0];\n+            wrapper = getVar(varPath.replace(iteratorPath + '.' + trg +\n+              '|', ''));\n+          }\n+          ret = getVarWithIterator(ret, iteratorPath)[trg];\n+          if (wrapper) {\n+            // TODO kimura これだとパイプを多重に指定できない・・・\n+            ret = (typeof wrapper == 'function') ? wrapper(ret, org) :\n+              wrapper[ret];\n+            break;\n+          }\n+          iteratorPath += '.' + trg;\n+        }\n+      }\n+      return ret;\n+    }\n+\n+    // -------------------------------------\n+    // iteratorがスタックされていればそれを返却する\n+    // -------------------------------------\n+    var getVarWithIterator = function(variable, iteratorPath) {\n+      var retVar = variable;\n+      var iterator = settings.iterators[iteratorPath];\n+      if (iterator) {\n+        retVar = iterator.this[iterator.idx];\n+      } else if ($.isArray(retVar)) {\n+        if (retVar.length == 1) {\n+          retVar = retVar[0];\n+        } else if (retVar.length == 0) {\n+          throw \"Bind data is not found.\";\n+        } else {\n+          throw \"Bind data is too many.\";\n+        }\n+      }\n+      return retVar;\n+    }\n+\n+    // -------------------------------------\n+    // data-wao-iteratorの実行\n+    // -------------------------------------\n+    var iterate = function($this, iteratorPath) {\n+      // 予備動作\n+      var $parent = $this.parent(); // 親要素を取得する\n+      var $template = $this.removeAttr('data-wao-iterator').clone(); // 自分自身をテンプレート化\n+      var $stack = $('<div />');\n+      var iterator = getIterator(iteratorPath); // 繰り返し用の変数を取得しておく\n+      $this.nextAll().each(function() {\n+        // TODO kimura 削除対象にwao属性が残っていたらエラーにする予定\n+        if ($(this).attr('data-wao') != 'keep' && !$(this).attr(","path":"lib/cli/template/_LOCAL/wao-bind.js","position":119,"original_position":119,"commit_id":"11b69b9347f6ce997882e8a8405fbd13ccb57943","original_commit_id":"11b69b9347f6ce997882e8a8405fbd13ccb57943","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Expected '!==' and instead saw '!='.","created_at":"2015-06-21T18:57:32Z","updated_at":"2015-06-21T18:57:32Z","html_url":"https://github.com/hws-wao/core/pull/53#discussion_r32896259","pull_request_url":"https://api.github.com/repos/hws-wao/core/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/hws-wao/core/pulls/comments/32896259"},"html":{"href":"https://github.com/hws-wao/core/pull/53#discussion_r32896259"},"pull_request":{"href":"https://api.github.com/repos/hws-wao/core/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/hws-wao/core/pulls/53","id":38188811,"html_url":"https://github.com/hws-wao/core/pull/53","diff_url":"https://github.com/hws-wao/core/pull/53.diff","patch_url":"https://github.com/hws-wao/core/pull/53.patch","issue_url":"https://api.github.com/repos/hws-wao/core/issues/53","number":53,"state":"open","locked":false,"title":"waoアプリ単体で動かしたい #22","user":{"login":"yujiroarai","id":2792310,"avatar_url":"https://avatars.githubusercontent.com/u/2792310?v=3","gravatar_id":"","url":"https://api.github.com/users/yujiroarai","html_url":"https://github.com/yujiroarai","followers_url":"https://api.github.com/users/yujiroarai/followers","following_url":"https://api.github.com/users/yujiroarai/following{/other_user}","gists_url":"https://api.github.com/users/yujiroarai/gists{/gist_id}","starred_url":"https://api.github.com/users/yujiroarai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yujiroarai/subscriptions","organizations_url":"https://api.github.com/users/yujiroarai/orgs","repos_url":"https://api.github.com/users/yujiroarai/repos","events_url":"https://api.github.com/users/yujiroarai/events{/privacy}","received_events_url":"https://api.github.com/users/yujiroarai/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-21T18:57:21Z","updated_at":"2015-06-21T18:57:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8723c9d242b137df9491f793e72e76e92f44a35a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hws-wao/core/pulls/53/commits","review_comments_url":"https://api.github.com/repos/hws-wao/core/pulls/53/comments","review_comment_url":"https://api.github.com/repos/hws-wao/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hws-wao/core/issues/53/comments","statuses_url":"https://api.github.com/repos/hws-wao/core/statuses/11b69b9347f6ce997882e8a8405fbd13ccb57943","head":{"label":"hws-wao:wao-cli","ref":"wao-cli","sha":"11b69b9347f6ce997882e8a8405fbd13ccb57943","user":{"login":"hws-wao","id":10883003,"avatar_url":"https://avatars.githubusercontent.com/u/10883003?v=3","gravatar_id":"","url":"https://api.github.com/users/hws-wao","html_url":"https://github.com/hws-wao","followers_url":"https://api.github.com/users/hws-wao/followers","following_url":"https://api.github.com/users/hws-wao/following{/other_user}","gists_url":"https://api.github.com/users/hws-wao/gists{/gist_id}","starred_url":"https://api.github.com/users/hws-wao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hws-wao/subscriptions","organizations_url":"https://api.github.com/users/hws-wao/orgs","repos_url":"https://api.github.com/users/hws-wao/repos","events_url":"https://api.github.com/users/hws-wao/events{/privacy}","received_events_url":"https://api.github.com/users/hws-wao/received_events","type":"Organization","site_admin":false},"repo":{"id":30413696,"name":"core","full_name":"hws-wao/core","owner":{"login":"hws-wao","id":10883003,"avatar_url":"https://avatars.githubusercontent.com/u/10883003?v=3","gravatar_id":"","url":"https://api.github.com/users/hws-wao","html_url":"https://github.com/hws-wao","followers_url":"https://api.github.com/users/hws-wao/followers","following_url":"https://api.github.com/users/hws-wao/following{/other_user}","gists_url":"https://api.github.com/users/hws-wao/gists{/gist_id}","starred_url":"https://api.github.com/users/hws-wao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hws-wao/subscriptions","organizations_url":"https://api.github.com/users/hws-wao/orgs","repos_url":"https://api.github.com/users/hws-wao/repos","events_url":"https://api.github.com/users/hws-wao/events{/privacy}","received_events_url":"https://api.github.com/users/hws-wao/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hws-wao/core","description":"","fork":false,"url":"https://api.github.com/repos/hws-wao/core","forks_url":"https://api.github.com/repos/hws-wao/core/forks","keys_url":"https://api.github.com/repos/hws-wao/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hws-wao/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hws-wao/core/teams","hooks_url":"https://api.github.com/repos/hws-wao/core/hooks","issue_events_url":"https://api.github.com/repos/hws-wao/core/issues/events{/number}","events_url":"https://api.github.com/repos/hws-wao/core/events","assignees_url":"https://api.github.com/repos/hws-wao/core/assignees{/user}","branches_url":"https://api.github.com/repos/hws-wao/core/branches{/branch}","tags_url":"https://api.github.com/repos/hws-wao/core/tags","blobs_url":"https://api.github.com/repos/hws-wao/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hws-wao/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hws-wao/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/hws-wao/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hws-wao/core/statuses/{sha}","languages_url":"https://api.github.com/repos/hws-wao/core/languages","stargazers_url":"https://api.github.com/repos/hws-wao/core/stargazers","contributors_url":"https://api.github.com/repos/hws-wao/core/contributors","subscribers_url":"https://api.github.com/repos/hws-wao/core/subscribers","subscription_url":"https://api.github.com/repos/hws-wao/core/subscription","commits_url":"https://api.github.com/repos/hws-wao/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/hws-wao/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/hws-wao/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/hws-wao/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/hws-wao/core/contents/{+path}","compare_url":"https://api.github.com/repos/hws-wao/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hws-wao/core/merges","archive_url":"https://api.github.com/repos/hws-wao/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hws-wao/core/downloads","issues_url":"https://api.github.com/repos/hws-wao/core/issues{/number}","pulls_url":"https://api.github.com/repos/hws-wao/core/pulls{/number}","milestones_url":"https://api.github.com/repos/hws-wao/core/milestones{/number}","notifications_url":"https://api.github.com/repos/hws-wao/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hws-wao/core/labels{/name}","releases_url":"https://api.github.com/repos/hws-wao/core/releases{/id}","created_at":"2015-02-06T13:36:30Z","updated_at":"2015-05-07T03:50:49Z","pushed_at":"2015-06-21T18:57:21Z","git_url":"git://github.com/hws-wao/core.git","ssh_url":"git@github.com:hws-wao/core.git","clone_url":"https://github.com/hws-wao/core.git","svn_url":"https://github.com/hws-wao/core","homepage":null,"size":2918,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":29,"forks":1,"open_issues":29,"watchers":0,"default_branch":"master"}},"base":{"label":"hws-wao:master","ref":"master","sha":"6437d2c307804938e8475a07366d9cbbe6b75770","user":{"login":"hws-wao","id":10883003,"avatar_url":"https://avatars.githubusercontent.com/u/10883003?v=3","gravatar_id":"","url":"https://api.github.com/users/hws-wao","html_url":"https://github.com/hws-wao","followers_url":"https://api.github.com/users/hws-wao/followers","following_url":"https://api.github.com/users/hws-wao/following{/other_user}","gists_url":"https://api.github.com/users/hws-wao/gists{/gist_id}","starred_url":"https://api.github.com/users/hws-wao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hws-wao/subscriptions","organizations_url":"https://api.github.com/users/hws-wao/orgs","repos_url":"https://api.github.com/users/hws-wao/repos","events_url":"https://api.github.com/users/hws-wao/events{/privacy}","received_events_url":"https://api.github.com/users/hws-wao/received_events","type":"Organization","site_admin":false},"repo":{"id":30413696,"name":"core","full_name":"hws-wao/core","owner":{"login":"hws-wao","id":10883003,"avatar_url":"https://avatars.githubusercontent.com/u/10883003?v=3","gravatar_id":"","url":"https://api.github.com/users/hws-wao","html_url":"https://github.com/hws-wao","followers_url":"https://api.github.com/users/hws-wao/followers","following_url":"https://api.github.com/users/hws-wao/following{/other_user}","gists_url":"https://api.github.com/users/hws-wao/gists{/gist_id}","starred_url":"https://api.github.com/users/hws-wao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hws-wao/subscriptions","organizations_url":"https://api.github.com/users/hws-wao/orgs","repos_url":"https://api.github.com/users/hws-wao/repos","events_url":"https://api.github.com/users/hws-wao/events{/privacy}","received_events_url":"https://api.github.com/users/hws-wao/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hws-wao/core","description":"","fork":false,"url":"https://api.github.com/repos/hws-wao/core","forks_url":"https://api.github.com/repos/hws-wao/core/forks","keys_url":"https://api.github.com/repos/hws-wao/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hws-wao/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hws-wao/core/teams","hooks_url":"https://api.github.com/repos/hws-wao/core/hooks","issue_events_url":"https://api.github.com/repos/hws-wao/core/issues/events{/number}","events_url":"https://api.github.com/repos/hws-wao/core/events","assignees_url":"https://api.github.com/repos/hws-wao/core/assignees{/user}","branches_url":"https://api.github.com/repos/hws-wao/core/branches{/branch}","tags_url":"https://api.github.com/repos/hws-wao/core/tags","blobs_url":"https://api.github.com/repos/hws-wao/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hws-wao/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hws-wao/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/hws-wao/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hws-wao/core/statuses/{sha}","languages_url":"https://api.github.com/repos/hws-wao/core/languages","stargazers_url":"https://api.github.com/repos/hws-wao/core/stargazers","contributors_url":"https://api.github.com/repos/hws-wao/core/contributors","subscribers_url":"https://api.github.com/repos/hws-wao/core/subscribers","subscription_url":"https://api.github.com/repos/hws-wao/core/subscription","commits_url":"https://api.github.com/repos/hws-wao/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/hws-wao/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/hws-wao/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/hws-wao/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/hws-wao/core/contents/{+path}","compare_url":"https://api.github.com/repos/hws-wao/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hws-wao/core/merges","archive_url":"https://api.github.com/repos/hws-wao/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hws-wao/core/downloads","issues_url":"https://api.github.com/repos/hws-wao/core/issues{/number}","pulls_url":"https://api.github.com/repos/hws-wao/core/pulls{/number}","milestones_url":"https://api.github.com/repos/hws-wao/core/milestones{/number}","notifications_url":"https://api.github.com/repos/hws-wao/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hws-wao/core/labels{/name}","releases_url":"https://api.github.com/repos/hws-wao/core/releases{/id}","created_at":"2015-02-06T13:36:30Z","updated_at":"2015-05-07T03:50:49Z","pushed_at":"2015-06-21T18:57:21Z","git_url":"git://github.com/hws-wao/core.git","ssh_url":"git@github.com:hws-wao/core.git","clone_url":"https://github.com/hws-wao/core.git","svn_url":"https://github.com/hws-wao/core","homepage":null,"size":2918,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":29,"forks":1,"open_issues":29,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hws-wao/core/pulls/53"},"html":{"href":"https://github.com/hws-wao/core/pull/53"},"issue":{"href":"https://api.github.com/repos/hws-wao/core/issues/53"},"comments":{"href":"https://api.github.com/repos/hws-wao/core/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/hws-wao/core/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/hws-wao/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hws-wao/core/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/hws-wao/core/statuses/11b69b9347f6ce997882e8a8405fbd13ccb57943"}}}}