]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
rearrangend some functions in jtageditor.pl, outsourced the common xml operation...
authorMichael Wiebusch <stratomaster@gmx.net>
Wed, 31 Jul 2013 16:17:41 +0000 (18:17 +0200)
committerMichael Wiebusch <stratomaster@gmx.net>
Wed, 31 Jul 2013 16:17:41 +0000 (18:17 +0200)
tools/jtageditor.pl
tools/xmlOperations.js [new file with mode: 0644]

index 5c1a37ff8c63bab41e7f579220cf2a4b07667879..fb0fe163d0ad78552e1710c3755505437caddd82 100755 (executable)
@@ -223,7 +223,7 @@ sub print_fileSelection {
   print
 "<input type='button' onclick='loadFile()' value='reload file' class='stdbutton'>";
   print
-"<input type='button' onclick='deleteFile()' value='delete file' class='stdbutton'>";
+"<input type='button' onclick='deleteFile(selectedConfigFile());loadFile()' value='delete file' class='stdbutton'>";
 
   print "</p>";
 
@@ -239,7 +239,7 @@ sub print_fileSelection {
   print_specSelector();
   print "</td><td>";
   print
-"<input type='button' onclick='createFile()' value='create file' class='stdbutton'>";
+"<input type='button' onclick='createFile(selectedSpecFile(),newFileName());reloadFileSelection(newFileName());loadFile()' value='create file' class='stdbutton'>";
   print "</td></tr></table>";
 
   print "</p>";
@@ -298,13 +298,13 @@ EOF
 
     if ( $xmlfile eq $configFile ) {  # we are printing the Specifications Tree
       print <<EOF;
-<td class='button_move' onclick='deleteSettings("$registerName","");'>&nbsp;X&nbsp;</td>
+<td class='button_move' onclick='deleteSettings(selectedConfigFile(),"$registerName","");reloadSetTree()'>&nbsp;X&nbsp;</td>
 EOF
     }
     if ( $xmlfile eq $specFile ) {    # we are printing the Settings Tree
 
       print <<EOF;
-<td class='button_move' onclick='copyDefaultRegister("$registerName");'>&nbsp;&rarr;&nbsp;</td>
+<td class='button_move' onclick='copyDefaultRegister(selectedConfigFile(),"$registerName");reloadSetTree()'>&nbsp;&rarr;&nbsp;</td>
 EOF
     }
 
@@ -390,7 +390,7 @@ EOF
     else {
       print <<EOF;
 <td align='right'>
-<input type='text' align='right' value='$fieldValue' onchange='saveSettings("$registerName","$fieldName",this.value)'  >
+<input type='text' align='right' value='$fieldValue' onchange='saveSettings(selectedConfigFile(),"$registerName","$fieldName",this.value);reloadSetTree()'  >
 </td>
 EOF
 
@@ -399,7 +399,7 @@ EOF
     print '</td>';
     if ( $xmlfile eq $specFile ) { # we are printing the Specifications tree
       print <<EOF;
-<td class='button_move' onclick='saveSettings("$registerName","$fieldName","$fieldValue");'>&nbsp;&rarr;&nbsp;</td>
+<td class='button_move' onclick='saveSettings(selectedConfigFile(),"$registerName","$fieldName","$fieldValue");'>&nbsp;&rarr;&nbsp;</td>
 EOF
     }
     if ( $xmlfile eq $configFile ) {    # we are printing the Settings Tree
@@ -407,7 +407,7 @@ EOF
       if ( $isHeritageFrom eq "" )
       {    # these are actual settings, not inherited!
         print <<EOF;
-<td class='button_move' onclick='deleteSettings("$registerName","$fieldName");'>&nbsp;X&nbsp;</td>
+<td class='button_move' onclick='deleteSettings(selectedConfigFile(),"$registerName","$fieldName");reloadSetTree()'>&nbsp;X&nbsp;</td>
 EOF
       }
       else {
@@ -458,7 +458,7 @@ sub print_ancestorInfo {
         . getFileLevel($ancestor) . "\",this.checked)'></td>";
       if ( getFileLevel($ancestor) eq "1" ) {
         print <<EOF;
-<td class='button_move' title='unlink includes' onclick='changeAncestor("")'>&nbsp;X&nbsp;</td>
+<td class='button_move' title='unlink includes' onclick='changeAncestor(selectedConfigFile(),"");reloadSetTree()'>&nbsp;X&nbsp;</td>
 EOF
 
       }
@@ -468,7 +468,7 @@ EOF
   else {    # print an ancestor selector!
     print "include settings from:<br>";
     print_fileSelector( "", "ancestorSelector",
-      "changeAncestor(this.options[this.selectedIndex].text)" );
+      "changeAncestor(selectedConfigFile(),this.options[this.selectedIndex].text);reloadSetTree()" );
 
   }
 
@@ -491,7 +491,7 @@ EOF
   printJavaScripts();
   print <<EOF;
 </HEAD>
-<BODY onload='reloadFileSelection()'>
+<BODY onload='reloadFileSelection(selectedConfigFile())'>
 <h2>JTAG Configuration File Editor</h2>
 <div id="debug">
 debug text
@@ -579,21 +579,10 @@ sub printJavaScripts {
 ####### javascript function land ################
 
   print <<EOF ;
-
+<script language="javascript" src="xmlOperations.js"></script> 
 <script language="javascript">
 
-function changeAncestor(newAncestor){
-  var file_ = encodeURIComponent(selectedConfigFile());  
-  var newAncestor_ = encodeURIComponent(newAncestor);  
-  getdata('xmlOperation.pl?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
-  reloadSetTree();
-}
 
-function deleteFile(){
-  var file_ = encodeURIComponent(selectedConfigFile());  
-  getdata('xmlOperation.pl?action=deleteFile&configFile='+file_,false);
-  loadFile();
-}
 
 
 function selectedConfigFile(){
@@ -659,10 +648,27 @@ debugOutput("load data from "+selectedConfigFile());
 visHash = new Object();
 reloadSpecTree();
 reloadSetTree();
-reloadFileSelection();
+reloadFileSelection(selectedConfigFile());
   
 }
 
+/*
+
+these should be now implemented in xmlOperations.js
+
+function changeAncestor(newAncestor){
+  var file_ = encodeURIComponent(selectedConfigFile());  
+  var newAncestor_ = encodeURIComponent(newAncestor);  
+  getdata('xmlOperation.pl?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
+  reloadSetTree();
+}
+
+function deleteFile(){
+  var file_ = encodeURIComponent(selectedConfigFile());  
+  getdata('xmlOperation.pl?action=deleteFile&configFile='+file_,false);
+  loadFile();
+}
+
 function createFile(){
   debugOutput("NewFileName: "+newFileName());
   var configFile_ = encodeURIComponent(newFileName());
@@ -673,10 +679,7 @@ function createFile(){
 
 }
 
-function reloadFileSelection(){
-var file_ = encodeURIComponent(selectedConfigFile());
-getdata('$me?print=fileSelection&configFile='+file_,'fileSelection',false);
-}
+
 
 function saveSettings(register,field,value){
 var file_ = encodeURIComponent(selectedConfigFile());
@@ -704,6 +707,9 @@ getdata("xmlOperation.pl?action=copyDefaultRegister&register="+register_+'&confi
 reloadSetTree();
 }
 
+*/
+
+
 function debugOutput(input){
 getdata("$me?debuginput="+encodeURIComponent(input),"debug",true);
 }
@@ -715,6 +721,10 @@ function writeToElementId(input,destId){
 
 }
 
+function reloadFileSelection(configFile){
+var file_ = encodeURIComponent(configFile);
+getdata('$me?print=fileSelection&configFile='+file_,'fileSelection',false);
+}
 
 function toggleVis(elementId,t) {
 if(document.getElementById(elementId)){
diff --git a/tools/xmlOperations.js b/tools/xmlOperations.js
new file mode 100644 (file)
index 0000000..5d34979
--- /dev/null
@@ -0,0 +1,54 @@
+
+function changeAncestor(configFile,newAncestor){
+  var file_ = encodeURIComponent(selectedConfigFile());  
+  var configFile_ = encodeURIComponent(configFile);  
+  var newAncestor_ = encodeURIComponent(newAncestor);  
+  getdata('xmlOperation.pl?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
+//   reloadSetTree();
+}
+
+
+function deleteFile(file){
+  var file_ = encodeURIComponent(file);  
+  getdata('xmlOperation.pl?action=deleteFile&configFile='+file_,false);
+//   loadFile();
+}
+
+
+function createFile(specFile,newFileName){
+//   debugOutput("NewFileName: "+newFileName());
+  var configFile_ = encodeURIComponent(newFileName);
+  var specFile_ = encodeURIComponent(specFile);
+  getdata("xmlOperation.pl?action=createFile&configFile="+configFile_+"&specFile="+specFile_,"debug",false);
+  getdata('$me?print=fileSelection&configFile='+configFile_,'fileSelection',false);
+//   loadFile();
+
+}
+
+function saveSettings(configFile,register,field,value){
+var file_ = encodeURIComponent(configFile);
+var register_ = encodeURIComponent(register);
+var field_ = encodeURIComponent(field);
+var value_ =  encodeURIComponent(value);
+
+getdata("xmlOperation.pl?action=save&configFile="+file_+"&register="+register_+"&field="+field_+"&value="+value_,"debug",false);
+// reloadSetTree();
+}
+
+function deleteSettings(configFile,register,field){
+var file_ = encodeURIComponent(configFile);
+var register_ = encodeURIComponent(register);
+var field_ = encodeURIComponent(field);
+
+getdata("xmlOperation.pl?action=delete&configFile="+file_+"&register="+register_+"&field="+field_,"debug",false);
+// reloadSetTree();
+}
+
+
+function copyDefaultRegister(configFile,register){
+var register_ = encodeURIComponent(register);
+var file_ =encodeURIComponent(configFile);
+getdata("xmlOperation.pl?action=copyDefaultRegister&register="+register_+'&configFile='+file_,"debug",false);
+// reloadSetTree();
+}
+