From 41ca8a72c7594bed3c5bb6fc38a5df8533d41e44 Mon Sep 17 00:00:00 2001
From: Suresh Alse <alseambusher@gmail.com>
Date: Sat, 13 Jun 2015 22:10:37 +0530
Subject: [PATCH] 1. fixed commands with quotes bug 2. Changed Startup macro
 from @startup to @reboot

---
 README.md           | 2 ++
 crontab.js          | 6 +++++-
 public/js/script.js | 2 +-
 views/index.ejs     | 3 +--
 views/popup.ejs     | 2 +-
 views/restore.ejs   | 3 +--
 6 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index b7baf73..1dd77a1 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,8 @@ Crontab UI
 
 Editing the plain text crontab is error prone for managing jobs, e.g., adding jobs, deleting jobs, or pausing jobs. A small mistake can easily bring down all the jobs and might cost you a lot of time. With Crontab UI, it is very easy to manage crontab. Here are the key features of Crontab UI.
 
+![flow](http://alseambusher.github.io/files/flow.gif)
+
 1. Easy setup
 2. Easy and safe adding, deleting or pausing jobs. Easy to maintain hundreds of jobs.
 3. Backups
diff --git a/crontab.js b/crontab.js
index 36df016..6b5c6a0 100644
--- a/crontab.js
+++ b/crontab.js
@@ -71,5 +71,9 @@ exports.backup = function(){
 
 exports.restore = function(db_name){
 	fs.createReadStream( __dirname + '/crontabs/' + db_name).pipe(fs.createWriteStream( __dirname + '/crontabs/crontab.db'));
-	db.loadDatabase();
+	db.loadDatabase(); // reload the database
+}
+
+exports.import = function(){
+	//TODO
 }
diff --git a/public/js/script.js b/public/js/script.js
index 9db4165..49ac907 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -63,7 +63,7 @@ function editJob(_id){
 	if(job){
 		$("#job").modal("show");
 		$("#job-name").val(job.name);
-		$("#job-command").val(job.command.replace("\"","\\\""));
+		$("#job-command").val(job.command);
 		// if macro not used
 		if(job.schedule.indexOf("@") != 0){
 			var components = job.schedule.split(" ");
diff --git a/views/index.ejs b/views/index.ejs
index 1c00ad5..3cbcbbf 100644
--- a/views/index.ejs
+++ b/views/index.ejs
@@ -11,8 +11,7 @@
 	$(function () {
 		// initialize tooltips
 		$('[data-toggle="tooltip"]').tooltip();
-		// TODO handle the commands with quotes
-		crontabs = JSON.parse('<%- crontabs %>');
+		crontabs = JSON.parse('<%- crontabs.replace(/\\\"/g,"\\\\\"") %>');
 		routes = JSON.parse('<%- routes %>');
 	})
 </script>
diff --git a/views/popup.ejs b/views/popup.ejs
index 224cede..77c5b1c 100644
--- a/views/popup.ejs
+++ b/views/popup.ejs
@@ -45,7 +45,7 @@
 	<label>Command</label>
 	<input type='text' class='form-control' id='job-command' onkeyup="job_command = $(this).val(); job_string();"/><br />
 	<label>Quick Schedule</label><br />
-	<a class="btn btn-primary" onclick="schedule = '@startup'; job_string();">Startup</a>
+	<a class="btn btn-primary" onclick="schedule = '@reboot'; job_string();">Startup</a>
 	<a class="btn btn-primary" onclick="schedule = '@hourly'; job_string();">Hourly</a>
 	<a class="btn btn-primary" onclick="schedule = '@daily'; job_string();">Daily</a>
 	<a class="btn btn-primary" onclick="schedule = '@monthly'; job_string();">Monthly</a>
diff --git a/views/restore.ejs b/views/restore.ejs
index dcc1132..3eb9980 100644
--- a/views/restore.ejs
+++ b/views/restore.ejs
@@ -11,8 +11,7 @@
 	$(function () {
 		// initialize tooltips
 		$('[data-toggle="tooltip"]').tooltip();
-		// TODO handle the commands with quotes
-		crontabs = JSON.parse('<%- crontabs %>');
+		crontabs = JSON.parse('<%- crontabs.replace(/\\\"/g,"\\\\\"") %>');
 		routes = JSON.parse('<%- routes %>');
 	})
 </script>