-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; }
<link rel="stylesheet" href="icedeb.css"/>
</head>
<script src="icedeb.js"></script>
- <h3>Query Debian pages</h3>
- <div class="icedeb-button" id="bts">Bug tracker (bugs.debian.org)</div>
- <div class="icedeb-button" id="pts">Package tracker (tracker.debian.org)</div>
- <div class="icedeb-button" id="deb">Package directory (packages.debian.org)</div>
- <div class="icedeb-button" id="ml">Mailing lists (lists.debian.org)</div>
- <div class="icedeb-button" id="ddpo">Developer overview</div>
- <div class="icedeb-button" id="buildd">Build daemons (buildd.debian.org)</div>
- <div class="icedeb-button" id="security">Security tracker (security-tracker.debian.org)</div>
- <textarea id="clipboard" contenteditable="true"></textarea>
+ <textarea id="clipboard" rows="1"></textarea>
+ <div id="button-list-container">
+ <div><span class="icedeb-button" id="bts">Bug tracker</span> (<a href="https://bugs.debian.org/">site</a>)</div>
+ <div><span class="icedeb-button" id="pts">Package tracker</span> (<a href="https://tracker.debian.org/">site</a>)</div>
+ <div><span class="icedeb-button" id="deb">Package directory</span> (<a href="https://packages.debian.org/">site</a>)</div>
+ <div><span class="icedeb-button" id="ml">Mailing lists</span> (<a href="https://lists.debian.org/">site</a>)</div>
+ <div><span class="icedeb-button" id="ddpo">Developer overview</span> (<a href="https://ddpo.debian.org/">site</a>)</div>
+ <div><span class="icedeb-button" id="buildd">Build logs</span> (<a href="https://buildd.debian.org/">site</a>)</div>
+ <div><span class="icedeb-button" id="security">Security tracker</span> (<a href="https://security-tracker.debian.org/">site</a>)</div>
+ </div>
<div id="error" class="hidden"></div>
- <p id="sorry" class="hidden">Sorry, no support for X11-style <q>selection clipboard</q>.</p>
</html>
);
}
-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;
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;
- }
- });