rework workarounds for crypto modules renamed in 2.6.24 & 2.6.25, add workaround...
[openwrt.git] / package / fonera-mp3 / src / cgi / json.js
1 var alpmp3_playtime = 0;
2 var alpmp3_state = 0;
3 var alpmp3_ip = "";
4 var obj_volume;
5 var obj_bass;
6 var obj_playtime;
7 var obj_sate;
8 var obj_filename;
9 var MP3Object;
10 var is_setup = 0;
11
12 function alpmp3_ajax_new_data(){
13 obj_bass.firstChild.nodeValue = MP3Object.alpmp3.bass;
14 obj_volume.firstChild.nodeValue = MP3Object.alpmp3.volume;
15 obj_state.firstChild.nodeValue = MP3Object.alpmp3.type;
16 obj_filename.firstChild.nodeValue = MP3Object.alpmp3.filename;
17 alpmp3_state = MP3Object.alpmp3.state;
18 if(Math.abs(alpmp3_playtime - MP3Object.alpmp3.playtime) > 1){
19 alpmp3_playtime = MP3Object.alpmp3.playtime;
20 }
21 }
22
23 function alpmp3_update_data(url){
24 var data;
25 var http_request = new XMLHttpRequest();
26 http_request.open("GET", url, true);
27 http_request.onreadystatechange = function () {
28 if (http_request.readyState == 4) {
29 if (http_request.status == 200) {
30 MP3Object = eval("(" + http_request.responseText + ")");
31 alpmp3_ajax_new_data();
32 } else {
33 alert("There was a problem with the URL.");
34 }
35 http_request = null;
36 }
37 }
38 http_request.send(null);
39 self.setTimeout("alpmp3_update_data('mp3_json.cgi');", 4000);
40 }
41
42 function alpmp3_remote(cmd){
43 var doit = "";
44 switch(cmd){
45 case 'volup':
46 if(MP3Object.alpmp3.volume < 30){
47 MP3Object.alpmp3.volume++;
48 }
49 doit = "?vol=" + MP3Object.alpmp3.volume;
50 break;
51 case 'voldown':
52 if(MP3Object.alpmp3.volume > 0){
53 MP3Object.alpmp3.volume--;
54 }
55 doit = "?vol=" + MP3Object.alpmp3.volume;
56 break;
57 case 'bassup':
58 if(MP3Object.alpmp3.bass < 30){
59 MP3Object.alpmp3.bass++;
60 }
61 doit = "?bass=" + MP3Object.alpmp3.bass;
62 break;
63 case 'bassdown':
64 if(MP3Object.alpmp3.volume < 30){
65 MP3Object.alpmp3.bass--;
66 }
67 doit = "?bass=" + MP3Object.alpmp3.bass;
68 break;
69 case 'stop':
70 doit = "?stop=1";
71 break;
72 case 'start':
73 doit = "?start=1";
74 break;
75 case 'next':
76 doit = "?next=1";
77 break;
78 case 'back':
79 doit = "?back=1";
80 break;
81 }
82 if(doit != ""){
83 var http_request2 = new XMLHttpRequest();
84 http_request2.open("GET", 'mp3_cmd.cgi'+doit, true);
85 http_request2.onreadystatechange = function () {
86 if (http_request2.readyState == 4) {
87 if (http_request2.status == 200) {
88 alpmp3_ajax_new_data();
89 } else {
90 alert("There was a problem with the URL.");
91 }
92 http_request2 = null;
93 }
94 }
95 http_request2.send(null);
96 }
97
98 }
99
100 function alpmp3_timeout(){
101 alpmp3_state = 0;
102 alert(alpmp3_playtime);
103 }
104
105 function alpmp3_playtime_update(){
106 self.setTimeout("alpmp3_playtime_update()", 1000);
107 if(alpmp3_state > 0){
108 alpmp3_playtime ++;
109 } else {
110 alpmp3_playtime = 0;
111 }
112 var s = alpmp3_playtime;
113 var h = 0;
114 var m = 0;
115 while(s > 3599){
116 h++;
117 s -= 3600;
118 }
119 while(s > 59){
120 m++;
121 s -= 60;
122 }
123 ptime = ((m < 10) ? "0" : "") + m + ":" + ((s < 10) ? "0" : "") + s;
124 if(h > 0){
125 ptime = ((h < 10) ? "0" : "") + h + ":" + ptime;
126 }
127 obj_playtime.firstChild.nodeValue = ptime;
128 }
129
130 function alpmp3_setup($ip){
131 if(is_setup == 0){
132 obj_volume = document.getElementById("alpmp3_volume");
133 obj_bass = document.getElementById("alpmp3_bass");
134 obj_state = document.getElementById("alpmp3_state");
135 obj_filename = document.getElementById("alpmp3_filename");
136 obj_playtime = document.getElementById("alpmp3_playtime");
137 is_setup = 1;
138 }
139 self.setTimeout("alpmp3_update_data('mp3_json.cgi');", 4000);
140 self.setTimeout("alpmp3_playtime_update()", 1000);
141 }
This page took 0.054385 seconds and 5 git commands to generate.