Skip to content
This repository was archived by the owner on Jan 1, 2020. It is now read-only.

Commit e678542

Browse files
committed
New version of keySharky for Safari
- added a way to enable/disable keyboard shortcuts, to free room from unwanted ones. - changed version to: 1.5.3
1 parent 76a944d commit e678542

File tree

3 files changed

+73
-25
lines changed

3 files changed

+73
-25
lines changed

safari.safariextension/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleShortVersionString</key>
14-
<string>1.5.2</string>
14+
<string>1.5.3</string>
1515
<key>CFBundleVersion</key>
16-
<string>3</string>
16+
<string>5</string>
1717
<key>Chrome</key>
1818
<dict>
1919
<key>Context Menu Items</key>

safari.safariextension/keysharky.html

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
// Init keysharky object
66
init: function(){
77
keysharky.groovesharkTabID = null;
8-
keysharky.debug = true;
8+
keysharky.debug = false;
99

1010
keysharky.defaults = {
11-
"play" : '{"modifiers":["control","alt","shift"],"keycode":90}',
12-
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88}',
13-
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65}',
14-
"next" : '{"modifiers":["control","alt","shift"],"keycode":68}',
15-
"favorite" : '{"modifiers":["control","alt"],"keycode":83}',
16-
"voteup" : '{"modifiers":["control","alt"],"keycode":65}',
17-
"votedown" : '{"modifiers":["control","alt"],"keycode":90}',
18-
"voteclear" : '{"modifiers":["control","alt"],"keycode":81}',
19-
"mute" : '{"modifiers":["control","shift"],"keycode":77}',
20-
"volup" : '{"modifiers":["control","shift"],"keycode":190}',
21-
"voldown" : '{"modifiers":["control","shift"],"keycode":188}'
11+
"play" : '{"modifiers":["control","alt","shift"],"keycode":90,"enabled":true}',
12+
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88,"enabled":true}',
13+
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65,"enabled":true}',
14+
"next" : '{"modifiers":["control","alt","shift"],"keycode":68,"enabled":true}',
15+
"favorite" : '{"modifiers":["control","alt"],"keycode":83,"enabled":true}',
16+
"voteup" : '{"modifiers":["control","alt"],"keycode":65,"enabled":true}',
17+
"votedown" : '{"modifiers":["control","alt"],"keycode":90,"enabled":true}',
18+
"voteclear" : '{"modifiers":["control","alt"],"keycode":81,"enabled":true}',
19+
"mute" : '{"modifiers":["control","shift"],"keycode":77,"enabled":true}',
20+
"volup" : '{"modifiers":["control","shift"],"keycode":190,"enabled":true}',
21+
"voldown" : '{"modifiers":["control","shift"],"keycode":188,"enabled":true}'
2222
};
2323

2424
safari.application.addEventListener("command", function(event) {
@@ -54,6 +54,14 @@
5454
dismatch = false;
5555
t = JSON.parse(localStorage[toggle]);
5656

57+
if (typeof(t["enabled"]) == "undefined"){
58+
t["enabled"] = true;
59+
localStorage[toggle] = JSON.stringify(t);
60+
}
61+
62+
if (!t["enabled"])
63+
continue;
64+
5765
if (t["modifiers"].length != request["modifiers"].length)
5866
continue;
5967

safari.safariextension/options.html

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
width: 350px;
1919
}
2020

21+
#wrap input.check {
22+
float: left;
23+
display: block;
24+
height: 28px;
25+
margin: 0 5px 0 0;
26+
padding: 0;
27+
}
28+
2129
#wrap span.label {
2230
display: block;
2331
float: left;
@@ -76,17 +84,17 @@
7684
this.debug = false;
7785
this.unAllowedKeys = [16, 17, 18, 91];
7886
this.defaults = {
79-
"play" : '{"modifiers":["control","alt","shift"],"keycode":90}',
80-
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88}',
81-
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65}',
82-
"next" : '{"modifiers":["control","alt","shift"],"keycode":68}',
83-
"favorite" : '{"modifiers":["control","alt"],"keycode":83}',
84-
"voteup" : '{"modifiers":["control","alt"],"keycode":65}',
85-
"votedown" : '{"modifiers":["control","alt"],"keycode":90}',
86-
"voteclear" : '{"modifiers":["control","alt"],"keycode":81}',
87-
"mute" : '{"modifiers":["control","shift"],"keycode":77}',
88-
"volup" : '{"modifiers":["control","shift"],"keycode":190}',
89-
"voldown" : '{"modifiers":["control","shift"],"keycode":188}'
87+
"play" : '{"modifiers":["control","alt","shift"],"keycode":90,"enabled":true}',
88+
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88,"enabled":true}',
89+
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65,"enabled":true}',
90+
"next" : '{"modifiers":["control","alt","shift"],"keycode":68,"enabled":true}',
91+
"favorite" : '{"modifiers":["control","alt"],"keycode":83,"enabled":true}',
92+
"voteup" : '{"modifiers":["control","alt"],"keycode":65,"enabled":true}',
93+
"votedown" : '{"modifiers":["control","alt"],"keycode":90,"enabled":true}',
94+
"voteclear" : '{"modifiers":["control","alt"],"keycode":81,"enabled":true}',
95+
"mute" : '{"modifiers":["control","shift"],"keycode":77,"enabled":true}',
96+
"volup" : '{"modifiers":["control","shift"],"keycode":190,"enabled":true}',
97+
"voldown" : '{"modifiers":["control","shift"],"keycode":188,"enabled":true}'
9098
};
9199

