From 8b2c99bd560cbea010ad051d5614e8e2d11c1729 Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Thu, 19 Jun 2014 23:14:03 +0530 Subject: fixed basic bugs --- cloud.css | 11 ++++++++ comment.js | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ comment.php | 23 ++++++++--------- index.php | 85 ++++++++++--------------------------------------------------- 4 files changed, 115 insertions(+), 84 deletions(-) create mode 100644 comment.js diff --git a/cloud.css b/cloud.css index 183a884..b08d687 100755 --- a/cloud.css +++ b/cloud.css @@ -140,3 +140,14 @@ display: inline-block; margin-right: 5px; float: right; } +#error-msg { + display: none; + padding: 5px; + border: 1px solid red; + background: #f5f5f5; +} +#success-msg { + display: none; + padding: 5px; + border: 2px solid green; +} diff --git a/comment.js b/comment.js new file mode 100644 index 0000000..a17ecd2 --- /dev/null +++ b/comment.js @@ -0,0 +1,80 @@ +$(document).ready(function(){ + function danger(obj) { + obj.css("border", "2px solid red"); + } + function safe(obj) { + obj.css("border", "2px solid #cccccc"); + } + + var $error_msg = $("#error-msg"); + var $success_msg = $("#success-msg"); + var $comment_form_wrapper = $("#comment-form-wrapper"); + var $comment_type = $("#comment-type"); + var $comment_body= $("#comment-body"); + var $comment_notify = $("#comment-notify"); + var $comment_email = $("#comment-email"); + var $comment_email_wrapper = $("#comment-email-wrapper"); + $comment_email_wrapper.hide(); + + $comment_notify.click(function() { + if($(this).attr("checked")) { + $comment_email_wrapper.show(); + } else { + $comment_email_wrapper.hide(); + } + }); + + $("#comment-form").submit(function(e) { + /* reset all the previous errors */ + var errors = 0; + safe($comment_type); + safe($comment_body); + safe($comment_email); + + if(!$("#example").val()) { + $error_msg.html("Please select a category, book, chapter and an example before reporting a bug.") + $error_msg.show(); + errors = 1; + } + if(!$comment_type.val()){ + danger($comment_type); + errors = 1; + } + if(!$comment_body.val()) { + danger($comment_body); + errors = 1; + } + if($comment_notify.attr("checked") && !$comment_email.val()) { + danger($comment_email); + errors = 1; + } + if(!errors) { + $.ajax({ + url: "comment.php", + data: { + category: $("#categories").val(), + books: $("#books").val(), + chapter: $("#books").val(), + example: $("#example").val(), + type: $comment_type.val(), + comment: $comment_body.val(), + email: $comment_email.val(), + }, + type: "POST", + dataType: "html", + success: function(data) { + $comment_form_wrapper.hide(); + $success_msg.show(); + } + }); + } + e.preventDefault(); + }); + + $("#commentBtn").click(function() { + $error_msg.hide(); + $success_msg.hide(); + $comment_form_wrapper.show(); + }); +}); + diff --git a/comment.php b/comment.php index 3c4845f..f4197d6 100755 --- a/comment.php +++ b/comment.php @@ -1,15 +1,13 @@ - - - Home | Scilab cloud - - - - - "Blank Code / Incorrect code", + 2 => "Output error", + 3 => "Execution error", + 4 => "Missing example(s)", + 6 => "Blank output", + 7 => "Any other" + ); if(isset($_POST['type']) && isset($_POST['comment'])){ $query = "insert into scilab_cloud_comment (type, comment, email,category,books,chapter,example) values(".$_POST['type'].", '".$_POST['comment']."', '".$_POST['email']."', '".$_POST['category']."', '".$_POST['books']."', '".$_POST['chapter']."', '".$_POST['example']."')"; if(mysql_query($query)){ @@ -17,10 +15,11 @@ echo "

Thank you for your valuable feedback.

"; $to = "rush2jrp@gmail.com, mukulrkulkarni@gmail.com, lavitha89@gmail.com, kannan@iitb.ac.in, kiran@fossee.in, manasdas17@gmail.com"; + // $to = "rush2jrp@gmail.com, jayaram@iitb.ac.in"; $subject = "New Cloud Comment"; $message = " A new comment has been posted.
- Type: {$_POST['type']}
+ Type: {$types[$_POST['type']]}
Comment: {$_POST['comment']}
Link: http://scilab.in/cloud_comments "; @@ -36,6 +35,4 @@ echo "

Sorry for the inconvience, please try again

"; } }else{ ?> - - diff --git a/index.php b/index.php index bcefa8b..4f2a15b 100755 --- a/index.php +++ b/index.php @@ -13,6 +13,7 @@ $(document).ready(function(){ var webroot = "http://cloud.scilab.in/"; + // var webroot = "http://localhost/cloud/"; var imgdata = ''; $("#single_image").fancybox(); $('.fancymenu').fancybox({title: ""}); @@ -191,68 +192,6 @@ }); }); -