parent
dec30ed854
commit
d10791bbad
5 changed files with 44 additions and 11 deletions
|
@ -103,8 +103,7 @@ chrome.contextMenus.create({
|
|||
id: "app:factory-reset"
|
||||
});
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(function(data) {
|
||||
if (data.menuItemId != "app:factory-reset") return;
|
||||
var emergencyReset = function() {
|
||||
if (mainWindow) mainWindow.close();
|
||||
var cleared = {
|
||||
local: false,
|
||||
|
@ -123,4 +122,9 @@ chrome.contextMenus.onClicked.addListener(function(data) {
|
|||
};
|
||||
chrome.storage.local.clear(check.bind(null, "local"));
|
||||
chrome.storage.sync.clear(check.bind(null, "sync"));
|
||||
};
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(function(data) {
|
||||
if (data.menuItemId != "app:factory-reset") return;
|
||||
emergencyReset();
|
||||
});
|
|
@ -65,5 +65,6 @@
|
|||
{ "label": "Menus (Default)", "command": "session:open-settings-defaults", "argument": "menus" },
|
||||
{ "label": "Reset User Preferences", "command": "settings:delete-local", "argument": "user" },
|
||||
{ "label": "Reset Keyboard", "command": "settings:delete-local", "argument": "keys" },
|
||||
{ "label": "Reset Menus", "command": "settings:delete-local", "argument": "menus" }
|
||||
{ "label": "Reset Menus", "command": "settings:delete-local", "argument": "menus" },
|
||||
{ "label": "Emergency Reset", "command": "settings:emergency-reset" }
|
||||
]
|
|
@ -95,7 +95,9 @@
|
|||
"sub": [
|
||||
{ "label": "User Preferences", "command": "settings:delete-local", "argument": "user", "palette": "Reset User Preferences" },
|
||||
{ "label": "Keyboard", "command": "settings:delete-local", "argument": "keys", "palette": "Reset Keyboard" },
|
||||
{ "label": "Menus", "command": "settings:delete-local", "argument": "menus", "palette": "Reset Menus" }
|
||||
{ "label": "Menus", "command": "settings:delete-local", "argument": "menus", "palette": "Reset Menus" },
|
||||
"divider",
|
||||
{ "label": "Emergency Reset", "command": "settings:emergency-reset", "palette": "Emergency Reset" }
|
||||
]
|
||||
},
|
||||
"divider",
|
||||
|
|
16
js/main.js
16
js/main.js
|
@ -60,13 +60,15 @@ require([
|
|||
chrome.runtime.requestUpdateCheck(function(status, details) {
|
||||
if (status == "update_available") {
|
||||
chrome.runtime.onUpdateAvailable.addListener(function() {
|
||||
chrome.notifications.create(updateID, {
|
||||
type: "basic",
|
||||
iconUrl: "icon-128.png",
|
||||
title: "Caret: Update Available",
|
||||
message: "An update to Caret version " + details.version + " is available. Would you like to update and restart now?",
|
||||
buttons: [ { title: "Yes, update and restart" }, { title: "No thanks" }]
|
||||
}, function(id) { updateID = id });
|
||||
chrome.notifications.clear(updateID, function() {
|
||||
chrome.notifications.create(updateID, {
|
||||
type: "basic",
|
||||
iconUrl: "icon-128.png",
|
||||
title: "Caret: Update Available",
|
||||
message: "An update to Caret version " + details.version + " is available. Would you like to update and restart now?",
|
||||
buttons: [ { title: "Yes, update and restart" }, { title: "No thanks" }]
|
||||
}, function(id) { updateID = id });
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -163,6 +163,30 @@ define([
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
command.on("settings:emergency-reset", function() {
|
||||
//unlike the menu item, let's confirm it here in case someone fat-fingers the menu/palette
|
||||
chrome.notifications.clear("settings:emergency-reset-confirm", function() {
|
||||
chrome.notifications.create("settings:emergency-reset-confirm", {
|
||||
type: "basic",
|
||||
iconUrl: "icon-128.png",
|
||||
title: "Confirm Emergency Reset",
|
||||
message: "This will wipe out all your settings and return Caret to its initial condition. Are you sure you want to do this?",
|
||||
buttons: [
|
||||
{ title: "Yes, reset all data" },
|
||||
{ title: "Cancel emergency reset" }
|
||||
]
|
||||
}, function() {});
|
||||
});
|
||||
});
|
||||
|
||||
chrome.notifications.onButtonClicked.addListener(function(id, index) {
|
||||
if (id != "settings:emergency-reset-confirm") return;
|
||||
if (index !== 0) return;
|
||||
chrome.runtime.getBackgroundPage(function(page) {
|
||||
page.emergencyReset();
|
||||
});
|
||||
});
|
||||
|
||||
return Settings;
|
||||
|
||||
|
|
Loading…
Reference in a new issue