]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
outsourced javascript routines from jtageditor.pl to jtageditor.js, added move and...
authorMichael Wiebusch <stratomaster@gmx.net>
Wed, 21 Aug 2013 17:43:45 +0000 (19:43 +0200)
committerMichael Wiebusch <stratomaster@gmx.net>
Wed, 21 Aug 2013 17:43:45 +0000 (19:43 +0200)
tools/jtageditor.js [new file with mode: 0644]
tools/jtageditor.pl
tools/xmlOperation.pl
tools/xmlOperations.js
tools/xmlRendering.pm

diff --git a/tools/jtageditor.js b/tools/jtageditor.js
new file mode 100644 (file)
index 0000000..f78fd40
--- /dev/null
@@ -0,0 +1,114 @@
+function selectedConfigFile(){
+if(document.getElementById("fileSelector")){
+var e = document.getElementById("fileSelector");
+return e.options[e.selectedIndex].text;
+}
+else {
+  return "";
+}
+}
+
+
+
+function selectedSpecFile(){
+if(document.getElementById("specSelector")){
+var e = document.getElementById("specSelector");
+return e.options[e.selectedIndex].text;}
+else {
+  return "";
+}
+}
+
+function newFileName(){
+if(document.getElementById("newFileName")){
+  var fileName = document.getElementById("newFileName").value;
+  var patt = /\.xml/i;
+  if(patt.test(fileName)){
+  return fileName;
+  } else {
+    return fileName+".xml";
+  }
+} else {
+  return "";
+}
+}
+
+function mvCpFileName(){
+if(document.getElementById("mvCpFileName")){
+  var fileName = document.getElementById("mvCpFileName").value;
+  var patt = /\.xml/i;
+  if(patt.test(fileName)){
+  return fileName;
+  } else {
+    return fileName+".xml";
+  }
+} else {
+  return "";
+}
+}
+
+
+function reloadSpecTree(){
+var file_ = encodeURIComponent(selectedConfigFile());
+getdata('jtageditor.pl?print=spectree&configFile='+file_,'roterBereich',false);
+showAgain();
+}
+
+function reloadSetTree(){
+var file_ = encodeURIComponent(selectedConfigFile());
+getdata('jtageditor.pl?print=settree&configFile='+file_,'blauerBereich',false);
+showAgain();
+}
+
+
+function loadFile(){
+
+debugOutput("load data from "+selectedConfigFile());
+visHash = new Object();
+reloadSpecTree();
+reloadSetTree();
+reloadFileSelection(selectedConfigFile());
+  
+}
+
+
+
+function debugOutput(input){
+getdata("jtageditor.pl?debuginput="+encodeURIComponent(input),"debug",true);
+}
+
+function writeToElementId(input,destId){
+  if(document.getElementById(destId).innerHTML){
+  document.getElementById(destId).innerHTML  = input;  
+  }
+
+}
+
+function reloadFileSelection(configFile){
+var file_ = encodeURIComponent(configFile);
+getdata('jtageditor.pl?print=fileSelection&configFile='+file_,'fileSelection',false);
+}
+
+
+
+
+function hideThisFileLevel(classname,checked){
+
+var array = document.getElementById("configFileRegisters").getElementsByClassName(classname);
+
+for(var i = 0; i < array.length; i++)
+{
+    if(checked){
+     array[i].style.visibility = 'visible';
+     
+    }else{
+      
+    array[i].style.visibility = 'collapse';
+    }
+    
+
+}
+
+
+}
+
index db625f0f700179d43af32732e89719e413099da5..02576e9ff9c9df55495a0c1744434bafc237a940 100755 (executable)
@@ -240,6 +240,22 @@ sub print_fileSelection {
   print "</td></tr></table>";
 
   print "</p>";
+  
+  print "<h3>move/copy this file</h3>";
+  print "<p>";
+  print "<table><tr>";
+  print "<td>new filename</td>";
+  print "</tr>";
+  print "<tr>";
+  print "<td>";
+  print "<input type='text' value='' id='mvCpFileName'>";
+  print "</td><td>";
+  print "<input type='button' onclick='moveFile(selectedConfigFile(),mvCpFileName());reloadFileSelection(mvCpFileName());loadFile()' value='rename/move' class='stdbutton'>";
+  print "<input type='button' onclick='copyFile(selectedConfigFile(),mvCpFileName());reloadFileSelection(mvCpFileName());loadFile()' value='copy' class='stdbutton'>";
+  print "</td></tr></table>";
+  
+  print "</p>";
+  
 
 
 }
