noalyss Version-9
todo_list.js
Go to the documentation of this file.
1/*
2 * This file is part of NOALYSS.
3 *
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18/* $Revision$ */
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief this file contains all the javascript needed by the todo_list.
24 * it requires prototype.js. The calling page must have
25 * the gDossier
26 *
27 */
28function todo_list_show(p_id)
29{
30 waiting_node();
31 /*
32 * create a div id based on p_id
33 */
34
35
36 try
37 {
38 var gDossier = $('gDossier').value;
39 var action = new Ajax.Request(
40 'ajax_misc.php',
41 {
42 method: 'get',
43 parameters:
44 {'show':1, 'id':p_id, 'gDossier':gDossier,op:'todo_list'},
45 onFailure: todo_list_show_error,
46 onSuccess: function (req)
47 {
48 if ( req.responseText === 'NOCONX') { reconnect();return;}
49 try
50 {
51 var todo_div=create_div({id:'todo_list_div'+p_id,cssclass:'add_todo_list'});
52
53
54
55 todo_div.style.top = (posY + offsetY) + 'px';
56 todo_div.style.left = (posX + offsetX - 200) + 'px';
57
58 var answer = req.responseXML;
59 var tl_id = answer.getElementsByTagName('tl_id');
60 var tl_content = answer.getElementsByTagName('tl_content');
61
62 if (tl_id.length == 0)
63 {
64 var rec = req.responseText;
65 alert_box(content[48] + rec);
66 }
67 var content = unescape_xml(getNodeText(tl_content[0]));
68 todo_div.innerHTML=content;
69
70 remove_waiting_node();
71 content.evalScripts();
72 Effect.SlideDown(todo_div, {duration: 0.1, direction: 'top-left'})
73 document.getElementById('todo_form_'+p_id)['p_desc'].scrollTop=0;
74 }
75 catch (e)
76 {
77 alert_box(e.message);
78 }
79 }
80 }
81 );
82 }
83 catch (e)
84 {
85 alert_box(content[48] + e.message);
86 }
87 return false;
88}
89function todo_list_show_error(request_json)
90{
91 alert_box(content[48]);
92}
93function add_todo()
94{
95 todo_list_show(0);
96}
97function todo_list_remove(p_ctl)
98{
99 smoke.confirm(content[50],
100 function (e) {
101 if ( !e ) {return;}
102 $("tr" + p_ctl).hide();
103 var gDossier = $('gDossier').value;
104
105 var action = new Ajax.Request(
106 'ajax_misc.php',
107 {
108 method: 'get',
109 parameters:{'del':1, 'id':p_ctl, 'gDossier':gDossier,op:'todo_list'}
110 }
111 );
112 return false;
113 });
114}
115/**
116 * Save the content of a todo note
117 * @param {type} p_form the form containing date, test , ...
118 *
119 */
120function todo_list_save(p_form)
121{
122 try {
123 var form=$('todo_form_'+p_form);
124 var json=form.serialize(true);
125 document.getElementById('todo_form_'+p_form)['p_desc'].scrollTop=0;
126 json['op']="todo_list";
127 new Ajax.Request('ajax_misc.php',
128 {
129 method:'post',
130 parameters:json,
131 onSuccess:function (req) {
132 // On success : reload the correct row and close
133 // the box
134 var answer = req.responseXML;
135 var tl_id = answer.getElementsByTagName('tl_id');
136 var content = answer.getElementsByTagName('row');
137 var style = answer.getElementsByTagName('style');
138
139 if (tl_id.length == 0)
140 {
141 var rec = req.responseText;
142 alert_box(content[48] + rec);
143 }
144 if ( getNodeText(tl_id[0]) == '0') {
145 smoke.alert(content[49]);
146 return;
147 }
148 var tr = $('tr'+p_form);
149 if ( p_form == 0)
150 {
151 tr=document.createElement('tr');
152 tr.id='tr'+getNodeText(tl_id[0]);
153 $('table_todo').appendChild(tr);
154 }
155 var html=getNodeText(content[0]);
156 tr.innerHTML=unescape_xml(html);
157 $w(tr.className).each ( function(p_class) { tr.removeClassName(p_class); } );
158 tr.addClassName(getNodeText(style[0]));
159 // remove the user list if exists
160 if ( $('shared_'+p_form)) {$('shared_'+p_form).remove();}
161 Effect.Fold('todo_list_div'+p_form,{duration:0.1});
162 }
163 }
164 );
165 }
166 catch (e) {
167 if ( console) console.log(e.message);
168 alert_box('todo_list_save '+e.message);
169 return false;
170 }
171 return false;
172}
173
174/**
175 * @brief toggle the zoom of the note
176 */
177var todo_maximize=false;
178/**
179 * @brief maximize or minimize the todo list from the
180 * dashboard.
181 * @returns {undefined}
182 */
183function zoom_todo ()
184{
185 waiting_box();
186 if ( ! todo_maximize)
187 {
188 var clonetodo=$('todo_listg_div').clone();
189 clonetodo.setAttribute('id','clone_todo_list')
190 clonetodo.setStyle({'z-index':1,'position':'absolute','width':'95%','height':'95%','top':'2%','right':'2%','left':'2%'})
191 clonetodo.innerHTML=$('todo_listg_div').innerHTML;
192 $('todo_listg_div').innerHTML="";
193 clonetodo.addClassName('inner_box');
194 clonetodo.removeClassName('box');
195 document.body.appendChild(clonetodo);
196 todo_maximize=true;
197 } else
198 {
199 todo_maximize=false;
200 $('todo_listg_div').innerHTML=$('clone_todo_list').innerHTML;
201 $('clone_todo_list').remove();
202 }
203
204 sorttable.makeSortable(document.getElementById('table_todo'));
205 remove_waiting_box();
206}
207function todo_list_share(p_note, p_dossier)
208{
209 waiting_node();
210 new Ajax.Request(
211 'ajax_misc.php',
212 {
213 method: "get",
214 parameters: {"act": 'shared_note',
215 "todo_id": p_note,
216 "gDossier": p_dossier,
217 op:'todo_list'
218 },
219 onSuccess: function (p_xml) {
220 try {
221 /**
222 * Show the little div to add other user
223 * or a error message if it is forbidden
224 */
225 remove_waiting_node();
226 var answer = p_xml.responseXML;
227 var content = answer.getElementsByTagName('content');
228 if (content.length == 0) {
229 return;
230 }
231 var html_content=unescape_xml(getNodeText(content[0]));
232 var shared_note = "shared_" + p_note;
233 create_div({"id": shared_note, "cssclass": "inner_box",drag:1});
234 $("shared_" + p_note).setStyle( { top : posY + offsetY+"px",left:posX+offsetY+"px","width":"25%"});
235 $("shared_" + p_note).hide();
236 $(shared_note).innerHTML = html_content;
237 $(shared_note).show();
238
239 } catch (e) {
240 alert_box(e.message);
241 }
242 }
243 }
244 );
245
246}
247function todo_list_set_share(note_id,p_login,p_dossier)
248{
249 waiting_node();
250 new Ajax.Request('ajax_misc.php',
251 {
252 method:"get",
253 parameters: { todo_id:note_id,act:"set_share","gDossier":p_dossier,"login":p_login,op:'todo_list'},
254 onSuccess:function() {
255 remove_waiting_node();
256 }
257 }
258 )
259}
260function todo_list_remove_share(note_id,p_login,p_dossier)
261{
262 waiting_node();
263 new Ajax.Request('ajax_misc.php',{
264 parameters : {
265 'gDossier':p_dossier,
266 'todo_id':note_id,
267 'login':p_login,
268 'act':"remove_share",
269 op:'todo_list'
270 },
271 method:"get",
272 onSuccess:function (p_xml) {
273 remove_waiting_node();
274 var answer=p_xml.responseXML;
275 var status=answer.getElementsByTagName('status');
276 if ( status.length == 0) {
277 alert_box ('erreur reponse ');
278 }
279 var status_code=getNodeText(status[0]);
280 if ( status_code == 'ok') {
281 $("tr" + note_id).hide();
282
283 }
284 }
285 });
286}