From 9ea0587db9a6d6e95099a8b28640c4b252dc36f9 Mon Sep 17 00:00:00 2001 From: inaleva Date: Sat, 7 Dec 2019 08:27:18 +0200 Subject: [PATCH] Added a new feature: Sending copied text as email through Gmail. --- index.html | 1 + selection.js | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e3a7957..f52b749 100644 --- a/index.html +++ b/index.html @@ -37,6 +37,7 @@

Menu Options Available

Share on Twitter Share on Facebook + Email on Gmail Google Search the text Copy the text Speak up the text diff --git a/selection.js b/selection.js index b919f3f..de716fe 100644 --- a/selection.js +++ b/selection.js @@ -59,6 +59,7 @@ const Selection = (function() { const menu = { twitter: true, facebook: true, + gmail: true, search: true, copy: true, speak: true, @@ -75,6 +76,16 @@ const Selection = (function() { icon: '' }; + + const gmailConfig = { + url: 'https://mail.google.com/mail/?view=cm&fs=1&body=', + icon: '' + + ''+ + ''+ + ''+ + ''+ + '' + } const searchConfig = { url: 'https://www.google.co.in/search?q=', icon: @@ -138,6 +149,16 @@ const Selection = (function() { return twbtn; } + function gmailButton() { + const url = window.location.href; + const gmlbtl = new Button(gmailConfig.icon, function() { + popupwindow(gmailConfig.url + encodeURIComponent(text) + ' ' + url , 'Email', 550, 295); + return false; + }); + + return gmlbtl; + } + function searchButton() { const searchbtn = new Button(searchConfig.icon, function() { popupwindow(searchConfig.url + encodeURIComponent(text), 'Search', 900, 540); @@ -177,7 +198,7 @@ const Selection = (function() { } function appendIcons() { - const myitems=[{feature:'twitter',call:twitterButton()},{feature:'facebook',call:facebookButton()},{feature:'search',call:searchButton()},{feature:'translate',call:translateButton()}, + const myitems=[{feature:'twitter',call:twitterButton()},{feature:'facebook',call:facebookButton()},{feature:'gmail',call:gmailButton()},{feature:'search',call:searchButton()},{feature:'translate',call:translateButton()}, {feature:'copy',call:copyButton()},{feature:'speak',call:speakButton()}] const div = document.createElement('div'); let count = 0; @@ -300,6 +321,7 @@ const Selection = (function() { function config(options) { menu.twitter = options.twitter === undefined ? menu.twitter : options.twitter; menu.facebook = options.facebook === undefined ? menu.facebook : options.facebook; + menu.gmail = options.gmail === undefined ? menu.gmail : options.gmail; menu.search = options.search === undefined ? menu.search : options.search; menu.translate = options.translate === undefined ? menu.translate : options.translate; menu.copy = options.copy === undefined ? menu.copy : options.copy;