Skip to content

Commit

Permalink
remove angle brackets from selection.
Browse files Browse the repository at this point in the history
fix system notifications.
  • Loading branch information
mdnsk committed Dec 29, 2017
1 parent 8d81ad1 commit bbd60e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/entry/content-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
PROXY_CONTENT_CLOSE_POPUP,
PROXY_CONTENT_RESIZE_POPUP,
PROXY_CONTENT_GET_DATA,
CONTENT_OPEN_POPUP
CONTENT_OPEN_POPUP,
BACKGROUND_SHOW_NOTIFICATION
} from '../messages';

const popup = new Popup();
Expand All @@ -30,7 +31,9 @@ chrome.runtime.onMessage.addListener(message => {
else if (message.id === CONTENT_OPEN_POPUP || message.id === PROXY_CONTENT_OPEN_POPUP) {

if (checkSelectionLength(message.text)) {
data = message;
data = Object.assign({}, message, {
text: removeHtmlTags(message.text)
});

if (message.id === PROXY_CONTENT_OPEN_POPUP && message.frameIndex > -1) {
searchFrame(window.frames[message.frameIndex], frame => {
Expand Down Expand Up @@ -90,7 +93,7 @@ function checkSelectionLength (text) {

if (text.length > maxLength) {
chrome.runtime.sendMessage({
id: 'show-notification',
id: BACKGROUND_SHOW_NOTIFICATION,
text: 'The selection is too long! It must be less than '+maxLength+' characters.'
});

Expand All @@ -99,3 +102,7 @@ function checkSelectionLength (text) {

return true;
}

function removeHtmlTags (text) {
return text.replace(/[<>]/g, '');
}
3 changes: 2 additions & 1 deletion src/vue/Translate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import api from '../leoApi';
import history from '../history';
import options from '../options';
import { BACKGROUND_SHOW_NOTIFICATION } from '../messages';
export default {
props: {
Expand Down Expand Up @@ -98,7 +99,7 @@
api.addWordToDictionary(this.text, translation, this.pageUrl, this.pageTitle, this.context).then(data => {
if (data.error_msg === '') {
chrome.runtime.sendMessage({
id: 'vue-show-notification',
id: BACKGROUND_SHOW_NOTIFICATION,
text: 'The "' + this.text + '" word has been added!'
});
Expand Down

0 comments on commit bbd60e3

Please sign in to comment.