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

Commit 836a2ff

Browse files
committed
New version of keySharky for Firefox
- changed version: 1.5.2 - added "Sound control" keyboard combos - added gsAPI methods for "Sound control" - bugfixes - updated "keySharky Options" window
1 parent 9a17ecb commit 836a2ff

File tree

6 files changed

+106
-14
lines changed

6 files changed

+106
-14
lines changed

firefox/content/firefoxOverlay.xul

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
<overlay id="keysharky-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
33

44
<script src="chrome://keysharky/content/overlay.js"/>
5-
5+
66
<keyset id="mainKeyset">
77
<key id="keysharky_key_fake" />
88
<!-- DO NOT REMOVE THIS FAKE KEY, OK? -->
99
</keyset>
10-
10+
1111
<commandset id="mainCommandSet">
1212
<command id="keysharky_cmd_play" oncommand="keysharky.toggle('play');" />
1313
<command id="keysharky_cmd_stop" oncommand="keysharky.toggle('stop');" />
1414
<command id="keysharky_cmd_previous" oncommand="keysharky.toggle('previous');" />
1515
<command id="keysharky_cmd_next" oncommand="keysharky.toggle('next');" />
16-
16+
1717
<command id="keysharky_cmd_favorite" oncommand="keysharky.toggle('favorite');" />
1818
<command id="keysharky_cmd_voteup" oncommand="keysharky.toggle('voteup');" />
1919
<command id="keysharky_cmd_voteclear" oncommand="keysharky.toggle('voteclear');" />
2020
<command id="keysharky_cmd_votedown" oncommand="keysharky.toggle('votedown');" />
21+
22+
<command id="keysharky_cmd_mute" oncommand="keysharky.toggle('mute');" />
23+
<command id="keysharky_cmd_volup" oncommand="keysharky.toggle('volup');" />
24+
<command id="keysharky_cmd_voldown" oncommand="keysharky.toggle('voldown');" />
2125
</commandset>
2226

2327
</overlay>

firefox/content/options.xul

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<textbox id="keysharky-toggle-next-shortcut" value="-"
4848
onkeypress="keysharky.applyCombo(event, 'next')" readonly="true" />
4949
</hbox>
50+
5051
</groupbox>
5152

5253
<groupbox id="keysharky-group-current">
@@ -81,6 +82,31 @@
8182
</hbox>
8283
</groupbox>
8384

85+
<groupbox id="keysharky-group-sound">
86+
<caption label="Sound control"/>
87+
88+
<hbox align="center">
89+
<checkbox onclick="keysharky.toggleCombo('mute');" id="keysharky-enabler-mute" class="enabler" label="Mute" />
90+
<spacer flex="1"/>
91+
<textbox id="keysharky-toggle-mute-shortcut" value="-"
92+
onkeypress="keysharky.applyCombo(event, 'mute')" readonly="true" />
93+
</hbox>
94+
95+
<hbox align="center">
96+
<checkbox onclick="keysharky.toggleCombo('volup');" id="keysharky-enabler-volup" class="enabler" label="Volume Up" />
97+
<spacer flex="1"/>
98+
<textbox id="keysharky-toggle-volup-shortcut" value="-"
99+
onkeypress="keysharky.applyCombo(event, 'volup')" readonly="true" />
100+
</hbox>
101+
102+
<hbox align="center">
103+
<checkbox onclick="keysharky.toggleCombo('voldown');" id="keysharky-enabler-voldown" class="enabler" label="Volume Down" />
104+
<spacer flex="1"/>
105+
<textbox id="keysharky-toggle-voldown-shortcut" value="-"
106+
onkeypress="keysharky.applyCombo(event, 'voldown')" readonly="true" />
107+
</hbox>
108+
</groupbox>
109+
84110
<groupbox id="keysharky-group-api-server">
85111
<caption label="API server"/>
86112

