summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayaram Pai2014-06-19 23:14:03 +0530
committerJayaram Pai2014-06-19 23:14:03 +0530
commit8b2c99bd560cbea010ad051d5614e8e2d11c1729 (patch)
tree289b247bfeeadcd4c191861428ecc65301c87c04
parent1b54f67fb2bc065c9e9dbb66d1e00e407d30456d (diff)
downloadscilab_cloud_interface-8b2c99bd560cbea010ad051d5614e8e2d11c1729.tar.gz
scilab_cloud_interface-8b2c99bd560cbea010ad051d5614e8e2d11c1729.tar.bz2
scilab_cloud_interface-8b2c99bd560cbea010ad051d5614e8e2d11c1729.zip
fixed basic bugs
-rwxr-xr-xcloud.css11
-rw-r--r--comment.js80
-rwxr-xr-xcomment.php23
-rwxr-xr-xindex.php85
4 files changed, 115 insertions, 84 deletions
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 @@
- <html>
- <head>
- <title>Home | Scilab cloud</title>
- <script src="jquery.js" type="text/javascript"></script>
-
-
- </head>
- <body>
<?php
require_once('db-connect.php');
- //var_dump($_POST);
- //die;
+ $types = array(
+ 1 => "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 "<p>Thank you for your valuable feedback.</p>";
$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. <br>
- Type: {$_POST['type']} <br>
+ Type: {$types[$_POST['type']]} <br>
Comment: {$_POST['comment']} <br>
Link: http://scilab.in/cloud_comments
";
@@ -36,6 +35,4 @@
echo "<p>Sorry for the inconvience, please try again</p>";
}
}else{ ?>
- </body>
-</html>
<?php } ?>
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 = '<img src="images/ajax-loader.gif">';
$("#single_image").fancybox();
$('.fancymenu').fancybox({title: ""});
@@ -191,68 +192,6 @@
});
});
</script>
- <script type="text/javascript">
- //Ajax form submission
- function commentSubmit() {
- //fetching all form values
- error_type = document.comment_form.error_type.value;
- comment = document.comment_form.comment.value;
- email = document.comment_form.email.value;
-
- //retrive the precise details
- category = document.getElementById("categories").value;
- books = document.getElementById("books");
- if(books) {
- books = books.value;
- }else {
- books = "null";
- }
-
- chapter = document.getElementById("chapter");
- if(chapter) {
- chapter = chapter.value;
- }else {
- chapter = "null";
- }
-
- example = document.getElementById("example");
- if(example) {
- example = example.value;
- }else {
- example = "null";
- }
-
- var xmlhttp;
- if (window.XMLHttpRequest) {
- // code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }else {
- // code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (xmlhttp.readyState==4 && xmlhttp.status==200) {
- document.getElementById("comment_form").style.display="none";
- document.getElementById("myDiv").innerHTML="Thanks for your comment.";
- }
- }
- request_string = "type="+error_type+"&comment="+comment+"&email="+email+"&category="+category+"&books="+books+"&chapter="+chapter+"&example="+example;
- xmlhttp.open("POST","http://cloud.scilab.in/comment.php",true);
- xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
- xmlhttp.send(request_string);
- }
-
- function showEmail() {
- checkbox = document.comment_form.notify;
- emailDiv = document.getElementById("email-notify");
- if(checkbox.checked){
- emailDiv.style.display = "block";
- }
- else{
- emailDiv.style.display = "none";
- }
- }
- </script>
</head>
<body background="images/body-bg.png" class="cls-body">
<div class="banner">
@@ -398,13 +337,15 @@
<a id="commentBtn" class="fancymenu" href="#lightbox-form"> Report bug / Give feedback</a>
<div id="lightbox-form" style="display:none">
- <div id="myDiv"></div>
+ <div id="error-msg"></div>
+ <div id="success-msg">Thank you for your valuable feedback.</div>
- <form name="comment_form" id="comment_form">
+ <div id="comment-form-wrapper">
+ <form id="comment-form" id="comment_form">
<p>Please fill the details.</p>
- <select name="error_type">
- <option>-- Select Type of issue --</option>
+ <select id="comment-type">
+ <option value=''>-- Select Type of issue --</option>
<option value=1> Blank Code / Incorrect code</option>
<option value=2>Output error</option>
<option value=3>Execution error</option>
@@ -415,16 +356,17 @@
<br><br>
<label>Description:</label><br>
- <textarea name="comment" rows="6" cols="50" placeholder="Please tell us more..."></textarea> <br><br>
- <input name="notify" type="checkbox" onclick="showEmail();"> I want to be notified. <br> <br>
+ <textarea id="comment-body" rows="6" cols="50" placeholder="Please tell us more..."></textarea> <br><br>
+ <input id="comment-notify" type="checkbox"> I want to be notified. <br> <br>
- <div id="email-notify">
+ <div id="comment-email-wrapper">
<label>Email (optional):</label><br>
- <input type="text" name='email'> <br><br>
+ <input id="comment-email" type="text" name='email'> <br><br>
</div>
- <input id="submitButtonId" type="button" value="Submit" onclick="commentSubmit();">
+ <input type="submit" value="Submit">
</form>
+ </div> <!-- #/comment-form-wrapper -->
</div>
</td>
</tr>
@@ -437,5 +379,6 @@
</div>
<script src="acknowledge.js"></script>
+ <script src="comment.js"></script>
</body>
</html>