forked from kepi/chromeEyeDropper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.html
239 lines (201 loc) · 9.34 KB
/
options.html
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Eye Dropper - Options</title>
<link type="text/css" rel="stylesheet" href="style.css?0.2.6" />
<link type="text/css" rel="stylesheet" href="inc/options/options.css?0.2.6" />
<script src="inc/jquery-1.7.1.min.js"></script>
<script src="inc/jquery-ui/js/jquery-ui-1.8.4.custom.min.js"></script>
<script src="inc/keycode.js"></script>
<link href="inc/jquery-ui/css/smoothness/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
// Saves options to localStorage.
function save_options() {
if (!window.localStorage) {
alert("Error local storage is unavailable.");
window.close();
}
window.localStorage.autoClipboard =
document.getElementById("autoClipboard").checked ? true : false;
window.localStorage.autoClipboardNoGrid =
document.getElementById("autoClipboardNoGrid").checked ? true : false;
window.localStorage.disableColorpicker =
document.getElementById("disableColorpicker").checked ? true : false;
window.localStorage.enableColorToolbox =
document.getElementById("enableColorToolbox").checked ? true : false;
window.localStorage.enableColorTooltip =
document.getElementById("enableColorTooltip").checked ? true : false;
window.localStorage.enableRightClickDeactivate =
document.getElementById("enableRightClickDeactivate").checked ? true : false;
cursor = document.getElementById('dropperCursorcrosshair').checked ? 'crosshair' : 'default';
window.localStorage.dropperCursor = cursor;
window.localStorage.keyActivate = $("#keyActivate").html();
// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 750);
}
// Restores select box state to saved value from localStorage.
function restore_options() {
document.getElementById("autoClipboard").checked =
(window.localStorage.autoClipboard === "true") ? true : false;
document.getElementById("autoClipboardNoGrid").checked =
(window.localStorage.autoClipboardNoGrid === "true") ? true : false;
document.getElementById("disableColorpicker").checked =
(window.localStorage.disableColorpicker === "true") ? true : false;
document.getElementById("enableColorToolbox").checked =
(window.localStorage.enableColorToolbox === "false") ? false : true;
document.getElementById("enableColorTooltip").checked =
(window.localStorage.enableColorTooltip === "false") ? false : true;
document.getElementById("enableRightClickDeactivate").checked =
(window.localStorage.enableRightClickDeactivate === "false") ? false : true;
cursor = (window.localStorage.dropperCursor === 'crosshair') ? 'crosshair' : 'default';
document.getElementById('dropperCursor'+cursor).checked = true;
key = window.localStorage.keyActivate;
if ( key == undefined || key == "" )
key = "none";
$("#keyActivate").html( key );
}
function keysStartListening() {
console.log('starting listener');
document.addEventListener("keydown", keyDown, false);
document.addEventListener("keypress", function(e) { e.preventDefault(); return false; }, false);
}
function keysStopListening() {
console.log('stoping listener');
document.removeEventListener("keydown", keyDown, false);
}
function keyDown(e) {
console.log('key down');
var k = KeyCode;
$("#shortKeyActivate").html(k.hot_key(k.translate_event(e)));
e.preventDefault();
}
function changeShortcut(shortcutName, key) {
console.log('changing shortcut');
chrome.windows.getAll({'populate':true}, function(windows){
windows.forEach(function(win) {
win.tabs.forEach(function(tab) {
if ( tab != undefined && tab.url.indexOf('http') == 0 ) {
chrome.tabs.sendRequest(tab.id, {type: "helper-change-shortcut", shortcut: shortcutName, key: key});
}
});
});
});
}
// On document load
$(document).ready(function() {
// show tabs
$("#tabs").tabs();
restore_options();
$("#keycode-dialog").dialog({
autoOpen: false,
height: 220,
width: 270,
modal: true,
title: "Set shortcut",
buttons: {
"Disable shortcut": function() {
key = "none";
$("#keyActivate").html(key);
$(this).dialog("close");
},
"Save shortcut": function() {
key = $("#shortKeyActivate").html();
$("#keyActivate").html(key);
window.localStorage.keyActivate = key;
changeShortcut('activate', key);
$(this).dialog("close");
}
},
close: function() {
keysStopListening();
}
});
$("#addKeyActivate").click(function(){
keysStartListening();
$("#keycode-dialog").dialog('open');
});
});
</script>
<script type="text/javascript">
/* <![CDATA[ */
(function() {
var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
t.parentNode.insertBefore(s, t);
})();
/* ]]> */
</script>
</head>
<body id="options-body">
<h1>Eye Dropper – Options</h1>
<div id="options">
<div id="tabs">
<ul>
<li><a href="#tab-1"><span>Main</span></a></li>
<li><a href="#tab-2"><span>Appearance</span></a></li>
<li><a href="#tab-3"><span>Color picker</span></a></li>
<li><a href="#tab-4"><span>Keyboard Shortcuts</span></a></li>
</ul>
<div id="tab-1">
<div class="opt">
<label for="autoClipboard">Automaticaly copy picked color to clipboard when picking from webpage</label> <input type="checkbox" name="autoClipboard" id="autoClipboard" />
</div>
<div class="opt">
<label for="autoClipboardNoGrid">Do not copy # character, only RGB color</label> <input type="checkbox" name="autoClipboardNoGrid" id="autoClipboardNoGrid" />
</div>
<div class="opt">
<label for="enableRightClickDeactivate">Disable webpage picking with mouse right click</label> <input type="checkbox" name="enableRightClickDeactivate" id="enableRightClickDeactivate" />
</div>
</div>
<div id="tab-2">
<div class="opt">
<label for="dropperCursor">Dropper cursor:</label>
<input type="radio" name="dropperCursor" value="default" id="dropperCursordefault" /> <img src="img/cursor_default.png" alt="default" style="cursor: default" />
<input type="radio" name="dropperCursor" value="crosshair" id="dropperCursorcrosshair" /> <img src="img/cursor_crosshair.png" alt="crosshair" style="cursor: crosshair" />
<cite>move mouse over icon to see how it looks like</cite>
</div>
<div class="opt">
<label for="enableColorToolbox">Enable box with color information in right bottom corner</label> <input type="checkbox" name="enableColorToolbox" id="enableColorToolbox" />
</div>
<div class="opt">
<label for="enableColorTooltip">Enable color tooltip next to the mouse cursor</label> <input type="checkbox" name="enableColorTooltip" id="enableColorTooltip" />
</div>
</div>
<div id="tab-3">
<div class="opt">
<label for="disableColorpicker">Completely disable Color picker</label> <input type="checkbox" name="disableColorpicker" id="disableColorpicker" />
</div>
</div>
<div id="tab-4">
<div class="opt">
Pick color from webpage: <a href="#" id="addKeyActivate"><span id="keyActivate"></span></a>
</div>
</div>
<div>
<button class="save" onclick="save_options()">Save</button>
<span id="status"></span>
</div>
</div>
</div>
<div id="donation">
<div>
<h2>Do you like Eye Dropper?</h2>
<span id="flattrButtonDonate"><a class="FlattrButton" style="display:none;" href="http://eye-dropper.kepi.cz/"></a><noscript><a href="http://flattr.com/thing/173858/Eye-Dropper" target="_blank"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a></noscript></span>
<p>First of all - if you like Eye Dropper <a href="https://chrome.google.com/webstore/detail/hmdcmlfkchdmnmnmheododdhjedfccka">rate it on Chrome Webstore</a> please.</p>
<p>If you find Eye Dropper useful, you can make donation using Flattr or Paypal. Any amount will help me with its continuous development. Thanks!</p>
<!-- Begin PayPal Donations -->
<form id="paypal-donation-options" action="https://www.paypal.com/cgi-bin/webscr" method="post"><div class="paypal-donations"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="[email protected]" /><input type="hidden" name="return" value="http://eye-dropper.kepi.cz/thanks-for-your-donation/" /><input type="hidden" name="item_name" value="Eye Dropper" /><input type="hidden" name="currency_code" value="USD" /><input type="image" src="inc/btn_donate_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." /></div></form>
</div>
</div>
<div id="keycode-dialog">
<p>Shortcut: <span id="shortKeyActivate">none</span></p>
<p id="info">Just press any keyboard shortcut you want to assign to this function and press Save when you are done.</p>
</div>
</body>
</html>