show message on find
This commit is contained in:
parent
72bf3cc2bd
commit
93bd0bc54f
4 changed files with 28 additions and 6 deletions
|
@ -14,6 +14,13 @@ const postPatternNotFound = (pattern) => {
|
||||||
'Pattern not found: ' + pattern);
|
'Pattern not found: ' + pattern);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const postPatternFound = (pattern) => {
|
||||||
|
return consoleFrames.postInfo(
|
||||||
|
window.document,
|
||||||
|
'Pattern found: ' + pattern,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const find = (string, backwards) => {
|
const find = (string, backwards) => {
|
||||||
let caseSensitive = false;
|
let caseSensitive = false;
|
||||||
let wrapScan = true;
|
let wrapScan = true;
|
||||||
|
@ -34,9 +41,12 @@ const findNext = (keyword, reset, backwards) => {
|
||||||
window.getSelection().removeAllRanges();
|
window.getSelection().removeAllRanges();
|
||||||
found = find(keyword, backwards);
|
found = find(keyword, backwards);
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (found) {
|
||||||
|
postPatternFound(keyword);
|
||||||
|
} else {
|
||||||
postPatternNotFound(keyword);
|
postPatternNotFound(keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: actions.FIND_SET_KEYWORD,
|
type: actions.FIND_SET_KEYWORD,
|
||||||
keyword,
|
keyword,
|
||||||
|
|
|
@ -62,10 +62,7 @@ const exec = (operation, repeat, settings) => {
|
||||||
return focuses.focusInput();
|
return focuses.focusInput();
|
||||||
case operations.URLS_YANK:
|
case operations.URLS_YANK:
|
||||||
urls.yank(window);
|
urls.yank(window);
|
||||||
return consoleFrames.postMessage(window.document, {
|
return consoleFrames.postInfo(window.document, 'Current url yanked');
|
||||||
type: messages.CONSOLE_SHOW_INFO,
|
|
||||||
text: 'Current url yanked',
|
|
||||||
});
|
|
||||||
case operations.URLS_PASTE:
|
case operations.URLS_PASTE:
|
||||||
return urls.paste(window, operation.newTab ? operation.newTab : false);
|
return urls.paste(window, operation.newTab ? operation.newTab : false);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -38,6 +38,10 @@ export default class FindComponent {
|
||||||
window.document,
|
window.document,
|
||||||
'Pattern not found: ' + state.keyword);
|
'Pattern not found: ' + state.keyword);
|
||||||
}
|
}
|
||||||
|
consoleFrames.postInfo(
|
||||||
|
window.document,
|
||||||
|
'Pattern found: ' + state.keyword,
|
||||||
|
);
|
||||||
return this.store.dispatch(findActions.next(state.keyword, false));
|
return this.store.dispatch(findActions.next(state.keyword, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +53,10 @@ export default class FindComponent {
|
||||||
window.document,
|
window.document,
|
||||||
'Pattern not found: ' + state.keyword);
|
'Pattern not found: ' + state.keyword);
|
||||||
}
|
}
|
||||||
|
consoleFrames.postInfo(
|
||||||
|
window.document,
|
||||||
|
'Pattern found: ' + state.keyword,
|
||||||
|
);
|
||||||
return this.store.dispatch(findActions.prev(state.keyword, false));
|
return this.store.dispatch(findActions.prev(state.keyword, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,11 @@ const postError = (doc, message) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export { initialize, blur, postMessage, postError };
|
const postInfo = (doc, message) => {
|
||||||
|
return postMessage(doc, {
|
||||||
|
type: messages.CONSOLE_SHOW_INFO,
|
||||||
|
text: message,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { initialize, blur, postError, postInfo };
|
||||||
|
|
Reference in a new issue