-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathindex-radio.php
More file actions
204 lines (177 loc) · 6.29 KB
/
Copy pathindex-radio.php
File metadata and controls
204 lines (177 loc) · 6.29 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
// +------------------------------------------------------------------------+
// | O!MPD, Copyright © 2015 Artur Sierzant |
// | http://www.ompd.pl |
// | |
// | |
// | netjukebox, Copyright © 2001-2012 Willem Bartels |
// | |
// | http://www.netjukebox.nl |
// | http://forum.netjukebox.nl |
// | |
// | This program is free software: you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation, either version 3 of the License, or |
// | (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program. If not, see <http://www.gnu.org/licenses/>. |
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Radio browser |
// +------------------------------------------------------------------------+
use AdinanCenci\RadioBrowser\RadioBrowser;
global $cfg, $db;
global $base_size, $spaces, $scroll_bar_correction;
authenticate('access_media');
// formattedNavigator
$nav = array();
$nav['name'][] = 'Library';
$nav['url'][] = 'index.php';
$nav['name'][] = 'Radio browser';
require_once('include/header.inc.php');
require 'vendor/autoload.php';
$tileSize = $_GET['tileSizePHP'];
$searchTag = $_GET['searchTag'];
//$server = RadioBrowser::pickAServer();
//$browser = new RadioBrowser($server);
if ($browser = initRadioBrowser()){
$countries = $browser->getCountries();
}
?>
<h1>Search radio stations</h1>
<table cellspacing="0" cellpadding="0" id="searchRadio" class="border">
<tr class="textspace"><td colspan="2"></td></tr>
<tr>
<td style="width: 5.5em;">Name:</td>
<td><input type="text" id="name" value="" style="width: 100%; max-width: 400px; margin-bottom: 4px"></td>
</tr>
<tr>
<td>Tag:</td>
<td><input type="text" id="tag" value="<?= $searchTag ?>" style="width: 100%; max-width: 400px; margin-bottom: 4px;"></td>
</tr>
<tr>
<td><label for="country">Country: </label></td>
<td>
<input id="country" list="countryList" style="width: 100%; max-width: 400px;" placeholder="All countries">
<datalist id="countryList">
<?php
foreach ($countries as $country) {
echo '<option value="' . $country['iso_3166_1'] . ' - ' . $country['name'] . '">' . $country['iso_3166_1'] . ' - ' . $country['name'] . '</option>';
}
?>
</datalist>
</td>
</tr>
<tr class="space"><td colspan="2"></td></tr>
<tr>
<td colspan="2">
<div class="buttons">
<span id="btnSearch" onClick="searchRadio()">Search</span>
<span id="btnSaved" onClick="showSavedRadios()">Show saved</span>
<span id="btnClear" onClick="clearForm()">Clear</span>
</div>
</td>
<td></td>
</tr>
</table>
<div id="searchResults">
<h1><span id="searchType"></span> <span id="stationsCount"></span></h1>
<div id="stationContainer"></div>
<div style="text-align: center; padding: 1em;" id="loadingIndicator">
<i class="fa fa-cog fa-spin icon-small"></i> Loading stations list...
</div>
</div>
<script>
$("#name").focus();
<?php
if ($searchTag){
//echo 'searchRadio();';
}
?>
$('#searchRadio :input').keypress(function (e) {
var key = e.which;
if(key == 13) // the enter key code
{
searchRadio();
return false;
}
});
function searchRadio(){
$("#searchType").html('Search results');
$("#stationsCount").html('');
$("#searchResults").show();
$("#stationContainer").html('');
$("#loadingIndicator").show();
var request = $.ajax({
url: "ajax-radio.php",
type: "POST",
data: {
action : "searchRadios",
name : $("#name").val().trim(),
tag : $("#tag").val().toLowerCase().trim(),
countrycode : $("#country").val()
},
dataType: "html"
});
request.done(function(data) {
$("#stationContainer").html(data);
$("#stationContainer").show();
$("#loadingIndicator").hide();
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
}
function clearForm(){
$("#name").val('');
$("#tag").val('');
$("#country").val('');
$("#searchResults").hide();
//showSavedRadios();
}
function showSavedRadios(){
$("#searchType").html('Saved radio stations');
$("#stationsCount").html('');
$("#searchResults").show();
$("#stationContainer").html('');
$("#loadingIndicator").show();
var request = $.ajax({
url: "ajax-radio.php",
type: "POST",
data: {
action : "showSavedRadios"
},
dataType: "html"
});
request.done(function(data) {
if (data){
$("#stationContainer").html(data);
$("#stationContainer").show();
}
else {
$("#stationContainer").hide();
}
$("#loadingIndicator").hide();
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
}
$(document).ready(function() {
if ($("#name").val() != '' || $("#tag").val() != '' || $("#country").val() != ''){
searchRadio();
}
else {
showSavedRadios();
}
})
</script>
<?php
require_once('include/footer.inc.php');
?>