{"action":"created","comment":{"url":"https://api.github.com/repos/measurement-kit/network-meter/pulls/comments/46048635","id":46048635,"diff_hunk":"@@ -109,11 +138,42 @@ var toggleOverlay = function() {\n     window.scrollTo(0,0);\n };\n \n-var formValid = function() {\n-    var argForm = document.getElementById(\"arg-form\");\n-    for(var i = 0; i < argForm.length; i++) {\n-        if (!argForm[i].validity.valid)\n-            return false;\n+var formValid = function(state) {\n+    var selectedIndex = state.run.get(\"selected\");\n+    var elements = document.getElementsByClassName(\"argument-container\");\n+\n+    for(var i = 0; i < elements.length; i++) {\n+        var textElement = elements[i].getElementsByTagName(\"input\")[0];\n+        if (textElement.type == \"text\") {\n+            var textName = getRNameFromElement(textElement);\n+            var textIndex = getIndexFromArgName(textName, state);\n+            var regexType = state.run.get(\"plugins[\" + selectedIndex +\n+                            \"].args[\" + textIndex + \"].regex\");\n+            var regex = placeholderToRegex(regexType);\n+            if (regex.test(textElement.value) == false) \n+                return false;\n+        }\n+    }\n+\n+    return true\n+}\n+\n+var placeholderToRegex = function(input) {\n+    switch (input) {\n+        case \"email\":\n+            return /^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$/i\n+            break;\n+        case \"IP\":\n+            return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/\n+            break;\n+        case \"domain\":\n+            return /^(?!:\\/\\/)([a-zA-Z0-9]+\\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\\.[a-zA-Z]{2,6}?$/i\n+            break;\n+        case \"hostname\":\n+            return /(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$)|(^(?!:\\/\\/)([a-zA-Z0-9]+\\.)?[a-zA-Z0-9][a-zA-Z0-9-]+\\.[a-zA-Z]{2,6}?$)/i\n+            break;\n+        case \"URL\":\n+            return /[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)/i\n+            break;\n     }","path":"exec.js","position":163,"original_position":163,"commit_id":"f3e55cf3b9fb8143da616d6eacbcd7faafc8aab1","original_commit_id":"f3e55cf3b9fb8143da616d6eacbcd7faafc8aab1","user":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"body":"What should we return from here in case `input` is different from all the cases anticipated in the `switch`?","created_at":"2015-11-27T13:55:47Z","updated_at":"2015-11-27T13:55:47Z","html_url":"https://github.com/measurement-kit/network-meter/pull/37#discussion_r46048635","pull_request_url":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/measurement-kit/network-meter/pulls/comments/46048635"},"html":{"href":"https://github.com/measurement-kit/network-meter/pull/37#discussion_r46048635"},"pull_request":{"href":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37","id":51375507,"html_url":"https://github.com/measurement-kit/network-meter/pull/37","diff_url":"https://github.com/measurement-kit/network-meter/pull/37.diff","patch_url":"https://github.com/measurement-kit/network-meter/pull/37.patch","issue_url":"https://api.github.com/repos/measurement-kit/network-meter/issues/37","number":37,"state":"open","locked":false,"title":"Js regexes","user":{"login":"0xPoly","id":2194999,"avatar_url":"https://avatars.githubusercontent.com/u/2194999?v=3","gravatar_id":"","url":"https://api.github.com/users/0xPoly","html_url":"https://github.com/0xPoly","followers_url":"https://api.github.com/users/0xPoly/followers","following_url":"https://api.github.com/users/0xPoly/following{/other_user}","gists_url":"https://api.github.com/users/0xPoly/gists{/gist_id}","starred_url":"https://api.github.com/users/0xPoly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xPoly/subscriptions","organizations_url":"https://api.github.com/users/0xPoly/orgs","repos_url":"https://api.github.com/users/0xPoly/repos","events_url":"https://api.github.com/users/0xPoly/events{/privacy}","received_events_url":"https://api.github.com/users/0xPoly/received_events","type":"User","site_admin":false},"body":"JS rewrite of #35 ","created_at":"2015-11-20T16:15:36Z","updated_at":"2015-11-27T13:55:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20f1855f54dc8a31090aa5c245749428f89bb8a5","assignee":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37/commits","review_comments_url":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37/comments","review_comment_url":"https://api.github.com/repos/measurement-kit/network-meter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/measurement-kit/network-meter/issues/37/comments","statuses_url":"https://api.github.com/repos/measurement-kit/network-meter/statuses/f3e55cf3b9fb8143da616d6eacbcd7faafc8aab1","head":{"label":"measurement-kit:js-regexes","ref":"js-regexes","sha":"f3e55cf3b9fb8143da616d6eacbcd7faafc8aab1","user":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"repo":{"id":35334187,"name":"network-meter","full_name":"measurement-kit/network-meter","owner":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/measurement-kit/network-meter","description":"Graphical frontend for various network tests","fork":false,"url":"https://api.github.com/repos/measurement-kit/network-meter","forks_url":"https://api.github.com/repos/measurement-kit/network-meter/forks","keys_url":"https://api.github.com/repos/measurement-kit/network-meter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/measurement-kit/network-meter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/measurement-kit/network-meter/teams","hooks_url":"https://api.github.com/repos/measurement-kit/network-meter/hooks","issue_events_url":"https://api.github.com/repos/measurement-kit/network-meter/issues/events{/number}","events_url":"https://api.github.com/repos/measurement-kit/network-meter/events","assignees_url":"https://api.github.com/repos/measurement-kit/network-meter/assignees{/user}","branches_url":"https://api.github.com/repos/measurement-kit/network-meter/branches{/branch}","tags_url":"https://api.github.com/repos/measurement-kit/network-meter/tags","blobs_url":"https://api.github.com/repos/measurement-kit/network-meter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/measurement-kit/network-meter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/measurement-kit/network-meter/git/refs{/sha}","trees_url":"https://api.github.com/repos/measurement-kit/network-meter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/measurement-kit/network-meter/statuses/{sha}","languages_url":"https://api.github.com/repos/measurement-kit/network-meter/languages","stargazers_url":"https://api.github.com/repos/measurement-kit/network-meter/stargazers","contributors_url":"https://api.github.com/repos/measurement-kit/network-meter/contributors","subscribers_url":"https://api.github.com/repos/measurement-kit/network-meter/subscribers","subscription_url":"https://api.github.com/repos/measurement-kit/network-meter/subscription","commits_url":"https://api.github.com/repos/measurement-kit/network-meter/commits{/sha}","git_commits_url":"https://api.github.com/repos/measurement-kit/network-meter/git/commits{/sha}","comments_url":"https://api.github.com/repos/measurement-kit/network-meter/comments{/number}","issue_comment_url":"https://api.github.com/repos/measurement-kit/network-meter/issues/comments{/number}","contents_url":"https://api.github.com/repos/measurement-kit/network-meter/contents/{+path}","compare_url":"https://api.github.com/repos/measurement-kit/network-meter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/measurement-kit/network-meter/merges","archive_url":"https://api.github.com/repos/measurement-kit/network-meter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/measurement-kit/network-meter/downloads","issues_url":"https://api.github.com/repos/measurement-kit/network-meter/issues{/number}","pulls_url":"https://api.github.com/repos/measurement-kit/network-meter/pulls{/number}","milestones_url":"https://api.github.com/repos/measurement-kit/network-meter/milestones{/number}","notifications_url":"https://api.github.com/repos/measurement-kit/network-meter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/measurement-kit/network-meter/labels{/name}","releases_url":"https://api.github.com/repos/measurement-kit/network-meter/releases{/id}","created_at":"2015-05-09T15:42:30Z","updated_at":"2015-10-02T09:31:02Z","pushed_at":"2015-11-20T16:15:37Z","git_url":"git://github.com/measurement-kit/network-meter.git","ssh_url":"git@github.com:measurement-kit/network-meter.git","clone_url":"https://github.com/measurement-kit/network-meter.git","svn_url":"https://github.com/measurement-kit/network-meter","homepage":"","size":476,"stargazers_count":2,"watchers_count":2,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":15,"forks":2,"open_issues":15,"watchers":2,"default_branch":"master"}},"base":{"label":"measurement-kit:master","ref":"master","sha":"8def4d16e0e0167e0de6db7699c091fc45579c7e","user":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"repo":{"id":35334187,"name":"network-meter","full_name":"measurement-kit/network-meter","owner":{"login":"measurement-kit","id":11982841,"avatar_url":"https://avatars.githubusercontent.com/u/11982841?v=3","gravatar_id":"","url":"https://api.github.com/users/measurement-kit","html_url":"https://github.com/measurement-kit","followers_url":"https://api.github.com/users/measurement-kit/followers","following_url":"https://api.github.com/users/measurement-kit/following{/other_user}","gists_url":"https://api.github.com/users/measurement-kit/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-kit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-kit/subscriptions","organizations_url":"https://api.github.com/users/measurement-kit/orgs","repos_url":"https://api.github.com/users/measurement-kit/repos","events_url":"https://api.github.com/users/measurement-kit/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-kit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/measurement-kit/network-meter","description":"Graphical frontend for various network tests","fork":false,"url":"https://api.github.com/repos/measurement-kit/network-meter","forks_url":"https://api.github.com/repos/measurement-kit/network-meter/forks","keys_url":"https://api.github.com/repos/measurement-kit/network-meter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/measurement-kit/network-meter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/measurement-kit/network-meter/teams","hooks_url":"https://api.github.com/repos/measurement-kit/network-meter/hooks","issue_events_url":"https://api.github.com/repos/measurement-kit/network-meter/issues/events{/number}","events_url":"https://api.github.com/repos/measurement-kit/network-meter/events","assignees_url":"https://api.github.com/repos/measurement-kit/network-meter/assignees{/user}","branches_url":"https://api.github.com/repos/measurement-kit/network-meter/branches{/branch}","tags_url":"https://api.github.com/repos/measurement-kit/network-meter/tags","blobs_url":"https://api.github.com/repos/measurement-kit/network-meter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/measurement-kit/network-meter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/measurement-kit/network-meter/git/refs{/sha}","trees_url":"https://api.github.com/repos/measurement-kit/network-meter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/measurement-kit/network-meter/statuses/{sha}","languages_url":"https://api.github.com/repos/measurement-kit/network-meter/languages","stargazers_url":"https://api.github.com/repos/measurement-kit/network-meter/stargazers","contributors_url":"https://api.github.com/repos/measurement-kit/network-meter/contributors","subscribers_url":"https://api.github.com/repos/measurement-kit/network-meter/subscribers","subscription_url":"https://api.github.com/repos/measurement-kit/network-meter/subscription","commits_url":"https://api.github.com/repos/measurement-kit/network-meter/commits{/sha}","git_commits_url":"https://api.github.com/repos/measurement-kit/network-meter/git/commits{/sha}","comments_url":"https://api.github.com/repos/measurement-kit/network-meter/comments{/number}","issue_comment_url":"https://api.github.com/repos/measurement-kit/network-meter/issues/comments{/number}","contents_url":"https://api.github.com/repos/measurement-kit/network-meter/contents/{+path}","compare_url":"https://api.github.com/repos/measurement-kit/network-meter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/measurement-kit/network-meter/merges","archive_url":"https://api.github.com/repos/measurement-kit/network-meter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/measurement-kit/network-meter/downloads","issues_url":"https://api.github.com/repos/measurement-kit/network-meter/issues{/number}","pulls_url":"https://api.github.com/repos/measurement-kit/network-meter/pulls{/number}","milestones_url":"https://api.github.com/repos/measurement-kit/network-meter/milestones{/number}","notifications_url":"https://api.github.com/repos/measurement-kit/network-meter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/measurement-kit/network-meter/labels{/name}","releases_url":"https://api.github.com/repos/measurement-kit/network-meter/releases{/id}","created_at":"2015-05-09T15:42:30Z","updated_at":"2015-10-02T09:31:02Z","pushed_at":"2015-11-20T16:15:37Z","git_url":"git://github.com/measurement-kit/network-meter.git","ssh_url":"git@github.com:measurement-kit/network-meter.git","clone_url":"https://github.com/measurement-kit/network-meter.git","svn_url":"https://github.com/measurement-kit/network-meter","homepage":"","size":476,"stargazers_count":2,"watchers_count":2,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":15,"forks":2,"open_issues":15,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37"},"html":{"href":"https://github.com/measurement-kit/network-meter/pull/37"},"issue":{"href":"https://api.github.com/repos/measurement-kit/network-meter/issues/37"},"comments":{"href":"https://api.github.com/repos/measurement-kit/network-meter/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/measurement-kit/network-meter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/measurement-kit/network-meter/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/measurement-kit/network-meter/statuses/f3e55cf3b9fb8143da616d6eacbcd7faafc8aab1"}}}}