-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
85 lines (75 loc) · 3.87 KB
/
Copy pathpopup.js
File metadata and controls
85 lines (75 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('getter-button').addEventListener(
'click', buttonPress)
});
chrome.storage.local.get(["user", "assignment", "supervoxel", "comment", "prefixes"], function(results) {
document.getElementById("user").value = typeof results.user !== "undefined" ? results.user : "";
document.getElementById("assignment").value = typeof results.assignment !== "undefined" ? results.assignment : "";
document.getElementById("supervoxel").value = typeof results.supervoxel !== "undefined" ? results.supervoxel : "";
document.getElementById("comment").value = typeof results.comment !== "undefined" ? results.comment : "";
document.getElementById("prefixes").value = typeof results.prefixes !== "undefined" ? results.prefixes : "1000,10000";
});
window.onload = function() {
document.getElementById("user").addEventListener('change', function () {
let user = document.getElementById("user").value;
chrome.storage.local.set({"user": user}, function () {
console.log("Changing user: " + user);
});
});
document.getElementById("assignment").addEventListener('change', function () {
let assignment = document.getElementById("assignment").value;
chrome.storage.local.set({"assignment": assignment}, function () {
console.log("Changing assignment: " + assignment);
});
});
document.getElementById("supervoxel").addEventListener('change', function () {
let supervoxel = document.getElementById("supervoxel").value;
chrome.storage.local.set({"supervoxel": supervoxel}, function () {
console.log("Changing supervoxel: " + supervoxel);
});
});
document.getElementById("comment").addEventListener('change', function () {
let comment = document.getElementById("comment").value;
chrome.storage.local.set({"comment": comment}, function () {
console.log("Changing comment: " + comment);
});
});
document.getElementById("prefixes").addEventListener('change', function () {
let prefixes = document.getElementById("prefixes").value;
chrome.storage.local.set({"prefixes": prefixes}, function () {
console.log("Changing prefixes: " + prefixes);
});
});
};
function buttonPress () {
let prefixes = document.getElementById("prefixes").value? document.getElementById("prefixes").value: "";
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type: "origin-data", prefixes: prefixes}, function (response) {
let user = document.getElementById("user").value? document.getElementById("user").value: "";
let assignment = document.getElementById("assignment").value? document.getElementById("assignment").value: "";
let supervoxel = document.getElementById("supervoxel").value? document.getElementById("supervoxel").value: "";
let comment = document.getElementById("comment").value? document.getElementById("comment").value: "";
let x = response.x? response.x: "";
let y = response.y? response.y: "";
let z = response.z? response.z: "";
let text = user+"\t"+
response.segID+"\t"+
assignment+"\t"+
supervoxel+"\t"+
x+", "+y+", "+z+"\t"+
comment;
console.log("pressed button");
console.log(text);
copyToClipboard(text);
});
});
}
function copyToClipboard (text) {
var sheetString = document.createElement('input');
document.body.appendChild(sheetString);
sheetString.setAttribute('value', text);
sheetString.focus();
sheetString.select();
document.execCommand('Copy');
document.body.removeChild(sheetString);
}