/[cvs]/nfo/php/scripts/gdwebint/public_html/js.js
ViewVC logotype

Annotation of /nfo/php/scripts/gdwebint/public_html/js.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Fri Apr 1 02:12:46 2005 UTC (19 years, 3 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
File MIME type: application/javascript
+ Feature: Activate specified playlist (via gdkeypad.pl)

1 joko 1.1 <!--
2    
3     // Common Functions
4    
5     function eMail(address) {
6     while (address != s) {
7     var s = address;
8     address = address.replace(/\sat\s/,"@");
9     address = address.replace(/\sdot\s/,".");
10     address = address.replace(/\sminus\s/,"-");
11     }
12     document.location.href = "mailto:" + address;
13     }
14    
15     function setHighlight(highlight,obj) {
16     if (highlight == 1) obj.style.backgroundColor = '#F4F4F4';
17     else obj.style.backgroundColor = '#FFFFFF';
18     }
19    
20     function setBgColor(obj,c) {
21     obj.style.backgroundColor = c;
22     }
23    
24     function gotoURL(wnd,addr) {
25     switch(wnd) {
26     case '_blank': window.open(addr,wnd); break;
27     case '_top': top.location.href = addr; break;
28     case '_parent': parent.location.href = addr; break;
29     case '_self': default: document.location.href = addr; break;
30     }
31     }
32    
33     function trimStr(str) {
34     while (str.charAt(0) == ' ') str = str.substr(1,str.length);
35     while (str.charAt(str.length-1) == ' ') str = str.substr(0,str.length-1);
36     return str;
37     }
38    
39     function goLegend(sid,highlight) {
40     if (!highlight) u = 'index.php?mode=legend&sid='+sid;
41     else u = 'index.php?mode=legend&highlight='+highlight+'&sid='+sid+'#'+highlight;
42    
43     window.open(u,'','height=400,width=500,dependent=yes,menubar=no,location=no,resizable=no,status=no,toolbar=no,scrollbars=yes');
44     return false;
45     }
46    
47     function clickRow(id,special,cycle) {
48     rowid = (special)?'special':'row';
49     if (!document.getElementById(rowid+id)) return false;
50    
51     box = document.getElementById('checkbox'+id);
52     row = document.getElementById(rowid+id);
53    
54     if (box) box.checked = !box.checked;
55     hoverRow(id,'over',special,cycle);
56     }
57    
58     function hoverRow(id,mode,special,cycle) {
59     rowid = (special)?'special':'row';
60     if (!document.getElementById(rowid+id)) return false;
61    
62     row = document.getElementById(rowid+id);
63     ischecked = (document.getElementById('checkbox'+id))?document.getElementById('checkbox'+id).checked:false;
64    
65     if (special) {
66     if (mode == 'over') {
67     row.style.backgroundColor = '#D5FFD5';
68     } else if (mode == 'out') {
69     if (ischecked) row.style.backgroundColor = (cycle)?'#E6FFE6':'#F2F9FF';
70     else row.style.backgroundColor = (cycle)?'#E6FFE6':'';
71     }
72     } else {
73     if (mode == 'over') {
74     row.style.backgroundColor = '#CEE7FF';
75     } else if (mode == 'out') {
76     if (ischecked) row.style.backgroundColor = (cycle)?'#E8F3FF':'#F2F9FF';
77     else row.style.backgroundColor = (cycle)?'#F4F4F4':'';
78     }
79     }
80     }
81    
82     function demoInfo() {
83     alert('This is an online demo version.\n\nYou cannot edit, delete or add\nanything here.');
84     }
85    
86     function setCheckboxes(aFormId, aElementsName, aCheck) {
87     if (!document.getElementById(aFormId)) return false;
88     if (!document.getElementById(aFormId).elements[aElementsName]) return false;
89    
90     elm = document.getElementById(aFormId).elements[aElementsName];
91     for (var i=0; i<elm.length; i++) {
92     elm[i].checked = aCheck;
93     col = (i % 2 == 0)?'#F4F4F4':'';
94     special = elm[i].id.substr(0,7) == 'special';
95     hoverRow(elm[i].value,'out',special,col);
96     }
97     }
98    
99     function setCheckboxesBetween(aFormId, aElementsName, aCheck) {
100     if (!document.getElementById(aFormId)) return false;
101     if (!document.getElementById(aFormId).elements[aElementsName]) return false;
102    
103     var first = -1; var last = -1;
104    
105     elm = document.getElementById(aFormId).elements[aElementsName];
106     for (var i=0; i<elm.length; i++) {
107     if (elm[i].checked && first == -1) first = i;
108     if (elm[i].checked && first > -1 && first != i) last = i;
109     }
110    
111     if (first == -1 || last == -1) {
112     alert('Please select at least two checkboxes.');
113     return false;
114     }
115    
116     for (var i=first; i<=last; i++) {
117     elm[i].checked = aCheck;
118     col = (i % 2 == 0)?'#F4F4F4':'';
119     special = elm[i].id.substr(0,7) == 'special';
120     hoverRow(elm[i].value,'out',special,col);
121     }
122     }
123    
124     function setCheckbox(aCheckboxId, aCheck) {
125     if (!document.getElementById(aCheckboxId)) return false;
126     document.getElementById(aCheckboxId).checked = aCheck;
127     }
128    
129     function swapCheckbox(aCheckboxId) {
130     if (!document.getElementById(aCheckboxId)) return false;
131     document.getElementById(aCheckboxId).checked = !document.getElementById(aCheckboxId).checked;
132     }
133    
134     function checkRadio(aRadioId) {
135     if (!document.getElementById(aRadioId)) return false;
136     document.getElementById(aRadioId).checked = true;
137     }
138    
139     // Hint Functions
140    
141     function showTip(current,e,html) {
142     if (document.getElementById) {
143     if (window.pageYOffset && window.pageYOffset > 0) { scrlTp = window.pageYOffset; }
144     else if (document.body && document.body.scrollTop && document.body.scrollTop > 0) { scrlTp = document.body.scrollTop; }
145     else { scrlTp = 0; }
146    
147     ttip = document.getElementById("tooltip");
148     ttip.innerHTML = html;
149    
150     ttip.style.width = "auto";
151     ttip.style.minWidth = "20px";
152     ttip.style.maxWidth = "280px";
153     ttip.style.height = current.style.height;
154     ttip.style.left = parseInt(e.clientX+10);
155     ttip.style.top = parseInt(e.clientY+scrlTp+20);
156     ttip.style.visibility = "visible";
157     }
158     else if (document.layers) {
159     theString = "<div class='ttip'>"+html+"</div>";
160     document.tooltip.document.write(theString);
161     document.tooltip.document.close();
162     document.tooltip.left = e.pageX+10;
163     document.tooltip.top = e.pageY+window.pageYOffset+10;
164     document.tooltip.visibility = "show";
165     }
166     }
167    
168     function hideTip(){
169     if (document.getElementById) { document.getElementById("tooltip").style.visibility = "hidden"; }
170     else if(document.layers) { document.tooltip.visibility = "hidden"; }
171     }
172    
173     document.write('<div id="tooltip" class="ttip" style="position: absolute; visibility:hidden; z-index: 0;"></div>');
174    
175     // Single Track Functions
176    
177     function goTrackSingleEdit(id,sid) {
178     document.location.href = 'edit.php?id='+id+'&sid='+sid;
179     }
180    
181     function goTrackSingleDelete(id,sid) {
182     g = confirm('Do you really want to delete\nthe selected file and its associated\ndatabase-entry?');
183     if (g) document.location.href = 'delete.php?mode=track&id='+id+'&sid='+sid;
184     }
185    
186     function goTrackSingleAdd(id,sid) {
187     document.location.href = 'playlists.php?mode=add&id='+id+'&sid='+sid;
188     }
189    
190     function goTrackdownload_singledownload(id,sid) {
191     document.location.href = 'download.php?id='+id+'&sid='+sid;
192     }
193    
194     // Bla
195     function getCheckedCount(form_id, elements_name) {
196     f = document.getElementById(form_id);
197     if (!f) return false;
198    
199     el = f.elements[elements_name];
200     if (!el) return false;
201    
202     for (var i=0, r=0; i<el.length; i++) {
203     if (el[i].checked) r++;
204     }
205    
206     return r;
207     }
208    
209     // Multi Track Functions
210    
211     function goTrackMultiEdit(form_id,elements_name) {
212     f = document.getElementById(form_id);
213     if (!f) return false;
214    
215     el = getCheckedCount(form_id,elements_name);
216     if (el > 0) {
217     f.mode.value = "multi";
218     f.action = "edit.php";
219     f.submit();
220     } else {
221     alert('Please select the entries you want to edit.');
222     }
223     }
224    
225     function goTrackMultiDelete(form_id,elements_name) {
226     f = document.getElementById(form_id);
227     if (!f) return false;
228    
229     el = getCheckedCount(form_id,elements_name);
230     if (el > 0) {
231     if (!confirm('Do you really want to delete ' + el + ' file/s\nfrom your hard disk, your database and all your playlists?')) return false;
232    
233     f.mode.value = "multi";
234     f.action = "delete.php";
235     f.submit();
236     } else {
237     alert('Please select the files you want to delete.');
238     }
239     }
240    
241     function goTrackMultiAdd(form_id,elements_name) {
242     f = document.getElementById(form_id);
243     if (!f) return false;
244    
245     el = getCheckedCount(form_id,elements_name);
246     if (el > 0) {
247     f.mode.value = "add";
248     f.action = "playlists.php";
249     f.submit();
250     } else {
251     alert('Please select the files you want to add\nto the playlist.');
252     }
253     }
254    
255     function goTrackdownload_multidownload(form_id,elements_name) {
256     f = document.getElementById(form_id);
257     if (!f) return false;
258    
259     el = getCheckedCount(form_id,elements_name);
260     if (el > 0) {
261     f.mode.value = "gzip";
262     f.action = "download.php";
263     f.submit();
264     } else {
265     alert('Please select the files you want to download.');
266     }
267     }
268    
269     function goTrackMultiPlay(form_id,elements_name) {
270     f = document.getElementById(form_id);
271     if (!f) return false;
272    
273     el = getCheckedCount(form_id,elements_name);
274     if (el > 0) {
275     f.mode.value = "playlist";
276     f.action = "download.php";
277     f.submit();
278     } else {
279     alert('Please select the files you want to download.');
280     }
281     }
282    
283     // Single Album Functions
284    
285     function goAlbumSingleAdd(id,sid) {
286     document.location.href = 'playlists.php?mode=albumadd&id='+id+'&sid='+sid;
287     }
288    
289     function goAlbumSinglePlay(id,sid) {
290     document.location.href = 'download.php?mode=album&id='+id+'&sid='+sid;
291     }
292    
293     function goAlbumSingleEdit(id,sid) {
294     document.location.href = 'edit.php?mode=album&id='+id+'&sid='+sid;
295     }
296    
297     function goAlbumSingleShow(id,sid) {
298     document.location.href = 'browse.php?mode=albums&id='+id+'&sid='+sid;
299     }
300    
301     function goAlbumSingleDelete(id,sid) {
302     g = confirm('Do you really want to delete\nthe selected album?\n\nWarning: This will delete all files, database\r\nentries and all playlist-entries!');
303     if (g) document.location.href = 'delete.php?mode=album&id='+id+'&sid='+sid;
304     }
305    
306     // Multi Album Functions
307    
308     function goAlbumMultiEdit(form_id,elements_name) {
309     f = document.getElementById(form_id);
310     if (!f) return false;
311    
312     el = getCheckedCount(form_id,elements_name);
313     if (el > 0) {
314     f.mode.value = "multialbum";
315     f.action = "edit.php";
316     f.submit();
317     } else {
318     alert('Please select the albums you want to edit.');
319     }
320     }
321    
322     function goAlbumMultiAdd(form_id,elements_name) {
323     f = document.getElementById(form_id);
324     if (!f) return false;
325    
326     el = getCheckedCount(form_id,elements_name);
327     if (el > 0) {
328     f.mode.value = "albummultiadd";
329     f.action = "playlists.php";
330     f.submit();
331     } else {
332     alert('Please select the albums you want to add.');
333     }
334     }
335    
336     function goAlbumMultiPlay(form_id,elements_name) {
337     alert('Not yet supported!');
338     }
339    
340     // Single Playlist Functions
341    
342     function goPlaylistSingleEntryDelete(pid,track,sid) {
343     document.location.href = 'playlists.php?mode=deleteentry&pid='+pid+'&track='+track+'&sid='+sid;
344     }
345    
346     function goPlaylistSingleEntryMoveUp(pid,track,sid) {
347     if (track == 1) {
348     alert('It is not possible to move up this entry.');
349     return;
350     }
351    
352     document.location.href = 'playlists.php?mode=moveup&pid='+pid+'&track='+track+'&sid='+sid;
353     }
354    
355     function goPlaylistSingleEntryMoveDown(pid,track,sid,cnt) {
356     if (track == cnt) {
357     alert('It is not possible to move down this entry.\nNote: This is the last entry!');
358     return;
359     }
360    
361     document.location.href = 'playlists.php?mode=movedown&pid='+pid+'&track='+track+'&sid='+sid;
362     }
363    
364    
365     function goPlaylistSingleDelete(id,sid) {
366     g = confirm('Do you really want to delete\nthe selected playlist?\n\nInfo: No files will be deleted.');
367     if (g) document.location.href = 'playlists.php?mode=delete&id='+id+'&sid='+sid;
368     }
369    
370     function goPlaylistSingleEmpty(id,sid) {
371     g = confirm('Do you really want to empty\nthe selected playlist?\n\nInfo: No files will be deleted.');
372     if (g) document.location.href = 'playlists.php?mode=empty&id='+id+'&sid='+sid;
373     }
374    
375     function goPlaylistSingleActivate(id,sid) {
376     document.location.href = 'playlists.php?mode=activate&id='+id+'&sid='+sid;
377     }
378    
379     function goPlaylistSingleEdit(id,sid) {
380     document.location.href = 'playlists.php?mode=edit&id='+id+'&sid='+sid;
381     }
382    
383     function goPlaylistSinglePlay(id,sid) {
384     document.location.href = 'playlists.php?mode=play&id='+id+'&sid='+sid;
385     }
386    
387     function goPlaylistSingleShow(id,sid) {
388     document.location.href = 'playlists.php?mode=show&id='+id+'&sid='+sid;
389     }
390    
391     function goPlaylistSingleShuffle(id,sid) {
392     document.location.href = 'playlists.php?mode=shuffle&id='+id+'&sid='+sid;
393     }
394    
395     // Multi Playlist Functions
396    
397     function goPlaylistMultiDelete(form_id,elements_name) {
398     f = document.getElementById(form_id);
399     if (!f) return false;
400    
401     el = getCheckedCount(form_id,elements_name);
402     if (el > 0) {
403     if (!confirm('Do you really want to delete\nthe selected playlists?\n\nInfo: No files will be deleted.')) return false;
404    
405     f.mode.value = "delete";
406     f.action = "playlists.php";
407     f.submit();
408     } else {
409     alert('Please select the playlists you want to delete.');
410     }
411     }
412    
413     function goPlaylistMultiEntriesDelete(form_id,elements_name) {
414     f = document.getElementById(form_id);
415     if (!f) return false;
416    
417     el = getCheckedCount(form_id,elements_name);
418     if (el > 0) {
419     f.mode.value = "deleteentries";
420     f.action = "playlists.php";
421     f.submit();
422     } else {
423     alert('Please select the entries you want to delete.');
424     }
425     }
426    
427     function goPlaylistMultiPlay(form_id,elements_name,shuffle) {
428     f = document.getElementById(form_id);
429     if (!f) return false;
430    
431     el = getCheckedCount(form_id,elements_name);
432     if (el > 0) {
433     f.mode.value = "multiplaylist"+shuffle;
434     f.action = "download.php";
435     f.submit();
436     } else {
437     alert('Please select the playlists you want to play.');
438     }
439     }
440    
441     function goPlaylistMultiEdit(form_id,elements_name) {
442     f = document.getElementById(form_id);
443     if (!f) return false;
444    
445     el = getCheckedCount(form_id,elements_name);
446     if (el > 0) {
447     alert('Not yet supported');
448     // f.mode.value = "multiplaylist";
449     // f.action = "edit.php";
450     // f.submit();
451     } else {
452     alert('Please select the playlists you want to play.');
453     }
454     }
455    
456     function goPlaylistMultiEmpty(form_id,elements_name) {
457     f = document.getElementById(form_id);
458     if (!f) return false;
459    
460     el = getCheckedCount(form_id,elements_name);
461     if (el > 0) {
462     if (!confirm('Do you really want to empty\nthe selected playlists?\n\nInfo: No files will be deleted.')) return false;
463    
464     f.mode.value = "multiempty";
465     f.action = "playlists.php";
466     f.submit();
467     } else {
468     alert('Please select the playlists you want to empty.');
469     }
470     }
471    
472     function goPlaylistMultiDownload(form_id,elements_name) {
473     f = document.getElementById(form_id);
474     if (!f) return false;
475    
476     el = getCheckedCount(form_id,elements_name);
477     if (el > 0) {
478     alert('Not yet supported');
479     // f.mode.value = "multiplaylist";
480     // f.action = "download.php";
481     // f.submit();
482     } else {
483     alert('Please select the playlists you want to download.');
484     }
485     }
486    
487     // Single Browse-Artist Functions
488    
489     function goArtistSingleShow(artist,sid) {
490     document.location.href = 'browse.php?artist='+artist+'&sid='+sid;
491     }
492    
493     function goArtistSingleAdd(artist,sid) {
494     document.location.href = 'playlists.php?mode=artistadd&artist='+artist+'&sid='+sid;
495     }
496    
497     function goArtistSinglePlay(artist,sid) {
498     document.location.href = 'download.php?mode=artist&artist='+artist+'&sid='+sid;
499     }
500    
501     // Multi Browse-Artist Functions
502    
503     function goArtistMultiPlay(form_id,elements_name,shuffle,sid) {
504     f = document.getElementById(form_id);
505     if (!f) return false;
506    
507     el = f.elements[elements_name];
508     if (!el) return false;
509    
510     elc = getCheckedCount(form_id,elements_name);
511     if (elc > 0) {
512     qstr = '';
513     shuffle = (shuffle)?1:0;
514    
515     for (var i=0, r=0; i<el.length; i++) {
516     if (!el[i].checked) continue;
517     nam = document.getElementById('name'+el[i].value);
518     if (!nam) continue;
519     qstr = qstr+'&artist[]='+nam.value;
520     }
521    
522     if (qstr == "") {
523     alert('Please select the artists you want to play.');
524     return false;
525     }
526    
527     document.location.href = 'download.php?mode=multiartist&shuffle='+shuffle+qstr+'&sid='+sid;
528     } else {
529     alert('Please select the artists you want to play.');
530     }
531     }
532    
533     function goArtistMultiAdd(form_id,elements_name,sid) {
534     f = document.getElementById(form_id);
535     if (!f) return false;
536    
537     el = f.elements[elements_name];
538     if (!el) return false;
539    
540     elc = getCheckedCount(form_id,elements_name);
541     if (elc > 0) {
542     qstr = '';
543    
544     for (var i=0, r=0; i<el.length; i++) {
545     if (!el[i].checked) continue;
546     nam = document.getElementById('name'+el[i].value);
547     if (!nam) continue;
548     qstr = qstr+'&artist[]='+nam.value;
549     }
550    
551     if (qstr == "") {
552     alert('Please select the artists you want to add.');
553     return false;
554     }
555    
556     document.location.href = 'playlists.php?mode=artistmultiadd'+qstr+'&sid='+sid;
557     } else {
558     alert('Please select the artists you want to add.');
559     }
560     }
561    
562     function goArtistMultiDelete(form_id,elements_name,sid) {
563     f = document.getElementById(form_id);
564     if (!f) return false;
565    
566     el = f.elements[elements_name];
567     if (!el) return false;
568    
569     elc = getCheckedCount(form_id,elements_name);
570     if (elc > 0) {
571     qstr = '';
572    
573     for (var i=0, r=0; i<el.length; i++) {
574     if (!el[i].checked) continue;
575     nam = document.getElementById('name'+el[i].value);
576     if (!nam) continue;
577     qstr = qstr+'&artist[]='+nam.value;
578     }
579    
580     if (qstr == "") {
581     alert('Please select the artists you want to delete.');
582     return false;
583     }
584    
585     document.location.href = 'delete.php?mode=multiartist'+qstr+'&sid='+sid;
586     } else {
587     alert('Please select the artists you want to delete.');
588     }
589     }
590    
591    
592     // Player Functions
593    
594     function playerUpdate(start,fpsec,fplayed,ftotal,state,mode) {
595     pin = document.getElementById('player');
596     if (!pin) return false;
597    
598     // time between now and 'start'
599     now = new Date();
600     startOffset = Math.round((now.getTime() - start.getTime())/1000);
601    
602     // state
603     if (state == 'pl') stateStr = 'playing...';
604     else if (state == 'st') stateStr = 'stopped';
605     else if (state == 'in') stateStr = 'paused';
606     else if (state == 'ff') stateStr = 'fast forward...';
607     else if (state == 'rw') stateStr = 'fast rewind...';
608    
609     // calculate total time and played time
610     lengthTotalSec = Math.round(ftotal/fpsec);
611     playedTotalSec = Math.round(fplayed/fpsec)+startOffset;
612    
613     lengthMin = Math.floor(lengthTotalSec/60);
614     lengthSec = Math.ceil(lengthTotalSec%60);
615     lengthStr = lengthMin + ':' + ((lengthSec < 10)?"0"+lengthSec:lengthSec);
616    
617     playedMin = Math.floor(playedTotalSec/60);
618     playedSec = Math.ceil(playedTotalSec%60);
619     playedStr = playedMin + ':' + ((playedSec < 10)?"0"+playedSec:playedSec);
620    
621     // Display (playing)
622     if (lengthTotalSec > playedTotalSec) {
623     pin.value = playedStr + ' / ' + lengthStr + ' ' + stateStr;
624     if (state == 'pl') setTimeout("playerUpdate(start,"+fpsec+","+fplayed+","+ftotal+",'"+state+"',"+mode+");",500);
625     }
626    
627     // Display (finished)
628     else if (lengthTotalSec > 0) {
629     stateStr = 'stopped';
630     pin.value = lengthStr + ' / ' + lengthStr + ' ' + stateStr;
631    
632     // if the player-mode is "real", reload the
633     // page two seconds after the end of the track
634     if (mode == 2) setTimeout("self.location.reload()",2000);
635     }
636     }
637    
638 joko 1.2 function goPlayerControl(command,isreal,sid, command_arg) {
639     document.location.href = 'index.php?mode=player&command='+command+'&command_arg='+command_arg+'&isreal='+isreal+'&sid='+sid;
640 joko 1.1 }
641    
642    
643     //-->

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed