PageSourceSearch

https://somafm.com/js/soma.js

js somafm.com collected 2026-09-24 08:47:17 UTC 7,043 bytes, 215 lines download raw bytes

1/* Site wide JS file */
2
3function SendMail(WhichDj, Server)
4{
5window.window.location="mailto:" + WhichDj + "@" + "SomaFM.com";
6}
7
8if (top !== self && document.referrer.match(/digg\.com\/\w{1,8}/)) {
9  top.location.replace(self.location.href);
10}
11
12
13
14// Still used?
15function popUpPlayer(Channel) {
16	URL="/popup/?" + Channel;
17	ChannelURL="/" + Channel;
18	newwindow=window.open(URL,'SomaPopupPlayer','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=410,height=260,left=0,top=0');
19	window.location.href=ChannelURL;
20	if (window.focus) {newwindow.focus()}
21	
22}
23
24
25
26// Declare a global reference for SomaPlayer24 window
27let playerWindow = null;
28
29
30
31function StartPlayer24(Channel) {
32	const screenHeight = window.screen.height;
33	const popHeight = screenHeight * 0.5; // 50% of the screen height
34	const URL = `/player24/station/${Channel}`;
35
36	// Detect touch devices and Safari
37	const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
38	const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) || navigator.vendor === "Apple Computer, Inc.";
39	const isSafariTouchDevice = isTouchDevice && isSafari;
40
41	// const isFirefoxForAndroid = /firefox.*android/i.test(navigator.userAgent);
42
43	const isFirefoxForAndroid = 
44		/firefox/i.test(navigator.userAgent) &&
45		/android/i.test(navigator.userAgent) &&
46		/mobile/i.test(navigator.userAgent);
47
48	// Open or refresh the player window
49	if (playerWindow && !playerWindow.closed) {
50	  // If the window is already open
51	  if (isSafariTouchDevice || isFirefoxForAndroid) {
52		playerWindow.close(); // Close the window for a fresh start on Safari touch devices
53		playerWindow = window.open(URL, 'SomaPlayer24'); // No "noopener" for Safari compatibility
54	  } else {
55		playerWindow.location.assign(URL); // Update the URL
56	  }
57	} else {
58	  // Open a new window or tab
59	  if (isSafariTouchDevice || isFirefoxForAndroid) {
60		playerWindow = window.open(URL, 'SomaPlayer24'); // Open in a new tab for Safari touch compatibility
61	  } else {
62		playerWindow = window.open(
63		  URL,
64		  'SomaPlayer24',
65		  `toolbar=no,titlebar=yes,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes,width=530,height=${popHeight},left=0,top=0`
66		);
67	  }
68	}
69
70	// Focus the player window if it opened successfully
71	if (playerWindow) {
72	  playerWindow.focus();
73	} else {
74	  console.warn("Unable to open SomaPlayer24 window. Possibly blocked by an extension or browser settings.");
75	}
76}
77
78
79
80function StartPlayer24xxx(Channel) {
81  var screenHeight = window.screen.height;
82  var popHeight = screenHeight * 0.5; // 50% of the screen height
83
84  var URL = "/player24/station/" + Channel;
85		
86  // Detect if the device is a touch device
87  var isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
88
89  // Detect if the device is a touch device
90  var isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
91
92  // Detect if the browser is Safari
93  var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) || navigator.vendor === "Apple Computer, Inc.";
94
95  // Combine both checks
96  var isSafariTouchDevice = isTouchDevice && isSafari;
97
98
99  
100  // Check if "SomaPlayer24" window is already open and not closed
101  if (playerWindow && !playerWindow.closed) {
102    // If the window exists, close it to allow for a fresh start
103    playerWindow.close();
104  }
105
106  // Open a new "SomaPlayer24" tab or popup window
107  if (isSafariTouchDevice) {
108    // For touch devices, open in a new tab for compatibility
109	// NOTE this is breaking some ChromeOS and not opening in new tab,
110    playerWindow = window.open(URL, 'SomaPlayer24'); // No "noopener" to improve Safari compatibility
111  } else {
112    // For non-touch devices, open a popup window with specific dimensions
113    playerWindow = window.open(URL, 'SomaPlayer24', 'toolbar=no,titlebar=yes,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes,width=530,height=' + popHeight + ',left=0,top=0');
114  }
115
116  // Focus on the "SomaPlayer24" window if it opened successfully
117  if (playerWindow) {
118    playerWindow.focus();
119  }  else {
120    console.warn("Unable to open SomaPlayer24 window. Possibly blocked by extension or setting");
121  }
122}
123
124
125function isOldDesktopSafari() {
126    const userAgent = navigator.userAgent;
127
128    // Check if it is Safari by confirming "Safari" and "Version" are present
129    const isSafari = userAgent.includes("Safari") && userAgent.includes("Version");
130
131    // Exclude Mobile Safari
132    const isNotMobile = !userAgent.includes("Mobile");
133
134    // Exclude Chrome or Chromium
135    const isNotChrome = !userAgent.includes("Chrome") && !userAgent.includes("Chromium");
136
137    // Find Safari version
138    const safariVersionMatch = userAgent.match(/Version\/(\d+)\./);
139    const safariVersion = safariVersionMatch ? parseInt(safariVersionMatch[1], 10) : null;
140
141    // Check if it’s Safari, not Chrome, not Mobile, and version is below 11
142    return isSafari && isNotMobile && isNotChrome && safariVersion !== null && safariVersion <= 12;
143}
144
145
146
147function StartPlayer24Z(Channel) {
148	// Call the appropriate function based on Safari version
149	if (isOldDesktopSafari()) {
150		console.log("Detected old version of Safari.");
151		StartPlayer(Channel);
152	} else {
153		console.log("Detected new version of Safari.");
154		StartPlayer24X(Channel);
155	}
156}
157
158// Popup and Change URL of background page to song history
159function StartPlayer18Popup(Channel) {
160	URL="/player/#/now-playing/" + Channel;
161	ChannelURL="/" + Channel + "/songhistory.html";
162	newwindow=window.open(URL,'SomaPlayer','toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes,width=530,height=460,left=0,top=0');
163	window.location.href=ChannelURL;
164	if (window.focus) {newwindow.focus()}
165
166}
167
168function StartPlayer18Only(Channel) {
169	URL="/player/#/now-playing/" + Channel;
170	ChannelURL="/" + Channel + "/songhistory.html";
171	newwindow=window.open(URL,'SomaPlayer','toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes,width=530,height=460,left=0,top=0');
172	if (window.focus) {newwindow.focus()}
173
174}
175
176// used by some embedded players like chillits
177// Eventually start the new 24 player with this
178function StartEmbeddedPlayer(Channel) {
179	StartPlayer18Only(Channel)
180}
181
182
183
184function StartPlayer(Channel) {
185	// maybe find a better way to find a touch device?
186	 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent)) {
187		PlayerURL="/player/#/now-playing/" + Channel;	
188		window.location.href=PlayerURL;
189	} else {
190		StartPlayer18Popup(Channel)
191	}
192}
193
194
195
196
197
198
199function isIE() {
200	return '\v'=='v';
201}
202
203
204function popUpSize(URL) {
205	day=new Date();
206	id=day.getTime();
207	eval("page" + id + "=window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=511,height=274,left=200,top=200');");
208}
209
210function popUpPage(URL) {
211	day=new Date();
212	id=day.getTime();
213	eval("page" + id + "=window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=760,height=540,left=200,top=200');");
214}
215

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.