From 16a162611edd866a4a5dc435cbed175ce0654eaf Mon Sep 17 00:00:00 2001 From: Randel Emens Date: Thu, 6 Jun 2019 19:18:52 -0700 Subject: [PATCH] Add image search --- selection.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/selection.js b/selection.js index b919f3f..6317c9c 100644 --- a/selection.js +++ b/selection.js @@ -63,6 +63,7 @@ const Selection = (function() { copy: true, speak: true, translate: true, + image: true, disable: false }; const twitterConfig = { @@ -102,6 +103,11 @@ const Selection = (function() { ''+ '' }; + const imageConfig = { + url: 'https://www.google.com/search?tbm=isch&q=', + icon: + '' + }; let selection = ''; let text = ''; @@ -170,6 +176,14 @@ const Selection = (function() { return tsbtn; } + function imageButton() { + const tsbtn = new Button(imageConfig.icon, function() { + popupwindow(imageConfig.url + text, 'Image', 900, 540); + return false; + }); + return tsbtn; + } + function IconStyle() { const style = document.createElement('style'); style.innerHTML = `.selection__icon{fill:${iconcolor};}`; @@ -178,7 +192,7 @@ const Selection = (function() { function appendIcons() { const myitems=[{feature:'twitter',call:twitterButton()},{feature:'facebook',call:facebookButton()},{feature:'search',call:searchButton()},{feature:'translate',call:translateButton()}, - {feature:'copy',call:copyButton()},{feature:'speak',call:speakButton()}] + {feature:'copy',call:copyButton()},{feature:'speak',call:speakButton()},{feature:'image',call:imageButton()}] const div = document.createElement('div'); let count = 0; myitems.forEach((item)=>{ @@ -304,6 +318,7 @@ const Selection = (function() { menu.translate = options.translate === undefined ? menu.translate : options.translate; menu.copy = options.copy === undefined ? menu.copy : options.copy; menu.speak = options.speak === undefined ? menu.speak : options.speak; + menu.image = options.image === undefined ? menu.image : options.image; menu.disable = options.disable === undefined ? menu.disable : options.disable; bgcolor = options.backgroundColor || '#333';