-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
123 lines (94 loc) · 6.42 KB
/
main.js
File metadata and controls
123 lines (94 loc) · 6.42 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
var request;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
} else {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
var searchbox= $('#s');
searchbox.keyup(function () {
var q = searchbox.val();
if(q.length >= 3 )
{
var output = '<h3 id="res">Резултати:</h3>'
$.post("search.php", { search: q },'json')
.done(function(data)
{
data=JSON.parse(data);
$.each(data , function(key,val){
output+= '<li class="fromSearch"><a href="topic.php?id='
output+= val.res['tpc_id']
output+= '">'
output+= val.res['tpc_title']
output+='</a></li>'
});
$('#result').html(output);
$(".fromSearch a").click(function(event) {
event.preventDefault();
var topic = ''
var href = $(this).attr("href");
$.get(href)
.done(function(data)
{
data=JSON.parse(data);
topic+= '<h2>'
topic+= data['tpc_title']
topic+= '</h2> <br /> <p>'
topic+= data['tpc_text']
topic+='</p>'
topic+= '<a id="showComment" href="comments.php?id='
topic+= data['tpc_id']
topic+= '"> Покажи коментари! </a>'
topic+= ''
$('#tabs-container').html(topic);
$("#showComment").click(function(event) {
event.preventDefault();
$('#showComment').hide(300);
var comments = '<h3>Коментари : </h3> <ul>'
var comHref = $(this).attr("href");
$.get(comHref).done(function(data){
data=JSON.parse(data);
$.each(data , function(key,val){
comments+= '<li class = "hasComment"> <div><h3><a href="mailto:'
comments+= val.cmt['cmt_mail']
comments+= '">'
comments+= val.cmt['cmt_user']
comments+= '</a> каза :</h3></div><p>'
comments+= val.cmt['cmt_text']
comments+= '</p></li> '
});
comments+= '<li class = "hasComment"> <h3>Напиши Коментар</h3>'
comments+= '<p><input type="text" id="name" size="15" placeholder="Име" /> '
comments+= '<input type="text" id="mail" size="15" placeholder="Email" /><br />'
comments+= ' <input type="text" id="comm" size="40" placeholder="Коментар" />'
comments+= '<input type="button" id="sendComment" value="Добави Коментар"></p></li>'
comments+='</ul>'
$('#tabs-container').append(comments);
$("#sendComment").click(function(event) {
var name =$('#name').val();
var mail =$('#mail').val();
var comm =$('#comm').val();
var newComment =''
id ='' ;
for (var i = comHref.length - 1; i >= 0; i--) {
if (comHref[i] >= 0 || comHref[i] <=9 ) {
id += comHref[i]; };
};
$.post("add.php?id=" + id, { uname: name , email: mail , comment:comm })
.done(function(data)
{
newComment+= ' <div><h3><a href="mailto:'
newComment+= mail
newComment+= '">'
newComment+= name
newComment+= '</a> каза :</h3></div><p>'
newComment+= comm
newComment+= '</p> '
$('.hasComment:last').html(newComment)
});
});
});
});
});
});
});
}});