forked from cbsandeep10/IMathAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts.js
More file actions
executable file
·96 lines (95 loc) · 2.88 KB
/
posts.js
File metadata and controls
executable file
·96 lines (95 loc) · 2.88 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
var haschanges = false;
$(function() {
$(".scorebox").on('keypress', function() {haschanges = true;});
});
function checkchgstatus(type,id) {
//type: 0 reply, 1 modify
if (haschanges) {
if (type==0) {
action = 'reply';
} else if (type==1) {
action = 'modify';
}
if (confirm("You have unsaved changes. Click OK to save changes before continuing, or Cancel to discard changes")) {
$("form").append('<input type="hidden" name="actionrequest" value="'+action+':'+id+'"/>').submit();
return false;
} else {
return true;
}
}
}
function toggleshow(butn) {
var forumgrp = $(butn).closest(".block").nextAll(".forumgrp").first();
if (forumgrp.hasClass("hidden")) {
forumgrp.removeClass("hidden");
butn.src = imasroot+'/img/collapse.gif';
} else {
forumgrp.addClass("hidden");
butn.src = imasroot+'/img/expand.gif';
}
}
function toggleitem(butn) {
var blockitems = $(butn).closest(".block").nextAll(".blockitems").first();
if (blockitems.hasClass("hidden")) {
blockitems.removeClass("hidden");
butn.value = _('Hide');
} else {
blockitems.addClass("hidden");
butn.value = _('Show');
}
}
function expandall() {
$(".expcol").each(function(i) {
var forumgrp = $(this).closest(".block").nextAll(".forumgrp").first().removeClass("hidden");
this.src = imasroot+'/img/collapse.gif';
});
}
function collapseall() {
$(".expcol").each(function(i) {
var forumgrp = $(this).closest(".block").nextAll(".forumgrp").first().addClass("hidden");
this.src = imasroot+'/img/expand.gif';
});
}
function showall() {
$(".shbtn").each(function(i) {
var blockitems = $(this).closest(".block").nextAll(".blockitems").first().removeClass("hidden");
this.value = _('Hide');
});
}
function hideall() {
$(".shbtn").each(function(i) {
var blockitems = $(this).closest(".block").nextAll(".blockitems").first().addClass("hidden");
this.value = _('Show');
});
}
function savelike(el) {
var like = (el.src.match(/gray/))?1:0;
var postid = el.id.substring(8);
$(el).parent().append('<img style="vertical-align: middle" src="../img/updating.gif" id="updating" alt="Updating"/>');
$.ajax({
url: "recordlikes.php",
data: {cid: cid, postid: postid, like: like},
dataType: "json"
}).done(function(msg) {
if (msg.aff==1) {
el.title = msg.msg;
$('#likecnt'+postid).text(msg.cnt>0?msg.cnt:'');
el.className = "likeicon"+msg.classn;
if (like==0) {
el.src = el.src.replace("liked","likedgray");
} else {
el.src = el.src.replace("likedgray","liked");
}
}
$('#updating').remove();
});
}
function toggletagged(id) {
var cursrc = $("#tag"+id).attr("src");
var settag = cursrc.match(/filled/)?0:1;
$.ajax({url: "savetagged.php?cid="+cid+"&threadid="+id+"&tagged="+settag})
.done(function(msg) { if (msg=="OK") {
if (settag==0) { $("#tag"+id).attr("src",cursrc.replace(/filled/,"empty"));}
else {$("#tag"+id).attr("src",cursrc.replace(/empty/,"filled"));}
}});
}