Skip to content

Commit 8a5bdf0

Browse files
committed
remove redundancy
1 parent 7b96473 commit 8a5bdf0

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

public/remote.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
var socket = io.connect();
2-
function sendMessage(msg) {
3-
if ($('#id').val() != "")
4-
{
5-
socket.emit('message', $('#id').val().replace(/ /g,'-').replace(/[^a-zA-Z0-9-\.]*/g,"").toLowerCase()+'.local:'+msg);
6-
}
7-
}
8-
92
$(function() {
103
$(document).bind("touchmove", function(e) {e.preventDefault();});
11-
$("#playpause").click(function() {sendMessage('playpause');});
12-
$("#prev").click(function() {sendMessage('play previous track');});
13-
$("#next").click(function() {sendMessage('play next track');});
14-
$('#id').val($.cookie('id'));
15-
$('#id').change(function() {$.cookie('id', $('#id').val(), { expires: 90 });});
4+
$("#controls button").click(function() { if ($('#id').val() != ""){
5+
socket.emit('message', $('#id').val().replace(/ /g,'-').replace(/[^a-zA-Z0-9-\.]*/g,"").toLowerCase()+'.local:' + this.id);
6+
}});
7+
$('#id').change(function() {$.cookie('id', $('#id').val(), { expires: 90 });}).val($.cookie('id'));
168
});

views/remote.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ html
3232
body
3333
div.container
3434
input(type='text')#id.form-control.input-sm
35-
div.btn-group
35+
div.btn-group#controls
3636
button#prev.btn.btn-info
3737
span.glyphicon.glyphicon-backward
3838
button#playpause.btn.btn-primary

0 commit comments

Comments
 (0)