Commit 85935b34 authored by Mikhail Karpenko's avatar Mikhail Karpenko
parents 2997e18c 569ab463
...@@ -21,15 +21,16 @@ function init() { ...@@ -21,15 +21,16 @@ 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() {
makeRequest('camogm_interface.php', '?cmd=run_camogm'); makeRequest('camogm_interface.php', '?cmd=run_camogm');
setTimeout('makeRequest("camogm_interface.php", "?cmd=setmov")', 500); // set MOV as default container format setTimeout('makeRequest("camogm_interface.php", "?cmd=setmov")', 500); // set MOV as default container format
} }
function mount_hdd() { function mount_hdd(callback) {
makeRequest('camogm_interface.php', '?cmd=mount'); makeRequest('camogm_interface.php','?cmd=mount',callback);
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";
} }
...@@ -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(); scan_devices("is_mounted(selected_device)");
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(list_files(\"\"))");
//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(); }
function find_selected_device(){
for(var i=0;i<devices.length;i++){ for(var i=0;i<devices.length;i++){
if (devices[i]=="/dev/hda1") selected_device = devices[i]; if (devices[i]=="/dev/hda1") selected_device = devices[i];
if (devices[i]=="/dev/sda1") selected_device = devices[i]; if (devices[i]=="/dev/sda1") selected_device = devices[i];
break; break;
} }
is_mounted(selected_device);
}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("");
} }
...@@ -217,6 +213,7 @@ function list_files(dir) { ...@@ -217,6 +213,7 @@ function list_files(dir) {
function process_list_file(xmldoc) { function process_list_file(xmldoc) {
var can_continue = true; var can_continue = true;
if (xmldoc.getElementsByTagName('list_files').length > 0) { if (xmldoc.getElementsByTagName('list_files').length > 0) {
if (xmldoc.getElementsByTagName('list_files')[0].firstChild!=null){
if (xmldoc.getElementsByTagName('list_files')[0].firstChild.data != null) { if (xmldoc.getElementsByTagName('list_files')[0].firstChild.data != null) {
if (xmldoc.getElementsByTagName('list_files')[0].firstChild.data == "no webshare found") { if (xmldoc.getElementsByTagName('list_files')[0].firstChild.data == "no webshare found") {
console.log("webshare not found"); console.log("webshare not found");
...@@ -229,8 +226,9 @@ function process_list_file(xmldoc) { ...@@ -229,8 +226,9 @@ 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>";
...@@ -288,6 +286,8 @@ function process_list_file(xmldoc) { ...@@ -288,6 +286,8 @@ function process_list_file(xmldoc) {
} }
response += "</table><br>"; response += "</table><br>";
document.getElementById('filelist').innerHTML = response; document.getElementById('filelist').innerHTML = response;
}else{
} }
} }
function start_compressor(parent, port) { function start_compressor(parent, port) {
...@@ -314,7 +314,7 @@ function update_audio_form(thisform) { ...@@ -314,7 +314,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 +339,20 @@ function makeRequest(url, parameters) { ...@@ -339,18 +339,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 +370,6 @@ function process_request(xmldoc) { ...@@ -368,7 +370,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":
...@@ -417,7 +418,8 @@ function process_recording(xmldoc) { ...@@ -417,7 +418,8 @@ function process_recording(xmldoc) {
document.getElementById('buffer_free').style.width = Math.round(buffer_free / 19791872 * 300); document.getElementById('buffer_free').style.width = Math.round(buffer_free / 19791872 * 300);
document.getElementById('buffer_used').style.width = Math.round(buffer_used / 19791872 * 300); document.getElementById('buffer_used').style.width = Math.round(buffer_used / 19791872 * 300);
get_hdd_space(); //get_hdd_space();
get_space(selected_mountpoint);
if (xmldoc.getElementsByTagName('buffer_overruns')[0].firstChild.data > 0) if (xmldoc.getElementsByTagName('buffer_overruns')[0].firstChild.data > 0)
alert ("Buffer overrun! current datarate exceeds max. write rate") alert ("Buffer overrun! current datarate exceeds max. write rate")
...@@ -425,7 +427,7 @@ function process_recording(xmldoc) { ...@@ -425,7 +427,7 @@ function process_recording(xmldoc) {
recording = false; recording = false;
function update_state() { function update_state() {
//if (recording) { //if (recording) {
makeRequest('camogm_interface.php', '?cmd=status'); makeRequest('camogm_interface.php','?cmd=status');
//setTimeout('update_state()', 200); //setTimeout('update_state()', 200);
//} //}
} }
...@@ -457,8 +459,9 @@ function toggle_recording() { ...@@ -457,8 +459,9 @@ function toggle_recording() {
} }
//setTimeout('list_files(getCookie("current_dir"))', 300); //setTimeout('list_files(getCookie("current_dir"))', 300);
setTimeout('get_hdd_space()', 600); //setTimeout('get_hdd_space()', 600);
//setTimeout(last_update, 900); //setTimeout(last_update, 900);
//get_space(selected_mountpoint);
} }
else // Start it else // Start it
{ {
...@@ -473,8 +476,8 @@ function toggle_recording() { ...@@ -473,8 +476,8 @@ function toggle_recording() {
document.getElementById('record_text').innerHTML = "<img src=\"images/stop.gif\" style=\"position:relative; bottom:-5px;\"> STOP"; document.getElementById('record_text').innerHTML = "<img src=\"images/stop.gif\" style=\"position:relative; bottom:-5px;\"> STOP";
document.getElementById('sitecoloumn').style.backgroundColor = "#AF2020"; document.getElementById('sitecoloumn').style.backgroundColor = "#AF2020";
//clearInterval(update_intvl); clearInterval(update_intvl);
//update_intvl = setInterval(update_state,1000); update_intvl = setInterval(update_state,1000);
} }
//update_state(); //update_state();
} }
......
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