-3 Removals
+3 Additions

Created by:phpboost

1 //Tableau contenant l'état de chaque catégorie 1 //Tableau contenant l'état de chaque catégorie
2 var cat_status = new Array(); 2 var cat_status = new Array();
3 3
4 //AJAX: fonction d'interaction avec le serveur 4 //AJAX: fonction d'interaction avec le serveur
5 function show_wiki_cat_contents(id_cat, display_select_link) 5 function show_wiki_cat_contents(id_cat, display_select_link)
6 { 6 {
7 var xhr_object = null; 7 var xhr_object = null;
8 var data = null; 8 var data = null;
9 var filename = PATH_TO_ROOT + "/wiki/xmlhttprequest.php" + (display_select_link != 0 ? "?display_select_link=1&token=" + TOKEN : "?token=" + TOKEN); 9 var filename = PATH_TO_ROOT + "/wiki/xmlhttprequest.php" + (display_select_link != 0 ? "?display_select_link=1&token=" + TOKEN : "?token=" + TOKEN);
10 10
11 if(window.XMLHttpRequest) // Firefox 11 if(window.XMLHttpRequest) // Firefox
12 xhr_object = new XMLHttpRequest(); 12 xhr_object = new XMLHttpRequest();
13 else if(window.ActiveXObject) // Internet Explorer 13 else if(window.ActiveXObject) // Internet Explorer
14 xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 14 xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
15 else // XMLHttpRequest non supporté par le navigateur 15 else // XMLHttpRequest non supporté par le navigateur
16 return; 16 return;
17 17
18 if( id_cat > 0 ) 18 if( id_cat > 0 )
19 { 19 {
20 //Si le dossier est fermé on l'ouvre sinon on le ferme 20 //Si le dossier est fermé on l'ouvre sinon on le ferme
21 if( cat_status[id_cat] == undefined ) 21 if( cat_status[id_cat] == undefined )
22 { 22 {
23 data = "id_cat=" + id_cat; 23 data = "id_cat=" + id_cat;
24 xhr_object.open("POST", filename, true); 24 xhr_object.open("POST", filename, true);
25 25
26 xhr_object.onreadystatechange = function() 26 xhr_object.onreadystatechange = function()
27 { 27 {
28 if( xhr_object.readyState == 4 ) 28 if( xhr_object.readyState == 4 )
29 { 29 {
30 document.getElementById("cat-" + id_cat).innerHTML = xhr_object.responseText; 30 document.getElementById("cat-" + id_cat).innerHTML = xhr_object.responseText;
31 document.getElementById("img-folder-" + id_cat).className = 'fa fa-folder-open'; 31 document.getElementById("img-folder-" + id_cat).className = 'fa fa-folder-open';
32 if( document.getElementById("img-subfolder-" + id_cat) ) 32 if( document.getElementById("img-subfolder-" + id_cat) )
33 document.getElementById("img-subfolder-" + id_cat).className = 'fa fa-minus-square-o'; 33 document.getElementById("img-subfolder-" + id_cat).className = 'far fa-minus-square';
34 cat_status[id_cat] = 1; 34 cat_status[id_cat] = 1;
35 } 35 }
36 } 36 }
37 37
38 xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 38 xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
39 xhr_object.send(data); 39 xhr_object.send(data);
40 } 40 }
41 else if( cat_status[id_cat] == 0 ) 41 else if( cat_status[id_cat] == 0 )
42 { 42 {
43 document.getElementById("cat-" + id_cat).style.display = 'block'; 43 document.getElementById("cat-" + id_cat).style.display = 'block';
44 document.getElementById("img-folder-" + id_cat).className = 'fa fa-folder-open'; 44 document.getElementById("img-folder-" + id_cat).className = 'fa fa-folder-open';
45 if( document.getElementById("img-subfolder-" + id_cat) ) 45 if( document.getElementById("img-subfolder-" + id_cat) )
46 document.getElementById("img-subfolder-" + id_cat).className = 'fa fa-minus-square-o'; 46 document.getElementById("img-subfolder-" + id_cat).className = 'far fa-minus-square';
47 cat_status[id_cat] = 1; 47 cat_status[id_cat] = 1;
48 } 48 }
49 else 49 else
50 { 50 {
51 document.getElementById("cat-" + id_cat).style.display = 'none'; 51 document.getElementById("cat-" + id_cat).style.display = 'none';
52 document.getElementById("img-folder-" + id_cat).className = 'fa fa-folder'; 52 document.getElementById("img-folder-" + id_cat).className = 'fa fa-folder';
53 if( document.getElementById("img-subfolder-" + id_cat) ) 53 if( document.getElementById("img-subfolder-" + id_cat) )
54 document.getElementById("img-subfolder-" + id_cat).className = 'fa fa-plus-square-o'; 54 document.getElementById("img-subfolder-" + id_cat).className = 'far fa-plus-square';
55 cat_status[id_cat] = 0; 55 cat_status[id_cat] = 0;
56 } 56 }
57 } 57 }
58 } 58 }
59 59
60 function select_cat(id_cat) 60 function select_cat(id_cat)
61 { 61 {
62 var xhr_object = null; 62 var xhr_object = null;
63 var data = null; 63 var data = null;
64 var filename = PATH_TO_ROOT + "/wiki/xmlhttprequest.php?select_cat=1&token=" + TOKEN; 64 var filename = PATH_TO_ROOT + "/wiki/xmlhttprequest.php?select_cat=1&token=" + TOKEN;
65 65
66 if(window.XMLHttpRequest) // Firefox 66 if(window.XMLHttpRequest) // Firefox
67 xhr_object = new XMLHttpRequest(); 67 xhr_object = new XMLHttpRequest();
68 else if(window.ActiveXObject) // Internet Explorer 68 else if(window.ActiveXObject) // Internet Explorer
69 xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 69 xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
70 else // XMLHttpRequest non supporté par le navigateur 70 else // XMLHttpRequest non supporté par le navigateur
71 return; 71 return;
72 72
73 if( id_cat >= 0 && id_cat != selected_cat ) 73 if( id_cat >= 0 && id_cat != selected_cat )
74 { 74 {
75 data = "selected_cat=" + id_cat; 75 data = "selected_cat=" + id_cat;
76 76
77 xhr_object.open("POST", filename, true); 77 xhr_object.open("POST", filename, true);
78 78
79 xhr_object.onreadystatechange = function() 79 xhr_object.onreadystatechange = function()
80 { 80 {
81 if( xhr_object.readyState == 4 ) 81 if( xhr_object.readyState == 4 )
82 { 82 {
83 document.getElementById("selected_cat").innerHTML = xhr_object.responseText; 83 document.getElementById("selected_cat").innerHTML = xhr_object.responseText;
84 document.getElementById("id_cat").value = id_cat; 84 document.getElementById("id_cat").value = id_cat;
85 document.getElementById("class-" + id_cat).className = "selected"; 85 document.getElementById("class-" + id_cat).className = "selected";
86 document.getElementById("class-" + selected_cat).className = ""; 86 document.getElementById("class-" + selected_cat).className = "";
87 selected_cat = id_cat; 87 selected_cat = id_cat;
88 } 88 }
89 } 89 }
90 90
91 xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 91 xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
92 92
93 xhr_object.send(data); 93 xhr_object.send(data);
94 } 94 }
95 } 95 }
96 96
97 function insert_link() 97 function insert_link()
98 { 98 {
99 var link_name = prompt(enter_text, title_link); 99 var link_name = prompt(enter_text, title_link);
100 if( link_name == "" ) 100 if( link_name == "" )
101 { 101 {
102 alert(enter_text); 102 alert(enter_text);
103 return false; 103 return false;
104 } 104 }
105 105
106 if (tinymce_editor) 106 if (tinymce_editor)
107 insertTinyMceContent('[link=' + url_encode_rewrite(link_name) + '][/link]'); //insertion pour tinymce. 107 insertTinyMceContent('[link=' + url_encode_rewrite(link_name) + '][/link]'); //insertion pour tinymce.
108 else 108 else
109 insertbbcode('[link=' + url_encode_rewrite(link_name) + ']', '[/link]', 'contents'); 109 insertbbcode('[link=' + url_encode_rewrite(link_name) + ']', '[/link]', 'contents');
110 } 110 }
111 111
112 function insert_paragraph(level) 112 function insert_paragraph(level)
113 { 113 {
114 var string = '-'; 114 var string = '-';
115 if( level > 5 || level < 1 ) 115 if( level > 5 || level < 1 )
116 return false; 116 return false;
117 for( var i = 1; i <= level; i++) 117 for( var i = 1; i <= level; i++)
118 string += "-"; 118 string += "-";
119 insert_paragraph_title('paragraph', string, string, 'contents'); 119 insert_paragraph_title('paragraph', string, string, 'contents');
120 } 120 }
121 121
122 //Insertion dans le champs. 122 //Insertion dans le champs.
123 function simple_insert_paragraph(id, open_balise, close_balise, field) 123 function simple_insert_paragraph(id, open_balise, close_balise, field)
124 { 124 {
125 var textarea = document.getElementById(field); 125 var textarea = document.getElementById(field);
126 var scroll = textarea.scrollTop; 126 var scroll = textarea.scrollTop;
127 127
128 var title = prompt(enter_paragraph_name, title_paragraph); 128 var title = prompt(enter_paragraph_name, title_paragraph);
129 129
130 if (tinymce_editor) { 130 if (tinymce_editor) {
131 insertTinyMceContent('<br/>' + open_balise + ' ' + title + ' ' + close_balise + '<br/>'); //insertion pour tinymce. 131 insertTinyMceContent('<br/>' + open_balise + ' ' + title + ' ' + close_balise + '<br/>'); //insertion pour tinymce.
132 } else { 132 } else {
133 if( close_balise != "" && title != null && title != enter_paragraph_name ) 133 if( close_balise != "" && title != null && title != enter_paragraph_name )
134 textarea.value += "\n" + open_balise + " " + title + " " + close_balise + "\n"; 134 textarea.value += "\n" + open_balise + " " + title + " " + close_balise + "\n";
135 135
136 textarea.focus(); 136 textarea.focus();
137 textarea.scrollTop = scroll; 137 textarea.scrollTop = scroll;
138 } 138 }
139 return; 139 return;
140 } 140 }
141 141
142 //Récupération de la sélection sur netscape, ajout des balises autour. 142 //Récupération de la sélection sur netscape, ajout des balises autour.
143 function netscape_sel_paragraph(id, target, open_balise, close_balise) 143 function netscape_sel_paragraph(id, target, open_balise, close_balise)
144 { 144 {
145 var sel_length = target.textLength; 145 var sel_length = target.textLength;
146 var sel_start = target.selectionStart; 146 var sel_start = target.selectionStart;
147 var sel_end = target.selectionEnd; 147 var sel_end = target.selectionEnd;
148 var scroll = target.scrollTop; //Position verticale. 148 var scroll = target.scrollTop; //Position verticale.
149 149
150 if( sel_end == 1 || sel_end == 2 ) 150 if( sel_end == 1 || sel_end == 2 )
151 { 151 {
152 sel_end = sel_length; 152 sel_end = sel_length;
153 } 153 }
154 154
155 var string_start = (target.value).substring(0, sel_start); 155 var string_start = (target.value).substring(0, sel_start);
156 var selection = (target.value).substring(sel_start, sel_end); 156 var selection = (target.value).substring(sel_start, sel_end);
157 var string_end = (target.value).substring(sel_end, sel_length); 157 var string_end = (target.value).substring(sel_end, sel_length);
158 158
159 var title = selection != "" ? selection : prompt(enter_paragraph_name, title_paragraph); 159 var title = selection != "" ? selection : prompt(enter_paragraph_name, title_paragraph);
160 160
161 if (tinymce_editor) { 161 if (tinymce_editor) {
162 insertTinyMceContent('<br/>' + open_balise + ' ' + title + ' ' + close_balise + '<br/>'); //insertion pour tinymce. 162 insertTinyMceContent('<br/>' + open_balise + ' ' + title + ' ' + close_balise + '<br/>'); //insertion pour tinymce.
163 } else { 163 } else {
164 if( title != null ) 164 if( title != null )
165 { 165 {
166 if( close_balise != "" && selection == "" ) 166 if( close_balise != "" && selection == "" )
167 { 167 {
168 target.value = string_start + "\n" + open_balise + " " + title + " " + close_balise + "\n" + string_end; 168 target.value = string_start + "\n" + open_balise + " " + title + " " + close_balise + "\n" + string_end;
169 target.setSelectionRange(string_start.length + (open_balise.length + 2), target.value.length - string_end.length - (close_balise.length+2)); 169 target.setSelectionRange(string_start.length + (open_balise.length + 2), target.value.length - string_end.length - (close_balise.length+2));
170 target.focus(); 170 target.focus();
171 } 171 }
172 else 172 else
173 { 173 {
174 target.value = string_start + "\n" + open_balise + ' ' + selection + ' ' + close_balise + "\n" + string_end; 174 target.value = string_start + "\n" + open_balise + ' ' + selection + ' ' + close_balise + "\n" + string_end;
175 target.setSelectionRange(string_start.length + (open_balise.length + 2), target.value.length - string_end.length - (close_balise.length+2)); 175 target.setSelectionRange(string_start.length + (open_balise.length + 2), target.value.length - string_end.length - (close_balise.length+2));
176 target.focus(); 176 target.focus();
177 } 177 }
178 } 178 }
179 179
180 target.scrollTop = scroll; //Remet à la bonne position le textarea. 180 target.scrollTop = scroll; //Remet à la bonne position le textarea.
181 } 181 }
182 182
183 return; 183 return;
184 } 184 }
185 185
186 //Récupération de la sélection sur IE, ajout des balises autour. 186 //Récupération de la sélection sur IE, ajout des balises autour.
187 function ie_sel_paragraph(id, target, open_balise, close_balise) 187 function ie_sel_paragraph(id, target, open_balise, close_balise)
188 { 188 {
189 selText = false; 189 selText = false;
190 var scroll = target.scrollTop; //Position verticale. 190 var scroll = target.scrollTop; //Position verticale.
191 191
192 selection = document.selection.createRange().text; // Sélection 192 selection = document.selection.createRange().text; // Sélection
193 193
194 var title = selection != "" ? selection : prompt(enter_paragraph_name, title_paragraph); 194 var title = selection != "" ? selection : prompt(enter_paragraph_name, title_paragraph);
195 195
196 if (tinymce_editor) { 196 if (tinymce_editor) {
197 insertTinyMceContent('<br/>' + open_balise + ' ' + title + ' ' + close_balise + '<br/>'); //insertion pour tinymce. 197 insertTinyMceContent('<br/>' + open_balise + ' ' + title + ' ' + close_balise + '<br/>'); //insertion pour tinymce.
198 } else { 198 } else {
199 if( title != null ) 199 if( title != null )
200 { 200 {
201 if( close_balise != "" && selection == "" ) 201 if( close_balise != "" && selection == "" )
202 document.selection.createRange().text = "\n" + open_balise + " " + title + " " + close_balise + "\n"; 202 document.selection.createRange().text = "\n" + open_balise + " " + title + " " + close_balise + "\n";
203 else 203 else
204 document.selection.createRange().text = "\n" + open_balise + ' ' + selection + ' ' + close_balise + "\n"; 204 document.selection.createRange().text = "\n" + open_balise + ' ' + selection + ' ' + close_balise + "\n";
205 } 205 }
206 206
207 target.scrollTop = scroll; //Remet à la bonne position le textarea. 207 target.scrollTop = scroll; //Remet à la bonne position le textarea.
208 selText = ''; 208 selText = '';
209 } 209 }
210 210
211 return; 211 return;
212 } 212 }
213 213
214 //Fonction d'insertion du BBcode dans le champs, tient compte du navigateur utilisé. 214 //Fonction d'insertion du BBcode dans le champs, tient compte du navigateur utilisé.
215 function insert_paragraph_title(id, open_balise, close_balise, field) 215 function insert_paragraph_title(id, open_balise, close_balise, field)
216 { 216 {
217 var area = document.getElementById(field); 217 var area = document.getElementById(field);
218 var nav = navigator.appName; //Recupère le nom du navigateur 218 var nav = navigator.appName; //Recupère le nom du navigateur
219 219
220 area.focus(); 220 area.focus();
221 221
222 if( nav == 'Microsoft Internet Explorer' ) // Internet Explorer 222 if( nav == 'Microsoft Internet Explorer' ) // Internet Explorer
223 ie_sel_paragraph(id, area, open_balise, close_balise); 223 ie_sel_paragraph(id, area, open_balise, close_balise);
224 else if( nav == 'Netscape' || nav == 'Opera' ) //Netscape ou opera 224 else if( nav == 'Netscape' || nav == 'Opera' ) //Netscape ou opera
225 netscape_sel_paragraph(id, area, open_balise, close_balise); 225 netscape_sel_paragraph(id, area, open_balise, close_balise);
226 else //insertion normale (autres navigateurs) 226 else //insertion normale (autres navigateurs)
227 simple_insert_paragraph(id, open_balise, close_balise, field); 227 simple_insert_paragraph(id, open_balise, close_balise, field);
228 228
229 return; 229 return;
230 } 230 }
231 231
232 //Fonction d'affichage du contenu d'une catégorie 232 //Fonction d'affichage du contenu d'une catégorie
233 function open_cat(id_cat) 233 function open_cat(id_cat)
234 { 234 {
235 var xhr_object = null; 235 var xhr_object = null;
236 var data = null; 236 var data = null;
237 var filename = PATH_TO_ROOT + "/wiki/xmlhttprequest.php?select_cat=1&display_select_link=0" + (id_cat == 0 ? "&root=1" : "") + "&token=" + TOKEN; 237 var filename = PATH_TO_ROOT + "/wiki/xmlhttprequest.php?select_cat=1&display_select_link=0" + (id_cat == 0 ? "&root=1" : "") + "&token=" + TOKEN;
238 238
239 if(window.XMLHttpRequest) // Firefox 239 if(window.XMLHttpRequest) // Firefox
240 xhr_object = new XMLHttpRequest(); 240 xhr_object = new XMLHttpRequest();
241 else if(window.ActiveXObject) // Internet Explorer 241 else if(window.ActiveXObject) // Internet Explorer
242 xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 242 xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
243 else // XMLHttpRequest non supporté par le navigateur 243 else // XMLHttpRequest non supporté par le navigateur
244 return; 244 return;
245 245
246 if( id_cat >= 0 && id_cat != selected_cat ) 246 if( id_cat >= 0 && id_cat != selected_cat )
247 { 247 {
248 data = "open_cat=" + id_cat; 248 data = "open_cat=" + id_cat;
249 249
250 xhr_object.open("POST", filename, true); 250 xhr_object.open("POST", filename, true);
251 251
252 xhr_object.onreadystatechange = function() 252 xhr_object.onreadystatechange = function()
253 { 253 {
254 if( xhr_object.readyState == 4 ) 254 if( xhr_object.readyState == 4 )
255 { 255 {
256 document.getElementById("cat-contents").innerHTML = xhr_object.responseText; 256 document.getElementById("cat-contents").innerHTML = xhr_object.responseText;
257 document.getElementById("class-" + id_cat).className = "selected"; 257 document.getElementById("class-" + id_cat).className = "selected";
258 document.getElementById("class-" + selected_cat).className = ""; 258 document.getElementById("class-" + selected_cat).className = "";
259 selected_cat = id_cat; 259 selected_cat = id_cat;
260 } 260 }
261 } 261 }
262 262
263 xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 263 xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
264 264
265 xhr_object.send(data); 265 xhr_object.send(data);
266 } 266 }
267 }267 }
Editor
Original Text
Changed Text
Recommended videos