Commit b9c2be88 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

mount/umount

parent 1a586b78
...@@ -21,7 +21,8 @@ function init() { ...@@ -21,7 +21,8 @@ function init() {
check_audio_hardware(); check_audio_hardware();
update_audio_form(document.getElementById("audioform")); update_audio_form(document.getElementById("audioform"));
calc_split_size(); calc_split_size();
scan_devices(); //calling "is_mounted" at response
scan_devices("is_mounted(selected_device)");
//global_timer = setInterval(timer_functions,2000); //global_timer = setInterval(timer_functions,2000);
} }
function reload() { function reload() {
...@@ -39,32 +40,30 @@ function process_mount_hdd(xmldoc) { ...@@ -39,32 +40,30 @@ function process_mount_hdd(xmldoc) {
if (response == "done") if (response == "done")
{ {
//setTimeout('is_hdd_mounted()', 500); //setTimeout('is_hdd_mounted()', 500);
is_hdd_mounted(); //is_mounted(,"scan_devices()");
setTimeout('scan_devices()', 800); console.log("mounted");
} }
} }
function mount_custom_partition(partition) { function mount_custom_partition(partition) {
if (document.getElementById("mount_point").value != "") { if (document.getElementById("mount_point").value != "") {
makeRequest('camogm_interface.php', '?cmd=mount&partition=' + partition + '&mountpoint=' + document.getElementById("mount_point").value); makeRequest('camogm_interface.php','?cmd=mount&partition='+partition+'&mountpoint='+document.getElementById("mount_point").value,"scan_devices()");
document.getElementById('directory').value = "/var/hdd/"; document.getElementById('directory').value = "/var/hdd/";
document.getElementById('mount_hdd_button').style.display = "none"; document.getElementById('mount_hdd_button').style.display = "none";
setTimeout('scan_devices()', 700);
} }
} }
function unmount_custom_partition(mountpoint) { function unmount_custom_partition(mountpoint) {
if (mountpoint != "") { if (mountpoint != "") {
makeRequest('camogm_interface.php','?cmd=umount&mountpoint='+mountpoint); //calling back scan_devices()
setTimeout('scan_devices()', 700); makeRequest('camogm_interface.php','?cmd=umount&mountpoint='+mountpoint,"scan_devices()");
//scan_devices();
} }
} }
function is_hdd_mounted() { function is_hdd_mounted() {
makeRequest('camogm_interface.php', '?cmd=is_hdd_mounted'); makeRequest('camogm_interface.php','?cmd=is_hdd_mounted');
} }
function is_mounted(dev){ function is_mounted(dev,callback){
makeRequest('camogm_interface.php', '?cmd=is_hdd_mounted&partition='+dev); makeRequest('camogm_interface.php','?cmd=is_hdd_mounted&partition='+dev,callback);
} }
function nothing_is_mounted_hide(){ function nothing_is_mounted_hide(){
...@@ -103,8 +102,9 @@ function process_is_hdd_mounted(xmldoc) { ...@@ -103,8 +102,9 @@ function process_is_hdd_mounted(xmldoc) {
} }
} }
function scan_devices() { //scan_devices() - fills the device list.
makeRequest('camogm_interface.php', '?cmd=listdevices'); function scan_devices(callback) {
makeRequest('camogm_interface.php','?cmd=listdevices',callback);
} }
var devices = Array(); var devices = Array();
...@@ -140,17 +140,15 @@ function process_scan_devices(xmldoc) { ...@@ -140,17 +140,15 @@ function process_scan_devices(xmldoc) {
content += "</table>"; content += "</table>";
document.getElementById('ajax_devices').innerHTML = content; document.getElementById('ajax_devices').innerHTML = content;
} }
if (devices.length>0){ find_selected_device();
nothing_is_mounted_hide(); }
for(var i=0;i<devices.length;i++){
if (devices[i]=="/dev/hda1") selected_device = devices[i]; function find_selected_device(){
if (devices[i]=="/dev/sda1") selected_device = devices[i]; for(var i=0;i<devices.length;i++){
break; if (devices[i]=="/dev/hda1") selected_device = devices[i];
} if (devices[i]=="/dev/sda1") selected_device = devices[i];
is_mounted(selected_device); break;
}else{ }
nothing_is_mounted_hide();
}
} }
function create_folder() { function create_folder() {
...@@ -174,13 +172,11 @@ function get_hdd_space() { ...@@ -174,13 +172,11 @@ function get_hdd_space() {
} }
function get_space(mountpoint){ function get_space(mountpoint){
console.log("getting space");
makeRequest('camogm_interface.php','?cmd=get_hdd_space&mountpoint='+mountpoint); makeRequest('camogm_interface.php','?cmd=get_hdd_space&mountpoint='+mountpoint);
} }
function process_hdd_space(xmldoc) { function process_hdd_space(xmldoc) {
var response = xmldoc.getElementsByTagName('get_hdd_space')[0].firstChild.data; var response = xmldoc.getElementsByTagName('get_hdd_space')[0].firstChild.data;
console.log("space is "+response);
document.getElementById('hdd_rem').innerHTML = Math.round(response/1024/1024/1024*100)/100 + " GB"; document.getElementById('hdd_rem').innerHTML = Math.round(response/1024/1024/1024*100)/100 + " GB";
//list_files(""); //list_files("");
} }
...@@ -230,7 +226,7 @@ function process_list_file(xmldoc) { ...@@ -230,7 +226,7 @@ function process_list_file(xmldoc) {
} }
} }
if (can_continue){ if (can_continue){
console.log("continued"); console.log("Processing file list");
var count = xmldoc.getElementsByTagName('file').length; var count = xmldoc.getElementsByTagName('file').length;
var response = "<table cellspacing=\"0px\" cellpadding=\"3px\" width=\"100%\">"; var response = "<table cellspacing=\"0px\" cellpadding=\"3px\" width=\"100%\">";
response += "<tr><td width=\"50%\"><b>File</b></td><td width=\"30%\"><b>Creation Date</b></td><td><b>Size</b></td></tr>"; response += "<tr><td width=\"50%\"><b>File</b></td><td width=\"30%\"><b>Creation Date</b></td><td><b>Size</b></td></tr>";
...@@ -314,7 +310,7 @@ function update_audio_form(thisform) { ...@@ -314,7 +310,7 @@ function update_audio_form(thisform) {
} }
} }
function makeRequest(url, parameters) { function makeRequest(url,parameters,callback) {
var http_request = false; var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,... if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest(); http_request = new XMLHttpRequest();
...@@ -339,18 +335,20 @@ function makeRequest(url, parameters) { ...@@ -339,18 +335,20 @@ function makeRequest(url, parameters) {
if (http_request.readyState == 4) { if (http_request.readyState == 4) {
if (http_request.status == 200) { if (http_request.status == 200) {
if (http_request.responseXML != null) { if (http_request.responseXML != null) {
process_request(http_request.responseXML); process_request(http_request.responseXML)
if (typeof callback != 'undefined') {
eval(callback);
}
} }
} }
} }
}; };
http_request.open('GET', url + parameters, true); http_request.open('GET', url+parameters, true);
http_request.send(null); http_request.send(null);
} }
function process_request(xmldoc) { function process_request(xmldoc) {
console.log("process_request");
if (xmldoc.getElementsByTagName('camogm_state').length > 0) { if (xmldoc.getElementsByTagName('camogm_state').length > 0) {
console.log(xmldoc.getElementsByTagName('state')[0].firstChild.data); console.log(xmldoc.getElementsByTagName('state')[0].firstChild.data);
process_recording(xmldoc); process_recording(xmldoc);
...@@ -368,7 +366,6 @@ function process_request(xmldoc) { ...@@ -368,7 +366,6 @@ function process_request(xmldoc) {
process_rename_file(xmldoc); process_rename_file(xmldoc);
break; break;
case "get_hdd_space": case "get_hdd_space":
console.log("Got space responze");
process_hdd_space(xmldoc); process_hdd_space(xmldoc);
break; break;
case "mount": case "mount":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment