visibility:visible;
}
+.hidden_by_default {
+ display:none;
+}
+
#theConsoleContainer {
/* visibility:collapse; */
margin:5px;
use lib "$FindBin::Bin/..";
use Environment;
use File::Basename;
+use File::Copy;
my $shared;
my $dispatch = {
table_hash => \&table_hash,
print_file => \&print_file,
+ delete_file => \&delete_file,
+ copy_file => \©_file,
+ move_file => \&move_file,
write_file => \&write_file
};
print "saved!";
}
+sub delete_file {
+ my $file = $q->param('file');
+ if ( -e $file ) {
+ unlink($file) or die "error while deleting file";
+ print "file was deleted";
+ } else {
+ print "selected file not found";
+ }
+}
+
+sub move_file {
+ my $file = $q->param('file');
+ my $newFile = $q->param('newFile');
+
+ if( -e $newFile ) {
+ print "file already exists!";
+ } else {
+ move($file,$newFile) or die "move failed!";
+ print "file moved!";
+ }
+}
+
+sub copy_file {
+ my $file = $q->param('file');
+ my $newFile = $q->param('newFile');
+
+ if( -e $newFile ) {
+ print "file already exists!";
+ } else {
+ copy($file,$newFile) or die "copy failed!";
+ print "file copied!";
+ }
+}
sub passHashToJs {
}
+function delete_file(){
+ $.ajax({
+ url: "editor.pl",
+ cache: false,
+ async: false,
+ dataType: "text",
+ data: {
+ sub : "delete_file",
+ file : setupFile
+ },
+ success: function(result) {
+ $("#report").html(result);
+ }
+ });
+}
+
+function get_newFilename() {
+ var fileName = $("#input_newFilename").val();
+ var patt = /\.xml/i;
+ if(patt.test(fileName)){
+ return fileName;
+ } else {
+ return fileName+".xml";
+ }
+}
+
+function copy_file(){
+ $.ajax({
+ url: "editor.pl",
+ cache: false,
+ async: false,
+ dataType: "text",
+ data: {
+ sub : "copy_file",
+ file : setupFile,
+ newFile : setupDir+get_newFilename()
+ },
+ success: function(result) {
+ $("#report").html(result);
+ set_clear_timer();
+ }
+ });
+}
+
+function move_file(){
+ $.ajax({
+ url: "editor.pl",
+ cache: false,
+ async: false,
+ dataType: "text",
+ data: {
+ sub : "move_file",
+ file : setupFile,
+ newFile : setupDir+get_newFilename()
+ },
+ success: function(result) {
+ $("#report").html(result);
+ set_clear_timer();
+ }
+ });
+}
+
+function delete_file(){
+ $.ajax({
+ url: "editor.pl",
+ cache: false,
+ async: false,
+ dataType: "text",
+ data: {
+ sub : "delete_file",
+ file : setupFile
+ },
+ success: function(result) {
+ $("#report").html(result);
+ set_clear_timer();
+ }
+ });
+}
+
+var timer;
$(document).ready(function(){
$("#setupeditorlink").attr("href","editor.pl?file="+encodeURIComponent(setupFile));
$("#systemeditorlink").attr("href","editor.pl?file="+encodeURIComponent(systemFile));
- $("#advancedOptionsContainer").hide();
- $("#theConsoleContainer").hide();
+ $("#setupcopylink").click(function(){
+ $("#setup_options_container").fadeToggle();
+ });
+
+ $("#button_copy").click(function(){
+ copy_file();
+ });
+ $("#button_move").click(function(){
+ move_file();
+ });
+ $("#button_delete").click(function(){
+ delete_file();
+ });
$("#advoptbtn").click(function(){
// toggleVis("advancedOptionsContainer");
$("#advancedOptionsContainer").fadeToggle();
var $target = $('html,body');
- $target.animate({scrollTop: $target.height()}, 1000);
+// $target.animate({scrollTop: $target.height()}, 1000);
});
$("#debugbtn").click(function(){
// toggleVis("theConsoleContainer");
$("#theConsoleContainer").fadeToggle();
var $target = $('html,body');
- $target.animate({scrollTop: $target.height()}, 1000);
+// $target.animate({scrollTop: $target.height()}, 1000);
});
+ timer = $.timer(function() {
+ clear_report();
+ timer.stop();
+ });
+
});
+
+function set_clear_timer(){
+ timer.set({time:3000,autostart: true});
+}
+
+function clear_report (){
+ $("#report").html(" ... ");
+}
{ -type => 'text/javascript', -src => './testgui.js'},
{ -type => 'text/javascript', -src => './hideAndShow.js'},
{ -type => 'text/javascript', -src => './getdata.js'},
+ { -type => 'text/javascript', -src => '../scripts/jquery.timer.js'},
{ -type => 'text/javascript', -src => './xmlOperations.js'}
]
);
$setup_selector->add_item(value=>'...');
$setup_selector->add_items_from_dir(dir=>$setupDir,ext=>"xml");
- print "<table><tr><td>";
+ print "<table><tr><td align='right'>";
print "chose setup: ";
print "</td><td>";
$setup_selector->print_html();
print "<a href='#' id='setupeditorlink' >edit setup file</a>";
print "</td><td>";
print "<a href='#' id='systemeditorlink' >edit system file</a>";
- print "</td></tr></table>";
+ print "</td><td>";
+ print "<a href='#' id='setupcopylink' >copy/move setup file</a>";
+ print "</td></tr>";
+
+ print "<tr id='setup_options_container' class='hidden_by_default'>";
+ print "<td align='right'>new filename:</td>";
+ print "<td colspan=2><input type='text' id='input_newFilename'>";
+ print "<input type='button' id='button_copy' value='copy'>";
+ print "<input type='button' id='button_move' value='move'>";
+ print "<input type='button' id='button_delete' value='delete'></td>";
+ print "<td colspan=5 id='report'></td>";
+
+ print "</tr>";
+
+ print "</table>";
print_setupStructure();
print "<script language='javascript'>\n";
print q%var setupFile = '%.$setupFile.q%';%."\n";
print q%var systemFile = '%.SYSTEMDIR."/".$systemName.".xml".q%';%."\n";
+ print q%var setupDir = '%.SETUPDIR.q%';%."\n";
print "var previewAreaIdHash = new Object();\n";
for my $sensorId (keys %previewAreaIdHash){
print "previewAreaIdHash[\"$sensorId\"]=\"".$previewAreaIdHash{$sensorId}."\";\n";
print "</p>";
- print "<div id='advancedOptionsContainer' class='stylishBox'>";
+ print "<div id='advancedOptionsContainer' class='stylishBox hidden_by_default'>";
print "<div class='header'>advanced options</div>";
print "<div id='advancedOptions'>";
print "</div>";
- print "<div id='theConsoleContainer' class='stylishBox'>";
+ print "<div id='theConsoleContainer' class='stylishBox hidden_by_default'>";
print "<div class='header'>debug output</div>";
print "<div id='theConsole'>[the \"console\"]</div>";
print "</div>";