-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
executable file
·121 lines (118 loc) · 3.23 KB
/
options.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var threadNum=new Array();
var onOptions = false;
function isIn(){
//console.log('in');
onOptions = true;
}
function isOut(){
//console.log('out');
onOptions = false;
//hideOptions();
}
function showOptions(btn){
isIn();
$(btn).css("background-color","#2093D0");
$(btn).css("color","#EEEEEE");
$(btn).css("border-color","#2093D0");
var o = $("#optionBox");
var pos = $("#options").offset();
pos.top+=26;
pos.left-=o.width()-$("#options").width();
o.css(pos);
o.fadeIn();
//console.log(o.offset());
setTimeout('threadNum.push(setInterval("hideOptions();",1000));',2000);
}
function hideOptions(){
//console.log("hide called");
if(!onOptions){
$(".colorBox").fadeOut();
btn=document.getElementById("options");
$(btn).css("background-color","#FFFFFF");
$(btn).css("color","#333333");
$(btn).css("border-color","#999999");
var o = $("#optionBox");
o.fadeOut();
for(var i in threadNum)
clearInterval(threadNum[i]);
}
}
function selectColor(input){
if($('#optionBox').is(':visible')){
var pos = $(input).offset();
pos.top;
pos.left+=$(input).width();
$("#colorpicker"+input.id).css(pos);
$("#colorpicker"+input.id).fadeIn();
}
}
function unselectColor(input){
$("#colorpicker"+input.id).fadeOut();
}
function confirm(){
shorten = $("#btn").val()=="on";
lineCol=$("#lineColor").val();
nodeCol=$("#nodeColor").val();
selLineCol= $("#selLineColor").val();
selNodeCol=$("#selNodeColor").val();
bgCol=$("#bgColor").val();
labelCol=$("#labelColor").val();
$("#infovis").css("background-color",bgCol);
$(".node").css("color",labelCol);
if(st){
st.controller.Node.color=nodeCol;
st.controller.Edge.color=lineCol;
st.refresh();
}
saveSettings();
onOptions=false;
hideOptions();
}
function saveSettings(){
localStorage.setItem("shorten",shorten);
localStorage.setItem("lineCol",lineCol);
localStorage.setItem("nodeCol",nodeCol);
localStorage.setItem("selLineCol",selLineCol);
localStorage.setItem("selNodeCol",selNodeCol);
localStorage.setItem("bgCol",bgCol);
localStorage.setItem("labelCol",labelCol);
}
function loadSettings(){
if(!localStorage.getItem("shorten")){
shorten = false;
lineCol='#23A4FF';
nodeCol='#333333' ;
selLineCol= "#111111";
selNodeCol="#E32D2D";
bgCol="#FFFFFF";
labelCol="#FFFFFF";
}
else{
shorten = stringToBoolean(localStorage.getItem("shorten"));
lineCol=localStorage.getItem("lineCol");
nodeCol=localStorage.getItem("nodeCol");
selLineCol= localStorage.getItem("selLineCol");
selNodeCol=localStorage.getItem("selNodeCol");
bgCol=localStorage.getItem("bgCol");
labelCol=localStorage.getItem("labelCol");
}
}
function stringToBoolean(string){
switch(string.toLowerCase()){
case "true": case "yes": case "1": return true;
case "false": case "no": case "0": case null: return false;
default: return Boolean(string);
}
}
function cancel(){
$("#btn").val(shorten?"on":"off");
$("#btn").attr("class",shorten?"on":"off");
$("#lineColor").val(lineCol);
$("#nodeColor").val(nodeCol);
$("#selLineColor").val(selLineCol);
$("#selNodeColor").val(selNodeCol);
$("#bgColor").val(bgCol);
$("#labelColor").val(labelCol);
onOptions=false;
hideOptions();
}