forked from cbsandeep10/IMathAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.js
More file actions
executable file
·61 lines (57 loc) · 1.77 KB
/
thread.js
File metadata and controls
executable file
·61 lines (57 loc) · 1.77 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
//IMathAS (c) 2007 David Lippman
//Flag toggles for discussion forum thread list
function togglecolor(threadid,tagged) {
var trchg = document.getElementById("tr"+threadid);
var imgchg = document.getElementById("tag"+threadid);
if (tagged==1) {
trchg.className = "tagged";
imgchg.src = imasroot+"/img/flagfilled.gif";
} else {
trchg.className = "";
imgchg.src = imasroot+"/img/flagempty.gif";
}
}
function toggletagged(threadid) {
var trchg = document.getElementById("tr"+threadid);
if (trchg.className=="tagged") {
submitTagged(threadid,0);
} else {
submitTagged(threadid,1);
}
return false;
}
function chgtagfilter() {
var tagfilter = document.getElementById("tagfilter").value;
window.location = tagfilterurl+'&tagfilter='+tagfilter;
}
function chgfilter() {
var ffilter = document.getElementById("ffilter").value;
window.location = tagfilterurl+'&ffilter='+ffilter;
}
function submitTagged(thread,tagged) {
url = AHAHsaveurl + '&threadid='+thread+'&tagged='+tagged;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (typeof req != 'undefined') {
req.onreadystatechange = function() {ahahDone(url, thread, tagged);};
req.open("GET", url, true);
req.send("");
}
}
function ahahDone(url, threadid, tagged) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
if (req.responseText=='OK') {
togglecolor(threadid, tagged);
} else {
alert(req.responseText);
alert("Oops, error toggling the tag");
}
} else {
alert(" Couldn't save changes:\n"+ req.status + "\n" +req.statusText);
}
}
}