-
Notifications
You must be signed in to change notification settings - Fork 0
/
bg.js
62 lines (50 loc) · 1.93 KB
/
bg.js
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
// change title
document.title = "jspx/src/eg/java/net" + document.title + ".java Eclipse";
// Add stylesheet
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", chrome.extension.getURL("style.css") );
document.getElementsByTagName("head")[0].appendChild(fileref);
// Add eclipse header
var eclipseheader = document.createElement("DIV");
eclipseheader.setAttribute("id", "eclipseheader");
var header = document.getElementById('header');
header.parentNode.insertBefore(eclipseheader, header);
// Left header image
var img = document.createElement("IMG");
img.src = chrome.extension.getURL("top-left.png");
eclipseheader.appendChild(img);
// Right header image
var img2 = document.createElement("IMG");
img2.src = chrome.extension.getURL("top-right.png");
img2.style.position = "absolute";
img2.style.right = "0px";
eclipseheader.appendChild(img2);
// Add eclipse project list
var eclipseprojects = document.createElement("DIV");
eclipseprojects.setAttribute("id", "eclipseprojects");
eclipseprojects.innerHTML = "<ul id='projectlist'>" + document.getElementById('sr-bar').innerHTML + "</ul>";
var content = document.getElementById('header');
content.parentNode.insertBefore(eclipseprojects , content);
if (window.addEventListener) {
var isCtrl = false;
window.addEventListener("keydown", function(e){
if (e.keyCode==88 && isCtrl) {
// Disable or enable stylesheet
if( fileref.disabled == true ) {
fileref.disabled=false;
document.getElementById('eclipseheader').style.display = 'block';
document.getElementById('eclipseprojects').style.display = 'block';
} else {
fileref.disabled=true;
document.getElementById('eclipseheader').style.display = 'none';
document.getElementById('eclipseprojects').style.display = 'none';
}
} else if(e.ctrlKey) {
isCtrl = true;
} else {
isCtrl = false;
}
});
}