From 617a2d0b7acc38fe20839b007b86d1144b78b074 Mon Sep 17 00:00:00 2001 From: robinhuy Date: Fri, 17 Mar 2017 23:21:02 +0700 Subject: [PATCH] fix notification on windows --- content.js | 78 +++++++++++++++++++++++++-------------------------- manifest.json | 4 ++- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/content.js b/content.js index deba24c..b7766f8 100644 --- a/content.js +++ b/content.js @@ -2,50 +2,50 @@ * Created by Robin Huy */ -function eieShowToast(icon) { - // Create toast container - var toastContainer = document.createElement('div'); - toastContainer.style.top = '10%'; - toastContainer.style.right = '7%'; - toastContainer.style.maxWidth = '80%'; - toastContainer.style.position = 'fixed'; - toastContainer.style.zIndex = '999999'; - toastContainer.style.fontSize = '15px'; - toastContainer.style.lineHeight = '1.5'; - toastContainer.style.color = 'rgba(0,0,0,0.87)'; +chrome.runtime.onMessage.addListener(function (request) { + function eieShowToast(icon) { + // Create toast container + var toastContainer = document.createElement('div'); + toastContainer.style.top = '10%'; + toastContainer.style.right = '7%'; + toastContainer.style.maxWidth = '80%'; + toastContainer.style.position = 'fixed'; + toastContainer.style.zIndex = '999999'; + toastContainer.style.fontSize = '15px'; + toastContainer.style.lineHeight = '1.5'; + toastContainer.style.color = 'rgba(0,0,0,0.87)'; - // Create toast - var toast = document.createElement('div'); - toast.style.transform = 'translateY(-35px)'; - toast.style.top = '35px'; - toast.style.marginTop = '10px'; - toast.style.padding = '10px 25px'; - toast.style.backgroundColor = '#323232'; - toast.style.color = '#ffffff'; - toast.style.display = 'flex'; - toast.style.alignItems = 'center'; - toast.style.justifyContent = 'space-between'; - toast.style.boxShadow = '0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2)'; + // Create toast + var toast = document.createElement('div'); + toast.style.transform = 'translateY(-35px)'; + toast.style.top = '35px'; + toast.style.marginTop = '10px'; + toast.style.padding = '10px 25px'; + toast.style.backgroundColor = '#323232'; + toast.style.color = '#ffffff'; + toast.style.display = 'flex'; + toast.style.alignItems = 'center'; + toast.style.justifyContent = 'space-between'; + toast.style.boxShadow = '0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2)'; - // Set text - var span = document.createElement('span'); - var text = document.createTextNode(icon + ' \u00A0 copied to clipboard'); - span.appendChild(text); - - // Append child - toast.appendChild(span); - toastContainer.appendChild(toast); - document.body.appendChild(toastContainer); + // Set text + var span = document.createElement('span'); + var text = document.createTextNode(icon + ' \u00A0 copied to clipboard'); + span.appendChild(text); - // Remove toast after 3 second - setTimeout(function () { - document.body.removeChild(toastContainer); - }, 3000); -} + // Append child + toast.appendChild(span); + toastContainer.appendChild(toast); + document.body.appendChild(toastContainer); + + // Remove toast after 3 second + setTimeout(function () { + document.body.removeChild(toastContainer); + }, 3000); + } -chrome.runtime.onMessage.addListener(function (request) { // Show toast when received message "copy emoticon" - if (request.action === 'copy emoticon') { + if (request.action === 'copy-emoticon') { eieShowToast(request.icon); } }); \ No newline at end of file diff --git a/manifest.json b/manifest.json index dc24785..7e44b01 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,10 @@ "manifest_version": 2, "name": "Emoticon input everywhere", + "short_name": "Emoticon input", "description": "Allow input emoticon in everywhere", - "version": "1.0", + "version": "1.1", + "author": "Robin Huy", "browser_action": { "default_icon": "icon.png",