GitHub PullRequestReviewCommentEvent at 2014-10-16 16:13:02
Repository: ipython
Actor: Carreau
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/ipython/ipython/pulls/comments/18966534","id":18966534,"diff_hunk":"@@ -0,0 +1,290 @@\n+// Copyright (c) IPython Development Team.\n+// Distributed under the terms of the Modified BSD License.\n+\n+define([\n+    'base/js/namespace',\n+    'jquery',\n+    'base/js/utils',\n+    'base/js/dialog',\n+], function(IPython, $, utils, dialog) {\n+    var ContentManager = function(options) {\n+        // Constructor\n+        //\n+        // A contentmanager handles passing file operations\n+        // to the back-end.  This includes checkpointing\n+        // with the normal file operations.\n+        //\n+        // Parameters:\n+        //  options: dictionary\n+        //      Dictionary of keyword arguments.\n+        //          events: $(Events) instance\n+        //          base_url: string\n+        this.version = 0.1;\n+        this.events = options.events;\n+        this.base_url = options.base_url;\n+    };\n+ \n+    /**\n+     * Notebook Functions\n+     */\n+\n+    /**\n+     * Load a notebook.\n+     *\n+     * Calls success_callback with notebook JSON object (as string), or\n+     * error_callback with error.\n+     *\n+     * @method load_notebook\n+     * @param {String} path\n+     * @param {String} name\n+     * @param {Function} success_callback\n+     * @param {Function} error_callback\n+     */\n+    ContentManager.prototype.load_notebook = function (path, name, success_callback, \n+        error_callback) {\n+        // We do the call with settings so we can set cache to false.\n+        var settings = {\n+            processData : false,\n+            cache : false,\n+            type : \"GET\",\n+            dataType : \"json\",\n+            success : success_callback,\n+            error : error_callback,\n+        };\n+        this.events.trigger('notebook_loading.Notebook');\n+        var url = utils.url_join_encode(\n+            this.base_url,\n+            'api/contents',\n+            path,\n+            name\n+        );\n+        $.ajax(url, settings);\n+    };\n+\n+\n+    /**\n+     * Creates a new notebook file at the specified path, and\n+     * opens that notebook in a new window.\n+     *\n+     * @method scroll_to_cell\n+     * @param {String} path The path to create the new notebook at\n+     */\n+    ContentManager.prototype.new_notebook = function(path) {\n+        var base_url = this.base_url;\n+        var settings = {\n+            processData : false,\n+            cache : false,\n+            type : \"POST\",\n+            dataType : \"json\",\n+            async : false,\n+            success : function (data, status, xhr){\n+                var notebook_name = data.name;\n+                window.open(\n+                    utils.url_join_encode(\n+                        base_url,\n+                        'contents',\n+                        path,\n+                        notebook_name\n+                    ),\n+                    '_blank'\n+                );\n+            },\n+            error : function(xhr, status, error) {\n+                utils.log_ajax_error(xhr, status, error);\n+                var msg;\n+                if (xhr.responseJSON && xhr.responseJSON.message) {\n+                    msg = xhr.responseJSON.message;\n+                } else {\n+                    msg = xhr.statusText;\n+                }\n+                dialog.modal({\n+                    title : 'Creating Notebook Failed',\n+                    body : \"The error was: \" + msg,\n+                    buttons : {'OK' : {'class' : 'btn-primary'}}\n+                });\n+            }\n+        };\n+        var url = utils.url_join_encode(\n+            base_url,\n+            'api/contents',\n+            path\n+        );\n+        $.ajax(url,settings);\n+    };\n+\n+    ContentManager.prototype.delete_notebook = function(name, path) {\n+        var settings = {\n+            processData : false,\n+            cache : false,\n+            type : \"DELETE\",\n+            dataType : \"json\",\n+            success : $.proxy(this.events.trigger, this.events,\n+                'notebook_deleted.ContentManager',\n+                {\n+                    name: name,\n+                    path: path\n+                }),\n+            error : utils.log_ajax_error\n+        };\n+        var url = utils.url_join_encode(\n+            this.base_url,\n+            'api/contents',\n+            path,\n+            name\n+        );\n+        $.ajax(url, settings);\n+    };\n+\n+    ContentManager.prototype.rename_notebook = function(path, name, new_name) {\n+        var that = this;\n+        var data = {name: new_name};\n+        var settings = {\n+            processData : false,\n+            cache : false,\n+            type : \"PATCH\",\n+            data : JSON.stringify(data),\n+            dataType: \"json\",\n+            headers : {'Content-Type': 'application/json'},\n+            success :  function (json, status, xhr) {\n+                that.events.trigger('notebook_rename_success.ContentManager',\n+                    json);\n+            },\n+            error : function (xhr, status, error) {\n+                that.events.trigger('notebook_rename_error.ContentManager',\n+                    [xhr, status, error]);\n+            }\n+        }\n+        var url = utils.url_join_encode(\n+            this.base_url,\n+            'api/contents',\n+            path,\n+            name\n+        );\n+        $.ajax(url, settings);\n+    };\n+\n+    ContentManager.prototype.save_notebook = function(path, name, content,\n+        extra_settings) {\n+        var that = content;\n+        // Create a JSON model to be sent to the server.\n+        var model = {\n+            name : name,\n+            path : path,\n+            type : \"notebook\",\n+            content : content\n+        };\n+        // time the ajax call for autosave tuning purposes.\n+        var start =  new Date().getTime();\n+        // We do the call with settings so we can set cache to false.\n+        var settings = {\n+            processData : false,\n+            cache : false,\n+            type : \"PUT\",\n+            data : JSON.stringify(model),\n+            headers : {'Content-Type': 'application/json'},\n+            success : $.proxy(this.events.trigger, this.events,\n+                'notebook_save_success.ContentManager',\n+                $.extend(model, { start : start })),\n+            error : function (xhr, status, error) {\n+                that.events.trigger('notebook_save_error.ContentManager',\n+                    [xhr, status, error, model]);\n+            }\n+        };\n+        if (extra_settings) {\n+            for (var key in extra_settings) {\n+                settings[key] = extra_settings[key];\n+            }\n+        }\n+        var url = utils.url_join_encode(\n+            this.base_url,\n+            'api/contents',\n+            path,\n+            name\n+        );\n+        $.ajax(url, settings);\n+    };\n+\n+    /**\n+     * Checkpointing Functions\n+     */\n+\n+    ContentManager.prototype.save_checkpoint = function() {\n+        // This is not necessary - integrated into save\n+    };\n+\n+    ContentManager.prototype.restore_checkpoint = function(notebook, id) {\n+        that = notebook;","path":"IPython/html/static/base/js/contentmanager.js","position":216,"original_position":216,"commit_id":"ba4c229a8b2bf3d52076a7aa2998cc4d272d2f2e","original_commit_id":"ba4c229a8b2bf3d52076a7aa2998cc4d272d2f2e","user":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=2","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"body":"`var that` or you attached that to global. \"use strict\" will raise on that. ","created_at":"2014-10-16T16:13:02Z","updated_at":"2014-10-16T16:13:02Z","html_url":"https://github.com/ipython/ipython/pull/6671#discussion_r18966534","pull_request_url":"https://api.github.com/repos/ipython/ipython/pulls/6671","_links":{"self":{"href":"https://api.github.com/repos/ipython/ipython/pulls/comments/18966534"},"html":{"href":"https://github.com/ipython/ipython/pull/6671#discussion_r18966534"},"pull_request":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6671"}}},"pull_request":{"url":"https://api.github.com/repos/ipython/ipython/pulls/6671","id":22533326,"html_url":"https://github.com/ipython/ipython/pull/6671","diff_url":"https://github.com/ipython/ipython/pull/6671.diff","patch_url":"https://github.com/ipython/ipython/pull/6671.patch","issue_url":"https://api.github.com/repos/ipython/ipython/issues/6671","number":6671,"state":"open","locked":false,"title":"Drive","user":{"login":"jhemmelg","id":949302,"avatar_url":"https://avatars.githubusercontent.com/u/949302?v=2","gravatar_id":"","url":"https://api.github.com/users/jhemmelg","html_url":"https://github.com/jhemmelg","followers_url":"https://api.github.com/users/jhemmelg/followers","following_url":"https://api.github.com/users/jhemmelg/following{/other_user}","gists_url":"https://api.github.com/users/jhemmelg/gists{/gist_id}","starred_url":"https://api.github.com/users/jhemmelg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhemmelg/subscriptions","organizations_url":"https://api.github.com/users/jhemmelg/orgs","repos_url":"https://api.github.com/users/jhemmelg/repos","events_url":"https://api.github.com/users/jhemmelg/events{/privacy}","received_events_url":"https://api.github.com/users/jhemmelg/received_events","type":"User","site_admin":false},"body":"Starting support for Google Drive.","created_at":"2014-10-10T00:24:09Z","updated_at":"2014-10-16T16:13:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a157d5a631cd18193bd9b0c2d9f32c53ebd9aaf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ipython/ipython/pulls/6671/commits","review_comments_url":"https://api.github.com/repos/ipython/ipython/pulls/6671/comments","review_comment_url":"https://api.github.com/repos/ipython/ipython/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/6671/comments","statuses_url":"https://api.github.com/repos/ipython/ipython/statuses/ba4c229a8b2bf3d52076a7aa2998cc4d272d2f2e","head":{"label":"jhemmelg:Drive","ref":"Drive","sha":"ba4c229a8b2bf3d52076a7aa2998cc4d272d2f2e","user":{"login":"jhemmelg","id":949302,"avatar_url":"https://avatars.githubusercontent.com/u/949302?v=2","gravatar_id":"","url":"https://api.github.com/users/jhemmelg","html_url":"https://github.com/jhemmelg","followers_url":"https://api.github.com/users/jhemmelg/followers","following_url":"https://api.github.com/users/jhemmelg/following{/other_user}","gists_url":"https://api.github.com/users/jhemmelg/gists{/gist_id}","starred_url":"https://api.github.com/users/jhemmelg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhemmelg/subscriptions","organizations_url":"https://api.github.com/users/jhemmelg/orgs","repos_url":"https://api.github.com/users/jhemmelg/repos","events_url":"https://api.github.com/users/jhemmelg/events{/privacy}","received_events_url":"https://api.github.com/users/jhemmelg/received_events","type":"User","site_admin":false},"repo":{"id":24609468,"name":"ipython","full_name":"jhemmelg/ipython","owner":{"login":"jhemmelg","id":949302,"avatar_url":"https://avatars.githubusercontent.com/u/949302?v=2","gravatar_id":"","url":"https://api.github.com/users/jhemmelg","html_url":"https://github.com/jhemmelg","followers_url":"https://api.github.com/users/jhemmelg/followers","following_url":"https://api.github.com/users/jhemmelg/following{/other_user}","gists_url":"https://api.github.com/users/jhemmelg/gists{/gist_id}","starred_url":"https://api.github.com/users/jhemmelg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhemmelg/subscriptions","organizations_url":"https://api.github.com/users/jhemmelg/orgs","repos_url":"https://api.github.com/users/jhemmelg/repos","events_url":"https://api.github.com/users/jhemmelg/events{/privacy}","received_events_url":"https://api.github.com/users/jhemmelg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jhemmelg/ipython","description":"Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.","fork":true,"url":"https://api.github.com/repos/jhemmelg/ipython","forks_url":"https://api.github.com/repos/jhemmelg/ipython/forks","keys_url":"https://api.github.com/repos/jhemmelg/ipython/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jhemmelg/ipython/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jhemmelg/ipython/teams","hooks_url":"https://api.github.com/repos/jhemmelg/ipython/hooks","issue_events_url":"https://api.github.com/repos/jhemmelg/ipython/issues/events{/number}","events_url":"https://api.github.com/repos/jhemmelg/ipython/events","assignees_url":"https://api.github.com/repos/jhemmelg/ipython/assignees{/user}","branches_url":"https://api.github.com/repos/jhemmelg/ipython/branches{/branch}","tags_url":"https://api.github.com/repos/jhemmelg/ipython/tags","blobs_url":"https://api.github.com/repos/jhemmelg/ipython/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jhemmelg/ipython/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jhemmelg/ipython/git/refs{/sha}","trees_url":"https://api.github.com/repos/jhemmelg/ipython/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jhemmelg/ipython/statuses/{sha}","languages_url":"https://api.github.com/repos/jhemmelg/ipython/languages","stargazers_url":"https://api.github.com/repos/jhemmelg/ipython/stargazers","contributors_url":"https://api.github.com/repos/jhemmelg/ipython/contributors","subscribers_url":"https://api.github.com/repos/jhemmelg/ipython/subscribers","subscription_url":"https://api.github.com/repos/jhemmelg/ipython/subscription","commits_url":"https://api.github.com/repos/jhemmelg/ipython/commits{/sha}","git_commits_url":"https://api.github.com/repos/jhemmelg/ipython/git/commits{/sha}","comments_url":"https://api.github.com/repos/jhemmelg/ipython/comments{/number}","issue_comment_url":"https://api.github.com/repos/jhemmelg/ipython/issues/comments/{number}","contents_url":"https://api.github.com/repos/jhemmelg/ipython/contents/{+path}","compare_url":"https://api.github.com/repos/jhemmelg/ipython/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jhemmelg/ipython/merges","archive_url":"https://api.github.com/repos/jhemmelg/ipython/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jhemmelg/ipython/downloads","issues_url":"https://api.github.com/repos/jhemmelg/ipython/issues{/number}","pulls_url":"https://api.github.com/repos/jhemmelg/ipython/pulls{/number}","milestones_url":"https://api.github.com/repos/jhemmelg/ipython/milestones{/number}","notifications_url":"https://api.github.com/repos/jhemmelg/ipython/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jhemmelg/ipython/labels{/name}","releases_url":"https://api.github.com/repos/jhemmelg/ipython/releases{/id}","created_at":"2014-09-29T19:25:03Z","updated_at":"2014-10-05T21:05:13Z","pushed_at":"2014-10-10T00:07:33Z","git_url":"git://github.com/jhemmelg/ipython.git","ssh_url":"git@github.com:jhemmelg/ipython.git","clone_url":"https://github.com/jhemmelg/ipython.git","svn_url":"https://github.com/jhemmelg/ipython","homepage":"http://ipython.org","size":60272,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"ipython:master","ref":"master","sha":"43b80ca3e4649b542d2fd5b884c90bcf5ce46e1a","user":{"login":"ipython","id":230453,"avatar_url":"https://avatars.githubusercontent.com/u/230453?v=2","gravatar_id":"","url":"https://api.github.com/users/ipython","html_url":"https://github.com/ipython","followers_url":"https://api.github.com/users/ipython/followers","following_url":"https://api.github.com/users/ipython/following{/other_user}","gists_url":"https://api.github.com/users/ipython/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython/subscriptions","organizations_url":"https://api.github.com/users/ipython/orgs","repos_url":"https://api.github.com/users/ipython/repos","events_url":"https://api.github.com/users/ipython/events{/privacy}","received_events_url":"https://api.github.com/users/ipython/received_events","type":"Organization","site_admin":false},"repo":{"id":658518,"name":"ipython","full_name":"ipython/ipython","owner":{"login":"ipython","id":230453,"avatar_url":"https://avatars.githubusercontent.com/u/230453?v=2","gravatar_id":"","url":"https://api.github.com/users/ipython","html_url":"https://github.com/ipython","followers_url":"https://api.github.com/users/ipython/followers","following_url":"https://api.github.com/users/ipython/following{/other_user}","gists_url":"https://api.github.com/users/ipython/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython/subscriptions","organizations_url":"https://api.github.com/users/ipython/orgs","repos_url":"https://api.github.com/users/ipython/repos","events_url":"https://api.github.com/users/ipython/events{/privacy}","received_events_url":"https://api.github.com/users/ipython/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipython/ipython","description":"Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.","fork":false,"url":"https://api.github.com/repos/ipython/ipython","forks_url":"https://api.github.com/repos/ipython/ipython/forks","keys_url":"https://api.github.com/repos/ipython/ipython/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipython/ipython/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipython/ipython/teams","hooks_url":"https://api.github.com/repos/ipython/ipython/hooks","issue_events_url":"https://api.github.com/repos/ipython/ipython/issues/events{/number}","events_url":"https://api.github.com/repos/ipython/ipython/events","assignees_url":"https://api.github.com/repos/ipython/ipython/assignees{/user}","branches_url":"https://api.github.com/repos/ipython/ipython/branches{/branch}","tags_url":"https://api.github.com/repos/ipython/ipython/tags","blobs_url":"https://api.github.com/repos/ipython/ipython/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipython/ipython/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipython/ipython/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipython/ipython/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipython/ipython/statuses/{sha}","languages_url":"https://api.github.com/repos/ipython/ipython/languages","stargazers_url":"https://api.github.com/repos/ipython/ipython/stargazers","contributors_url":"https://api.github.com/repos/ipython/ipython/contributors","subscribers_url":"https://api.github.com/repos/ipython/ipython/subscribers","subscription_url":"https://api.github.com/repos/ipython/ipython/subscription","commits_url":"https://api.github.com/repos/ipython/ipython/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipython/ipython/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipython/ipython/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipython/ipython/issues/comments/{number}","contents_url":"https://api.github.com/repos/ipython/ipython/contents/{+path}","compare_url":"https://api.github.com/repos/ipython/ipython/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipython/ipython/merges","archive_url":"https://api.github.com/repos/ipython/ipython/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipython/ipython/downloads","issues_url":"https://api.github.com/repos/ipython/ipython/issues{/number}","pulls_url":"https://api.github.com/repos/ipython/ipython/pulls{/number}","milestones_url":"https://api.github.com/repos/ipython/ipython/milestones{/number}","notifications_url":"https://api.github.com/repos/ipython/ipython/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipython/ipython/labels{/name}","releases_url":"https://api.github.com/repos/ipython/ipython/releases{/id}","created_at":"2010-05-10T04:46:06Z","updated_at":"2014-10-16T14:43:07Z","pushed_at":"2014-10-16T15:26:32Z","git_url":"git://github.com/ipython/ipython.git","ssh_url":"git@github.com:ipython/ipython.git","clone_url":"https://github.com/ipython/ipython.git","svn_url":"https://github.com/ipython/ipython","homepage":"http://ipython.org","size":125873,"stargazers_count":5000,"watchers_count":5000,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1448,"mirror_url":null,"open_issues_count":867,"forks":1448,"open_issues":867,"watchers":5000,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6671"},"html":{"href":"https://github.com/ipython/ipython/pull/6671"},"issue":{"href":"https://api.github.com/repos/ipython/ipython/issues/6671"},"comments":{"href":"https://api.github.com/repos/ipython/ipython/issues/6671/comments"},"review_comments":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6671/comments"},"review_comment":{"href":"https://api.github.com/repos/ipython/ipython/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ipython/ipython/pulls/6671/commits"},"statuses":{"href":"https://api.github.com/repos/ipython/ipython/statuses/ba4c229a8b2bf3d52076a7aa2998cc4d272d2f2e"}}}}