]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
modularized my code further, created xmlOperation.pl as a CGI portal to functionality...
authorMichael Wiebusch <stratomaster@gmx.net>
Thu, 25 Jul 2013 16:31:15 +0000 (18:31 +0200)
committerMichael Wiebusch <stratomaster@gmx.net>
Thu, 25 Jul 2013 16:31:15 +0000 (18:31 +0200)
tools/Common.pm
tools/jtageditor.pl
tools/testgui.pl
tools/xmlOperation.pl [new file with mode: 0755]

index 555577addd9dbda7d5c96cdf9cc698171b9fd9ae..913be8c7ea57c2ca4a6886455230e4f26697c12b 100644 (file)
@@ -8,6 +8,14 @@
 ## misc utilities
 ###############################
 
+sub printHash {
+  my $hashref = $_[0];
+  for my $element ( keys %{$hashref} ) {
+    print $element. "=" . $hashref->{$element} . "<br>\n";
+  }
+}
+
+
 sub getStdIn {
 #write std in into an array and return that
 # if semicola are somewhere, interprete 
index 954749726295ab671dd05b2bb2469655f7e7e413..aa52e467803328212374e1f82cbcd2c66a77888e 100755 (executable)
@@ -17,6 +17,7 @@ print "Content-type: text/html\n\n";
 # build ancestry without ancestry tree outside
 
 # find a solution for fileLevel <=6
+# our to ENV
 
 
 # DONE
@@ -540,12 +541,7 @@ sub by_name {
   return $a_name cmp $b_name;
 }
 
-sub printHash {
-  my $hashref = $_[0];
-  for my $element ( keys %{$hashref} ) {
-    print $element. "=" . $hashref->{$element} . "<br>\n";
-  }
-}
+
 
 sub read_input {
   my $buffer;
@@ -603,13 +599,13 @@ sub printJavaScripts {
 function changeAncestor(newAncestor){
   var file_ = encodeURIComponent(selectedConfigFile());  
   var newAncestor_ = encodeURIComponent(newAncestor);  
-  getdata('$me?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
+  getdata('xmlOperation.pl?action=changeAncestor&configFile='+file_+'&newAncestor='+newAncestor_,false);
   reloadSetTree();
 }
 
 function deleteFile(){
   var file_ = encodeURIComponent(selectedConfigFile());  
-  getdata('$me?action=deleteFile&configFile='+file_,false);
+  getdata('xmlOperation.pl?action=deleteFile&configFile='+file_,false);
   loadFile();
 }
 
@@ -685,7 +681,7 @@ function createFile(){
   debugOutput("NewFileName: "+newFileName());
   var configFile_ = encodeURIComponent(newFileName());
   var specFile_ = encodeURIComponent(selectedSpecFile());
-  getdata("$me?action=createFile&configFile="+configFile_+"&specFile="+specFile_,"debug",false);
+  getdata("xmlOperation.pl?action=createFile&configFile="+configFile_+"&specFile="+specFile_,"debug",false);
   getdata('$me?print=fileSelection&configFile='+configFile_,'fileSelection',false);
   loadFile();
 
@@ -697,33 +693,28 @@ getdata('$me?print=fileSelection&configFile='+file_,'fileSelection',false);
 }
 
 function saveSettings(register,field,value){
-//getdata("$me?debuginput=tralla","debug");
 var file_ = encodeURIComponent(selectedConfigFile());
 var register_ = encodeURIComponent(register);
 var field_ = encodeURIComponent(field);
 var value_ =  encodeURIComponent(value);
 
-getdata("$me?action=save&configFile="+file_+"&register="+register_+"&field="+field_+"&value="+value_,"debug",false);
-//getdata("$me?print=settree","blauerBereich",true);
+getdata("xmlOperation.pl?action=save&configFile="+file_+"&register="+register_+"&field="+field_+"&value="+value_,"debug",false);
 reloadSetTree();
 }
 
 function deleteSettings(register,field){
-//getdata("$me?debuginput=tralla","debug");
 var file_ = encodeURIComponent(selectedConfigFile());
 var register_ = encodeURIComponent(register);
 var field_ = encodeURIComponent(field);
 
-getdata("$me?action=delete&configFile="+file_+"&register="+register_+"&field="+field_,"debug",false);
-//getdata("$me?print=settree","blauerBereich",true);
+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("$me?action=copyDefaultRegister&register="+register_+'&configFile='+file_,"debug",false);
-//getdata("$me?print=settree","blauerBereich",true);
+getdata("xmlOperation.pl?action=copyDefaultRegister&register="+register_+'&configFile='+file_,"debug",false);
 reloadSetTree();
 }
 
index 9f027ff65560a18758f026d74daba30d9cb5d561..84417995e82255260f7878db2ab0d78c3ade116b 100755 (executable)
@@ -26,12 +26,16 @@ print start_html(
 );
 
 print h2("testgui");
-print "<p> still more to come </p>";
 
-print escapeHTML("hallo<<<>>>&&&!!"),br;
-print escapeHTML($here);
 
-chdir("./preview") or die "could not change directory!";
-system("./run.pl -t 0.1 -id ccc1ccc1");
-chdir($here);
+print "<div>";
 
+print "<table>";
+print "<tr><td>IVDREF1A</td><td>IVDREF1B</td></tr>";
+print "<tr><td><input type='text' id='IVDREF1A'></td></tr>";
+print "</table>";
+
+
+print "</div>";
+
+print end_html;
diff --git a/tools/xmlOperation.pl b/tools/xmlOperation.pl
new file mode 100755 (executable)
index 0000000..d585cae
--- /dev/null
@@ -0,0 +1,118 @@
+#!/usr/bin/perl -w
+#print "Content-type: text/html\n\n";
+
+
+my $me = "xmlOperation.pl";
+
+use strict;
+use warnings;
+use XML::LibXML;
+use POSIX;
+use CGI ':standard';
+
+use CGI::Carp qw(fatalsToBrowser);
+# use HTML::Entities;
+
+require Common;
+require xmlOperations;
+
+our $confDir = '../config';
+our $specDir = '../specs';
+
+
+my $q = CGI->new;
+
+print header;
+print start_html(
+-title=>'xmlOperation',
+-style=>{'src'=>'../layout/styles.css'}
+);
+
+print h2("debug output");
+
+
+unless ($q->param()){
+  print "usage:",br;
+  print escapeHTML("http://[...]/tools/xmlOperation.pl?action=[action]&[parameter]&[parameter]& ..."),br;
+  print br,br;
+  print "possible actions: save, delete, copyDefaultRegister, createFile, deleteFile, changeAncestor",br,br;
+  print "parameter summary:",br;
+  print "save a value into a specific field:",br;
+  print escapeHTML("action=save&configFile=[configFile]&register=[register]&field=[field]&value=[value]"),br,br;
+  print "delete a specific field:",br;
+  print escapeHTML("action=delete&configFile=[configFile]&register=[register]&field=[field]"),br,br;
+  print "delete a whole register:",br;
+  print escapeHTML("action=delete&configFile=[configFile]&register=[register]"),br,br;
+  print "copy a register including default values from the specification to the config file:",br;
+  print escapeHTML("action=copyDefaultRegister&configFile=[configFile]&register=[register]"),br,br;
+  print "create a new config file based on the given specification file",br;
+  print escapeHTML("action=createFile&configFile=[configFile]&specFile=[specFile]"),br,br;
+  print "delete a config file",br;
+  print escapeHTML("action=deleteFile&configFile=[configFile]"),br,br;
+  print "change the ancestor (include directive) of config file",br;
+  print escapeHTML("action=changeAncestor&configFile=[configFile]&newAncestor=[newAncestor]"),br,br;
+
+}
+
+if ( defined $q->param('action') ) {
+
+  if ( $q->param('action') eq 'save' ) {
+    parseConfigFile( $q->param('configFile') );
+    save( $q->param('register'), $q->param('field'), $q->param('value') );
+    writeConfigFile();
+    report_and_quit();
+  }
+  if ( $q->param('action') eq 'delete' ) {
+    parseConfigFile( $q->param('configFile') );
+    del( $q->param('register'), $q->param('field') );
+    writeConfigFile();
+    report_and_quit();
+  }
+  if ( $q->param('action') eq 'copyDefaultRegister' ) {
+    parseConfigAndSpec( $q->param('configFile') );
+    del( $q->param('register'), "" ); # delete existing register from setfile
+    copyDefaultRegister( $q->param('register') );
+    writeConfigFile();
+    report_and_quit();
+  }
+  if ( $q->param('action') eq 'createFile' ) {
+    createConfigFile( $q->param('configFile'), $q->param('specFile') );
+    writeConfigFile();
+    report_and_quit();
+  }
+
+  if ( $q->param('action') eq 'deleteFile' ) {
+    deleteFile( $q->param('configFile') );
+    report_and_quit();
+  }
+
+  if ( $q->param('action') eq 'changeAncestor' ) {
+    parseConfigFile( $q->param('configFile') );
+    changeAncestor( $q->param('newAncestor') );
+    writeConfigFile();
+    report_and_quit();
+  }
+
+}
+
+
+
+
+print end_html;
+
+sub report_and_quit {
+  print br,br;
+  print "action ".$q->param('action')." executed with following parameters:",br;
+  my @params = $q->param();
+  print "<table>";
+  for (@params) {
+    print "<tr><td>";
+    print escapeHTML($_);
+    print "</td><td>=</td><td>";
+    print escapeHTML($q->param($_));
+    print "</td>";
+  
+  }
+  print "</table>";
+  exit;
+}