summaryrefslogtreecommitdiff
path: root/javascript/ajax.js
blob: e838c3c9ce55dff3a7675d2d16d6d5b53d4a5785 (plain)
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
function ajax()
{
    var xhr=null;
    
    xhr = new XMLHttpRequest();
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { alert_ajax(xhr); };
        
    xhr.open("GET", "streamstatus.php", true);
    xhr.send(null);
}

function alert_ajax(xhr)
{
	if (xhr.readyState==4)
	{
		var docXML= xhr.responseXML;
		var streamstatus = null;
		var items = docXML.getElementsByTagName("streamstatus")
	
		streamstatus = items.item(0).firstChild.data;
		if ( streamstatus == 'error' )
			this.location.href = 'error.php';
		else
			swapPic();
	}
}

function playmusic(path,name)
{
    var xhr=null;

    xhr = new XMLHttpRequest();
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { openpls(xhr); };

    xhr.open("GET", "genplaylist.php?path=" + path + "&name=" + name, false);
    xhr.send(null);

}

function openpls(xhr)
{
        if (xhr.readyState==4)
        {
                var docXML= xhr.responseXML;
                var streamstatus = null;
                var items = docXML.getElementsByTagName("m3u")

                streamstatus = items.item(0).firstChild.data;
                if ( streamstatus == 'error' ) {
                        this.location.href = 'error.php';
               		}
                
		//this.location.href = 'playlist/playlist.m3u';        
		//document.s1.Play();
	}		
}