From 8b4cc4bb03e6fdd909226a01d0ef3332c1256d5f Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 18 Jun 2017 20:57:47 +0000 Subject: [PATCH] nicer popup, site links, remove text about absent selection-clipboard support --- icedeb.css | 28 ++++++++++---- icedeb.html | 20 +++++----- icedeb.js | 103 ++++++++++++++++++++++++++-------------------------- 3 files changed, 83 insertions(+), 68 deletions(-) diff --git a/icedeb.css b/icedeb.css index d1b2f8b..c12c541 100644 --- a/icedeb.css +++ b/icedeb.css @@ -1,10 +1,24 @@ -div.icedeb-button { - background: lightgray; +body { padding: 1ex; } +#clipboard { margin: 2px; } + +#button-list-container { + background: linear-gradient(to bottom, hsl(222,4%,89%) 0%, hsl(0,0%,100%) 100%); + display: flex; + flex-direction: column; + padding: 0.1ex; +} +#button-list-container > * { + margin: 0.5ex; + padding 0.1ex; +} + +.icedeb-button { border-radius: 5px; + cursor: pointer; + color: blue; } -.hidden { display: none; } -#clipboard { - position: absolute; - left: -50000px; +.icedeb-button:hover { + text-decoration: underline; } -#sorry { font-size: 80%; } +.hidden { display: none; } +a, a:visited { color: blue; } diff --git a/icedeb.html b/icedeb.html index c00a15b..f709ee9 100644 --- a/icedeb.html +++ b/icedeb.html @@ -5,15 +5,15 @@ -

Query Debian pages

-
Bug tracker (bugs.debian.org)
-
Package tracker (tracker.debian.org)
-
Package directory (packages.debian.org)
-
Mailing lists (lists.debian.org)
-
Developer overview
-
Build daemons (buildd.debian.org)
-
Security tracker (security-tracker.debian.org)
- + +
+
Bug tracker (site)
+
Package tracker (site)
+
Package directory (site)
+
Mailing lists (site)
+
Developer overview (site)
+
Build logs (site)
+
Security tracker (site)
+
- diff --git a/icedeb.js b/icedeb.js index dcd1197..8c2a7e6 100644 --- a/icedeb.js +++ b/icedeb.js @@ -45,23 +45,48 @@ function open_tab(url) { ); } -document.addEventListener('click', (e) => { - console.log(e.button); +function open_link(url, in_new_tab) { + if (in_new_tab) { + open_tab(url); + return; + } + + browser.tabs.query({active:true, currentWindow:true}) + .then( + function(tabs) { + browser.tabs.executeScript(tabs[0].id, {file: '/icedeb-content.js'}) + .then( + function(){ + browser.tabs.sendMessage( tabs[0].id, {url:url} ); + }, + function(err){ + console.log('Error executing script', err); + }); + + }, + function(err) { + console.log('Error querying the active tab of the current window', err); + open_tab(url); + } + ); +} + +function link_clicked(e) { + if (e.target.tagName == 'a') { + open_link(e.target.href, e.button == 1); + e.preventDefault(); + return false; + } + if ( !e.target.classList.contains('icedeb-button') ) return; let autoclose = true; let clip_input = document.getElementById("clipboard"); - clip_input.focus(); - if (!document.execCommand("paste")) { - let err = document.getElementById('error'); - err.textContent = 'Error executing Paste'; - err.classList.remove('hidden'); - return; - } + let clip = trim(clip_input.value); - let clip = trim(clip_input.textContent); + console.log(clip); let url; @@ -93,49 +118,25 @@ document.addEventListener('click', (e) => { break; } - if (e.button == 1) { - open_tab(url); - if (autoclose) window.close(); - return; - } + open_link(url, e.button == 1); + if (autoclose) window.close(); +} - browser.tabs.query({active:true, currentWindow:true}) - .then( - function(tabs) { - browser.tabs.executeScript(tabs[0].id, {file: '/icedeb-content.js'}) - .then( - function(){ - browser.tabs.sendMessage( tabs[0].id, {url:url} ); - if (autoclose) window.close(); - }, - function(err){ - console.log('Error executing script', err); - }); +window.addEventListener('load', (e) => { + document.getElementById('button-list-container').addEventListener('click', link_clicked); - }, - function(err) { - console.log('Error querying the active tab of the current window', err); - open_tab(url); - if (autoclose) window.close(); - } - ); -}); + document.addEventListener('change', (e) => { + if ( !e.target.classList.contains('icedeb-option') ) + return; -document.addEventListener('change', (e) => { - if ( !e.target.classList.contains('icedeb-option') ) - return; + save_settings(); + }); - save_settings(); + let clip_input = document.getElementById("clipboard"); + clip_input.focus(); + if (!document.execCommand("paste")) { + let err = document.getElementById('error'); + err.textContent = 'Error retrieving clipboard contents'; + err.classList.remove('hidden'); + } }); - -browser.runtime.getPlatformInfo() - .then(function(info) { - console.log(info.os); - - switch (info.os) { - case 'linux': - case 'openbsd': - document.getElementById('sorry').classList.remove('hidden'); - break; - } - }); -- 2.39.2