-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComments.js
executable file
·91 lines (80 loc) · 2.03 KB
/
Comments.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Contains all the functions that are ready to be
* executed upon the loading of a dom document,
* specifically, functions that are triggered by
* clicks.
*/
$(document).ready(function() {
/**
* Upon a click to an accordion button,
* - remove the on class from all buttons
* - close all open slides
* - add the on class to the button
* - open the slide.
*/
$('.accordionButton').click(function() {
$('.accordionButton').removeClass('on');
$('.accordionContent').slideUp('normal');
if($(this).next().is(':hidden') == true) {
$(this).addClass('on');
$(this).next().slideDown('normal');
}
});
/**
* Hide all the contents upon loading.
*/
$(".accordionContent").hide();
/**
* Loads in the homepage when the
* homepage button is clicked.
*/
$("a.homepage").click(function() {
$.ajax( {
type: "GET",
dataType: "html",
url: "Invoker.php",
cache: false,
success: function(html) {
$("body").html(html);
}
});
});
/**
* Loads in the query page when the submit
* button is pressed (to submit a comment).
*/
$(".comment_submit").click(function() {
var element = $(this);
var id = element.attr("id");
var comment = $("#comment"+id).val();
var assignment = $("#assignment"+id).val();
var parent_id = $("#parent_id"+id).val();
var dataString = "assignment="+assignment + "&parent_id="+parent_id + "&comment="+comment;
if (comment == "") {
alert("Please enter a comment");
}
else {
$.ajax( {
type: "POST",
url: "Query.php",
data: dataString,
cache: false,
success: function(html) {
$("body").html(html);
}
});
}
return false;
});
});
/**
* Toggers comment form visibility.
* @param id - the id of the comment form
*/
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}