firefox/content/overlay.js

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ var keysharky = {
1212
"voteup" : function(){ keysharky.gsliteswf.voteCurrentSong(1); },
1313
"votedown" : function(){ keysharky.gsliteswf.voteCurrentSong(-1); },
1414
"voteclear" : function(){ keysharky.gsliteswf.voteCurrentSong(0); },
15+
16+
"mute" : function(){ keysharky.gsliteswf.setIsMuted(keysharky.gsliteswf.getIsMuted() ? false : true); },
17+
"volup" : function(){ keysharky.gsliteswf.setVolume(keysharky.gsliteswf.getVolume() + 10); },
18+
"voldown" : function(){ keysharky.gsliteswf.setVolume(keysharky.gsliteswf.getVolume() - 10); }
1519
};
1620

1721
this.defaults = {
@@ -25,13 +29,20 @@ var keysharky = {
2529
"votedown" : '{"modifiers":["control","alt"],"key":"Z","keycode":"","enabled":true}',
2630
"voteclear" : '{"modifiers":["control","alt"],"key":"Q","keycode":"","enabled":true}',
2731

32+
"mute" : '{"modifiers":["control","shift"],"key":"M","keycode":"","enabled":true}',
33+
"volup" : '{"modifiers":["control","shift"],"key":">","keycode":"","enabled":true}',
34+
"voldown" : '{"modifiers":["control","shift"],"key":"<","keycode":"","enabled":true}',
35+
2836
"server_port" : 8800
2937
}
3038

3139
this.serverMethods = {
3240
"currentSong" : function(){ return keysharky.gsliteswf.getCurrentSongStatus(); },
3341
"nextSong" : function(){ return keysharky.gsliteswf.getNextSong(); },
3442
"previousSong" : function(){ return keysharky.gsliteswf.getPreviousSong(); },
43+
44+
"volume" : function(){ return keysharky.gsliteswf.getVolume(); },
45+
"muted" : function(){ return keysharky.gsliteswf.getIsMuted(); },
3546
};
3647

3748
this.consoleObject = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
@@ -70,11 +81,13 @@ var keysharky = {
7081

7182
this.gsAPI.registerErrorHandler(404, this.serverErrorParser);
7283
this.gsAPI.registerPathHandler("/", this.serverErrorParser);
84+
7385
this.gsAPI.registerPathHandler("/gs-version", this.serverGroovesharkVersion);
7486
this.gsAPI.registerPathHandler("/gs-api-version", this.serverGroovesharkAPIVersion);
87+
this.gsAPI.registerPathHandler("/setVolume", this.serverVolumeControl);
7588

7689
for (var method in this.serverMethods){
77-
this.gsAPI.registerPathHandler("/" + method, this.serverSong);
90+
this.gsAPI.registerPathHandler("/" + method, this.serverInfo);
7891
}
7992

8093
for(var toggle in this.allToggles){
@@ -104,6 +117,45 @@ var keysharky = {
104117
return true;
105118
},
106119

120+
serverVolumeControl: function(request, response){
121+
122+
var volume = /^(\d+)$/i.exec(request.queryString);
123+
var toggled = false;
124+
125+
if (volume != null && volume[1] >= 0 && volume[1] <= 100){
126+
127+
try {
128+
keysharky.gsliteswf.setVolume(volume[1]);
129+
toggled = true;
130+
}catch(e){
131+
132+
try{
133+
keysharky.findGrooveshark();
134+
135+
keysharky.gsliteswf.setVolume(volume[1]);
136+
toggled = true;
137+
}catch(e){}
138+
139+
}
140+
141+
if (toggled){
142+
143+
response.setStatusLine("1.1", 200, "OK");
144+
response.write("VOLUME SET TO " + volume[1]);
145+
146+
}else{
147+
148+
response.setStatusLine("1.1", 500, "FAILED");
149+
response.write("COULDN'T SET VOLUME");
150+
151+
}
152+
}else{
153+
response.setStatusLine("1.1", 500, "FAILED");
154+
response.write("BAD VOLUME VALUE. MUST BE BETWEEN 0 AND 100.");
155+
}
156+
157+
},
158+
107159
// Retrieves info about GroovesharkAPI version
108160
serverGroovesharkAPIVersion: function(request, response){
109161
try {
@@ -178,8 +230,8 @@ var keysharky = {
178230
}
179231
},
180232

181-
// Shows previous/current/next song status in plain text
182-
serverSong: function(request, response){
233+
// Retrieves and shows status messages
234+
serverInfo: function(request, response){
183235
var method = /\/(\w+)/i.exec(request.path);
184236
var jsonArr = {};
185237

@@ -197,26 +249,30 @@ var keysharky = {
197249

198250
response.setHeader("Cache-Control", "no-cache", false);
199251

200-
if (json){
252+
if (typeof(json) != "undefined"){
201253
response.setStatusLine("1.1", 200, "OK");
202254

203255
if (method[1] == "currentSong"){
204256

205257
response.write("status: " + json.status + "\n");
206258
jsonArr = json.song;
207259

208-
}else{
260+
}else if (method[1] == "nextSong" || method[1] == "previousSong"){
209261

210262
jsonArr = json;
211263

264+
}else{
265+
266+
jsonArr[method[1]] = json;
267+
212268
}
213269

214270
for(var status in jsonArr){
215271
response.write(status + ": " + jsonArr[status] + "\n");
216272
}
217273
}else{
218274
response.setStatusLine("1.1", 500, "FAILED");
219-
response.write("COULDN'T RETRIEVE SONG STATUS");
275+
response.write("COULDN'T RETRIEVE '" + method[1] + "' STATUS");
220276
}
221277

222278
},
@@ -463,7 +519,6 @@ var keysharky = {
463519
for(var toggle in this.allToggles){
464520
id_arr[i] = toggle;
465521
json_arr[i] = this.getPref(toggle);
466-
467522
i++;
468523
}
469524

@@ -492,6 +547,7 @@ var keysharky = {
492547

493548
this.optionsDoc.getElementById("keysharky-group-playback").style.display = "none";
494549
this.optionsDoc.getElementById("keysharky-group-current").style.display = "none";
550+
this.optionsDoc.getElementById("keysharky-group-sound").style.display = "none";
495551
this.optionsDoc.getElementById("keysharky-group-readme").style.display = "none";
496552

497553
}
@@ -728,7 +784,6 @@ var keysharky = {
728784
}
729785

730786
}catch(e){
731-
this.log(e);
732787
this.setPref(id, this.JSON.parse(this.defaults[id]));
733788
}
734789

firefox/defaults/preferences/prefs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ pref('extensions.keysharky.voteup', '{"modifiers":["control","alt"],"key":"A
88
pref('extensions.keysharky.votedown', '{"modifiers":["control","alt"],"key":"Z","keycode":"","enabled":true}');
99
pref('extensions.keysharky.voteclear', '{"modifiers":["control","alt"],"key":"Q","keycode":"","enabled":true}');
1010

11+
pref('extensions.keysharky.mute', '{"modifiers":["control","shift"],"key":"M","keycode":"","enabled":true}');
12+
pref('extensions.keysharky.volup', '{"modifiers":["control","shift"],"key":">","keycode":"","enabled":true}');
13+
pref('extensions.keysharky.voldown', '{"modifiers":["control","shift"],"key":"<","keycode":"","enabled":true}');
14+
1115
pref('extensions.keysharky.server_port', 8800);
1216
pref('extensions.keysharky.server_autostart', false);

firefox/install.rdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<RDF:Description RDF:about="rdf:#$kLx0i3"
66
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
77
em:minVersion="3.0"
8-
em:maxVersion="4.0b7" />
8+
em:maxVersion="4.0b8" />
99
<RDF:Description RDF:about="urn:mozilla:install-manifest"
1010
em:id="keysharky@intars.students"
1111
em:name="keySharky"
1212
em:description="Add missing keyboard functionality to Grooveshark!"
13-
em:version="1.5.1"
13+
em:version="1.5.2"
1414
em:creator="Intars Students"
1515
em:optionsURL="chrome://keysharky/content/options.xul"
1616
em:iconURL="chrome://keysharky/skin/keysharky.png">

firefox/skin/options.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#keysharky-toggle-favorite-shortcut,
2222
#keysharky-toggle-voteup-shortcut,
2323
#keysharky-toggle-voteclear-shortcut,
24-
#keysharky-toggle-votedown-shortcut {
24+
#keysharky-toggle-votedown-shortcut,
25+
#keysharky-toggle-mute-shortcut,
26+
#keysharky-toggle-volup-shortcut,
27+
#keysharky-toggle-voldown-shortcut {
2528
width: 250px;
2629
}

0 commit comments

Comments
 (0)