console.log(); let uchip = null; let textone ='ssssssssssssssssssss'; let textTwo ='fffffffffff'; Dropzone.autoDiscover = false; $(document).ready(function() { uchip = new Uchip(); listServerCast(); $('#services').DataTable(); var myDropzone = new Dropzone("div#dropzoneDragArea", { paramName: "file", url: "?module=servercast&acc=uploadFiles", previewsContainer: 'div.dropzone-previews', addRemoveLinks: true, autoProcessQueue: true, uploadMultiple: false, parallelUploads: 1, maxFiles: 10, init: function() { var myDropzone = this; $("form[name='demoform']").submit(function(event) { event.preventDefault(); URL = $("#demoform").attr('action'); formData = $('form #demoform').serialize(); $.ajax({ type: 'POST', url: URL, data: formData, success: function(result){ if(result.status == "success"){ console.log(result); myDropzone.processQueue(); return false; }else{ console.log("error"); return false; } } }); }); this.on('sending', function(file, xhr, formData){ formData.append("media", $("#media_galery").val()); formData.append("server", $("#idServerCast").val()); }); this.on("success", function (file, response) { $('#demoform')[0].reset(); $('.dropzone-previews').empty(); }); this.on("queuecomplete", function () { search_music('none'); disk_consumption() }); this.on("sendingmultiple", function() { // Gets triggered when the form is actually being sent. // Hide the success button or the complete form. }); this.on("successmultiple", function(files, response) { // Gets triggered when the files have successfully been sent. // Redirect user or notify of success. }); this.on("errormultiple", function(files, response) { // Gets triggered when there was an error sending the files. // Maybe show form again, and notify user of error }); } }); $('[data-toggle="tooltip"]').tooltip(); } ); function tabshoutcast(){ $("#_icecast_tab_").hide(); $("#_shoustcast_tab_").show(); } function tabicecast(){ $("#_shoustcast_tab_").hide(); $("#_icecast_tab_").show(); } function autodjDetails(){ $("#autodjList").hide(); $("#autodjDetails").fadeIn(); $("#menuTable .nav-link").removeClass('active in'); $("#menuTable .nav-item").removeClass('active'); $("#listRepDJ").addClass('active in'); $("#menuTable #li_listRepDJ").addClass('active'); search_music('none'); serviceSt(); disk_consumption(); return false; } function disk_consumption(){ var id =$("#idServerCast").val(); uchip.call('module=servercast&acc=disk_consumption', { data: 'server=' + id, callback: function (response) { console.log(response); var disk_pack = response.disk_pack; var disk_use = response.disk_use; var poscen = (100 / disk_pack) * disk_use; poscen = Math.round(poscen); var disk_use_div = Math.round(disk_use/1024); var disk_pack_div = Math.round(disk_pack/1024); $("#autodjDetails .progress-bar").html(disk_use_div+' MB/'+disk_pack_div+' MB/'); $("#autodjDetails .progress-bar").css("width", poscen+'%'); } }); } function searchDataAutoJd(id){ uchip.call('module=servercast&acc=searchDataAutoJd', { data: 'id=' + id, callback: function (response) { console.log(response); if(response.status =='OK'){ var data = response.data; var myplaylist = data.myplaylist; var tamanoP = myplaylist.length; var jingles = data.jingles; var tamanoJ = jingles.length; var msj = "Playback in progress of List "+myplaylist.substr(0, (tamanoP-4))+" and Jingle "+jingles.substr(0, (tamanoJ-4))+""; $("#alrtviewsound").html(msj); $("#alrtviewsound").show(); }else{ } } }); } function serviceSt(){ var id =$("#idServerCast").val(); $(".btStatusAutoDj").addClass('disabled'); $(".btStatusAutoDj").attr('disabled',true); uchip.call('module=servercast&acc=serviceSt', { data: 'id=' + id, callback: function (response) { if(response.autodj == 'ON'){ $(".btStatusAutoDj").html(''); $(".btStatusAutoDj").removeClass('btn-primary'); $(".btStatusAutoDj").addClass('btn-danger'); $(".btStatusAutoDj").removeClass('disabled'); $(".btStatusAutoDj").attr('disabled',false); $(".btStatusAutoDj").attr('title','Parar'); $(".titleautodj").html(' AutoDJ ONLine'); $("#alrtviewsound_no").hide(); searchDataAutoJd(id); // }else if(response.autodj == 'OFF'){ $(".btStatusAutoDj").html(''); $(".btStatusAutoDj").removeClass('btn-danger'); $(".btStatusAutoDj").addClass('btn-primary'); $(".btStatusAutoDj").removeClass('disabled'); $(".btStatusAutoDj").attr('disabled',false); $(".btStatusAutoDj").attr('title','Iniciar'); $(".titleautodj").html(' AutoDJ OFFLine'); $("#alrtviewsound").hide(); $("#alrtviewsound_no").show(); } console.log(response); return false; } }); } function autodjList() { var id =$("#idServerCast").val(); $(".titleServer").html(id.toUpperCase()); $("#menuTable .nav-item").removeClass('active'); $("#menuTable .nav-link").removeClass('active in'); $("#li_listRepDJ").addClass('active'); $("#listRepDJ").addClass('active in'); $(".tabsCast").hide(); uchip.call('module=servercast&acc=autodjList', { data: 'id=' + id, callback: function (response) { $("#autodjDetails #playlist").html(response.playlist); $("#DTRotation tbody").html(response.rotationTable); $("#DTistCron tbody").html(response.scheduledTable); $("#DTJingle tbody").html(response.jinglesTable); $("#autodjDetails #playlist").html(response.playlist); $("#autodjDetails #playlist").html(response.playlist); $("#table_services").hide(); $("#DTRotation").dataTable(); $("#DTJingle").dataTable(); $("#DTistCron").dataTable(); $("#autodjList").fadeIn(); return false; } }); return false; } function salirAutoDJ(){ return menuTab('autodjList',$("#idServerCast").val()); } function MyServices(){ $(".tabsCast").hide(); $("#table_services").fadeIn(); return false; } function removifilePlayMedia(file,name){ $("#modal_delete_file_media #idfile").val(file); $("#modal_delete_file_media #filename").html(name); $("#modal_delete_file_media").modal('toggle'); return false; } function Overvier(idnew){ var myVar; if(idnew!='' && idnew !=undefined){$("#idServerCast").val(idnew);} var id = $("#idServerCast").val(); $(".titleServer").html(id.toUpperCase()); $("#table_services").hide(); $(".tabsCast").hide(); $("#overvier").fadeIn(); $("#menuTable .nav-item").removeClass('active'); $("#menuTable .nav-link").removeClass('active in'); $("#menuTable #li_Overvier").addClass('active'); $("#menuTable #Overvier-tab").addClass('active in'); myVar = setInterval(DetailsOverCast, 6000); console.log(myVar); detailServer(); serviceSt(); return false; } function detailServer(){ var server = $("#idServerCast").val(); uchip.call('module=servercast&acc=detailServer', { data: 'server=' + server, callback: function (response) { console.log(response); $("#labeltype").html(response.type_server); $("#labelip").html(response.ip); $("#labelport").html(response.port); var disk = response.disk_pack; var diskuse = response.disk_use; if(diskuse==0){diskuse=1;} var porcentaje = (diskuse * 100) / disk; porcentaje = Math.round(porcentaje); if(porcentaje==0){porcentaje=1;} $("#grafdisk").html('
'); return false; } }); } function Config(){ var id = $("#idServerCast").val(); uchip.call('module=servercast&acc=Config', { data: 'id=' + id, callback: function (response) { $("#confGeneral #typeServer").val(response.server); $("#confGeneral #package").val('none'); $("#confGeneral #user").val('{{ users }}'); $("#confGeneral #port").val(response.port); var config = response.conf; var dominios = response.domains; var opDomain =''; dominios.forEach(function(dominio, index) { opDomain +=''; }); $("#confGeneral #domain").html(opDomain); $("#confGeneral #pass").val(config.password); $("#confGeneral #passAdmin").val(config.adminPassword); $("#confLimites #mounting").val(1); $("#confLimites #autodj").val(1); $("#confLimites #bitrate").val(config.bitrate); $("#confLimites #max_users").val(config.max_users); $("#confLimites #bandwidth").val(config.bandwidth); $("#confLimites #disk_quota").val(config.disk_quota); $(".titleServer").html(id.toUpperCase()); $("#table_services").hide(); $(".tabsCast").hide(); $("#MenuConfDiv").fadeIn(); $("#config").fadeIn(); $("#menuTable .nav-link").removeClass('active in'); $("#menuTable .nav-item").removeClass('active'); $("#menuTable #li-config").addClass('active'); $("#menuTable #Config-tab").addClass('active in'); return false; } }); return false; } function Conf_general(){ $("#menuConfig .nav-link").removeClass('active in'); $("#Conf_general-tab").addClass('active in'); $(".divConf").hide(); $("#detConf_general").fadeIn(); return false; } function Conf_limites(){ $("#menuConfig .nav-link").removeClass('active in'); $("#Conf_limites-tab").addClass('active in'); $(".divConf").hide(); $("#detConf_limites").fadeIn(); return false; } function Conf_plugins() { $("#menuConfig .nav-link").removeClass('active in'); $("#Conf_plugins-tab").addClass('active in'); $(".divConf").hide(); $("#detConf_plugins").fadeIn(); return false; } function Conf_autodj(){ $("#menuConfig .nav-link").removeClass('active in'); $("#Conf_autodj-tab").addClass('active in'); $(".divConf").hide(); $("#detConf_autodj").fadeIn(); return false; } function Conf_rele(){ $("#menuConfig .nav-link").removeClass('active in'); $("#detConf_rele-tab").addClass('active in'); $(".divConf").hide(); $("#detConf_rele").fadeIn(); return false; } function restarSV(id){ $("#btnrest_"+id).attr('disabled',true); $("#btnrest_"+id).addClass('disabled'); $("#icon_"+id).addClass('fa-spin'); uchip.call('module=servercast&acc=restarSV', { data: 'server=' + id, callback: function (response) { console.log(response); noti_bubble('Successful restart','Success','success',false,false,'4000',true); $("#btnrest_"+id).attr('disabled',false); $("#btnrest_"+id).removeClass('disabled'); $("#icon_"+id).removeClass('fa-spin'); } }); } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function DjManager(){ $("#table_services").hide(); $("#MenuConfDiv").hide(); $("#menuTable li").removeClass('active in'); $("#DjManager-tab").addClass('active in'); $(".tabsCast").hide(); $("#djmanager").fadeIn(); return false; } function listServerCast(){ uchip.call('module=servercast&acc=infoCast', { //data: 'key=' + key + '&lines=' + lines, callback: function (response) { $("#services tbody").html(response.listServer); $("#services").dataTable(); } }); } function search_music(folder){ if(folder == 'none'){ if($("#listMediaId").val()==''){ $("#listMediaId").val('media'); } folder =$("#listMediaId").val(); }else{ $("#listMediaId").val(folder); } $("#btnmedias .media").removeClass('disabled'); $("#btnmedias .media").attr('disabled',false); $("#btnmedias #btnmusic_"+folder).addClass('disabled'); $("#btnmedias #btnmusic_"+folder).attr('disabled',true); $("#fileOrigen").html('('+datatype+')
'; $("#deletePlayList #name_playlist").html(textmodal); $("#deletePlayList #playlistname").val(lista); $("#deletePlayList #typeplaylist").val(datatype); $("#deletePlayList").modal('toggle'); return false; }); $("#btn_delete_playlist").click(function (){ $("#btn_delete_playlist").addClass('disabled'); $("#btn_delete_playlist").attr('disabled', true); var list = $("#deletePlayList #playlistname").val(); var typelist = $("#deletePlayList #typeplaylist").val(); uchip.call('module=servercast&acc=deletePlayList', { data: 'list=' + list+'&type='+typelist+'&server='+$("#titleCast #idServerCast").val(), callback: function (response) { console.log(response); if(response.status == 'OK'){ $("#autodjDetails #playlist option[value='"+list+"']").hide(); $("#autodjDetails #playlist option[value='']").attr("selected", true); masterPlayplist(); $("#deletePlayList").modal('toggle'); noti_bubble('Service restarted successfully','Success!','success',false,false,'3000',true); }else{ noti_bubble(response.msj,'Error!','error',false,false,'3000',true); } $("#btn_delete_playlist").removeClass('disabled'); $("#btn_delete_playlist").attr('disabled', false); return false; } }); return false; }); var Base64 = { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_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((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_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; } }