douban_fm_hotkey 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/douban_fm_hotkey/server/public/client.js +100 -0
- data/lib/douban_fm_hotkey/server/public/like.png +0 -0
- data/lib/douban_fm_hotkey/server/public/{app.js → server.js} +2 -2
- data/lib/douban_fm_hotkey/server/public/unlike.png +0 -0
- data/lib/douban_fm_hotkey/server/views/layout.erb +1 -1
- data/lib/douban_fm_hotkey/server.rb +1 -1
- data/lib/douban_fm_hotkey/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d948984d0443ce13dc2b7e3ab74dceaf2cdad183
|
4
|
+
data.tar.gz: 5afbee5ee50c18eb1d04e2945b5d41b926c5e7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4003f2878db1f770bdecacfe12b0f3d0f3e2cffc1355ce2d118182b2d567a0a7be4c78be1045feae381366b87d8d6a01b6182b2dbea7664a44bf57b0df9e8e
|
7
|
+
data.tar.gz: 59615351cea6d2281c98b68869d66f604f8fb660b239ff1e3a16f149691f1bb95803fae853c205c1d7915e38f6f5b1c5d75eaac429c33e209c5bfbcd71f1d866
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,100 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
var client = new Faye.Client('http://localhost:1988/faye');
|
4
|
+
|
5
|
+
client.subscribe('/hotkey', function(msg) {
|
6
|
+
var songInfo = getSongInfo();
|
7
|
+
if (msg.cmd == 'info') {
|
8
|
+
sendNotification(songInfo.song.coverUrl, songInfo.song.artistName, songInfo.song.songName);
|
9
|
+
} else {
|
10
|
+
window.DBR.act(msg.cmd);
|
11
|
+
if (msg.cmd == 'pause' || msg.cmd == 'love') {
|
12
|
+
publishSongInfo(songInfo);
|
13
|
+
if (msg.cmd == 'love') {
|
14
|
+
var img;
|
15
|
+
if (window.DBR.selected_like()) {
|
16
|
+
img = 'like.png'
|
17
|
+
} else {
|
18
|
+
img = 'unlike.png'
|
19
|
+
}
|
20
|
+
sendNotification('http://localhost:1988/' + img, songInfo.song.artistName, songInfo.song.songName);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
});
|
25
|
+
|
26
|
+
client.subscribe('/get_info', function() {
|
27
|
+
publishSongInfo(getSongInfo());
|
28
|
+
});
|
29
|
+
|
30
|
+
var interval = window.setInterval(function() {
|
31
|
+
if (window.extStatusHandler) {
|
32
|
+
clearInterval(interval);
|
33
|
+
var originExtStatusHandler = window.extStatusHandler;
|
34
|
+
window.extStatusHandler = function(info) {
|
35
|
+
var parsedInfo = $.parseJSON(info);
|
36
|
+
if (parsedInfo.type == 'start') {
|
37
|
+
var songInfo = {
|
38
|
+
song: {
|
39
|
+
artistName: parsedInfo.song.artist,
|
40
|
+
channelName: getChannelName(parsedInfo.channel),
|
41
|
+
coverUrl: parsedInfo.song.picture,
|
42
|
+
songName: parsedInfo.song.title
|
43
|
+
},
|
44
|
+
radio: {
|
45
|
+
is_paused: false,
|
46
|
+
selected_like: parsedInfo.song.like
|
47
|
+
}
|
48
|
+
};
|
49
|
+
publishSongInfo(songInfo);
|
50
|
+
sendNotification(songInfo.song.coverUrl, songInfo.song.artistName, songInfo.song.songName);
|
51
|
+
}
|
52
|
+
originExtStatusHandler(info);
|
53
|
+
};
|
54
|
+
}
|
55
|
+
}, 100);
|
56
|
+
|
57
|
+
var getSongInfo = function() {
|
58
|
+
return {
|
59
|
+
song: window.FM.getCurrentSongInfo(),
|
60
|
+
radio: {
|
61
|
+
is_paused: window.DBR.is_paused(),
|
62
|
+
selected_like: window.DBR.selected_like()
|
63
|
+
}
|
64
|
+
};
|
65
|
+
};
|
66
|
+
|
67
|
+
var sendNotification = function(image, title, content) {
|
68
|
+
if (window.webkitNotifications.checkPermission() == 0) {
|
69
|
+
var notification = window.webkitNotifications.createNotification(
|
70
|
+
image, title, content
|
71
|
+
);
|
72
|
+
notification.onshow = function() {
|
73
|
+
setTimeout(function() {
|
74
|
+
notification.close()
|
75
|
+
}, 5000);
|
76
|
+
};
|
77
|
+
notification.show();
|
78
|
+
} else {
|
79
|
+
window.webkitNotifications.requestPermission();
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
var publishSongInfo = function(info) {
|
84
|
+
client.publish('/info', info);
|
85
|
+
};
|
86
|
+
|
87
|
+
var getChannelName = function(id) {
|
88
|
+
id = parseInt(id, 10);
|
89
|
+
if (id === 0 || id === -9) {
|
90
|
+
return "私人兆赫"
|
91
|
+
} else {
|
92
|
+
if (id === -3 || id === -8) {
|
93
|
+
return "红心兆赫"
|
94
|
+
} else {
|
95
|
+
return $("#fm-channel-list .channel[cid=" + id + "] .chl_name").first().text()
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
})();
|
Binary file
|
@@ -2,7 +2,7 @@ $(function() {
|
|
2
2
|
|
3
3
|
var client = new Faye.Client('/faye');
|
4
4
|
|
5
|
-
client.subscribe('/
|
5
|
+
client.subscribe('/info', function(message) {
|
6
6
|
console.log(message);
|
7
7
|
$pause_button = $('button.pause');
|
8
8
|
$love_button = $('button.love');
|
@@ -22,7 +22,7 @@ $(function() {
|
|
22
22
|
$('#song-name').html('歌名: ' + message.song.songName);
|
23
23
|
});
|
24
24
|
|
25
|
-
client.publish('/
|
25
|
+
client.publish('/get_info', { get: 1 });
|
26
26
|
|
27
27
|
$buttons = $('button');
|
28
28
|
$buttons.click(function() {
|
Binary file
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<title>Douban FM Hotkey</title>
|
6
6
|
<script type="text/javascript" src="faye.js"></script>
|
7
7
|
<script type="text/javascript" src="jquery.js"></script>
|
8
|
-
<script type="text/javascript" src="
|
8
|
+
<script type="text/javascript" src="server.js"></script>
|
9
9
|
<link rel="stylesheet" href="style.css" />
|
10
10
|
</head>
|
11
11
|
<body>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: douban_fm_hotkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wei Zhu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye
|
@@ -95,9 +95,12 @@ files:
|
|
95
95
|
- bin/douban_fm_hotkey
|
96
96
|
- douban_fm_hotkey.gemspec
|
97
97
|
- lib/douban_fm_hotkey/server.rb
|
98
|
-
- lib/douban_fm_hotkey/server/public/
|
98
|
+
- lib/douban_fm_hotkey/server/public/client.js
|
99
99
|
- lib/douban_fm_hotkey/server/public/jquery.js
|
100
|
+
- lib/douban_fm_hotkey/server/public/like.png
|
101
|
+
- lib/douban_fm_hotkey/server/public/server.js
|
100
102
|
- lib/douban_fm_hotkey/server/public/style.css
|
103
|
+
- lib/douban_fm_hotkey/server/public/unlike.png
|
101
104
|
- lib/douban_fm_hotkey/server/views/index.erb
|
102
105
|
- lib/douban_fm_hotkey/server/views/layout.erb
|
103
106
|
- lib/douban_fm_hotkey/version.rb
|