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

1.configs 2.speedup

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