aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/commands/complete.js84
-rw-r--r--src/shared/commands/index.js3
-rw-r--r--src/shared/messages.js7
-rw-r--r--src/shared/operations.js7
-rw-r--r--src/shared/settings/default.js8
-rw-r--r--src/shared/settings/properties.js2
-rw-r--r--src/shared/versions/index.js39
-rw-r--r--src/shared/versions/release-notes.js8
-rw-r--r--src/shared/versions/storage.js11
9 files changed, 80 insertions, 89 deletions
diff --git a/src/shared/commands/complete.js b/src/shared/commands/complete.js
deleted file mode 100644
index 0bdbab8..0000000
--- a/src/shared/commands/complete.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import * as tabs from 'background/tabs';
-import * as histories from 'background/histories';
-
-const getOpenCompletions = (command, keywords, searchConfig) => {
- return histories.getCompletions(keywords).then((pages) => {
- let historyItems = pages.map((page) => {
- return {
- caption: page.title,
- content: command + ' ' + page.url,
- url: page.url
- };
- });
- let engineNames = Object.keys(searchConfig.engines);
- let engineItems = engineNames.filter(name => name.startsWith(keywords))
- .map(name => ({
- caption: name,
- content: command + ' ' + name
- }));
-
- let completions = [];
- if (engineItems.length > 0) {
- completions.push({
- name: 'Search Engines',
- items: engineItems
- });
- }
- if (historyItems.length > 0) {
- completions.push({
- name: 'History',
- items: historyItems
- });
- }
- return completions;
- });
-};
-
-const getCompletions = (line, settings) => {
- let typedWords = line.trim().split(/ +/);
- let typing = '';
- if (!line.endsWith(' ')) {
- typing = typedWords.pop();
- }
-
- if (typedWords.length === 0) {
- return Promise.resolve([]);
- }
- let name = typedWords.shift();
- let keywords = typedWords.concat(typing).join(' ');
-
- switch (name) {
- case 'o':
- case 'open':
- case 't':
- case 'tabopen':
- case 'w':
- case 'winopen':
- return getOpenCompletions(name, keywords, settings.search);
- case 'b':
- case 'buffer':
- return tabs.getCompletions(keywords).then((gotTabs) => {
- let items = gotTabs.map((tab) => {
- return {
- caption: tab.title,
- content: name + ' ' + tab.title,
- url: tab.url,
- icon: tab.favIconUrl
- };
- });
- return [
- {
- name: 'Buffers',
- items: items
- }
- ];
- });
- }
- return Promise.resolve([]);
-};
-
-const complete = (line, settings) => {
- return getCompletions(line, settings);
-};
-
-export default complete;
diff --git a/src/shared/commands/index.js b/src/shared/commands/index.js
deleted file mode 100644
index 78cb4df..0000000
--- a/src/shared/commands/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import complete from './complete';
-
-export { complete };
diff --git a/src/shared/messages.js b/src/shared/messages.js
index de00a3f..1f9c816 100644
--- a/src/shared/messages.js
+++ b/src/shared/messages.js
@@ -32,6 +32,7 @@ export default {
CONSOLE_SHOW_ERROR: 'console.show.error',
CONSOLE_SHOW_INFO: 'console.show.info',
CONSOLE_SHOW_FIND: 'console.show.find',
+ CONSOLE_HIDE: 'console.hide',
FOLLOW_START: 'follow.start',
FOLLOW_REQUEST_COUNT_TARGETS: 'follow.request.count.targets',
@@ -44,6 +45,12 @@ export default {
FIND_NEXT: 'find.next',
FIND_PREV: 'find.prev',
+ FIND_GET_KEYWORD: 'find.get.keyword',
+ FIND_SET_KEYWORD: 'find.set.keyword',
+
+ ADDON_ENABLED_QUERY: 'addon.enabled.query',
+ ADDON_ENABLED_RESPONSE: 'addon.enabled.response',
+ ADDON_TOGGLE_ENABLED: 'addon.toggle.enabled',
OPEN_URL: 'open.url',
diff --git a/src/shared/operations.js b/src/shared/operations.js
index 008e9eb..b022537 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -1,4 +1,7 @@
export default {
+ // Hide console, or cancel some user actions
+ CANCEL: 'cancel',
+
// Addons
ADDON_ENABLE: 'addon.enable',
ADDON_DISABLE: 'addon.disable',
@@ -10,6 +13,7 @@ export default {
COMMAND_SHOW_TABOPEN: 'command.show.tabopen',
COMMAND_SHOW_WINOPEN: 'command.show.winopen',
COMMAND_SHOW_BUFFER: 'command.show.buffer',
+ COMMAND_SHOW_ADDBOOKMARK: 'command.show.addbookmark',
// Scrolls
SCROLL_VERTICALLY: 'scroll.vertically',
@@ -34,6 +38,9 @@ export default {
// Focus
FOCUS_INPUT: 'focus.input',
+ // Page
+ PAGE_SOURCE: 'page.source',
+
// Tabs
TAB_CLOSE: 'tabs.close',
TAB_CLOSE_FORCE: 'tabs.close.force',
diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js
index 3c4dcac..a435099 100644
--- a/src/shared/settings/default.js
+++ b/src/shared/settings/default.js
@@ -11,6 +11,7 @@ export default {
"w": { "type": "command.show.winopen", "alter": false },
"W": { "type": "command.show.winopen", "alter": true },
"b": { "type": "command.show.buffer" },
+ "a": { "type": "command.show.addbookmark", "alter": true },
"k": { "type": "scroll.vertically", "count": -1 },
"j": { "type": "scroll.vertically", "count": 1 },
"h": { "type": "scroll.horizonally", "count": -1 },
@@ -27,6 +28,8 @@ export default {
"u": { "type": "tabs.reopen" },
"K": { "type": "tabs.prev", "count": 1 },
"J": { "type": "tabs.next", "count": 1 },
+ "gT": { "type": "tabs.prev", "count": 1 },
+ "gt": { "type": "tabs.next", "count": 1 },
"g0": { "type": "tabs.first" },
"g$": { "type": "tabs.last" },
"<C-6>": { "type": "tabs.prevsel" },
@@ -37,8 +40,8 @@ export default {
"zi": { "type": "zoom.in" },
"zo": { "type": "zoom.out" },
"zz": { "type": "zoom.neutral" },
- "f": { "type": "follow.start", "newTab": false },
- "F": { "type": "follow.start", "newTab": true },
+ "f": { "type": "follow.start", "newTab": false, "background": false },
+ "F": { "type": "follow.start", "newTab": true, "background": false },
"H": { "type": "navigate.history.prev" },
"L": { "type": "navigate.history.next" },
"[[": { "type": "navigate.link.prev" },
@@ -46,6 +49,7 @@ export default {
"gu": { "type": "navigate.parent" },
"gU": { "type": "navigate.root" },
"gi": { "type": "focus.input" },
+ "gf": { "type": "page.source" },
"y": { "type": "urls.yank" },
"p": { "type": "urls.paste", "newTab": false },
"P": { "type": "urls.paste", "newTab": true },
diff --git a/src/shared/settings/properties.js b/src/shared/settings/properties.js
index 37dc881..4bda8d6 100644
--- a/src/shared/settings/properties.js
+++ b/src/shared/settings/properties.js
@@ -5,12 +5,14 @@
const types = {
hintchars: 'string',
smoothscroll: 'boolean',
+ adjacenttab: 'boolean',
};
// describe default values of a property
const defaults = {
hintchars: 'abcdefghijklmnopqrstuvwxyz',
smoothscroll: false,
+ adjacenttab: true,
};
export { types, defaults };
diff --git a/src/shared/versions/index.js b/src/shared/versions/index.js
new file mode 100644
index 0000000..ee9f3b5
--- /dev/null
+++ b/src/shared/versions/index.js
@@ -0,0 +1,39 @@
+import * as storage from './storage';
+import * as releaseNotes from './release-notes';
+import manifest from '../../../manifest.json';
+
+const NOTIFICATION_ID = 'vimvixen-update';
+
+const notificationClickListener = (id) => {
+ if (id !== NOTIFICATION_ID) {
+ return;
+ }
+
+ browser.tabs.create({ url: releaseNotes.url(manifest.version) });
+ browser.notifications.onClicked.removeListener(notificationClickListener);
+};
+
+const checkUpdated = () => {
+ return storage.load().then((prev) => {
+ if (!prev) {
+ return true;
+ }
+ return manifest.version !== prev;
+ });
+};
+
+const notify = () => {
+ browser.notifications.onClicked.addListener(notificationClickListener);
+ return browser.notifications.create(NOTIFICATION_ID, {
+ 'type': 'basic',
+ 'iconUrl': browser.extension.getURL('resources/icon_48x48.png'),
+ 'title': 'Vim Vixen ' + manifest.version + ' has been installed',
+ 'message': 'Click here to see release notes',
+ });
+};
+
+const commit = () => {
+ storage.save(manifest.version);
+};
+
+export { checkUpdated, notify, commit };
diff --git a/src/shared/versions/release-notes.js b/src/shared/versions/release-notes.js
new file mode 100644
index 0000000..6ef2335
--- /dev/null
+++ b/src/shared/versions/release-notes.js
@@ -0,0 +1,8 @@
+const url = (version) => {
+ if (version) {
+ return 'https://github.com/ueokande/vim-vixen/releases/tag/' + version;
+ }
+ return 'https://github.com/ueokande/vim-vixen/releases/';
+};
+
+export { url };
diff --git a/src/shared/versions/storage.js b/src/shared/versions/storage.js
new file mode 100644
index 0000000..37603c8
--- /dev/null
+++ b/src/shared/versions/storage.js
@@ -0,0 +1,11 @@
+const load = () => {
+ return browser.storage.local.get('version').then(({ version }) => {
+ return version;
+ });
+};
+
+const save = (version) => {
+ return browser.storage.local.set({ version });
+};
+
+export { load, save };