]> git.ktnx.net Git - icedeb.git/blobdiff - icedeb.js
Add support for the Debian Maintainer Dashboard
[icedeb.git] / icedeb.js
index c36044c7c6d3a4d75c29cb3cc37f218aaa25f21e..0d42d9c949d274f315d9fc9b3fc82adfc38875aa 100644 (file)
--- a/icedeb.js
+++ b/icedeb.js
@@ -116,15 +116,10 @@ function link_clicked(e) {
     return false;
   }
 
-  if ( !e.target.classList.contains('icedeb-button') )
-    return;
-
-  let autoclose = true;
-
   let clip_input = document.getElementById("clipboard");
   let clip = trim(clip_input.value);
 
-  console.log(clip);
+  if(clip_input.value == '') return;
 
   let url;
 
@@ -146,6 +141,9 @@ function link_clicked(e) {
       if (clip != '')
         url += '?login=' + clip;
       break;
+    case 'dmd':
+      url = 'https://udd.debian.org/dmd.cgi?email1=' + clip;
+      break;
     case 'buildd':
       url = 'https://buildd.debian.org/' + clip;
       break;
@@ -164,8 +162,26 @@ function link_clicked(e) {
       }
     });
 
-window.addEventListener('load', (e) => {
-  document.getElementById('button-list-container').addEventListener('click', link_clicked);
+  e.preventDefault();
+  return false;
+}
+
+function get_clipboard_contents() {
+  let clip_pot = document.getElementById('clip-pot');
+  let clip_input = document.getElementById("clipboard");
+  clip_pot.focus();
+  if (document.execCommand("Paste")) {
+    clip_input.value = clip_pot.textContent.trim();
+    clip_input.focus();
+    clip_input.setSelectionRange(0, clip_input.value.length)
+  }
+}
+
+window.addEventListener('DOMContentLoaded', (e) => {
+  document.querySelectorAll('.icedeb-button, #button-list-container a')
+    .forEach(function(el){
+      el.addEventListener('mouseup', link_clicked);
+    });
 
   document.addEventListener('change', (e) => {
     if ( !e.target.classList.contains('icedeb-option') )
@@ -174,11 +190,7 @@ window.addEventListener('load', (e) => {
     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');
-  }
+  window.requestAnimationFrame(()=>{
+    window.requestAnimationFrame(get_clipboard_contents);
+  });
 });