'use strict';

/* global Connector */

(function() {
		var playerObserver = new MutationObserver(function() {
		if (document.querySelector('#d-content')) {
			playerObserver.disconnect();
			var actualObserver = new MutationObserver(Connector.onStateChanged);
			actualObserver.observe(document.querySelector('#d-content'), {
				childList: true,
				subtree: true,
				attributes: true,
				characterData: true
			});
		}
	});

	playerObserver.observe(document.body, {
		childList: true,
		subtree: true,
		attributes: false,
		characterData: false
	});
})();

var isPlayingLiveRadio = function() {
  if($('#d-secondary-control-left .disabled').size() == 1 && $('#d-secondary-control-right .disabled').size() == 1) {
    return 'true';
  } else {
    return 'false';
  }
}

Connector.getArtist = function() {
  if(isPlayingLiveRadio() === 'true') {
    var songTitle =  $('.d-queue-info .song-title').text();
    if(songTitle.indexOf("-") == -1) {
      //Maybe ad or program, so ignore
      return null;
    }
    var results = songTitle.split("-");
    return results[0].trim();
  }else {
    return $('#d-info-text .d-sub-text-1').text();
  }
};

Connector.getTrack = function() {
  if(isPlayingLiveRadio() === 'true') {
    var songTitle =  $('.d-queue-info .song-title').text();
    if(songTitle.indexOf("-") == -1) {
      //Maybe ad or program, so ignore
      return null;
    }
    var results = songTitle.split("-");
    return results[1].trim();
  }else {
    return $('#d-info-text .d-main-text').text();
  }
}

Connector.isPlaying = function () {
	return $('#d-primary-control .play').size() == 0;
};

@@ -593,20 +593,20 @@
 ion() %7B%0A
-  
+%09
 if
+ 
 ($('#d-s
@@ -711,20 +711,18 @@
 == 1) %7B%0A
-    
+%09%09
 return '
@@ -728,18 +728,17 @@
 'true';%0A
-  
+%09
 %7D else %7B
@@ -734,28 +734,26 @@
 ;%0A%09%7D else %7B%0A
-    
+%09%09
 return 'fals
@@ -756,21 +756,21 @@
 false';%0A
-  
+%09
 %7D%0A%7D
+;
 %0A%0AConnec
@@ -790,36 +790,36 @@
  = function() %7B%0A
-  
+%09
 if
+ 
 (isPlayingLiveRa
@@ -830,36 +830,34 @@
 ) === 'true') %7B%0A
-    
+%09%09
 var songTitle = 
@@ -888,38 +888,37 @@
 title').text();%0A
-    
+%09%09
 if
+ 
 (songTitle.index
@@ -912,35 +912,35 @@
 ngTitle.indexOf(
-%22-%22
+'-'
 ) == -1) %7B%0A     
@@ -926,38 +926,35 @@
 f('-') == -1) %7B%0A
-      
+%09%09%09
 //Maybe ad or pr
@@ -962,38 +962,35 @@
 gram, so ignore%0A
-      
+%09%09%09
 return null;%0A   
@@ -982,34 +982,30 @@
 eturn null;%0A
-    %7D%0A    
+%09%09%7D%0A%09%09
 var results 
@@ -1018,34 +1018,32 @@
 Title.split(
-%22-%22);%0A    
+'-');%0A%09%09
 return resul
@@ -1052,38 +1052,36 @@
 %5B0%5D.trim();%0A
-  %7D
+%09%7D 
 else %7B%0A
-    
+%09%09
 return $('#d
@@ -1115,18 +1115,17 @@
 text();%0A
-  
+%09
 %7D%0A%7D;%0A%0ACo
@@ -1156,20 +1156,20 @@
 ion() %7B%0A
-  
+%09
 if
+ 
 (isPlayi
@@ -1196,20 +1196,18 @@
 rue') %7B%0A
-    
+%09%09
 var song
@@ -1258,14 +1258,13 @@
 ();%0A
-    
+%09%09
 if
+ 
 (son
@@ -1278,19 +1278,19 @@
 indexOf(
-%22-%22
+'-'
 ) == -1)
@@ -1292,22 +1292,19 @@
 = -1) %7B%0A
-      
+%09%09%09
 //Maybe 
@@ -1332,14 +1332,11 @@
 ore%0A
-      
+%09%09%09
 retu
@@ -1348,18 +1348,14 @@
 ll;%0A
-    %7D%0A    
+%09%09%7D%0A%09%09
 var 
@@ -1384,18 +1384,16 @@
 lit(
-%22-%22);%0A    
+'-');%0A%09%09
 retu
@@ -1418,22 +1418,20 @@
 ();%0A
-  %7D
+%09%7D 
 else %7B%0A
-    
+%09%09
 retu
@@ -1476,13 +1476,13 @@
 ();%0A
-  
+%09
 %7D%0A%7D
+;
 %0A%0ACo
@@ -1562,15 +1562,16 @@
 ize() ==
+=
  0;%0A%7D;%0A

Fix jshint and linter errors.