00001 window.onload=function(){ init(); };
00002
00003 function init(){
00004 setPageTitle();
00005 x_viewPlaylist(viewPlaylist_cb);
00006 x_playlistInfo(plinfo_cb);
00007 setPLTitle();
00008 setCurrentPage();
00009 updateBox(page,0);
00010 }
00011 function empty_cb(new_data){
00012
00013 }
00014
00015 function setPageNav(){
00016
00017 }
00018
00019 function switchPage(newpage){
00020 prevpage = page;
00021 page = newpage;
00022
00023 updateBox(page,0);
00024 setPageTitle();
00025 setCurrentPage();
00026
00027 }
00028
00029 function setPLTitle(){
00030 document.getElementById("pl_title").innerHTML = " <?php echo t("Playlist"); ?> ";
00031 }
00032
00033 function viewPlaylist_cb(new_data){
00034 document.getElementById("playlist").innerHTML = new_data;
00035 }
00036
00037 function setCurrentPage(){
00038 var x = document.getElementById('nav');
00039 var y = x.getElementsByTagName('a');
00040 for (var i=0;i < y.length;i++){
00041 y[i].removeAttribute("class");
00042 if(y[i].id == page)
00043 y[i].setAttribute('class','c');
00044 }
00045 }
00046
00047 function getDropDown(type,id){
00048 x_getDropDown(type,id,getDropDown_cb);
00049 }
00050
00051 function getDropDown_cb(new_data){
00052 ul = document.getElementById("browse_ul");
00053 ul.innerHTML = new_data;
00054 ul.style.display = 'block';
00055 }
00056
00057 function closeDropDown(){
00058 ul = document.getElementById("browse_ul");
00059 ul.style.display = 'none';
00060 ul.innerHTML = '';
00061 }
00062
00063 function savePL_cb(data){
00064 var save_form = '<h2><?php echo t('Save/Rename Playlist'); ?></h2>' +
00065 '<form onsubmit="return savePL(\'save\',this)" method="get" action="">' +
00066 '<strong><?php echo t('Playlist Name'); ?></strong><br/>' +
00067 '<?php echo t('Enter a new name for your playlist'); ?><br><br>' +
00068 '<input type="text" name="save_pl_name" id="save_pl_name" size="25" />' +
00069 '<input style="left: 350px; position: absolute;" type="submit" value="<?php echo t('Save/Rename'); ?>" />' +
00070 '</form>' +
00071 '<br><hr><br>' +
00072 '<input style="left: 350px; position: absolute;" type="button"' +
00073 ' onclick="savePL(\'close\',0); return false;" value="<?php echo t('Cancel'); ?>" />';
00074 document.getElementById("box_extra").innerHTML = save_form;
00075 document.getElementById("box_extra").style.display = 'block';
00076 }
00077
00078 function savePL(type,data){
00079 if(type=='open'){
00080 savePL_cb(data);
00081 return false;
00082 }
00083 else if(type=='save'){
00084 var pl_name = data.save_pl_name.value;
00085 x_savePlaylist(pl_name,0,save_Playlist_cb);
00086 x_playlistInfo(plinfo_cb);
00087
00088 return false;
00089 }
00090 else if(type=='close')
00091 document.getElementById("box_extra").style.display = 'none';
00092 }
00093
00094 function save_Playlist_cb(new_data){
00095 box = document.getElementById("box_extra");
00096 box.innerHTML = new_data;
00097 setTimeout("box.style.display='none'","1250");
00098 }
00099
00100 function movePLItem(direction,item){
00101 var y;
00102 var temp;
00103 var pos = 0;
00104 temp = item;
00105 while (temp.previousSibling)
00106 {
00107 pos++;
00108 temp = temp.previousSibling;
00109 }
00110
00111 if(direction == "up")
00112 y = item.previousSibling;
00113 else if(direction == "down")
00114 y = item.nextSibling;
00115
00116 if(y && y.nodeName == 'LI'){
00117 pl_move(pos, pos + ("up" == direction ? -1 : 1));
00118
00119 var temp = y.innerHTML;
00120 y.innerHTML = item.innerHTML;
00121 item.innerHTML = temp;
00122 Fat.fade_element(y.id,null,900,'#ffcc99','#f3f3f3');
00123 }
00124 }
00125
00126 function setBgcolor(id, c)
00127 {
00128 if(id != ('pl'+nowplaying)){
00129 var o = document.getElementById(id);
00130 o.style.backgroundColor = c;
00131 }
00132 }
00133
00134 function setPageTitle(){
00135 var pages= new Array()
00136 pages["browse"]="<?php echo t("Browse Music"); ?> ";
00137 pages["search"]="<?php echo t("Search Music"); ?> ";
00138 pages["random"]="<?php echo t("Create a Random Mix"); ?> ";
00139 pages["playlists"]="<?php echo t("Load a Saved Playlist"); ?> ";
00140 pages["stats"]="<?php echo t("Server Statistics"); ?> ";
00141 document.getElementById("pagetitle").innerHTML = pages[page];
00142
00143 }
00144
00145 function getRandItems(type){
00146
00147 document.getElementById("rand_items").innerHTML = '';
00148 x_getRandItems(type,getRandItems_cb);
00149 }
00150
00151 function getRandItems_cb(new_data){
00152 document.getElementById("rand_items").innerHTML = new_data;
00153 }
00154
00155 function updateBox_cb(new_data){
00156 document.getElementById("info").innerHTML = new_data;
00157 document.getElementById("loading").style.display = 'none';
00158
00159 if(clearbc==1)
00160 breadcrumb();
00161 clearbc = 1;
00162
00163 }
00164
00165 function updateBox(type,itemid){
00166 document.getElementById("loading").style.display = 'block';
00167 x_musicLookup(type,itemid,updateBox_cb);
00168
00169 if(type == 'genre' || type == 'letter'){
00170 bc_parenttype = '';
00171 bc_parentitem = '';
00172 }
00173 else if(type == 'album' || (type == 'artist' && bc_parenttype != '')){
00174 if(bc_childtype == 'all'){
00175 bc_parenttype = bc_childtype;
00176 bc_parentitem = bc_childitem;
00177 }
00178 }
00179 else if(type == 'browse' || type == 'search' || type == 'about' || type == 'prefs' || type == 'random' || type == 'admin' || type == 'playlists' || type == 'stats'){
00180
00181 bc_parenttype = '';
00182 bc_parentitem = '';
00183 itemid='';
00184 type='';
00185 }
00186 else{
00187 bc_parenttype = bc_childtype;
00188 bc_parentitem = bc_childitem;
00189 }
00190
00191 bc_childitem = itemid;
00192 bc_childtype = type;
00193
00194 }
00195
00196 function deletePlaylist(id){
00197 if(confirm("<?php echo t('Are you sure you want to DELETE THIS SAVED PLAYLIST?'); ?>")){
00198 x_deletePlaylist(id,deletePlaylist_cb);
00199 }
00200 }
00201
00202 function deletePlaylist_cb(new_data){
00203
00204 clearbc = 0;
00205 x_musicLookup('playlists',0,updateBox_cb);
00206 setMsgText("<?php echo t('Saved Playlist Successfully Deleted'); ?>");
00207
00208 if (new_data){
00209 x_viewPlaylist(viewPlaylist_cb);
00210 x_playlistInfo(plinfo_cb);
00211 }
00212 }
00213
00214 function plrem(item){
00215 var temp = item;
00216 var pos = 0;
00217 while (temp.previousSibling)
00218 {
00219 pos++;
00220 temp = temp.previousSibling;
00221 }
00222
00223 x_playlist_rem(pos,plrem_cb);
00224 }
00225
00226 function plrem_cb(rem){
00227 p = document.getElementById("playlist");
00228 d_nested = p.childNodes[rem];
00229 throwaway_node = p.removeChild(d_nested);
00230 x_playlistInfo(plinfo_cb);
00231 }
00232
00233 function pladd(type,id){
00234 x_playlist_add(type,id,pladd_cb);
00235 }
00236
00237 function pladd_cb(new_data){
00238
00239 if(new_data[0] == 1){
00240 x_viewPlaylist(viewPlaylist_cb);
00241 x_playlistInfo(plinfo_cb);
00242 }
00243 else if (new_data[0] == 2){
00244 alert(new_data[1]);
00245 }
00246 else{
00247 document.getElementById("playlist").innerHTML += new_data[0];
00248
00249 for(var i=2; i < new_data[1]+2; i++){
00250 Fat.fade_element(new_data[i],null,1400,'#B4EAA2','#f3f3f3');
00251 }
00252 x_playlistInfo(plinfo_cb);
00253 }
00254 }
00255
00256 function pl_move(item1,item2){
00257 x_playlist_move(item1,item2,pl_move_cb);
00258 }
00259
00260 function pl_move_cb(){
00261
00262 }
00263
00264 function plclear(){
00265 x_clearPlaylist(plinfo_cb);
00266 document.getElementById("playlist").innerHTML = "";
00267 }
00268
00269 function plinfo_cb(new_data){
00270 document.getElementById("pl_info").innerHTML = new_data;
00271 }
00272
00273 function breadcrumb(){
00274 x_buildBreadcrumb(page,bc_parenttype,bc_parentitem,bc_childtype,bc_childitem,breadcrumb_cb);
00275 }
00276
00277 function breadcrumb_cb(new_data){
00278
00279 document.getElementById("breadcrumb").innerHTML = new_data;
00280 }
00281
00282 function play(type,id){
00283 document.getElementById('hidden').src = null;
00284 document.getElementById("hidden").src = "<?php echo stream_url(); ?>mp3act_hidden.php?type="+type+"&id="+id;
00285 }
00286
00287 function randAdd(data){
00288 var type = data.random_type.value;
00289 if(type == ""){
00290 setMsgText("You must choose a random type");
00291 return false;
00292 }
00293 var num=0;
00294 num = data.random_count.value;
00295 var items ='';
00296 if(type != 'all'){
00297 for(var i=0;i<data.random_items.options.length;i++){
00298 if(data.random_items.options[i].selected == true)
00299 items += ',' + data.random_items.options[i].value;
00300 }
00301
00302 if(items == ""){
00303 setMsgText("You must choose at least one random item");
00304 return false;
00305 }
00306 items = items.substring(1);
00307 }
00308 x_randAdd(type,num,items,randadd_cb);
00309 return false;
00310
00311 }
00312
00313 function randadd_cb(new_data){
00314 x_viewPlaylist(viewPlaylist_cb);
00315 x_playlistInfo(plinfo_cb);
00316 }
00317
00318 function play_cb(new_data){
00319
00320 }
00321
00322 function setMsgText(text){
00323 document.getElementById("breadcrumb").innerHTML = "<span class='error'>"+text+"</span>";
00324 Fat.fade_element('breadcrumb',null,2000,'#F5C2C2','#ffffff');
00325 }
00326
00327 function searchMusic(form){
00328 if(form.searchbox.value == '' || form.searchbox.value == '[<?php echo t("enter your search terms"); ?>]'){
00329 setMsgText("You Must Enter Something to Search For");
00330 }
00331 else{
00332 document.getElementById("breadcrumb").innerHTML = "";
00333 x_searchMusic(form.searchbox.value,form.search_options.value,updateBox_cb);
00334 }
00335 return false;
00336 }