Skip to content

Commit

Permalink
New version of keySharky for Google Chrome
Browse files Browse the repository at this point in the history
- added a way to enable/disable keyboard shortcuts, to free room from unwanted ones.
- changed version to: 1.5.3
  • Loading branch information
intarstudents committed Jan 26, 2011
1 parent 416c3b0 commit 76a944d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 23 deletions.
31 changes: 20 additions & 11 deletions google-chrome/keysharky.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
keysharky.debug = false;

keysharky.defaults = {
"play" : '{"modifiers":["control","alt","shift"],"keycode":90}',
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88}',
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65}',
"next" : '{"modifiers":["control","alt","shift"],"keycode":68}',
"favorite" : '{"modifiers":["control","alt"],"keycode":83}',
"voteup" : '{"modifiers":["control","alt"],"keycode":65}',
"votedown" : '{"modifiers":["control","alt"],"keycode":90}',
"voteclear" : '{"modifiers":["control","alt"],"keycode":81}',
"mute" : '{"modifiers":["control","shift"],"keycode":77}',
"volup" : '{"modifiers":["control","shift"],"keycode":190}',
"voldown" : '{"modifiers":["control","shift"],"keycode":188}'
"play" : '{"modifiers":["control","alt","shift"],"keycode":90,"enabled":true}',
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88,"enabled":true}',
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65,"enabled":true}',
"next" : '{"modifiers":["control","alt","shift"],"keycode":68,"enabled":true}',
"favorite" : '{"modifiers":["control","alt"],"keycode":83,"enabled":true}',
"voteup" : '{"modifiers":["control","alt"],"keycode":65,"enabled":true}',
"votedown" : '{"modifiers":["control","alt"],"keycode":90,"enabled":true}',
"voteclear" : '{"modifiers":["control","alt"],"keycode":81,"enabled":true}',
"mute" : '{"modifiers":["control","shift"],"keycode":77,"enabled":true}',
"volup" : '{"modifiers":["control","shift"],"keycode":190,"enabled":true}',
"voldown" : '{"modifiers":["control","shift"],"keycode":188,"enabled":true}'
};

// Wait for keyup in another tab and then toggle gsliteswf object in Grooveshark flash player page.
Expand All @@ -44,6 +44,15 @@
for(var toggle in localStorage){
dismatch = false;
t = JSON.parse(localStorage[toggle]);
keysharky.log(typeof(t["enabled"]));

if (typeof(t["enabled"]) == "undefined"){
t["enabled"] = true;
localStorage[toggle] = JSON.stringify(t);
}

if (!t["enabled"])
continue;

if (t["modifiers"].length != request["modifiers"].length)
continue;
Expand Down
2 changes: 1 addition & 1 deletion google-chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keySharky",
"version": "1.5.2",
"version": "1.5.3",
"description": "Add missing keyboard functionality to Grooveshark!",
"background_page": "keysharky.html",
"options_page": "options.html",
Expand Down
63 changes: 52 additions & 11 deletions google-chrome/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
width: 350px;
}

#wrap input.check {
float: left;
display: block;
height: 28px;
margin: 0 5px 0 0;
padding: 0;
}

#wrap span.label {
display: block;
float: left;
Expand Down Expand Up @@ -76,17 +84,17 @@
this.debug = false;
this.unAllowedKeys = [16, 17, 18, 91];
this.defaults = {
"play" : '{"modifiers":["control","alt","shift"],"keycode":90}',
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88}',
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65}',
"next" : '{"modifiers":["control","alt","shift"],"keycode":68}',
"favorite" : '{"modifiers":["control","alt"],"keycode":83}',
"voteup" : '{"modifiers":["control","alt"],"keycode":65}',
"votedown" : '{"modifiers":["control","alt"],"keycode":90}',
"voteclear" : '{"modifiers":["control","alt"],"keycode":81}',
"mute" : '{"modifiers":["control","shift"],"keycode":77}',
"volup" : '{"modifiers":["control","shift"],"keycode":190}',
"voldown" : '{"modifiers":["control","shift"],"keycode":188}'
"play" : '{"modifiers":["control","alt","shift"],"keycode":90,"enabled":true}',
"stop" : '{"modifiers":["control","alt","shift"],"keycode":88,"enabled":true}',
"prev" : '{"modifiers":["control","alt","shift"],"keycode":65,"enabled":true}',
"next" : '{"modifiers":["control","alt","shift"],"keycode":68,"enabled":true}',
"favorite" : '{"modifiers":["control","alt"],"keycode":83,"enabled":true}',
"voteup" : '{"modifiers":["control","alt"],"keycode":65,"enabled":true}',
"votedown" : '{"modifiers":["control","alt"],"keycode":90,"enabled":true}',
"voteclear" : '{"modifiers":["control","alt"],"keycode":81,"enabled":true}',
"mute" : '{"modifiers":["control","shift"],"keycode":77,"enabled":true}',
"volup" : '{"modifiers":["control","shift"],"keycode":190,"enabled":true}',
"voldown" : '{"modifiers":["control","shift"],"keycode":188,"enabled":true}'
};

this.uiOptions();
Expand Down Expand Up @@ -155,6 +163,8 @@
// If bad combo, let user try new cambo
if (!this.checkJSON(combo))
return;

combo["enabled"] = document.getElementById("keysharky-enabler-" + id).checked === true ? true : false;

this.uiChangeCombos(id, combo);
this.setPref(id, combo);
Expand Down Expand Up @@ -295,6 +305,11 @@
if (document.getElementById(id_arr[i])){
document.getElementById(id_arr[i]).value = str;
}

if (document.getElementById("keysharky-enabler-" + id_arr[i]) && json_arr[i]["enabled"]){
document.getElementById("keysharky-enabler-" + id_arr[i]).setAttribute("checked", json_arr[i]["enabled"]);
}

}
},

Expand All @@ -305,6 +320,12 @@
var json = JSON.parse(localStorage[id]);

if (this.checkJSON(json)){

if (typeof(json["enabled"]) == "undefined"){
json["enabled"] = true;
localStorage[id] = JSON.stringify(json);
}

return json;
}
}catch(e){
Expand All @@ -329,6 +350,15 @@
}else{
return false;
}
},

toggleEnabled: function(event, id){
if (this.defaults[id]){
var json = keysharkyOptions.getPref(id);

json["enabled"] = event.checked === true ? true : false;
keysharkyOptions.setPref(id, json);
}
}
};

Expand All @@ -340,66 +370,77 @@
<div id="wrap">
<div class="clear heading">Playback control</div>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit 76a944d

Please sign in to comment.