@@ -388,168 +404,13 @@ sub printJavaScripts {
 
   print <<EOF ;
 <script language="javascript" src="xmlOperations.js"></script> 
-<script language="javascript">
-
-
-
-
-function selectedConfigFile(){
-if(document.getElementById("fileSelector")){
-var e = document.getElementById("fileSelector");
-return e.options[e.selectedIndex].text;
-}
-else {
-  return "";
-}
-}
-
-function selectedSpecFile(){
-if(document.getElementById("specSelector")){
-var e = document.getElementById("specSelector");
-return e.options[e.selectedIndex].text;}
-else {
-  return "";
-}
-}
-
-function newFileName(){
-if(document.getElementById("newFileName")){
-  var fileName = document.getElementById("newFileName").value;
-  var patt = /\.xml/i;
-  if(patt.test(fileName)){
-  return fileName;
-  } else {
-    return fileName+".xml";
-  }
-} else {
-  return "";
-}
-}
-
-
-
-
-function reloadSpecTree(){
-var file_ = encodeURIComponent(selectedConfigFile());
-getdata('$me?print=spectree&configFile='+file_,'roterBereich',false);
-showAgain();
-}
-
-function reloadSetTree(){
-var file_ = encodeURIComponent(selectedConfigFile());
-getdata('$me?print=settree&configFile='+file_,'blauerBereich',false);
-showAgain();
-}
-
-
-function loadFile(){
-
-debugOutput("load data from "+selectedConfigFile());
-visHash = new Object();
-reloadSpecTree();
-reloadSetTree();
-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();
-}
+<script language="javascript" src="jtageditor.js"></script> 
 
-function deleteFile(){
-  var file_ = encodeURIComponent(selectedConfigFile());  
-  getdata('xmlOperation.pl?action=deleteFile&configFile='+file_,false);
-  loadFile();
-}
-
-function createFile(){
-  debugOutput("NewFileName: "+newFileName());
-  var configFile_ = encodeURIComponent(newFileName());
-  var specFile_ = encodeURIComponent(selectedSpecFile());
-  getdata("xmlOperation.pl?action=createFile&configFile="+configFile_+"&specFile="+specFile_,"debug",false);
-  getdata('$me?print=fileSelection&configFile='+configFile_,'fileSelection',false);
-  loadFile();
 
-}
 
 
 
-function saveSettings(register,field,value){
-var file_ = encodeURIComponent(selectedConfigFile());
-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(register,field){
-var file_ = encodeURIComponent(selectedConfigFile());
-var register_ = encodeURIComponent(register);
-var field_ = encodeURIComponent(field);
-
-getdata("xmlOperation.pl?action=delete&configFile="+file_+"&register="+register_+"&field="+field_,"debug",false);
-reloadSetTree();
-}
-
-function copyDefaultRegister(register){
-var register_ = encodeURIComponent(register);
-var file_ =encodeURIComponent(selectedConfigFile());
-getdata("xmlOperation.pl?action=copyDefaultRegister&register="+register_+'&configFile='+file_,"debug",false);
-reloadSetTree();
-}
-
-*/
-
-
-function debugOutput(input){
-getdata("$me?debuginput="+encodeURIComponent(input),"debug",true);
-}
-
-function writeToElementId(input,destId){
-  if(document.getElementById(destId).innerHTML){
-  document.getElementById(destId).innerHTML  = input;  
-  }
-
-}
-
-function reloadFileSelection(configFile){
-var file_ = encodeURIComponent(configFile);
-getdata('$me?print=fileSelection&configFile='+file_,'fileSelection',false);
-}
-
-
-
-
-function hideThisFileLevel(classname,checked){
-
-var array = document.getElementById("configFileRegisters").getElementsByClassName(classname);
-
-for(var i = 0; i < array.length; i++)
-{
-    if(checked){
-     array[i].style.visibility = 'visible';
-     
-    }else{
-      
-    array[i].style.visibility = 'collapse';
-    }
-    
-
-}
-
-
-}
 
-</script>
 
 <script language="javascript" src="getdata.js"></script>
 <script language="javascript" src="hideAndShow.js"></script>
index 44d14c8452236e41bb7c6cf5066e193a323b0e01..1e0b1303938e3847c2684110264ede22ca8756c5 100755 (executable)
@@ -62,6 +62,35 @@ unless ($q->param()){
 
 if ( defined $q->param('action') ) {
 
+
+  if ( $q->param('action') eq 'moveFile' ) {
+    my $configFile = $q->param('configFile');
+    my $newFile = $q->param('newFile');
+    
+    unless ( -e $confDir.$configFile) {
+        die "config file $configFile not found\n";
+    }
+    
+    system("mv ".$confDir.$configFile." ".$confDir.$newFile);
+    report_param();
+    exit();
+    
+  }
+  
+  if ( $q->param('action') eq 'copyFile' ) {
+    my $configFile = $q->param('configFile');
+    my $newFile = $q->param('newFile');
+    
+    unless ( -e $confDir.$configFile) {
+        die "config file $configFile not found\n";
+    }
+    
+    system("cp ".$confDir.$configFile." ".$confDir.$newFile);
+    report_param();
+    exit();
+    
+  }
+  
   if ( $q->param('action') eq 'save' ) {
     parseConfigFile( $q->param('configFile') );
     
index 35f1703f8a461f6ed56dd1f0785ac9106d7c88f9..5d3573743f0462ae766674d5f660b6bf88db6068 100644 (file)
@@ -1,4 +1,16 @@
 
+function moveFile(configFile,newFile){
+  var configFile_ = encodeURIComponent(configFile);  
+  var newFile_ = encodeURIComponent(newFile);  
+  getdata('xmlOperation.pl?action=moveFile&configFile='+configFile_+'&newFile='+newFile_,false);
+}
+
+function copyFile(configFile,newFile){
+  var configFile_ = encodeURIComponent(configFile);  
+  var newFile_ = encodeURIComponent(newFile);  
+  getdata('xmlOperation.pl?action=copyFile&configFile='+configFile_+'&newFile='+newFile_,false);
+}
+
 function changeAncestor(configFile,newAncestor){
   var file_ = encodeURIComponent(selectedConfigFile());  
   var configFile_ = encodeURIComponent(configFile);  
index c1c6ed62db52d73cefa446f26bbaef22dfd66c66..bcf0d32de3699c4488c24da0cf822b2bbcae40bf 100644 (file)
@@ -246,7 +246,7 @@ EOF
     }
     else {
       print qq%
-<td align='right'>
+<td align='center'>
 <input type='text' align='right' value='$fieldValue' onchange='saveSettings("$configFileName","$registerName","$fieldName",this.value);$editorRefreshCommand'  >%;
 
      print_conversionMenu($registerName,$fieldName,$conversionTableId);