1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Author: Gustavo Gonçalves
// This script is to use with the Fogger App. I great program of Ubuntu (linux) system.
// http://www.reddit.com/r/ubuntuappshowdown/comments/vggkn/app_submission_fogger_turn_cloud_apps_into_ubuntu/

(function() {
var desktop = new fogger.Desktop();
var started = 0;
var currentmusic = 0;

var setupFogger = function(desktop) {

  // Unity - Quicklist
  desktop.quicklist.addItem({name: 'Play/Pause',  callback: function() { window.Grooveshark.togglePlayPause() }});
  desktop.quicklist.addItem({name: 'Next',        callback: function() { window.Grooveshark.next() }});
  desktop.quicklist.addItem({name: 'Previous',    callback: function() { window.Grooveshark.previous() }});
  desktop.quicklist.addItem({name: 'Favorite',    callback: function() { window.Grooveshark.favoriteCurrentSong() }});
  desktop.quicklist.addItem({name: 'Add To Library', callback: function() { window.Grooveshark.addCurrentSongToLibrary() }});
  desktop.quicklist.addItem({name: 'Radio:Smile', callback: function() { window.Grooveshark.voteCurrentSong(1) }});
  desktop.quicklist.addItem({name: 'Radio:Frown', callback: function() { window.Grooveshark.voteCurrentSong(-1) }});
  desktop.quicklist.addItem({name: 'Radio:Clear', callback: function() { window.Grooveshark.voteCurrentSong(0) }});
 
  // Menu
  //desktop.newMenu('Playlists').addItem({name: 'Play/Pause test', callback: function() { window.Grooveshark.togglePlayPause() }});

  // Callback when the song status changes
  window.Grooveshark.setSongStatusCallback(songstatus);

  started = 1;
}; //setup Fogger

function songstatus(currentStatus, playingOnly) {
   var song = currentStatus.song;
   var status = currentStatus.status;
   
   if (status == 'playing' && currentmusic!=song.songID) { 
      desktop.notify(song.artistName, song.songName); 
      currentmusic = song.songID;
   };
   if (status == 'completed') { 
      desktop.notify('Grooveshark', 'The current list ended'); 
      currentmusic = 0;
   };
};

function loadscript() {
   if(window.Grooveshark) {
      if (started==0) {
         setupFogger(desktop); 
       }
   } else { 
      setTimeout(loadscript, 1000);
   }
};

loadscript();

})();