{"action":"created","comment":{"url":"https://api.github.com/repos/glpi-project/glpi/pulls/comments/50130082","id":50130082,"diff_hunk":"@@ -5554,6 +5556,105 @@ static function showCheckboxMatrix(array $columns, array $rows, array $options=a\n       return $param['rand'];\n    }\n \n+   /**\n+    * In this function, we redefine 'window.alert' javascript function\n+    * by a jquery-ui dialog equivalent (but prettier).\n+    */\n+   static function redefineAlert() {\n+      echo self::scriptBlock(\"\n+      window.old_alert = window.alert;\n+      window.alert = function(message, fallback) {\n+         if (fallback) {\n+            old_alert(message);\n+            return;\n+         }\n+         message = message.replace('\\\\n', '<br>');\n+         $(document.createElement('div'))\n+            .attr({\n+               title: '\".__(\"Information\").\"',\n+               class: 'alert'\n+            })\n+            .html(message)\n+            .dialog({\n+               buttons: {\n+                  \".__('OK').\": function() {\n+                     $(this).dialog('close');\n+                  }\n+               },\n+               close: function(){\n+                  $(this).remove();\n+               },\n+               draggable: true,\n+               modal: true,\n+               resizable: false,\n+               width: 'auto'\n+            });\n+      };\");\n+   }\n+\n+\n+   /**\n+    * In this function, we redefine 'window.confirm' javascript function\n+    * by a jquery-ui dialog equivalent (but prettier).\n+    * This dialog is normally asynchronous and can't return a boolean like naive window.confirm.\n+    * We manage this behavior with a global variable 'confirmed' who watchs the acceptation of dialog.\n+    * In this case, we trigger a new click on element to return the value (and without display dialog)\n+    */\n+   static function redefineConfirm() {\n+      echo self::scriptBlock(\"\n+      var confirmed = false;\n+      var lastClickedElement;\n+\n+      // store last clicked element on dom\n+      $(document).click(function(event) {\n+          lastClickedElement = $(event.target);\n+      });\n+\n+      // asynchronous confirm dialog with jquery ui\n+      var newConfirm = function(message, clickedObject) {\n+         message = message.replace('\\\\n', '<br>');\n \n+         $('<div>').html(message).dialog({\n+            position: ['center', 100],\n+            dialogClass: 'fixed',\n+            buttons: {\n+               '\"._sx('button', 'Confirm').\"': function () {\n+                  $(this).dialog('close');\n+                  confirmed = true;\n+\n+                  //trigger click on the same element (to return true value)\n+                  lastClickedElement.click();\n+\n+                  // re-init confirmed (to permit usage of 'confirm' function again in the page)\n+                  // maybe timeout is not essential ...\n+                  setTimeout(function(){  confirmed = false; }, 100);\n+               },\n+               '\"._sx('button', 'Cancel').\"': function () {\n+                  $(this).dialog('close');\n+                  confirmed = false;\n+               }\n+            },\n+            close: function () {\n+                $(this).remove();\n+            },\n+            draggable: false,\n+            modal: true,\n+            resizable: false,\n+            width: 'auto'\n+         });\n+      };\n+\n+      // redefine native 'confirm' function\n+      window.confirm = function (message, elem) {\n+         // if watched var isn't true, we can display dialog\n+         if(!confirmed) {\n+            // call asynchronous dialog\n+            newConfirm(message);\n+         }\n+\n+         // return early\n+         return confirmed;\n+      };\");\n+   }\n }\n ?>","path":"inc/html.class.php","position":107,"original_position":114,"commit_id":"1004f0e86340f8d0aa5f7028b814cbd17c836fac","original_commit_id":"823126cb8d9e151434e6ae5c7c49129c7e69c502","user":{"login":"newls","id":4069983,"avatar_url":"https://avatars.githubusercontent.com/u/4069983?v=3","gravatar_id":"","url":"https://api.github.com/users/newls","html_url":"https://github.com/newls","followers_url":"https://api.github.com/users/newls/followers","following_url":"https://api.github.com/users/newls/following{/other_user}","gists_url":"https://api.github.com/users/newls/gists{/gist_id}","starred_url":"https://api.github.com/users/newls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/newls/subscriptions","organizations_url":"https://api.github.com/users/newls/orgs","repos_url":"https://api.github.com/users/newls/repos","events_url":"https://api.github.com/users/newls/events{/privacy}","received_events_url":"https://api.github.com/users/newls/received_events","type":"User","site_admin":false},"body":"haha @tomolimo i was scared of a tomahawklimo to be sent :p ","created_at":"2016-01-19T15:56:11Z","updated_at":"2016-01-19T15:56:11Z","html_url":"https://github.com/glpi-project/glpi/pull/380#discussion_r50130082","pull_request_url":"https://api.github.com/repos/glpi-project/glpi/pulls/380","_links":{"self":{"href":"https://api.github.com/repos/glpi-project/glpi/pulls/comments/50130082"},"html":{"href":"https://github.com/glpi-project/glpi/pull/380#discussion_r50130082"},"pull_request":{"href":"https://api.github.com/repos/glpi-project/glpi/pulls/380"}}},"pull_request":{"url":"https://api.github.com/repos/glpi-project/glpi/pulls/380","id":56462558,"html_url":"https://github.com/glpi-project/glpi/pull/380","diff_url":"https://github.com/glpi-project/glpi/pull/380.diff","patch_url":"https://github.com/glpi-project/glpi/pull/380.patch","issue_url":"https://api.github.com/repos/glpi-project/glpi/issues/380","number":380,"state":"open","locked":false,"title":"Override native js functions window.alert and window.confirm ","user":{"login":"orthagh","id":418844,"avatar_url":"https://avatars.githubusercontent.com/u/418844?v=3","gravatar_id":"","url":"https://api.github.com/users/orthagh","html_url":"https://github.com/orthagh","followers_url":"https://api.github.com/users/orthagh/followers","following_url":"https://api.github.com/users/orthagh/following{/other_user}","gists_url":"https://api.github.com/users/orthagh/gists{/gist_id}","starred_url":"https://api.github.com/users/orthagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orthagh/subscriptions","organizations_url":"https://api.github.com/users/orthagh/orgs","repos_url":"https://api.github.com/users/orthagh/repos","events_url":"https://api.github.com/users/orthagh/events{/privacy}","received_events_url":"https://api.github.com/users/orthagh/received_events","type":"User","site_admin":false},"body":"(with identical behaviors)\r\n\r\nFor a prettier dialog : \r\n\r\n![image](https://cloud.githubusercontent.com/assets/418844/12419185/b794732c-beb4-11e5-8e6c-f0d110086f60.png)\r\n","created_at":"2016-01-19T12:59:25Z","updated_at":"2016-01-19T15:56:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c762fbcf267458c699716e8b4acdbefd31a18377","assignee":{"login":"orthagh","id":418844,"avatar_url":"https://avatars.githubusercontent.com/u/418844?v=3","gravatar_id":"","url":"https://api.github.com/users/orthagh","html_url":"https://github.com/orthagh","followers_url":"https://api.github.com/users/orthagh/followers","following_url":"https://api.github.com/users/orthagh/following{/other_user}","gists_url":"https://api.github.com/users/orthagh/gists{/gist_id}","starred_url":"https://api.github.com/users/orthagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orthagh/subscriptions","organizations_url":"https://api.github.com/users/orthagh/orgs","repos_url":"https://api.github.com/users/orthagh/repos","events_url":"https://api.github.com/users/orthagh/events{/privacy}","received_events_url":"https://api.github.com/users/orthagh/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/glpi-project/glpi/milestones/2","html_url":"https://github.com/glpi-project/glpi/milestones/0.91","labels_url":"https://api.github.com/repos/glpi-project/glpi/milestones/2/labels","id":1254820,"number":2,"title":"0.91","description":"","creator":{"login":"orthagh","id":418844,"avatar_url":"https://avatars.githubusercontent.com/u/418844?v=3","gravatar_id":"","url":"https://api.github.com/users/orthagh","html_url":"https://github.com/orthagh","followers_url":"https://api.github.com/users/orthagh/followers","following_url":"https://api.github.com/users/orthagh/following{/other_user}","gists_url":"https://api.github.com/users/orthagh/gists{/gist_id}","starred_url":"https://api.github.com/users/orthagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orthagh/subscriptions","organizations_url":"https://api.github.com/users/orthagh/orgs","repos_url":"https://api.github.com/users/orthagh/repos","events_url":"https://api.github.com/users/orthagh/events{/privacy}","received_events_url":"https://api.github.com/users/orthagh/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":10,"state":"open","created_at":"2015-08-14T08:19:25Z","updated_at":"2016-01-19T12:59:25Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/glpi-project/glpi/pulls/380/commits","review_comments_url":"https://api.github.com/repos/glpi-project/glpi/pulls/380/comments","review_comment_url":"https://api.github.com/repos/glpi-project/glpi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/glpi-project/glpi/issues/380/comments","statuses_url":"https://api.github.com/repos/glpi-project/glpi/statuses/1004f0e86340f8d0aa5f7028b814cbd17c836fac","head":{"label":"orthagh:0.91/override_js_alert_and_confirm_functions","ref":"0.91/override_js_alert_and_confirm_functions","sha":"1004f0e86340f8d0aa5f7028b814cbd17c836fac","user":{"login":"orthagh","id":418844,"avatar_url":"https://avatars.githubusercontent.com/u/418844?v=3","gravatar_id":"","url":"https://api.github.com/users/orthagh","html_url":"https://github.com/orthagh","followers_url":"https://api.github.com/users/orthagh/followers","following_url":"https://api.github.com/users/orthagh/following{/other_user}","gists_url":"https://api.github.com/users/orthagh/gists{/gist_id}","starred_url":"https://api.github.com/users/orthagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orthagh/subscriptions","organizations_url":"https://api.github.com/users/orthagh/orgs","repos_url":"https://api.github.com/users/orthagh/repos","events_url":"https://api.github.com/users/orthagh/events{/privacy}","received_events_url":"https://api.github.com/users/orthagh/received_events","type":"User","site_admin":false},"repo":{"id":40602932,"name":"glpi","full_name":"orthagh/glpi","owner":{"login":"orthagh","id":418844,"avatar_url":"https://avatars.githubusercontent.com/u/418844?v=3","gravatar_id":"","url":"https://api.github.com/users/orthagh","html_url":"https://github.com/orthagh","followers_url":"https://api.github.com/users/orthagh/followers","following_url":"https://api.github.com/users/orthagh/following{/other_user}","gists_url":"https://api.github.com/users/orthagh/gists{/gist_id}","starred_url":"https://api.github.com/users/orthagh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orthagh/subscriptions","organizations_url":"https://api.github.com/users/orthagh/orgs","repos_url":"https://api.github.com/users/orthagh/repos","events_url":"https://api.github.com/users/orthagh/events{/privacy}","received_events_url":"https://api.github.com/users/orthagh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/orthagh/glpi","description":"Official repository for GLPi 0.x","fork":true,"url":"https://api.github.com/repos/orthagh/glpi","forks_url":"https://api.github.com/repos/orthagh/glpi/forks","keys_url":"https://api.github.com/repos/orthagh/glpi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orthagh/glpi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orthagh/glpi/teams","hooks_url":"https://api.github.com/repos/orthagh/glpi/hooks","issue_events_url":"https://api.github.com/repos/orthagh/glpi/issues/events{/number}","events_url":"https://api.github.com/repos/orthagh/glpi/events","assignees_url":"https://api.github.com/repos/orthagh/glpi/assignees{/user}","branches_url":"https://api.github.com/repos/orthagh/glpi/branches{/branch}","tags_url":"https://api.github.com/repos/orthagh/glpi/tags","blobs_url":"https://api.github.com/repos/orthagh/glpi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orthagh/glpi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orthagh/glpi/git/refs{/sha}","trees_url":"https://api.github.com/repos/orthagh/glpi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orthagh/glpi/statuses/{sha}","languages_url":"https://api.github.com/repos/orthagh/glpi/languages","stargazers_url":"https://api.github.com/repos/orthagh/glpi/stargazers","contributors_url":"https://api.github.com/repos/orthagh/glpi/contributors","subscribers_url":"https://api.github.com/repos/orthagh/glpi/subscribers","subscription_url":"https://api.github.com/repos/orthagh/glpi/subscription","commits_url":"https://api.github.com/repos/orthagh/glpi/commits{/sha}","git_commits_url":"https://api.github.com/repos/orthagh/glpi/git/commits{/sha}","comments_url":"https://api.github.com/repos/orthagh/glpi/comments{/number}","issue_comment_url":"https://api.github.com/repos/orthagh/glpi/issues/comments{/number}","contents_url":"https://api.github.com/repos/orthagh/glpi/contents/{+path}","compare_url":"https://api.github.com/repos/orthagh/glpi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orthagh/glpi/merges","archive_url":"https://api.github.com/repos/orthagh/glpi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orthagh/glpi/downloads","issues_url":"https://api.github.com/repos/orthagh/glpi/issues{/number}","pulls_url":"https://api.github.com/repos/orthagh/glpi/pulls{/number}","milestones_url":"https://api.github.com/repos/orthagh/glpi/milestones{/number}","notifications_url":"https://api.github.com/repos/orthagh/glpi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orthagh/glpi/labels{/name}","releases_url":"https://api.github.com/repos/orthagh/glpi/releases{/id}","created_at":"2015-08-12T13:43:15Z","updated_at":"2015-08-12T13:43:24Z","pushed_at":"2016-01-19T14:00:47Z","git_url":"git://github.com/orthagh/glpi.git","ssh_url":"git@github.com:orthagh/glpi.git","clone_url":"https://github.com/orthagh/glpi.git","svn_url":"https://github.com/orthagh/glpi","homepage":"","size":220435,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"glpi-project:master","ref":"master","sha":"4d326ae9aaf78d203005c1da24fc3b46144815c5","user":{"login":"glpi-project","id":13361707,"avatar_url":"https://avatars.githubusercontent.com/u/13361707?v=3","gravatar_id":"","url":"https://api.github.com/users/glpi-project","html_url":"https://github.com/glpi-project","followers_url":"https://api.github.com/users/glpi-project/followers","following_url":"https://api.github.com/users/glpi-project/following{/other_user}","gists_url":"https://api.github.com/users/glpi-project/gists{/gist_id}","starred_url":"https://api.github.com/users/glpi-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glpi-project/subscriptions","organizations_url":"https://api.github.com/users/glpi-project/orgs","repos_url":"https://api.github.com/users/glpi-project/repos","events_url":"https://api.github.com/users/glpi-project/events{/privacy}","received_events_url":"https://api.github.com/users/glpi-project/received_events","type":"Organization","site_admin":false},"repo":{"id":39182755,"name":"glpi","full_name":"glpi-project/glpi","owner":{"login":"glpi-project","id":13361707,"avatar_url":"https://avatars.githubusercontent.com/u/13361707?v=3","gravatar_id":"","url":"https://api.github.com/users/glpi-project","html_url":"https://github.com/glpi-project","followers_url":"https://api.github.com/users/glpi-project/followers","following_url":"https://api.github.com/users/glpi-project/following{/other_user}","gists_url":"https://api.github.com/users/glpi-project/gists{/gist_id}","starred_url":"https://api.github.com/users/glpi-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glpi-project/subscriptions","organizations_url":"https://api.github.com/users/glpi-project/orgs","repos_url":"https://api.github.com/users/glpi-project/repos","events_url":"https://api.github.com/users/glpi-project/events{/privacy}","received_events_url":"https://api.github.com/users/glpi-project/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/glpi-project/glpi","description":"Official repository for GLPi 0.x","fork":false,"url":"https://api.github.com/repos/glpi-project/glpi","forks_url":"https://api.github.com/repos/glpi-project/glpi/forks","keys_url":"https://api.github.com/repos/glpi-project/glpi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/glpi-project/glpi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/glpi-project/glpi/teams","hooks_url":"https://api.github.com/repos/glpi-project/glpi/hooks","issue_events_url":"https://api.github.com/repos/glpi-project/glpi/issues/events{/number}","events_url":"https://api.github.com/repos/glpi-project/glpi/events","assignees_url":"https://api.github.com/repos/glpi-project/glpi/assignees{/user}","branches_url":"https://api.github.com/repos/glpi-project/glpi/branches{/branch}","tags_url":"https://api.github.com/repos/glpi-project/glpi/tags","blobs_url":"https://api.github.com/repos/glpi-project/glpi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/glpi-project/glpi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/glpi-project/glpi/git/refs{/sha}","trees_url":"https://api.github.com/repos/glpi-project/glpi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/glpi-project/glpi/statuses/{sha}","languages_url":"https://api.github.com/repos/glpi-project/glpi/languages","stargazers_url":"https://api.github.com/repos/glpi-project/glpi/stargazers","contributors_url":"https://api.github.com/repos/glpi-project/glpi/contributors","subscribers_url":"https://api.github.com/repos/glpi-project/glpi/subscribers","subscription_url":"https://api.github.com/repos/glpi-project/glpi/subscription","commits_url":"https://api.github.com/repos/glpi-project/glpi/commits{/sha}","git_commits_url":"https://api.github.com/repos/glpi-project/glpi/git/commits{/sha}","comments_url":"https://api.github.com/repos/glpi-project/glpi/comments{/number}","issue_comment_url":"https://api.github.com/repos/glpi-project/glpi/issues/comments{/number}","contents_url":"https://api.github.com/repos/glpi-project/glpi/contents/{+path}","compare_url":"https://api.github.com/repos/glpi-project/glpi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/glpi-project/glpi/merges","archive_url":"https://api.github.com/repos/glpi-project/glpi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/glpi-project/glpi/downloads","issues_url":"https://api.github.com/repos/glpi-project/glpi/issues{/number}","pulls_url":"https://api.github.com/repos/glpi-project/glpi/pulls{/number}","milestones_url":"https://api.github.com/repos/glpi-project/glpi/milestones{/number}","notifications_url":"https://api.github.com/repos/glpi-project/glpi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/glpi-project/glpi/labels{/name}","releases_url":"https://api.github.com/repos/glpi-project/glpi/releases{/id}","created_at":"2015-07-16T07:20:21Z","updated_at":"2016-01-17T13:40:52Z","pushed_at":"2016-01-19T14:32:39Z","git_url":"git://github.com/glpi-project/glpi.git","ssh_url":"git@github.com:glpi-project/glpi.git","clone_url":"https://github.com/glpi-project/glpi.git","svn_url":"https://github.com/glpi-project/glpi","homepage":"","size":221133,"stargazers_count":70,"watchers_count":70,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":88,"forks":42,"open_issues":88,"watchers":70,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/glpi-project/glpi/pulls/380"},"html":{"href":"https://github.com/glpi-project/glpi/pull/380"},"issue":{"href":"https://api.github.com/repos/glpi-project/glpi/issues/380"},"comments":{"href":"https://api.github.com/repos/glpi-project/glpi/issues/380/comments"},"review_comments":{"href":"https://api.github.com/repos/glpi-project/glpi/pulls/380/comments"},"review_comment":{"href":"https://api.github.com/repos/glpi-project/glpi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/glpi-project/glpi/pulls/380/commits"},"statuses":{"href":"https://api.github.com/repos/glpi-project/glpi/statuses/1004f0e86340f8d0aa5f7028b814cbd17c836fac"}}}}