1/* common JS functions that are used throughout the app. update dummyId in kfjc-base.html 2 * so that new new code is loaded whenever making changes here. 3 */ 4 5function updatePlaylist() { 6 jQuery.ajax("/api/playlists/current.php/", { 7 dataType: "json", 8 success: function(current) { 9 var trackTitle = current.track_title || ""; 10 var trackArtist = current.artist || ""; 11 var airName = current.air_name || ""; 12 var programName = current.program_name || ""; 13 var isRebroadcast = airName.toLowerCase().indexOf("rebroadcast") >= 0; 14 var haveHost = !isRebroadcast && airName.length > 0 && programName.length > 0; 15 var haveTrack = trackTitle.length != 0; 16 17 $("#onair-dj").text(airName); 18 $("#onair-connector1").text(haveHost ? "hosts" : ""); 19 $("#onair-program").text(isRebroadcast ? "" : programName); 20 $("#onair-track").text(trackTitle); 21 $("#onair-connector2").text(haveTrack ? "by" : ""); 22 $("#onair-artist").text(trackArtist); 23 } 24 }); 25} 26 27function startUpdatePlaylist() { 28 $(document).ready(function(){ 29 updatePlaylist(); 30 setInterval(updatePlaylist, 30000); // every 30 seconds 31 }); 32} 33 34function openPopup(href) { 35 window.open( 36 href, 37 'kfjcpopupplayer', 38 'location=no,width=380,height=560,scrollbars=no,resizable=no,toolbar=no,directories=no,menubar=no,status=no' 39 ) 40} 41 42 43 44async function sendGetRequest(url = "", method='GET') { 45 console.log("send get request: " + url); 46 const args ={method: method, headers: { "Content-Type": "application/json", }}; 47 return fetch(url, args) 48 .then((response)=>{return response.json()}) 49 .then((responseJson)=>{return responseJson}) 50 .catch((error) => { 51 var msg = `Get error: ${error}`; // here when server returns html error msg. 52 return({status: msg, 'error': true}); 53 }); 54} 55 56async function sendPostRequest(url = "", data = {}) { 57 console.log("send post request: " + url); 58 const args ={method: 'POST', headers: { "Content-Type": "application/json", }, body: JSON.stringify(data)}; 59 return fetch(url, args) 60 .then((response)=>{ 61 if (response.ok) 62 return response.json() 63 else 64 return response.text().then(text => { throw new Error(text) }) 65 }).then((responseJson)=>{ 66 return responseJson}) 67 .catch((error) => { 68 console.log("post error: " + error); 69 return({status: error, 'error': true}); 70 }); 71} 72
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.