|
18 | 18 | width: 350px; |
19 | 19 | } |
20 | 20 |
|
| 21 | + #wrap input.check { |
| 22 | + float: left; |
| 23 | + display: block; |
| 24 | + height: 28px; |
| 25 | + margin: 0 5px 0 0; |
| 26 | + padding: 0; |
| 27 | + } |
| 28 | + |
21 | 29 | #wrap span.label { |
22 | 30 | display: block; |
23 | 31 | float: left; |
|
76 | 84 | this.debug = false; |
77 | 85 | this.unAllowedKeys = [16, 17, 18, 91]; |
78 | 86 | 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}' |
90 | 98 | }; |
91 | 99 |
|
92 | 100 | this.uiOptions(); |
|
156 | 164 | if (!this.checkJSON(combo)) |
157 | 165 | return; |
158 | 166 |
|
| 167 | + combo["enabled"] = document.getElementById("keysharky-enabler-" + id).checked === true ? true : false; |
| 168 | + |
159 | 169 | this.uiChangeCombos(id, combo); |
160 | 170 | this.setPref(id, combo); |
161 | 171 | } |
|
295 | 305 | if (document.getElementById(id_arr[i])){ |
296 | 306 | document.getElementById(id_arr[i]).value = str; |
297 | 307 | } |
| 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 | + } |
298 | 312 | } |
299 | 313 | }, |
300 | 314 |
|
|
305 | 319 | var json = JSON.parse(localStorage[id]); |
306 | 320 |
|
307 | 321 | if (this.checkJSON(json)){ |
| 322 | + |
| 323 | + if (typeof(json["enabled"]) == "undefined"){ |
| 324 | + json["enabled"] = true; |
| 325 | + localStorage[id] = JSON.stringify(json); |
| 326 | + } |
| 327 | + |
308 | 328 | return json; |
309 | 329 | } |
310 | 330 | }catch(e){ |
|
329 | 349 | }else{ |
330 | 350 | return false; |
331 | 351 | } |
| 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 | + } |
332 | 361 | } |
333 | 362 | }; |
334 | 363 |
|
|
340 | 369 | <div id="wrap"> |
341 | 370 | <div class="clear heading">Playback control</div> |
342 | 371 |
|
| 372 | + <input id="keysharky-enabler-play" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'play')" /> |
343 | 373 | <span class="label">Play/Pause</span> |
344 | 374 | <input id="play" class="combos-input" type="text" value="-" readonly="true" |
345 | 375 | onkeydown="keysharkyOptions.applyCombo(event, 'play')" /> |
346 | 376 |
|
347 | 377 | <div class="clear"></div> |
348 | 378 |
|
| 379 | + <input id="keysharky-enabler-stop" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'stop')" /> |
349 | 380 | <span class="label">Stop</span> |
350 | 381 | <input id="stop" class="combos-input" type="text" value="-" readonly="true" |
351 | 382 | onkeydown="keysharkyOptions.applyCombo(event, 'stop')" /> |
352 | 383 |
|
353 | 384 | <div class="clear"></div> |
354 | 385 |
|
| 386 | + <input id="keysharky-enabler-prev" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'prev')" /> |
355 | 387 | <span class="label">Previous song</span> |
356 | 388 | <input id="prev" class="combos-input" type="text" value="-" readonly="true" |
357 | 389 | onkeydown="keysharkyOptions.applyCombo(event, 'prev')" /> |
358 | 390 |
|
359 | 391 | <div class="clear"></div> |
360 | 392 |
|
| 393 | + <input id="keysharky-enabler-next" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'next')" /> |
361 | 394 | <span class="label">Next song</span> |
362 | 395 | <input id="next" class="combos-input" type="text" value="-"readonly="true" |
363 | 396 | onkeydown="keysharkyOptions.applyCombo(event, 'next')" /> |
364 | 397 |
|
365 | 398 | <div class="clear heading">Current song</div> |
366 | 399 |
|
| 400 | + <input id="keysharky-enabler-favorite" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'favorite')" /> |
367 | 401 | <span class="label">Favorite</span> |
368 | 402 | <input id="favorite" class="combos-input" type="text" value="-"readonly="true" |
369 | 403 | onkeydown="keysharkyOptions.applyCombo(event, 'favorite')" /> |
370 | 404 |
|
371 | 405 | <div class="clear"></div> |
372 | 406 |
|
| 407 | + <input id="keysharky-enabler-voteup" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'voteup')" /> |
373 | 408 | <span class="label">Vote up :)</span> |
374 | 409 | <input id="voteup" class="combos-input" type="text" value="-"readonly="true" |
375 | 410 | onkeydown="keysharkyOptions.applyCombo(event, 'voteup')" /> |
376 | 411 |
|
377 | 412 | <div class="clear"></div> |
378 | 413 |
|
| 414 | + <input id="keysharky-enabler-votedown" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'votedown')" /> |
379 | 415 | <span class="label">Vote down :(</span> |
380 | 416 | <input id="votedown" class="combos-input" type="text" value="-"readonly="true" |
381 | 417 | onkeydown="keysharkyOptions.applyCombo(event, 'votedown')" /> |
382 | 418 |
|
383 | 419 | <div class="clear"></div> |
384 | 420 |
|
| 421 | + <input id="keysharky-enabler-voteclear" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'voteclear')" /> |
385 | 422 | <span class="label">Reset vote</span> |
386 | 423 | <input id="voteclear" class="combos-input" type="text" value="-"readonly="true" |
387 | 424 | onkeydown="keysharkyOptions.applyCombo(event, 'voteclear')" /> |
388 | 425 |
|
389 | 426 | <div class="clear heading">Sound control</div> |
390 | 427 |
|
| 428 | + <input id="keysharky-enabler-mute" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'mute')" /> |
391 | 429 | <span class="label">Mute</span> |
392 | 430 | <input id="mute" class="combos-input" type="text" value="-"readonly="true" |
393 | 431 | onkeydown="keysharkyOptions.applyCombo(event, 'mute')" /> |
394 | 432 |
|
395 | 433 | <div class="clear"></div> |
396 | 434 |
|
| 435 | + <input id="keysharky-enabler-volup" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'volup')" /> |
397 | 436 | <span class="label">Volume Up</span> |
398 | 437 | <input id="volup" class="combos-input" type="text" value="-"readonly="true" |
399 | 438 | onkeydown="keysharkyOptions.applyCombo(event, 'volup')" /> |
400 | 439 |
|
401 | 440 | <div class="clear"></div> |
402 | 441 |
|
| 442 | + <input id="keysharky-enabler-voldown" class="check" type="checkbox" onclick="keysharkyOptions.toggleEnabled(this, 'voldown')" /> |
403 | 443 | <span class="label">Volume Down</span> |
404 | 444 | <input id="voldown" class="combos-input" type="text" value="-"readonly="true" |
405 | 445 | onkeydown="keysharkyOptions.applyCombo(event, 'voldown')" /> |
|
0 commit comments