Mercurial > hg > vamp-website
comparison forum/Themes/default/xml_board.js @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 var cur_topic_id, cur_msg_id, buff_subject, cur_subject_div, in_edit_mode = 0; | |
2 var hide_prefixes = Array(); | |
3 | |
4 function modify_topic(topic_id, first_msg_id, cur_session_id) | |
5 { | |
6 if (!window.XMLHttpRequest) | |
7 return; | |
8 if (typeof(window.opera) != "undefined") | |
9 { | |
10 var test = new XMLHttpRequest(); | |
11 if (typeof(test.setRequestHeader) != "function") | |
12 return; | |
13 } | |
14 | |
15 if (in_edit_mode == 1) | |
16 { | |
17 if (cur_topic_id == topic_id) | |
18 return; | |
19 else | |
20 modify_topic_cancel(); | |
21 } | |
22 | |
23 in_edit_mode = 1; | |
24 mouse_on_div = 1; | |
25 cur_topic_id = topic_id; | |
26 | |
27 if (typeof window.ajax_indicator == "function") | |
28 ajax_indicator(true); | |
29 | |
30 getXMLDocument(smf_scripturl + "?action=quotefast;quote=" + first_msg_id + ";sesc=" + cur_session_id + ";modify;xml", onDocReceived_modify_topic); | |
31 } | |
32 | |
33 function onDocReceived_modify_topic(XMLDoc) | |
34 { | |
35 cur_msg_id = XMLDoc.getElementsByTagName("message")[0].getAttribute("id"); | |
36 | |
37 cur_subject_div = document.getElementById('msg_' + cur_msg_id.substr(4)); | |
38 buff_subject = getInnerHTML(cur_subject_div); | |
39 | |
40 // Here we hide any other things they want hiding on edit. | |
41 set_hidden_topic_areas('none'); | |
42 | |
43 modify_topic_show_edit(XMLDoc.getElementsByTagName("subject")[0].childNodes[0].nodeValue); | |
44 | |
45 if (typeof window.ajax_indicator == "function") | |
46 ajax_indicator(false); | |
47 } | |
48 | |
49 function modify_topic_cancel() | |
50 { | |
51 setInnerHTML(cur_subject_div, buff_subject); | |
52 set_hidden_topic_areas(''); | |
53 | |
54 in_edit_mode = 0; | |
55 return false; | |
56 } | |
57 | |
58 function modify_topic_save(cur_session_id) | |
59 { | |
60 if (!in_edit_mode) | |
61 return true; | |
62 | |
63 var i, x = new Array(); | |
64 x[x.length] = 'subject=' + escape(textToEntities(document.forms.quickModForm['subject'].value)).replace(/\+/g, "%2B"); | |
65 x[x.length] = 'topic=' + parseInt(document.forms.quickModForm.elements['topic'].value); | |
66 x[x.length] = 'msg=' + parseInt(document.forms.quickModForm.elements['msg'].value); | |
67 | |
68 if (typeof window.ajax_indicator == "function") | |
69 ajax_indicator(true); | |
70 | |
71 sendXMLDocument(smf_scripturl + "?action=jsmodify;topic=" + parseInt(document.forms.quickModForm.elements['topic'].value) + ";sesc=" + cur_session_id + ";xml", x.join("&"), modify_topic_done); | |
72 | |
73 return false; | |
74 } | |
75 | |
76 function modify_topic_done(XMLDoc) | |
77 { | |
78 if (!XMLDoc) | |
79 { | |
80 modify_topic_cancel(); | |
81 return true; | |
82 } | |
83 | |
84 var message = XMLDoc.getElementsByTagName("smf")[0].getElementsByTagName("message")[0]; | |
85 var subject = message.getElementsByTagName("subject")[0]; | |
86 var error = message.getElementsByTagName("error")[0]; | |
87 | |
88 if (typeof window.ajax_indicator == "function") | |
89 ajax_indicator(false); | |
90 | |
91 if (!subject || error) | |
92 return false; | |
93 | |
94 subjectText = subject.childNodes[0].nodeValue; | |
95 | |
96 modify_topic_hide_edit(subjectText); | |
97 | |
98 set_hidden_topic_areas(''); | |
99 | |
100 in_edit_mode = 0; | |
101 | |
102 return false; | |
103 } | |
104 | |
105 // Simply restore any hidden bits during topic editing. | |
106 function set_hidden_topic_areas(set_style) | |
107 { | |
108 for (var i = 0; i < hide_prefixes.length; i++) | |
109 { | |
110 if (document.getElementById(hide_prefixes[i] + cur_msg_id.substr(4)) != null) | |
111 document.getElementById(hide_prefixes[i] + cur_msg_id.substr(4)).style.display = set_style; | |
112 } | |
113 } |