2 * This file is part of NOALYSS.
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.
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.
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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
23 * \brief this file contains all the javascript needed by the todo_list.
24 * it requires prototype.js. The calling page must have
28function todo_list_show(p_id)
32 * create a div id based on p_id
38 var gDossier = $('gDossier').value;
39 var action = new Ajax.Request(
44 {'show':1, 'id':p_id, 'gDossier':gDossier,op:'todo_list'},
45 onFailure: todo_list_show_error,
46 onSuccess: function (req)
48 if ( req.responseText === 'NOCONX') { reconnect();return;}
51 var todo_div=create_div({id:'todo_list_div'+p_id,cssclass:'add_todo_list'});
55 todo_div.style.top = (posY + offsetY) + 'px';
56 todo_div.style.left = (posX + offsetX - 200) + 'px';
58 var answer = req.responseXML;
59 var tl_id = answer.getElementsByTagName('tl_id');
60 var tl_content = answer.getElementsByTagName('tl_content');
62 if (tl_id.length == 0)
64 var rec = req.responseText;
65 alert_box(content[48] + rec);
67 var content = unescape_xml(getNodeText(tl_content[0]));
68 todo_div.innerHTML=content;
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;
85 alert_box(content[48] + e.message);
89function todo_list_show_error(request_json)
91 alert_box(content[48]);
97function todo_list_remove(p_ctl)
99 smoke.confirm(content[50],
102 $("tr" + p_ctl).hide();
103 var gDossier = $('gDossier').value;
105 var action = new Ajax.Request(
109 parameters:{'del':1, 'id':p_ctl, 'gDossier':gDossier,op:'todo_list'}
116 * Save the content of a todo note
117 * @param {type} p_form the form containing date, test , ...
120function todo_list_save(p_form)
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',
131 onSuccess:function (req) {
132 // On success : reload the correct row and close
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');
139 if (tl_id.length == 0)
141 var rec = req.responseText;
142 alert_box(content[48] + rec);
144 if ( getNodeText(tl_id[0]) == '0') {
145 smoke.alert(content[49]);
148 var tr = $('tr'+p_form);
151 tr=document.createElement('tr');
152 tr.id='tr'+getNodeText(tl_id[0]);
153 $('table_todo').appendChild(tr);
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});
167 if ( console) console.log(e.message);
168 alert_box('todo_list_save '+e.message);
175 * @brief toggle the zoom of the note
177var todo_maximize=false;
179 * @brief maximize or minimize the todo list from the
181 * @returns {undefined}
186 if ( ! todo_maximize)
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);
200 $('todo_listg_div').innerHTML=$('clone_todo_list').innerHTML;
201 $('clone_todo_list').remove();
204 sorttable.makeSortable(document.getElementById('table_todo'));
205 remove_waiting_box();
207function todo_list_share(p_note, p_dossier)
214 parameters: {"act": 'shared_note',
216 "gDossier": p_dossier,
219 onSuccess: function (p_xml) {
222 * Show the little div to add other user
223 * or a error message if it is forbidden
225 remove_waiting_node();
226 var answer = p_xml.responseXML;
227 var content = answer.getElementsByTagName('content');
228 if (content.length == 0) {
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();
240 alert_box(e.message);
247function todo_list_set_share(note_id,p_login,p_dossier)
250 new Ajax.Request('ajax_misc.php',
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();
260function todo_list_remove_share(note_id,p_login,p_dossier)
263 new Ajax.Request('ajax_misc.php',{
265 'gDossier':p_dossier,
268 'act':"remove_share",
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 ');
279 var status_code=getNodeText(status[0]);
280 if ( status_code == 'ok') {
281 $("tr" + note_id).hide();