aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/actions/find.js25
-rw-r--r--src/content/actions/operation.js2
-rw-r--r--src/content/components/common/mark.js4
-rw-r--r--src/content/console-frames.js27
4 files changed, 20 insertions, 38 deletions
diff --git a/src/content/actions/find.js b/src/content/actions/find.js
index b3d7e30..e08d7e5 100644
--- a/src/content/actions/find.js
+++ b/src/content/actions/find.js
@@ -9,25 +9,6 @@ import messages from 'shared/messages';
import actions from 'content/actions';
import * as consoleFrames from '../console-frames';
-const postPatternNotFound = (pattern) => {
- return consoleFrames.postError(
- window.document,
- 'Pattern not found: ' + pattern);
-};
-
-const postPatternFound = (pattern) => {
- return consoleFrames.postInfo(
- window.document,
- 'Pattern found: ' + pattern,
- );
-};
-
-const postNoPrevious = () => {
- return consoleFrames.postError(
- window.document,
- 'No previous search keywords');
-};
-
const find = (string, backwards) => {
let caseSensitive = false;
let wrapScan = true;
@@ -60,13 +41,13 @@ const findNext = async(currentKeyword, reset, backwards) => {
});
}
if (!keyword) {
- return postNoPrevious();
+ return consoleFrames.postError('No previous search keywords');
}
let found = find(keyword, backwards);
if (found) {
- postPatternFound(keyword);
+ consoleFrames.postInfo('Pattern found: ' + keyword);
} else {
- postPatternNotFound(keyword);
+ consoleFrames.postError('Pattern not found: ' + keyword);
}
return {
diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js
index 1aeb8be..b96c6b9 100644
--- a/src/content/actions/operation.js
+++ b/src/content/actions/operation.js
@@ -85,7 +85,7 @@ const exec = (operation, repeat, settings, addonEnabled) => {
break;
case operations.URLS_YANK:
urls.yank(window);
- consoleFrames.postInfo(window.document, 'Current url yanked');
+ consoleFrames.postInfo('Current url yanked');
break;
case operations.URLS_PASTE:
urls.paste(
diff --git a/src/content/components/common/mark.js b/src/content/components/common/mark.js
index 1ed636b..0f838a9 100644
--- a/src/content/components/common/mark.js
+++ b/src/content/components/common/mark.js
@@ -33,7 +33,7 @@ export default class MarkComponent {
}
if (key.ctrlKey || key.metaKey || key.altKey) {
- consoleFrames.postError(window.document, 'Unknown mark');
+ consoleFrames.postError('Unknown mark');
} else if (globalKey(key.key) && markStage.setMode) {
this.doSetGlobal(key);
} else if (globalKey(key.key) && markStage.jumpMode) {
@@ -55,7 +55,7 @@ export default class MarkComponent {
doJump(marks, key, smoothscroll) {
if (!marks[key.key]) {
- consoleFrames.postError(window.document, 'Mark is not set');
+ consoleFrames.postError('Mark is not set');
return;
}
diff --git a/src/content/console-frames.js b/src/content/console-frames.js
index 0c0ec02..401765c 100644
--- a/src/content/console-frames.js
+++ b/src/content/console-frames.js
@@ -16,22 +16,23 @@ const blur = (doc) => {
iframe.blur();
};
-const postMessage = (doc, message) => {
- let iframe = doc.getElementById('vimvixen-console-frame');
- iframe.contentWindow.postMessage(JSON.stringify(message), '*');
-};
-
-const postError = (doc, message) => {
- return postMessage(doc, {
- type: messages.CONSOLE_SHOW_ERROR,
- text: message,
+const postError = (text) => {
+ browser.runtime.sendMessage({
+ type: messages.CONSOLE_FRAME_MESSAGE,
+ message: {
+ type: messages.CONSOLE_SHOW_ERROR,
+ text,
+ },
});
};
-const postInfo = (doc, message) => {
- return postMessage(doc, {
- type: messages.CONSOLE_SHOW_INFO,
- text: message,
+const postInfo = (text) => {
+ browser.runtime.sendMessage({
+ type: messages.CONSOLE_FRAME_MESSAGE,
+ message: {
+ type: messages.CONSOLE_SHOW_INFO,
+ text,
+ },
});
};