From de31ea193a608867ad3bb4e6a93f2f138fe361fc Mon Sep 17 00:00:00 2001 From: Johannes Gilger Date: Thu, 26 Mar 2009 12:42:56 +0100 Subject: [PATCH] HistoryView: Confirm paste to Gist if github.user is unset This patch relates to ticket #58. It adds a method which will ask for confirmation when pasting to Gist as an anonymous user. Since users which have github.user and github.token set can easily delete pasted snippets no confirmation is needed for them. Signed-off-by: Johannes Gilger --- html/views/history/history.js | 27 +++++++++++++++++++++++++++ html/views/history/index.html | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/html/views/history/history.js b/html/views/history/history.js index f8d6f64..9b1b30e 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -45,6 +45,33 @@ var Commit = function(obj) { }; + +var confirm_gist = function(confirmation_message) { + + // Check whether github user/token are set in .gitconfig + // If yes, we can paste without waiting for confirmation + token = Controller.getConfig_("github.token"); + login = Controller.getConfig_("github.user"); + if (token && login) { + gistie(); + return; + } + + // Set optional confirmation_message + confirmation_message = confirmation_message || "Yes. Paste this commit."; + // Show div#notification, since it?s set to display:none; by default + $("notification").style.display = ""; + // Reset the class (and therefore the color) + $("notification").setAttribute("class", ""); + // Hide img#spinner, since it?s visible by default + $("spinner").style.display = "none"; + // Insert the verification links into div#notification_message + $("notification_message").innerHTML = 'This will upload your commit to http://gist.github.com/' + + '
Are you sure you want to continue?

' + + 'No. Cancel. | ' + + '' + confirmation_message + ''; +} + var gistie = function() { notify("Uploading code to Gistie..", 0); diff --git a/html/views/history/index.html b/html/views/history/index.html index e5a5cf9..1fdba5d 100644 --- a/html/views/history/index.html +++ b/html/views/history/index.html @@ -14,7 +14,7 @@