/** * Playlist * * Manage registered user playlists */ var playlistUrl = 'playlist.php'; /** * Get cross-browser XMLHTTPRequest */ function objAjax() { var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } /** * Add video to playlist */ function addToPlaylist(videoId) { var requestObj = objAjax(); requestObj.open("GET", playlistUrl + '?vid=' + videoId, true); requestObj.onreadystatechange = function() { if (requestObj.readyState == 4) { if (requestObj.responseText == 1) // this pattern @xxx@ is handled by translateJs.php, where the therm inside is translated alert('Video Added to Playlist'); else if (confirm('You need to be signed in to add videos to your playlist. Do you want to sign up?')) location = 'login.php'; } } requestObj.send(null); }