2 require_once("LinkClass.php");
3 require_once("DataEntry.php");
5 $url = '<a href="#" onclick="act(\'%s\');"><img src="/img/%s" title="%s" /></a>'."\n";
8 $controls .= sprintf( $url, 'pause', 'pause.png', 'Pause the playback');
9 $controls .= sprintf( $url, 'resume','resume.png','Resume the paused playback');
10 $controls .= sprintf( $url, 'next', 'next.png', 'Skip ahead to the next track');
11 $controls .= sprintf( $url, 'stop', 'stop.png', 'Stop playing tracks');
12 $controls .= sprintf( $url, 'clear', 'clear.png', 'Clear the currently queued tracks');
13 $controls .= sprintf( $url, 'off', 'off.png', 'Shut music server down and turn off');
16 if ( "$lltr" <> "" ) $url .= "&lltr=" . rawurlencode($lltr);
17 elseif ( "$altr" <> "" ) $url .= "&altr=" . rawurlencode($altr);
18 if ( "$a" <> "" ) $url .= "&a=" . rawurlencode($a);
19 elseif ( "$l" <> "" ) $url .= "&l=" . rawurlencode($l);
21 if ( !isset($ltrtype) ) {
23 if ( preg_match( '/album.php/', $_SERVER['REQUEST_URI']) ) $ltrtype = 'album';
26 $url = $_SERVER['PHP_SELF'] . preg_replace( '/^&/', '?', $url . '&' );
27 if ( !preg_match( '{/(artist|album)\.php}', $url) ) {
28 error_log( "$sysabbr: DBG: >>$url<< " . (preg_match('{/(artist|album)\.php}', $url)?
'true':'false') );
29 // $url = preg_replace( '{/[a-z0-9_-]+\.php}i', '/artist.php', $url );
30 $url .= sprintf('type=%s&', $ltrtype);
32 $ls = new LinkSet( '<a href="'.str_replace('%','%%',$url).'altr=%s"%s%s>%s</a>', 'alphabetica' );
33 error_log( "$sysabbr: DBG: >>$ls->template<<" );
35 $menubar = '<table width="100%" border="0"><tr class="tr_menu"><td class="h3"><span id="current_type" onclick="toggle_type();">'.ucfirst($ltrtype).'</span>s:</td><td id="alphabet">';
36 $qry = new AwlQuery("SELECT letter, pattern, $ltrtype"."_count AS count FROM letter_groups ORDER BY 1;");
37 if ( $qry->Exec("artist") && $qry->rows() > 0 ) {
38 while ( $letter = $qry->Fetch() ) {
39 $help = "Display $letter->count $ltrtype"."s beginning with the letter '$letter->letter'.";
40 $display = $letter->letter
;
41 if ( trim($letter->letter
) == "#" ) {
42 $help = 'List all '."$letter->count $ltrtype".'s not beginning with an alphabetic character.';
44 $menubar .= $ls->Link( urlencode($letter->pattern
), $display, $help );
48 // $menubar .= '<td class="h3">Search:</td>';
49 $sf = new EntryForm( $refresh_url, $GLOBALS, true );
51 $menubar .= $sf->StartForm(array('method' => 'get'));
52 if ( isset($lltr) ) $menubar .= $sf->HiddenField( 'lltr', $lltr );
53 if ( isset($altr) ) $menubar .= $sf->HiddenField( 'altr', $altr );
54 if ( isset($a) ) $menubar .= $sf->HiddenField( 'a', $a );
55 else if ( isset($l) ) $menubar .= $sf->HiddenField( 'l', $l );
56 $f = new EntryField( 'text', 'search',
57 array( 'title' => 'Enter a regular expression to search for artists / albums that match that',
58 'size' => '15', 'class' => 'search_field'),
60 $menubar .= '<td align="right">'.$f->Render().'</td>';
61 $menubar .= '<td>'.$sf->SubmitButton("submit","Search").'</td>';
62 $menubar .= $sf->EndForm();
64 $ls = new LinkSet("", "alphabetica");
65 $menubar .= '<td align="right">';
66 $menubar .= $ls->Link("/", "Home");
67 $menubar .= $ls->Link("/artist.php", "Artist");
68 $menubar .= $ls->Link("/album.php", "Album");
69 // $menubar .= $ls->Link("/genre.php", "Genre");
70 // $menubar .= $ls->Link("/stream.php", "Streams");
73 $menubar .= '</tr></table>';
75 // $menubar .= '<hr class="thin_hr">';
79 <script language="javascript"><!--
80 function toggle_type() {
81 var type_span = document.getElementById('current_type');
82 var type = type_span.innerHTML.toLowerCase();
85 if ( type == 'artist' ) { type = 'album'; }
86 else if ( type == 'album' ) { type = 'stream'; }
87 else if ( type == 'stream' ) { type = 'genre'; }
88 else if ( type == 'genre' ) { type = 'artist'; }
90 type_span.innerHTML = type.substring(0,1).toUpperCase() + type.substring(1);
92 var alphabet = document.getElementById('alphabet').childNodes;
96 var title_match = new RegExp('([0-9]+ )?' + old_type,'g');
98 for (var i = 0; i < alphabet.length; i++)
100 href = alphabet[i].href;
101 alphabet[i].href = href.replace(old_type,type);
102 title = alphabet[i].title;
103 alphabet[i].title = title.replace(title_match,type);
104 // if ( alphabet[i].innerHTML == 'F' ) {
105 // alert(alphabet[i].title);
111 var base_url = 'http://aiw/';
112 var status_req = new XMLHttpRequest();
114 var redo_queue = true;
115 function update_now_playing() {
116 var td = document.getElementById('now_playing');
117 status_req.open('GET', base_url + 'current.php', true);
118 status_req.onreadystatechange = function (aEvt) {
119 if ( status_req.readyState == 4 ) {
120 if ( status_req.status == 200 ) {
121 if ( td.innerHTML != status_req.responseText ) {
122 td.innerHTML = status_req.responseText;
123 var in_td = td.childNodes;
125 if ( in_td.length == 1 ) {
126 var nodecontent = status_req.responseText;
127 if ( nodecontent.match(/Nothing is currently playing/i) ) {
128 title = 'Adorno: stopped';
130 else if ( nodecontent.match(/paused/i) ) {
131 title = 'Adorno: paused';
133 in_td = in_td[0].childNodes;
135 for ( var i=0; i < in_td.length; i++ ) {
136 if ( in_td[i].innerHTML == undefined ) continue;
138 title = in_td[i].innerHTML;
140 title = title + ' : ' + in_td[i].innerHTML;
142 document.title = title;
145 else if ( redo_queue )
149 // td.innerHTML = "<p>Error loading page</p>";
152 status_req.send(null);
153 mytime=setTimeout('update_now_playing()',10000);
156 function update_queue() {
157 var td = document.getElementById('queue');
159 status_req.open('GET', base_url + 'queue.php', true);
160 status_req.onreadystatechange = function (aEvt) {
161 if ( status_req.readyState == 4 ) {
162 if ( status_req.status == 200 ) {
163 td.innerHTML = status_req.responseText;
166 // td.innerHTML = "<p>Error loading page</p>";
169 status_req.send(null);
172 var last_action_result = '';
173 function act( action ) {
174 var act_req = new XMLHttpRequest();
175 status_req.open('GET', base_url + 'action.php?action=' + action, true);
176 status_req.onreadystatechange = function (aEvt) {
177 if ( status_req.readyState == 4 ) {
178 if ( status_req.status == 200 ) {
179 last_action_result = 'success';
181 update_now_playing();
184 last_action_result = 'failure';
187 status_req.send(null);
190 function enqueue(artist,album,track) {
191 var act_req = new XMLHttpRequest();
192 var details = '&a=' + artist + '&l=' + album;
193 if ( track != '' ) details = details + '&t=' + track;
194 var url = base_url + 'action.php?action=enqueue' + details
196 status_req.open('GET', url, true);
197 status_req.onreadystatechange = function (aEvt) {
198 if ( status_req.readyState == 4 ) {
199 if ( status_req.status == 200 ) {
200 last_action_result = 'success';
202 update_now_playing();
205 last_action_result = 'failure';
208 status_req.send(null);
213 <td id="now_playing">Stopped</td>
222 <form id="urlform" method="POST"><input name="url" class="playurl" type="text"><input class="submit" type="submit" name="act" value="Play URL"></form>
224 <script language="javascript"><!--
225 update_now_playing();