92100
this.uiOptions();
@@ -156,6 +164,8 @@
156164
if (!this.checkJSON(combo))
157165
return;
158166

167+
combo["enabled"] = document.getElementById("keysharky-enabler-" + id).checked === true ? true : false;
168+
159169
this.uiChangeCombos(id, combo);
160170
this.setPref(id, combo);
161171
}
@@ -295,6 +305,10 @@
295305
if (document.getElementById(id_arr[i])){
296306
document.getElementById(id_arr[i]).value = str;
297307
}
308+
309+
if (document.getElementById("keysharky-enabler-" + id_arr[i]) && json_arr[i]["enabled"]){
310+
document.getElementById("keysharky-enabler-" + id_arr[i]).setAttribute("checked", json_arr[i]["enabled"]);
311+
}
298312
}
299313
},
300314

@@ -305,6 +319,12 @@
305319
var json = JSON.parse(localStorage[id]);
306320

307321
if (this.checkJSON(json)){
322+
323+
if (typeof(json["enabled"]) == "undefined"){
324+
json["enabled"] = true;
325+
localStorage[id] = JSON.stringify(json);
326+
}
327+
308328
return json;
309329
}
310330
}catch(e){
@@ -329,6 +349,15 @@
329349
}else{
330350
return false;
331351
}
352+
},
353+
354+
toggleEnabled: function(event, id){
355+
if (this.defaults[id]){
356+
var json = keysharkyOptions.getPref(id);
357+
358+
json["enabled"] = event.checked === true ? true : false;
359+
keysharkyOptions.setPref(id, json);
360+
}
332361
}
333362
};
334363

@@ -340,66 +369,77 @@
340369
<div id="wrap">
341370
<div class="clear heading">Playback control</div>
342371

372+
<input id="keysharky-enabler-play" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'play')" />
343373
<span class="label">Play/Pause</span>
344374
<input id="play" class="combos-input" type="text" value="-" readonly="true"
345375
onkeydown="keysharkyOptions.applyCombo(event, 'play')" />
346376

347377
<div class="clear"></div>
348378

379+
<input id="keysharky-enabler-stop" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'stop')" />
349380
<span class="label">Stop</span>
350381
<input id="stop" class="combos-input" type="text" value="-" readonly="true"
351382
onkeydown="keysharkyOptions.applyCombo(event, 'stop')" />
352383

353384
<div class="clear"></div>
354385

386+
<input id="keysharky-enabler-prev" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'prev')" />
355387
<span class="label">Previous song</span>
356388
<input id="prev" class="combos-input" type="text" value="-" readonly="true"
357389
onkeydown="keysharkyOptions.applyCombo(event, 'prev')" />
358390

359391
<div class="clear"></div>
360392

393+
<input id="keysharky-enabler-next" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'next')" />
361394
<span class="label">Next song</span>
362395
<input id="next" class="combos-input" type="text" value="-"readonly="true"
363396
onkeydown="keysharkyOptions.applyCombo(event, 'next')" />
364397

365398
<div class="clear heading">Current song</div>
366399

400+
<input id="keysharky-enabler-favorite" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'favorite')" />
367401
<span class="label">Favorite</span>
368402
<input id="favorite" class="combos-input" type="text" value="-"readonly="true"
369403
onkeydown="keysharkyOptions.applyCombo(event, 'favorite')" />
370404

371405
<div class="clear"></div>
372406

407+
<input id="keysharky-enabler-voteup" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'voteup')" />
373408
<span class="label">Vote up :)</span>
374409
<input id="voteup" class="combos-input" type="text" value="-"readonly="true"
375410
onkeydown="keysharkyOptions.applyCombo(event, 'voteup')" />
376411

377412
<div class="clear"></div>
378413

414+
<input id="keysharky-enabler-votedown" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'votedown')" />
379415
<span class="label">Vote down :(</span>
380416
<input id="votedown" class="combos-input" type="text" value="-"readonly="true"
381417
onkeydown="keysharkyOptions.applyCombo(event, 'votedown')" />
382418

383419
<div class="clear"></div>
384420

421+
<input id="keysharky-enabler-voteclear" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'voteclear')" />
385422
<span class="label">Reset vote</span>
386423
<input id="voteclear" class="combos-input" type="text" value="-"readonly="true"
387424
onkeydown="keysharkyOptions.applyCombo(event, 'voteclear')" />
388425

389426
<div class="clear heading">Sound control</div>
390427

428+
<input id="keysharky-enabler-mute" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'mute')" />
391429
<span class="label">Mute</span>
392430
<input id="mute" class="combos-input" type="text" value="-"readonly="true"
393431
onkeydown="keysharkyOptions.applyCombo(event, 'mute')" />
394432

395433
<div class="clear"></div>
396434

435+
<input id="keysharky-enabler-volup" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'volup')" />
397436
<span class="label">Volume Up</span>
398437
<input id="volup" class="combos-input" type="text" value="-"readonly="true"
399438
onkeydown="keysharkyOptions.applyCombo(event, 'volup')" />
400439

401440
<div class="clear"></div>
402441

442+
<input id="keysharky-enabler-voldown" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'voldown')" />
403443
<span class="label">Volume Down</span>
404444
<input id="voldown" class="combos-input" type="text" value="-"readonly="true"
405445
onkeydown="keysharkyOptions.applyCombo(event, 'voldown')" />

0 commit comments

Comments
 (0)