| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054 |
- function GetURLParameter(sParam)
- {
- var sPageURL = window.location.search.substring(1);
- var sURLVariables = sPageURL.split('&');
- for (var i = 0; i < sURLVariables.length; i++)
- {
- var sParameterName = sURLVariables[i].split('=');
- if (sParameterName[0] == sParam)
- {
- return sParameterName[1];
- }
- }
- }
- function checkSession() {
- var ret = true;
- var request = new XMLHttpRequest();
- request.open('GET', 'modules/litefm/SessionCheck.php', false);
- request.onload = function(e) {
- var session = JSON.parse(this.responseText);
- if(!session.valid) {
- alert("Your session has expired.");
- window.location = "index.php";
- ret = false;
- }
- }
- request.send(null);
- return ret;
- }
- function detectIE() {
- var ua = window.navigator.userAgent;
- var msie = ua.indexOf('MSIE ');
- var trident = ua.indexOf('Trident/');
- if (msie > 0) {
- // IE 10 or older => return version number
- return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
- }
- if (trident > 0) {
- // IE 11 (or newer) => return version number
- var rv = ua.indexOf('rv:');
- return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
- }
- // other browser
- return false;
- }
- var ie = detectIE();
- if (!Date.now) {
- Date.now = function() { return new Date().getTime(); }
- }
- function indexedDBOk() {
- return "indexedDB" in window;
- }
- function downloadFile(home_id, file_id, file_size, file_name)
- {
- if(checkSession() == false) { return; }
- var fileNode = document.getElementById('fileid'+file_id);
- var aLink = document.getElementById('jsDwl'+file_id);
- if (aLink.getAttribute('disabled') == 'disabled') {
- return;
- }
- aLink.setAttribute('disabled','disabled');
- var did = Date.now();
- var bytesDownloaded = 0;
- var progressbar = document.createElement('DIV');
- var progress = document.createElement('DIV');
- var percentage = document.createElement("SPAN");
- progressbar.setAttribute('id','progress_'+file_id);
- progressbar.setAttribute('style', 'background:white;'+
- 'height:4px;'+
- 'width:400px;'+
- 'border:1px solid black;'+
- 'position:absolute;'+
- 'z-index:2;');
- percentage.setAttribute('id','percentage_'+file_id);
- progressbar.appendChild(progress);
- fileNode.appendChild(progressbar);
- fileNode.appendChild(percentage);
- progressbar = document.getElementById('progress_'+file_id);
- progress = progressbar.firstChild;
- percentage = document.getElementById('percentage_'+file_id);
- var key = 1;
- var db;
- var memoryStore;
-
- function failure() {
- progressbar.parentNode.removeChild(progressbar);
- percentage.parentNode.removeChild(percentage);
- window.onbeforeunload = false;
- window.onunload = false;
- }
-
- function init() {
- if(ie)
- {
- if(ie >= 10)
- {
- memoryStore = [];
- getFilePart();
- }
- else
- {
- failure();
- alert('Your browser does not support this function.');
- return;
- }
- }
- else
- {
- if( !indexedDBOk() )
- {
- failure();
- alert('Your browser does not support this function.');
- return;
- }
-
- var openRequest = indexedDB.open(did,1);
-
- openRequest.onupgradeneeded = function(e) {
- var thisDB = e.target.result;
-
- if(!thisDB.objectStoreNames.contains("dl_parts")) {
- thisDB.createObjectStore("dl_parts");
- }
- }
-
- openRequest.onsuccess = function(e) {
- db = e.target.result;
- getFilePart();
- }
-
- openRequest.onerror = function(e) {
- failure();
- cleanUp();
- alert(e.target.error.name);
- return;
- }
- }
- }
- function addBuffer(arraybuffer, key) {
- if(ie)
- {
- // Store the blob in memory
- memoryStore.push(new Blob([arraybuffer]));
- }
- else
- {
- // Store the blob in indexedDB
- var transaction = db.transaction(["dl_parts"],"readwrite");
- var store = transaction.objectStore("dl_parts");
- var request = store.add(new Blob([arraybuffer]), key);
- request.onerror = function(e) {
- failure();
- cleanUp();
- alert(e.target.error.name);
- return;
- }
- }
- }
- function getAllParts() {
- if(ie)
- {
- navigator.msSaveOrOpenBlob(new Blob(memoryStore), file_name);
- }
- else
- {
- var trans = db.transaction(["dl_parts"],"readonly");
- var store = trans.objectStore("dl_parts");
- var parts = [];
- trans.oncomplete = function(evt) {
- try
- {
- var fileUrl = (window.URL || window.webkitURL).createObjectURL(new Blob(parts));
- var a = document.createElement('a');
- a.href = fileUrl;
- a.target = '_blank';
- a.download = file_name || fileUrl;
- var evt=new MouseEvent('click', {'view':window,'bubbles':true,'cancelable':true});
- a.dispatchEvent(evt);
- // Otherwise Firefox fails starting the download.
- setTimeout(function() { window.URL.revokeObjectURL(a.href); }, 1);
- parts = [];
- }
- catch(e)
- {
- console.log(e);
- }
- };
-
- var cursorRequest = store.openCursor();
-
- cursorRequest.onerror = function(error) {
- failure();
- cleanUp();
- alert(error);
- return;
- };
-
- cursorRequest.onsuccess = function(evt) {
- var cursor = evt.target.result;
- if (cursor) {
- parts.push(cursor.value);
- cursor.continue();
- }
- };
- }
- }
-
- function cleanUp() {
- if(ie)
- {
- memoryStore = [];
- }
- else
- {
- db.close();
- indexedDB.deleteDatabase(did);
- }
- var xhr = new XMLHttpRequest();
- xhr.open('POST', "home.php?m=litefm&home_id="+home_id+"&p=get&remove_did="+did+"&type=cleared", false);
- xhr.send(null);
- window.onunload = false;
- }
-
- function getFilePart()
- {
- var xhr = new XMLHttpRequest();
- xhr.open('POST', "home.php?m=litefm&home_id="+home_id+"&item="+file_id+"&name="+file_name+"&p=get&type=cleared&size="+file_size+"&did="+did, true);
- xhr.responseType = 'arraybuffer';
- xhr.onload = function(e) {
- if(this.response.byteLength != 0)
- {
- var lapTime = Date.now() - did; // milliseconds from download start
- // Uncompress and calculate the statistics.
- var compressed = new Uint8Array(this.response);
- var inflate = new Zlib.Inflate(compressed);
- var plain = inflate.decompress();
- bytesDownloaded += plain.byteLength;
- var multiplier = 1000 / lapTime;
- var MBs = (bytesDownloaded / 1000000) * multiplier;
- var value = bytesDownloaded * 100 / file_size;
- progress.setAttribute('style', 'background:blue;'+
- 'height:4px;'+
- 'width:'+value+'%;');
- percentage.innerHTML = " "+(Math.round(value * 100) / 100)+"% - "+MBs.toFixed(2)+"MB/s";
- addBuffer(plain, key++);
- // Get the next part
- getFilePart();
- }
- else
- {
- getAllParts();
- // Otherwise Firefox fails starting the download.
- setTimeout(function() { cleanUp(); }, 60000);
- // element.remove(); fails on IE
- progressbar.parentNode.removeChild(progressbar);
- percentage.parentNode.removeChild(percentage);
- aLink.removeAttribute('disabled');
- window.onbeforeunload = false;
- }
- };
- xhr.send(null);
- }
-
- window.onbeforeunload = function(){
- return 'A file download is in progress';
- };
-
- window.onunload = function(){
- cleanUp();
- }
-
- init();
- }
- $(document).ready(function(){
- /* translation & info */
- var select_at_least_one_item = $('#dialog').attr('data-select_at_least_one_item'),
- ask_delete = $('#dialog').attr('data-ask_delete'),
- ask_rename = $('#dialog').attr('data-ask_rename'),
- ask_move = $('#dialog').attr('data-ask_move'),
- ask_copy = $('#dialog').attr('data-ask_copy'),
- ask_compress = $('#dialog').attr('data-ask_compress'),
- ask_uncompress = $('#dialog').attr('data-ask_uncompress'),
- archive_name = $('#dialog').attr('data-archive_name'),
- archive_type = $('#dialog').attr('data-archive_type'),
- file_name = $('#dialog').attr('data-file_name'),
- folder_name = $('#dialog').attr('data-folder_name'),
- compresses_files_separately = $('#dialog').attr('data-compresses_files_separately'),
- to = $('#dialog').attr('data-to'),
- yes = $('#dialog').attr('data-yes'),
- no = $('#dialog').attr('data-no'),
- max_file_uploads = $('#dialog').attr('data-max_file_uploads'),
- upload_to_web = $('#dialog').attr('data-upload_to_web'),
- transfer_to_server = $('#dialog').attr('data-transfer_to_server'),
- upload = $('#dialog').attr('data-upload'),
- ask_change_attr = $('#dialog').attr('data-ask_change_attr'),
- ask_send_by_email = $('#dialog').attr('data-ask_send_by_email'),
- subject = $('#dialog').attr('data-subject'),
- message = $('#dialog').attr('data-message'),
- dest_email = $('#dialog').attr('data-dest_email'),
- user_email = $('#dialog').attr('data-user_email');
- // Home id
- var home_id = GetURLParameter('home_id');
- // Browse folder (when using "move/uncompress")
- $('.folder').each(function(){
- $(this).click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost[ 'm' ] = 'user_games';
- addpost[ 'p' ] = 'browser';
- addpost[ 'home_id' ] = $('.levelup').attr('data-home-id');
- addpost[ 'item' ] = $(this).attr('data-item');
- addpost[ 'type' ] = 'cleared';
- $.ajax({
- type: "GET",
- url: "home.php",
- data: addpost,
- success: function(data){
- data = data.replace("user_games.js","litefm.js");
- $( "#browser" ).html(data);
- }
- });
- });
- });
- // Back to previous folder (when using "move/uncompress")
- $('.levelup').click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost[ 'm' ] = 'user_games';
- addpost[ 'p' ] = 'browser';
- addpost[ 'home_id' ] = $(this).attr('data-home-id');
- addpost[ 'back' ] = 'back';
- addpost[ 'type' ] = 'cleared';
- $.ajax({
- type: "GET",
- url: "home.php",
- data: addpost,
- success: function(data){
- data = data.replace("user_games.js","litefm.js");
- $( "#browser" ).html(data);
- }
- });
- });
- // Create new folder (when using "move/uncompress")
- $('#addfolder').click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost[ 'm' ] = 'user_games';
- addpost[ 'p' ] = 'browser';
- addpost[ 'home_id' ] = home_id;
- addpost[ 'create_folder' ] = 'create_folder';
- addpost[ 'folder_name' ] = $('input[name=dirname]').val();
- addpost[ 'type' ] = 'cleared';
- $.ajax({
- type: "GET",
- url: "home.php",
- data: addpost,
- success: function(data){
- data = data.replace("user_games.js","litefm.js");
- $( "#browser" ).html(data);
- }
- });
- });
- // Switch checkboxes
- $("#switch_check").click(function(){
- var checkBoxes = $('input[class="item"]');
- checkBoxes.prop("checked", !checkBoxes.prop("checked"));
- });
- // Remove
- $("#remove.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.remove = '';
- var item = '';
- var value = '';
- var items = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value');
- addpost.items.push(item);
- items += "<br>"+value;
- });
- if(items != '')
- {
- $('#dialog').html(ask_delete.replace("%s", ":"+items));
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- // Rename
- $("#rename.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.values = [];
- addpost.rename = '';
- var value = '';
- var items = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value').replace('"', """);
- addpost.items.push(item);
- items += "<br><input class='rename' type=text style='width:100%;' name='"+item+"' value=\""+value+"\">";
- });
- if(items != '')
- {
- $('#dialog').html(ask_rename+":"+items);
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- $('input[class="rename"]').each(function(){
- value = $(this).val();
- addpost.values.push(value);
- });
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- // Move
- $("#move.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.values = [];
- addpost.move = '';
- var value = '';
- var items = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value');
- addpost.items.push(item);
- items += "<br>"+value;
- });
- if(items != '')
- {
- var addpostb = {};
- addpostb[ 'm' ] = 'user_games';
- addpostb[ 'p' ] = 'browser';
- addpostb[ 'home_id' ] = home_id;
- addpostb[ 'folder' ] = $('#dialog').attr('data-folder');
- addpostb[ 'type' ] = 'cleared';
- $.ajax({
- type: "GET",
- url: "home.php",
- data: addpostb,
- async: false,
- success: function(data){
- data = data.replace("user_games.js","litefm.js");
- $('#dialog').html(ask_move+":"+items+"<br>"+to+":<br><div id='browser' >"+data+"</div>");
- }
- });
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.selected_path = $('#selected_path').text();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- // Copy
- $("#copy.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.values = [];
- addpost.copy = '';
- var value = '';
- var items = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value');
- addpost.items.push(item);
- items += "<br>"+value;
- });
- if(items != '')
- {
- var addpostb = {};
- addpostb[ 'm' ] = 'user_games';
- addpostb[ 'p' ] = 'browser';
- addpostb[ 'home_id' ] = home_id;
- addpostb[ 'folder' ] = $('#dialog').attr('data-folder');
- addpostb[ 'type' ] = 'cleared';
- $.ajax({
- type: "GET",
- url: "home.php",
- data: addpostb,
- async: false,
- success: function(data){
- data = data.replace("user_games.js","litefm.js");
- $('#dialog').html(ask_copy+":"+items+"<br>"+to+":<br><div id='browser' >"+data+"</div>");
- }
- });
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.selected_path = $('#selected_path').text();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- // Compress
- $("#compress.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.compress = '';
- var value = '';
- var items = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value');
- addpost.items.push(item);
- items += "<br>"+value;
- });
- if(items != '')
- {
- $('#dialog').html(ask_compress+":"+items+"<br>"+
- "<label for='archive_name'>"+archive_name+"</label>\n"+
- "<input name='archive_name' id='archive_name' type=text value='archive' ><br>\n"+
- "<label for='archive_type'>"+archive_type+"</label>\n"+
- "<select name='archive_type' id='archive_type' >\n"+
- "<option value='zip'>zip</option>\n"+
- "<option value='tbz'>tbz</option>\n"+
- "<option value='tgz'>tgz</option>\n"+
- "<option value='tar'>tar</option>\n"+
- "<option value='bz2'>bz2 ("+compresses_files_separately+")</option>\n"+
- "</select>");
-
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.archive_name = $('#archive_name').val();
- addpost.archive_type = $('#archive_type').val();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- // Uncompress
- $("#uncompress.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.values = [];
- addpost.uncompress = '';
- var value = '';
- var items = '';
- var ext = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value');
- ext = value.split('.').pop();
- if(ext.match(/^(tar|tgz|gz|Z|zip|bz2|tbz|lzma|xz|txz)$/i) != null)
- {
- addpost.items.push(item);
- items += "<br>"+value;
- }
- });
- if(items != '')
- {
- var addpostb = {};
- addpostb[ 'm' ] = 'user_games';
- addpostb[ 'p' ] = 'browser';
- addpostb[ 'home_id' ] = home_id;
- addpostb[ 'folder' ] = $('#dialog').attr('data-folder');
- addpostb[ 'type' ] = 'cleared';
- $.ajax({
- type: "GET",
- url: "home.php",
- data: addpostb,
- async: false,
- success: function(data){
- data = data.replace("user_games.js","litefm.js");
- $('#dialog').html(ask_uncompress+":"+items+"<br>"+to+":<br><div id='browser' >"+data+"</div>");
- }
- });
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.selected_path = $('#selected_path').text();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- // Create File
- $("#create_file.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.create_file = '';
- $('#dialog').html("<label for='file_name'>"+file_name+"</label>\n"+
- "<input id='file_name' type=text style='width:100%;' name='file_name' >");
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.file_name = $('input[id="file_name"]').val();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- });
- // Create Folder
- $("#create_folder.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.create_folder = '';
- $('#dialog').html("<label for='folder_name'>"+folder_name+"</label>\n"+
- "<input id='folder_name' type=text style='width:100%;' name='folder_name' >");
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.folder_name = $('input[id="folder_name"]').val();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- });
- // upload
- $("#upload.operations-button").click(function(){
- if(checkSession() == false) { return; }
- $('#dialog').html('<div class="uploadLiteFMStatus status"></div>\
- <form id="upload" action="home.php?m=litefm&home_id='+home_id+'&type=cleared&data_type=json" method="post" enctype="multipart/form-data">\
- <input type="file" name="files[]" multiple="multiple" id="files">\
- <input type="submit" name="upload" id="uploadsubmit" value="'+upload+'" >\
- </form>\
- <div class="progress">\
- '+upload_to_web+':<br><progress class="bar" max="100" style="width:100%;" ></progress><div class="percent"></div >\
- '+transfer_to_server+':<br><progress class="bar2" max="100" style="width:100%;" ></progress><div class="percent2"></div >\
- </div>');
- /* variables */
- var progress = $('.progress');
- var percent = $('.percent');
- var bar = $('.bar');
- var percent2 = $('.percent2');
- var bar2 = $('.bar2');
- progress.hide();
- $('#dialog').dialog({
- autoOpen: true,
- width: 350,
- modal: true,
- close: function() {
- $( this ).dialog( "close" );
- window.location.href = window.location.href.replace('&back','');
- }
- });
- /* submit form with ajax request using jQuery.form plugin */
- $('form#upload').ajaxForm({
- /* set data type json */
- dataType:'json',
- beforeSubmit : function(arr, $form, options){
- $(".uploadLiteFMStatus").html("");
- if(!$("form#upload input#uploadsubmit").hasClass('disabled')){
- var i = 0;
- $.each(arr, function(index, input) {
- if(typeof input.value.name !== 'undefined')
- {
- i++;
- }
- });
- if( i > max_file_uploads )
- {
- alert("The upload exceeds the max_file_uploads directive in php.ini ("+max_file_uploads+" files).");
- return false;
- }
- if( i == 0)
- {
- return false;
- }
- }else{
- return false;
- }
- },
- /* reset before submitting */
- beforeSend: function() {
- progress.show();
- percent.html('0%');
- percent2.html('0%');
- $("form#upload input#files, form#upload input#uploadsubmit").removeClass('disabled').addClass('disabled').prop('disabled', true);
- },
- /* progress bar call back*/
- uploadProgress: function(event, position, total, percentComplete) {
- var pVel = percentComplete + '%';
- bar.val(percentComplete);
- percent.html(pVel);
- },
- error: function(jqXHR, textStatus, errorThrown){
- $(".uploadLiteFMStatus").html(textStatus + " " + errorThrown);
- $("form#upload input#files, form#upload input#uploadsubmit").removeClass('disabled').prop('disabled', false);
- },
- /* success call back */
- success: function(data) {
- if(typeof data.count !== 'undefined')
- {
- var files_qty = data.count,
- files_info = data.files,
- percent_file = [],
- file_complete = [],
- percent_total = 0,
- pVel = "",
- rond_total = 0;
- var refresh = setInterval(function(){
- $.each(files_info, function(index, file){
- if(typeof file_complete[index] !== 'undefined' && file_complete[index] == true)
- {
- return true;
- }
- $.ajax({
- type: "POST",
- url: 'home.php?m=litefm&home_id='+home_id+'&type=cleared&pid='+file['pid']+'&size='+file['size']+'&filename='+file['filename']+"&data_type=json",
- dataType:'json',
- async: false,
- success: function(data){
- percent_file[index] = data.pct / parseInt(files_qty);
- file_complete[index] = data.complete;
- }
- });
- });
-
- percent_total = 0;
- $.each(percent_file, function(index, percent){
- percent_total += percent;
- });
-
- rond_total = parseInt(percent_total);
- pVel = rond_total + '%';
- bar2.val(rond_total);
- percent2.html(pVel);
-
- var stop_refresh = true;
- $.each(file_complete, function(index, complete){
- if(complete == false)
- {
- stop_refresh = false;
- return false;
- }
- });
-
- if(stop_refresh == true)
- {
- $("form#upload input#files, form#upload input#uploadsubmit").removeClass('disabled').prop('disabled', false);
- clearInterval(refresh);
- }
- }, 2000);
- }
- else
- {
- if(typeof data.error.post_max_size !== 'undefined')
- {
- alert(data.error.post_max_size);
- }
- if(typeof data.error.error_message !== 'undefined')
- {
- var error_messages = "";
- $.each(data.error.error_message, function(index, message){
- error_messages += message+"\n\n";
- });
- alert(error_messages);
- }
- }
- }
- });
- });
- // secure file
- $(".chattrButton").each(function(){
- $(this).click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.secure_file = '',
- addpost.set_attr = $(this).attr('data-set_attr'),
- addpost.file_name = $(this).attr('data-file_name');
- addpost.item = $(this).attr('data-item');
- $('#dialog').html(ask_change_attr.replace("%file_name%",addpost.file_name));
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- });
- });
- // send_by_email
- $("#send_by_email.operations-button").click(function(){
- if(checkSession() == false) { return; }
- var addpost = {};
- addpost.items = [];
- addpost.send_by_email = '';
- var value = '';
- var items = '';
- $('input[class="item"]:checked').each(function(){
- item = $(this).attr('data-item');
- value = $(this).attr('value');
- addpost.items.push(item);
- items += "<br>"+value;
- });
- if(items != '')
- {
- if(user_email == "")
- {
- user_email = "destination@email";
- }
- $('#dialog').html(ask_send_by_email+":"+items+"<br>"+
- "<label for='archive_name'>"+archive_name+"</label><br>\n"+
- "<input name='archive_name' id='archive_name' type=text value='archive' style='width:100%;'><br>\n"+
- "<label for='archive_type'>"+archive_type+"</label><br>\n"+
- "<select name='archive_type' id='archive_type' style='width:100%;'>\n"+
- "<option value='zip'>zip</option>\n"+
- "<option value='tbz'>tbz</option>\n"+
- "<option value='tgz'>tgz</option>\n"+
- "<option value='tar'>tar</option>\n"+
- "<option value='bz2'>bz2 ("+compresses_files_separately+")</option>\n"+
- "</select><br>"+
- "<label for='subject'>"+subject+"</label><br>\n"+
- "<input name='subject' id='subject' type=text value='Files attached' style='width:100%;'><br>\n"+
- "<label for='message'>"+message+"</label><br>\n"+
- "<textarea name='message' id='message' style='width:100%;'>There are the files you requested from OGP</textarea><br>\n"+
- "<label for='dest_email'>"+dest_email+"</label><br>\n"+
- "<input name='dest_email' id='dest_email' type=text value='"+user_email+"' style='width:100%;'><br>\n");
-
- $('#dialog').dialog({
- autoOpen: true,
- width: 450,
- modal: true,
- buttons: [{ text: yes, click: function(){
- addpost.archive_name = $('#archive_name').val();
- addpost.archive_type = $('#archive_type').val();
- addpost.subject = $('#subject').val();
- addpost.message = $('#message').val();
- addpost.dest_email = $('#dest_email').val();
- $.ajax({
- type: "POST",
- url: "home.php?m=litefm&home_id="+home_id+"&type=cleared",
- data: addpost,
- success: function(data){
- data = $.trim(data);
- if(data != '')
- {
- alert(data);
- }
- },
- complete: function(){
- window.location.href = window.location.href.replace('&back','');
- }
- });
- $( this ).dialog( "close" );
- }
- },{ text: no, click: function(){
- $( this ).dialog( "close" );
- }
- }],
- close: function() {
- $( this ).dialog( "close" );
- }
- });
- }
- else
- {
- alert(select_at_least_one_item);
- }
- });
- });
|