From e7c5a2e04a023cdeb65a8577bc1df9f75f0948de Mon Sep 17 00:00:00 2001
From: Michael Wiebusch
Date: Wed, 21 Aug 2013 19:43:45 +0200
Subject: [PATCH] outsourced javascript routines from jtageditor.pl to
jtageditor.js, added move and copy feature to jtageditor
---
tools/jtageditor.js | 114 +++++++++++++++++++++++++++
tools/jtageditor.pl | 173 ++++-------------------------------------
tools/xmlOperation.pl | 29 +++++++
tools/xmlOperations.js | 12 +++
tools/xmlRendering.pm | 2 +-
5 files changed, 173 insertions(+), 157 deletions(-)
create mode 100644 tools/jtageditor.js
diff --git a/tools/jtageditor.js b/tools/jtageditor.js
new file mode 100644
index 0000000..f78fd40
--- /dev/null
+++ b/tools/jtageditor.js
@@ -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';
+ }
+
+
+}
+
+
+}
+
diff --git a/tools/jtageditor.pl b/tools/jtageditor.pl
index db625f0..02576e9 100755
--- a/tools/jtageditor.pl
+++ b/tools/jtageditor.pl
@@ -240,6 +240,22 @@ sub print_fileSelection {
print "";
print "
";
+
+ print "move/copy this file
";
+ print "";
+ print "
";
+
+ print "";
+
}
@@ -388,168 +404,13 @@ sub printJavaScripts {
print <
-
-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_+"®ister="+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_+"®ister="+register_+"&field="+field_,"debug",false);
-reloadSetTree();
-}
-
-function copyDefaultRegister(register){
-var register_ = encodeURIComponent(register);
-var file_ =encodeURIComponent(selectedConfigFile());
-getdata("xmlOperation.pl?action=copyDefaultRegister®ister="+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';
- }
-
-
-}
-
-
-}
-
diff --git a/tools/xmlOperation.pl b/tools/xmlOperation.pl
index 44d14c8..1e0b130 100755
--- a/tools/xmlOperation.pl
+++ b/tools/xmlOperation.pl
@@ -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') );
diff --git a/tools/xmlOperations.js b/tools/xmlOperations.js
index 35f1703..5d35737 100644
--- a/tools/xmlOperations.js
+++ b/tools/xmlOperations.js
@@ -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);
diff --git a/tools/xmlRendering.pm b/tools/xmlRendering.pm
index c1c6ed6..bcf0d32 100644
--- a/tools/xmlRendering.pm
+++ b/tools/xmlRendering.pm
@@ -246,7 +246,7 @@ EOF
}
else {
print qq%
-
+ |
%;
print_conversionMenu($registerName,$fieldName,$conversionTableId);
--
2.43.0
|