Commit 13c80c28 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1.configs 2.speedup

parent 8af5b504
...@@ -143,7 +143,7 @@ function init(){ ...@@ -143,7 +143,7 @@ function init(){
$("#controls_"+index).addClass("hidden_content"); $("#controls_"+index).addClass("hidden_content");
debugfs_data[index].state = 0; debugfs_data[index].state = 0;
} }
update_debugfs_config(); update_debugfs_config(index);
}); });
$(".flags_cb").change(function(){ $(".flags_cb").change(function(){
...@@ -334,29 +334,35 @@ function init_ui_controls(record,index){ ...@@ -334,29 +334,35 @@ function init_ui_controls(record,index){
url:"debugfs.php?cmd=reread&file="+file, url:"debugfs.php?cmd=reread&file="+file,
queue: true, queue: true,
success:function(data){ success:function(data){
//console.log("Welcome "+id+" & "+file);
rec = jQuery.parseJSON(data); rec = jQuery.parseJSON(data);
target = $("#content_"+id).find("#content_td"); target = $("#content_"+id).find("#content_td");
//apply existing checkboxes to rec //apply existing checkboxes to rec
oldrec = debugfs_data[id]; oldrec = debugfs_data[id];
j = dropdown_active_config(rec,id); //to save to active config
j = dropdown_active_config(oldrec,id);
lnew = rec.configs[j].lines.length; //console.log("Ze Jay is "+j);
lnew = rec.configs[0].lines.length;
lold = debugfs_data[id].configs[j].lines.length; lold = debugfs_data[id].configs[j].lines.length;
//restore checkboxes
for(var i=0;i<lnew;i++){ for(var i=0;i<lnew;i++){
if (i<lold) { if (i<lold) {
rec.configs[j].lines[i].flags=oldrec.configs[j].lines[i].flags; rec.configs[0].lines[i].flags=oldrec.configs[j].lines[i].flags;
}else{ }else{
rec.configs[j].lines[i].flags=oldrec.configs[j].lines[lold-1].flags; rec.configs[0].lines[i].flags=oldrec.configs[j].lines[lold-1].flags;
} }
} }
//copy back
oldrec.configs[j].lines = JSON.parse(JSON.stringify(rec.configs[0].lines));
//update debugfs_data fill_content(oldrec.configs[j].lines,id,target);
debugfs_data[id].configs[j] = rec.configs[j];
fill_content(rec.configs[j].lines,id,target);
fill_content_rebind_events(); fill_content_rebind_events();
} }
}); });
...@@ -496,17 +502,23 @@ function dropdown_select_config(index,config_index){ ...@@ -496,17 +502,23 @@ function dropdown_select_config(index,config_index){
$("#dropdown_"+index).html(record.configs[config_index].name+caret); $("#dropdown_"+index).html(record.configs[config_index].name+caret);
record.configs[ac].state = 0; record.configs[ac].state = 0;
record.configs[config_index].state = 1; record.configs[config_index].state = 1;
var target = $("#content_"+index).find("#content_td");
fill_content(record.configs[config_index].lines,index,target);
fill_content_rebind_events();
//restore checkboxes! //restore checkboxes!
update_debugfs_config(); update_debugfs_config(index);
} }
} }
function update_debugfs_config(){ function update_debugfs_config(index){
var file = debugfs_data[index].file;
console.log("syncing debugfs config"); console.log("syncing debugfs config");
//console.log(debugfs_data); //console.log(debugfs_data);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "debugfs.php?cmd=sync", url: "debugfs.php?cmd=sync&file="+file,
data: JSON.stringify(debugfs_data), data: JSON.stringify(debugfs_data),
dataType: "json" dataType: "json"
}); });
......
...@@ -100,55 +100,56 @@ function update_config($data){ ...@@ -100,55 +100,56 @@ function update_config($data){
function apply_config_to_control(){ function apply_config_to_control(){
global $tmp_config, $DEBUGFSFILE; global $tmp_config, $DEBUGFSFILE;
$longstring = "";
$arr_config = json_decode(file_get_contents($tmp_config),true); $arr_config = json_decode(file_get_contents($tmp_config),true);
foreach($arr_config as $k0 => $v0){ foreach($arr_config as $v0){
if ($v0['state']==1){ if ($v0['state']==1){
foreach($v0['configs'] as $k1 => $v1){ foreach($v0['configs'] as $v1){
if ($v1['state']==1){ if ($v1['state']==1){
foreach($v1['lines'] as $k2 => $v2){ foreach($v1['lines'] as $v2){
$file = $v2['file']; $file = $v2['file'];
$lineno = $v2['lineno']; $lineno = $v2['lineno'];
$flag = $v2['flags']; $flag = $v2['flags'];
if ($flag=="p") $sign = "+"; if ($flag=="p") $sign = "+";
else $sign = "-"; else $sign = "-";
exec("echo -n 'file $file line $lineno ${sign}p' > $DEBUGFSFILE"); $newstring = "file $file line $lineno ${sign}p;";
//there's a limit
if (strlen($longstring.$newstring)>4095){
exec("echo -n '$longstring' > $DEBUGFSFILE");
$longstring = $newstring;
}else{
$longstring .= $newstring;
}
//echo "echo -n 'file $file line $lineno ${sign}p'\n"; //echo "echo -n 'file $file line $lineno ${sign}p'\n";
} }
} }
} }
} }
} }
exec("echo -n '$longstring' > $DEBUGFSFILE");
echo "Done"; echo "Done";
} }
function apply_flag($flag){ function apply_flag($flag){
global $tmp_config, $DEBUGFSFILE; global $tmp_config, $DEBUGFSFILE;
$longstring = "";
//add short command for all here
$arr_config = json_decode(file_get_contents($tmp_config),true); $arr_config = json_decode(file_get_contents($tmp_config),true);
foreach($arr_config as $k0 => $v0){ foreach($arr_config as $v0){
if ($v0['state']==1){ if ($v0['state']==1){
foreach($v0['configs'] as $k1 => $v1){ foreach($v0['configs'] as $v1){
if ($v1['state']==1){ if ($v1['state']==1){
$cmd = "echo -n 'file ".$v0['file']." $flag' > $DEBUGFSFILE"; $newstring = "file ".$v0['file']." $flag;";
exec($cmd); if (strlen($longstring.$newstring)>4095){
/* exec("echo -n '$longstring' > $DEBUGFSFILE");
foreach($v1['lines'] as $k2 => $v2){ $longstring = $newstring;
$file = $v2['file']; }else{
$lineno = $v2['lineno']; $longstring .= $newstring;
$cmd = "echo -n 'file $file line $lineno $flag' > $DEBUGFSFILE";
//echo "$cmd\n";
exec($cmd);
//echo "echo -n 'file $file line $lineno ${sign}p'\n";
} }
*/
} }
} }
} }
} }
exec("echo -n '$longstring' > $DEBUGFSFILE");
echo "Done"; echo "Done";
} }
...@@ -266,8 +267,10 @@ if ($cmd=="save"){ ...@@ -266,8 +267,10 @@ if ($cmd=="save"){
if ($cmd=="sync"){ if ($cmd=="sync"){
//list saved configs here //list saved configs here
$file = $_GET['file'];
$data = file_get_contents("php://input"); $data = file_get_contents("php://input");
update_config($data); update_config($data);
apply_config_to_control();
} }
if ($cmd=="savetofs"){ if ($cmd=="savetofs"){
......
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