var dont_select_tree_node = false;
var last_selected_album_from_artist = false;
var from_cellclick = false;
var youtube_window = false;
var cooliris_window = false;
var user_editor = "";
var setup_editor = "";
var player_window = false;
var cooliris_dont_reload = false;
var queryStore = new Array();
var history_position = 0;
function open_cooliris()
{
// Some sample html
if(!cooliris_window)
{
var feed = escape("album_feed.php?query=" + album_obj.getStore().baseParams.query + "&fields=" + album_obj.getStore().baseParams.fields + "&sort=" + album_obj.getStore().sortInfo.field + "&sort_dir=" + album_obj.getStore().sortInfo.direction);
var html = [
'
'
];
cooliris_window = new Ext.Window({
layout: 'fit',
title: "Albums",
id: 'cooliris_windowID',
width: 655,
bodyStyle: 'padding: 5px;',
height: 420,
stateful: false,
resizeable: false,
closeAction:'close',
autoScroll: true,
html: html.join(''),
plain: false,
listeners:
{
close:function(p)
{
cooliris_window = "";
}
}
});
cooliris_window.show();
}
}
function cut_array_to_n_elements(data,n)
{
var result = new Array();
for(i=0;i 3 ? matches[2].length % 3 : 0;
return (matches[1] ? matches[1] : '') + (remainder ? matches[2].substr(0, remainder) + thousands_sep : '') + matches[2].substr(remainder).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep) + (decimals ? dec_point + (+matches[3] || 0).toFixed(decimals).substr(2) : '');
}
function expand_nodes(step,path_array,node)
{
if(step<=(path_array.length - 1))
{
if(path_array[step]=="")
var new_node = node.findChild( "my_root", 1 );
else
var new_node = node.findChild( "name", path_array[step] );
if(new_node)
{
new_node.expand(false,true,function() {
step = step + 1;
if(step<=(path_array.length - 1))
expand_nodes(step,path_array,new_node);
else
{
dont_select_tree_node = true;
new_node.select();
}
}
);
}
}
}
function open_path(path)
{
var store = Ext.getCmp("mp3_list").getStore();
if(store.lastOptions && store.lastOptions.params)
store.lastOptions.params[store.paramNames.start] = 0;
if(path) store.baseParams.full_path = path;
else store.baseParams.full_path = "";
store.baseParams.albumID = 0;
store.baseParams.artistID = 0;
var letter = store.baseParams.letter_filter;
if(letter)
Ext.getCmp('button_filter[' + letter + ']').toggle(false);
Ext.getCmp('button_filter[]').toggle(true);
store.baseParams.letter_filter = '';
mp3_list_obj.last_filter = '';
Ext.getCmp("main_search_fieldID").setValue('');
Ext.getCmp("main_search_full_text_fieldID").setValue('');
store.baseParams.fields = "";
store.baseParams.query = "";
store.baseParams.full_text_search = "";
store.reload({
callback: function()
{
path = "/" + path;
var path_array = path.split("/");
var current_node = Ext.getCmp("dir_treeID").getRootNode();
expand_nodes(0,path_array,current_node);
}
});
}
function addslashes( str ) {
return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}
function extras_menu(data,from)
{
return new Ext.menu.Menu({
items: [
{
myid: 'youtube-entry',
iconCls:'icon-youtube',
text:'Videos on youtube'
}
,
{
myid: 'lyrics-entry',
iconCls:'icon-lyrics',
text:'Lyrics'
}
,new Ext.menu.Separator(),
{
myid: 'download-entry',
iconCls:'icon-download',
text:'Download'
}
,
{
myid: 'edit-entry',
iconCls:'icon-cd-edit',
text:'Edit'
}
],
listeners: {
itemclick: function(item) {
var node = item.parentMenu.contextNode;
switch (item.myid) {
case 'youtube-entry':
var title = data.title;
if(data.artist)
title = data.artist + " - " + title;
if(youtube_window)
youtube_window.close();
youtube_window = new Ext.Window({
layout: 'fit',
tbar: [
{ iconCls: 'icon-left', id: 'youtube_back', disabled: 'true', text: 'Back', handler: function(){
Ext.getCmp("youtube_forward").enable();
Ext.getCmp("youtube_windowID").body.update(youtube_cache_page1);
Ext.getCmp("youtube_back").disable();
}},
{ iconCls: 'icon-right', id: 'youtube_forward', disabled: 'true', text: 'Forward', handler: function(){
Ext.getCmp("youtube_back").enable();
Ext.getCmp("youtube_windowID").body.update(youtube_cache_page2);
Ext.getCmp("youtube_forward").disable();
}}],
id: 'youtube_windowID',
title: title,
width: 510,
height: 454,
bodyStyle: 'padding: 5px;',
resizable: false,
closeAction:'close',
autoScroll: true,
autoLoad: {
url: 'youtube_list.php',
params: 'title=' + encodeURIComponent(data.title) + "&artist=" + encodeURIComponent(data.artist),
callback: function(el,success,response,options) {
youtube_cache_page1 = response.responseText;
}
},
plain: false
});
youtube_window.show();
break;
case 'lyrics-entry':
var title = data.title;
if(data.artist)
title = data.artist + " - " + title;
win = new Ext.Window({
layout: 'fit',
title: title,
id: 'lyrics_windowID',
width: 500,
bodyStyle: 'padding: 5px;',
height: 500,
closeAction:'close',
autoScroll: true,
autoLoad: {url: 'lyrics.php', params: 'action=getSong&title=' + encodeURIComponent(data.title) + "&artist=" + encodeURIComponent(data.artist)},
plain: false
});
win.show();
break;
case 'download-entry':
if(DEMO_MODE)
{
Ext.MessageBox.show({
title: 'Demo-Version',
msg: 'The download of songs is not available in the demo.',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
}
else
window.open("download.php?ID=" + data.ID);
break;
case 'edit-entry':
var tag_editor_form = new Ext.form.FormPanel({
baseParams: { },
baseCls: 'x-plain',
labelWidth: 60,
id: 'tag_editor_formID',
url:'save-form.php',
defaultType: 'textfield',
items: [{
fieldLabel: 'Filename',
name: 'filename',
anchor:'100%', // anchor width by percentage
allowBlank: false
},{
fieldLabel: 'Artist',
name: 'artist',
anchor:'100%' // anchor width by percentage
},{
fieldLabel: 'Title',
name: 'title',
anchor: '100%' // anchor width by percentage
},{
fieldLabel: 'Album',
name: 'album',
anchor: '100%' // anchor width by percentage
},{
fieldLabel: 'Genre',
name: 'genre',
anchor: '100%' // anchor width by percentage
},{
fieldLabel: 'year',
name: 'year',
width: '50' // anchor width by percentage
},{
fieldLabel: 'Track #',
name: 'track',
width: '50' // anchor width by percentage
}]
});
var tag_editor = new Ext.Window({
title: 'Tag-Editor',
width: 500,
height:270,
minWidth: 300,
minHeight: 270,
layout: 'fit',
plain:true,
bodyStyle:'padding:5px;',
buttonAlign:'center',
items: tag_editor_form,
buttons: [{
iconCls: 'icon-accept',
text: 'Save',
handler: function()
{
if(DEMO_MODE)
{
Ext.MessageBox.show({
title: 'Demo-Version',
msg: 'The import of tags is not available in the demo',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
}
else
{
tag_editor_form.getForm().baseParams.ID = data.ID;
tag_editor_form.getForm().baseParams.old_filename = htmlspecialchars_decode(data.filename);
tag_editor_form.getForm().baseParams.full_path = htmlspecialchars_decode(data.full_path);
tag_editor_form.getForm().baseParams.artistID = data.artistID;
tag_editor_form.getForm().baseParams.albumID = data.albumID;
tag_editor_form.getForm().baseParams.year = data.year;
tag_editor_form.getForm().baseParams.old_artist = htmlspecialchars_decode(data.artist);
tag_editor_form.getForm().baseParams.old_album = htmlspecialchars_decode(data.album);
tag_editor_form.getForm().submit(
{
url:'save_tags.php',
waitMsg:'Saving...',
success:function(form, action)
{
if(action.result.msg)
Ext.Msg.alert('Saving...', action.result.msg);
if(from=="mp3_list")
mp3_list_obj.getStore().reload();
else if(from=="play_list")
playlist_obj.getStore().reload();
tag_editor.close();
},
failure:function(form, action)
{
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Error', 'Invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Error', 'Ajax-communication with server failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Error', action.result.msg);
}
tag_editor.close();
}
})
}
}
},{
iconCls: 'icon-cancel',
text: 'Cancel',
handler: function()
{
tag_editor.close();
}
}
]
});
tag_editor.show();
var form = tag_editor_form.getForm();
form.findField("filename").setValue(htmlspecialchars_decode(data.filename));
form.findField("artist").setValue(htmlspecialchars_decode(data.artist));
form.findField("title").setValue(htmlspecialchars_decode(data.title));
form.findField("year").setValue(htmlspecialchars_decode(data.year));
form.findField("album").setValue(htmlspecialchars_decode(data.album));
form.findField("genre").setValue(htmlspecialchars_decode(data.genre));
break;
}
}
}
});
}
function GridRenderDuration(value, p, record) {
return renderDuration(value);
}
function renderFilesize(value, p, record) {
return number_format(value/1024,0,',','.') + " KB";
}
function renderBitrate(value, p, record) {
return number_format(value/1000,0,',','.') + " kbps";
}
function renderNumber(value, p, record) {
return number_format(value,0,',','.');
}
function renderLink(value, p, record)
{
return String.format(
'{1}',
record.get('ID'),value);
}
function renderArtist(value, p, record)
{
if(record.get('artistID')!=0)
return String.format(
'{1}',
record.get('artistID'),value);
else
return value;
}
function renderAlbum(value, p, record)
{
return String.format(
'{1}',
record.get('albumID'),value);
}
function renderPath(value, p, record)
{
return String.format(
'{1}',
addslashes(record.get('full_path')),value);
}
function enable_disable_buttons(form_name,enable)
{
if (enable)
{
Ext.getCmp(form_name + 'new_buttonID').enable();
if (Ext.getCmp(form_name + 'navigationID').getValue() && Ext.getCmp(form_name + 'formID').getForm().reader.jsonData.rows[0].type!="guest" && Ext.getCmp(form_name + 'formID').getForm().reader.jsonData.rows[0].type!="admin")
Ext.getCmp(form_name + 'delete_buttonID').enable();
else
Ext.getCmp(form_name + 'delete_buttonID').disable();
Ext.getCmp(form_name + 'save_buttonID').enable();
}
else
{
Ext.getCmp(form_name + 'new_buttonID').disable();
Ext.getCmp(form_name + 'delete_buttonID').disable();
Ext.getCmp(form_name + 'save_buttonID').disable();
}
}
function open_user_form(userID)
{
if(!user_editor)
{
user_editor = new Ext.Window({
title: 'User-Editor',
width: 670,
height: 370,
resizable: false,
layout: 'fit',
border: false,
stateful: false,
plain:true,
bodyStyle:'padding:5px;',
buttonAlign:'center',
items: user_form(userID),
listeners:
{
close:function(p)
{
user_editor = "";
}
}
});
user_editor.show();
}
}
function open_setup_form()
{
if(!setup_editor)
{
setup_editor = new Ext.Window({
title: 'Setup-Editor',
width: 670,
height: 370,
resizable: false,
layout: 'fit',
border: false,
stateful: false,
plain:true,
bodyStyle:'padding:5px;',
buttonAlign:'center',
items: setup_form(),
listeners:
{
close:function(p)
{
setup_editor = "";
}
}
});
setup_editor.show();
}
}
function my_about()
{
Ext.MessageBox.show({
title: 'About MyWebJukebox 1.3.1',
msg: 'Homepage: www.mywebjukebox.at
Written by Kamil Malinski
License: GNU GPL license v3
Framework: ExtJS 3.0
Beta-Tester:
Mexx
B4n4n3
megahorst
Thanks to: Wisti (feedback), schubl (feedback), Niki (feedback), Sinusblitz (feedback), Matthieu (english localization)',
buttons: Ext.MessageBox.OK
});
}
/**
*
* UTF-8 data encode / decode
* http://www.webtoolkit.info/
*
**/
function cp1252_to_unicode(c)
{
if (c < 160)
{
if (c==128) c=8364;
else if (c==129) c=160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
else if (c==130) c=8218;
else if (c==131) c=402;
else if (c==132) c=8222;
else if (c==133) c=8230;
else if (c==134) c=8224;
else if (c==135) c=8225;
else if (c==136) c=710;
else if (c==137) c=8240;
else if (c==138) c=352;
else if (c==139) c=8249;
else if (c==140) c=338;
else if (c==141) c=160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
else if (c==142) c=381;
else if (c==143) c=160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
else if (c==144) c=160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
else if (c==145) c=8216;
else if (c==146) c=8217;
else if (c==147) c=8220;
else if (c==148) c=8221;
else if (c==149) c=8226;
else if (c==150) c=8211;
else if (c==151) c=8212;
else if (c==152) c=732;
else if (c==153) c=8482;
else if (c==154) c=353;
else if (c==155) c=8250;
else if (c==156) c=339;
else if (c==157) c=160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
else if (c==158) c=382;
else if (c==159) c=376;
} //if
return c
}
var Utf8 = {
// public method for url encoding
encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode(cp1252_to_unicode((c >> 6) | 192));
utftext += String.fromCharCode(cp1252_to_unicode((c & 63) | 128));
}
else {
//console.log(String.fromCharCode((c >> 12) | 224) + ",",String.fromCharCode(((c >> 6) & 63) | 128) + "," + String.fromCharCode((c & 63) | 128));
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// public method for url decoding
decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
function in_array(needle,stack)
{
for(var i=0;i",
plain: false,
listeners:
{
resize: function()
{
/*if(!player_obj.volume)
var volume = 100;
else
var volume = player_obj.volume;
player_volume_bar.setValue(volume);*/
//soundManager.last_position = 0;
},
beforeclose: function(p)
{
Ext.getCmp("right_southID").show();
if(!Ext.getCmp("right_pangelID").isVisible())
{
Ext.getCmp("right_pangelID").expand(false);
}
var playing_info = document.getElementById("playing_info_content");
var parent_node = playing_info.parentNode;
var removed_node = parent_node.removeChild(playing_info);
document.getElementById("playing_info").appendChild(removed_node);
//init_player(true);
player_window = false;
player_obj.undock_button.show();
var parent = document.getElementById("playing_info_content");
var child = document.getElementById("info_cover_row");
var song_info = document.getElementById("song_info");
parent.insertBefore(song_info,child);
cp.set("player_window_show",0);
Ext.getCmp("right_pangelID").doLayout();
//player_obj.play_song(player_obj.last_data);
}
}
});
player_window.show();
if(player_obj.undock_button)
player_obj.undock_button.hide();
var parent = document.getElementById("playing_info_content");
var child = document.getElementById("song_info");
var info_cover_row = document.getElementById("info_cover_row");
parent.insertBefore(info_cover_row,child);
cp.set("player_window_show",1);
Ext.getCmp("right_southID").hide();
Ext.getCmp("right_pangelID").doLayout();
var removed_node = parent_node.removeChild(playing_info);
document.getElementById("window_playing_info").appendChild(removed_node);
//init_player(true);
//player_obj.play_song(player_obj.last_data);
}
}
function clear_cache()
{
Ext.Msg.show({
title:'Warning',
msg: 'Are you sure that you want to clear the cache?',
buttons: Ext.Msg.YESNO,
buttonText: Ext.MessageBox.buttonText.yes = 'Yes',
buttonText: Ext.MessageBox.buttonText.no = 'No',
icon: Ext.MessageBox.QUESTION,
fn: function(btn)
{
if(btn=="yes")
{
if(DEMO_MODE)
{
Ext.MessageBox.show({
title: 'Demo-Version',
msg: 'You can not clear cache in the demo',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
}
else
{
Ext.Ajax.request(
{
url:'clear_cache.php',
params: { },
waitMsg:'Deleting...',
success:function(form, action)
{
Ext.Msg.show({
title: 'Delete',
msg: 'Successfully deleted',
minWidth: 200,
modal: true,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
},
failure:function(form,action)
{
Ext.Msg.show({
title: 'Error',
msg: 'Error while trying to delete the cache',
minWidth: 200,
modal: true,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
}
})
}
}
}
}
)
}