[6092] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <HTML> |
---|
| 3 | <HEAD> |
---|
| 4 | <script type="text/javascript" src="./libs/jquery.js"></script> |
---|
[6312] | 5 | <script type="text/javascript" src="./libs/jquery.json-2.3.min.js"></script> |
---|
[6383] | 6 | <script type="text/javascript" src="./libs/json2.js"></script> |
---|
[6092] | 7 | <script type="text/javascript" src="./libs/jsonreport.js"></script> |
---|
| 8 | <script type="text/javascript" src="./libs/Base64.js"></script> |
---|
| 9 | <TITLE>..:: Página de Teste - REST API ::..</TITLE> |
---|
| 10 | <META http-equiv="Content-Type" content="text/html; charset=utf-8"> |
---|
| 11 | <style type="text/css"> |
---|
| 12 | * { |
---|
| 13 | font-family: sans-serif, verdana, arial; |
---|
| 14 | font-size: 12px; |
---|
| 15 | } |
---|
| 16 | table { |
---|
| 17 | background:#ECECEC; |
---|
| 18 | padding:5px; |
---|
| 19 | border:1px solid black |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | .loader |
---|
| 23 | { |
---|
| 24 | position:absolute; |
---|
| 25 | padding: 5px; |
---|
| 26 | right:10px; |
---|
| 27 | top:10px; |
---|
| 28 | color: black; |
---|
| 29 | text-align:center; |
---|
| 30 | border: solid 1px black; |
---|
| 31 | z-index: 200; |
---|
| 32 | } |
---|
| 33 | </style> |
---|
| 34 | </HEAD> |
---|
[6383] | 35 | <BODY style="margin-bottom:10px;padding:0px;overflow:hidden"> |
---|
[6092] | 36 | <DIV style="display:none" class="loader" id="loader"> |
---|
| 37 | <label id="loader_msg"></label><br> |
---|
| 38 | <img src="./images/loader.gif"/> |
---|
| 39 | </DIV> |
---|
[6383] | 40 | <DIV style="overflow:auto;height:100%;float:left;width:30%;padding-right:10px"> |
---|
| 41 | <TABLE style="width:100%"> |
---|
[6092] | 42 | <TR><TD><b>Servidor</b></TD> |
---|
| 43 | <TD><select id="server"><option value="">Selecionar ....</option></select> |
---|
| 44 | <input id="bt_servers" type="button" value="Listar Servidores" onclick="javascript:jExecute('AvailableServers')"/> |
---|
| 45 | </TD> |
---|
| 46 | </TR> |
---|
[6383] | 47 | <TR><TD><b>Login</b></TD><TD><input type="text" id="user"/> |
---|
| 48 | <input id="bt_login" type="button" value="Conectar" onclick="javascript:jExecute('Login')"/> |
---|
| 49 | <input class="ui-button" id="bt_logout" type="button" value="Desconectar" onclick="javascript:jExecute('Logout')"/> |
---|
| 50 | </TD></TR> |
---|
| 51 | <TR><TD><b>Senha</b></TD><TD><input type="password" id="password"/></TD></TR> |
---|
| 52 | <TR><TD colspan=2> |
---|
| 53 | <input id="bt_myPicture" type="button" value="Visualizar Foto" onclick="javascript:jExecute('GetMyPicture')"/> |
---|
| 54 | <input id="bt_error" type="button" value="Teste Erro" onclick="javascript:jExecute('Teste')"/> |
---|
| 55 | <input id="bt_version" type="button" value="Versão API" onclick="javascript:jExecute('ExpressoVersion')"/> |
---|
| 56 | </TD></TR> |
---|
| 57 | </TABLE> |
---|
| 58 | <BR> |
---|
| 59 | <TABLE style="width:100%"> |
---|
| 60 | <TR><TD><b>Suporte /<br>Sugestão</b></TD> |
---|
| 61 | <TD><textarea id="text_message">Texto do e-mail de suporte/sugestao!!</textarea></TD> |
---|
| 62 | </TR> |
---|
| 63 | <TR><TD></TD> |
---|
| 64 | <TD><input id="bt_sugestao" type="button" value="Enviar Sugestão" onclick="javascript:jExecute('SendSupportFeedback')"/></TD> |
---|
[6311] | 65 | </TR> |
---|
[6092] | 66 | </TABLE> |
---|
[6383] | 67 | <BR> |
---|
| 68 | <TABLE style="width:100%"> |
---|
[6339] | 69 | <TR><TD><b>Para</b></TD> <TD><input type="text" id="msg_to"/></TD></TR> |
---|
| 70 | <TR><TD><b>CC</b></TD> <TD><input type="text" id="msg_cc"/></TD></TR> |
---|
| 71 | <TR><TD><b>CCo</b></TD> <TD><input type="text" id="msg_bcc"/></TD></TR> |
---|
| 72 | <TR><TD><b>Responder a</b></TD> <TD><input type="text" id="msg_replyto"/></TD></TR> |
---|
| 73 | <TR><TD><b>Assunto</b></TD> <TD><input type="text" id="msg_subject"/></TD></TR> |
---|
| 74 | <TR><TD><b>Conteudo</b></TD> <TD><textarea id="text_message_body">Texto do e-mail enviado.</textarea></TD></TR> |
---|
[6383] | 75 | <TR><TD colspan=2><input type="file" id="msg_attach_1"/></TD></TR> |
---|
| 76 | <TR><TD colspan=2><input type="file" id="msg_attach_2"/></TD></TR> |
---|
| 77 | <TR><TD></TD> |
---|
| 78 | <TD><input id="bt_send_msg" type="button" value="Enviar Mensagem" onclick="javascript:jExecute('Send')"/></TD></TR> |
---|
[6339] | 79 | </TABLE> |
---|
[6383] | 80 | <BR> |
---|
| 81 | <TABLE style="width:100%"> |
---|
| 82 | <TR><TD nowrap><b>Pastas IMAP</b></TD> |
---|
| 83 | <TD><input type="text" id="search_folders"/> |
---|
| 84 | <input id="bt_listFolders" type="button" value="Pesquisar" onclick="javascript:jExecute('Mail/Folders')"/> |
---|
| 85 | |
---|
| 86 | <TR><TD></TD> |
---|
[6156] | 87 | <TD colspan=2><select id="folder_id" onchange="javascript:jExecute('Mail/Messages')"><option value="INBOX">Selecionar pasta</option></select> |
---|
[6383] | 88 | <input id="bt_del_folder" type="button" value="Apagar Pasta" onclick="javascript:jExecute('DelFolder')"/> |
---|
| 89 | <input id="bt_clear_trash" type="button" value="Esvaziar Lixeira" onclick="javascript:jExecute('CleanTrash')"/> |
---|
| 90 | <input id="bt_rename_folder" type="button" value="Renomear Pasta" onclick="javascript:jExecute('RenameFolder')"/> |
---|
[6092] | 91 | </TD> |
---|
[6383] | 92 | </TR> |
---|
| 93 | <TR><TD></TD> |
---|
| 94 | <TD colspan="3"><input type="text" id="new_folder_name"/> |
---|
| 95 | <input id="bt_add_folder" type="button" value="Adicionar Pasta" onclick="javascript:jExecute('AddFolder')"/> |
---|
[6156] | 96 | </TD> |
---|
| 97 | </TR> |
---|
[6383] | 98 | <TR><TD colspan=3><HR></TD></TR> |
---|
| 99 | <TR><TD><b>Mensagens</b></TD><TD> |
---|
| 100 | <select id="message_id" onchange="javascript:jExecute('getMessage')"><option value="-1">Selecionar mensagem</option></select> |
---|
| 101 | </TD></TR> |
---|
| 102 | <TR><TD colspan=3><HR></TD></TR> |
---|
| 103 | <TR><TD><b>Anexos</b></TD><TD> |
---|
| 104 | <select id="attachment_id" onchange="javascript:jExecute('getAttachment')"><option value="-1">Selecionar Anexo</option></select> |
---|
[6092] | 105 | </TD> |
---|
| 106 | </TR> |
---|
[6383] | 107 | </TABLE><BR> |
---|
| 108 | <TABLE style="width:100%"> |
---|
| 109 | <TR><TD colspan=2><b>Catálogo</b></TD><TD><input type="radio" name="contactType" value="1" checked="checked">Pessoal<input type="radio" name="contactType" value="2"/>Global</TD></TR> |
---|
| 110 | <TR><TD></TD> |
---|
| 111 | <TD colspan=2><input type="text" id="search_catalog"/><input id="bt_catalog" type="button" value="Pesquisar" onclick="javascript:jExecute('getCatalog')"/> |
---|
| 112 | <br><select id="sel_catalog" onchange="javascript:jExecute('getCatalogPicture')"><option value="-1">Selecionar contato</option></select> |
---|
[6092] | 113 | </TD> |
---|
[6383] | 114 | </TR> |
---|
[6092] | 115 | </TABLE> |
---|
[6424] | 116 | <BR> |
---|
| 117 | <TABLE style="width:100%"> |
---|
| 118 | <TR><TD><b>Eventos</b></TD> |
---|
| 119 | <TD><b>De</b> <input type="text" id="events_date_start" size="19" maxlength="19" value="20/05/2012 00:00:00"/></TD> |
---|
| 120 | </TR> |
---|
| 121 | <TR><TD></TD> |
---|
| 122 | <TD><b>Até</b> <input type="text" id="events_date_end" size="19" maxlength="19" value="30/05/2012 23:59:59"/></TD> |
---|
| 123 | </TR> |
---|
| 124 | <TR><TD></TD> |
---|
| 125 | <TD><label title='Eventos com duração de mais de um dia, são quebrados em um registro por dia'><input type="checkbox" id="events_split_event" checked/> Split Event</label> <input id="bt_events" type="button" value="Pesquisar" onclick="javascript:jExecute('getEvents')"/></TD> |
---|
| 126 | </TR> |
---|
| 127 | </TABLE> |
---|
[6383] | 128 | </DIV> |
---|
| 129 | <DIV style="overflow:auto;height:100%;float:right;width:69%"> |
---|
| 130 | <TABLE> |
---|
| 131 | <TR><TD><b>Resposta JSON-RPC</b> |
---|
[6092] | 132 | <input id="bt_clear" type="button" value="Limpar Saída" onclick="javascript:clearOut()"/> |
---|
[6383] | 133 | </TD></TR> |
---|
| 134 | <TR><TD style="background:#FFF !important;padding:0px;"> |
---|
| 135 | <img id="img_photo" style="display:none;"/> |
---|
| 136 | <div id="message" class="jsonreport"></div> |
---|
| 137 | </TD></TR> |
---|
| 138 | </TABLE> |
---|
| 139 | </DIV> |
---|
[6092] | 140 | </BODY> |
---|
| 141 | <script language="Javascript"> |
---|
| 142 | |
---|
| 143 | function clearOut(){ |
---|
| 144 | $('#message').html(""); |
---|
| 145 | $('#img_photo').hide(); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | function dispatch(_action, response, _search){ |
---|
| 149 | var a_response = jQuery.parseJSON(response); |
---|
| 150 | if(a_response){ |
---|
| 151 | |
---|
| 152 | if(a_response.result && a_response.result.auth) { |
---|
| 153 | setCookie ("auth", a_response.result.auth); |
---|
| 154 | setCookie ("server", $('#server').val()); |
---|
[6383] | 155 | invalidateFields("in"); |
---|
[6092] | 156 | } |
---|
| 157 | else if(_action == 'Logout' || (a_response.error && a_response.error.code == 7 )) { |
---|
| 158 | clearOut(); |
---|
| 159 | setCookie ("auth", ''); |
---|
| 160 | setCookie ("server", ''); |
---|
[6383] | 161 | invalidateFields("out"); |
---|
[6092] | 162 | } |
---|
| 163 | } |
---|
| 164 | $('#message').append("<BR>"); |
---|
| 165 | if(a_response.error){ |
---|
| 166 | clearOut(); |
---|
| 167 | $('#message').append("<font color='red'>[erro "+a_response.error.code+"] "+a_response.error.message+"</font>"); |
---|
| 168 | return; |
---|
| 169 | } |
---|
| 170 | if(a_response.result){ |
---|
| 171 | if(typeof(a_response.result) != 'object') { |
---|
| 172 | $('#message').append("<font color='green'>"+a_response.result+"</font>"); |
---|
| 173 | return; |
---|
| 174 | } |
---|
| 175 | if(a_response.result.folders) { |
---|
| 176 | $("#folder_id").find('option').remove().end().append("<option value='-1'>Selecionar Pasta</option>"); |
---|
| 177 | for (var j in a_response.result.folders){ |
---|
| 178 | $("#folder_id").append("<option value='"+a_response.result.folders[j].folderID+"'>"+ |
---|
| 179 | a_response.result.folders[j].folderName+"</option>"); |
---|
| 180 | } |
---|
[6316] | 181 | $('#folder_id').prop('disabled',false); |
---|
| 182 | $('#new_folder_name').prop('disabled',false); |
---|
| 183 | $('#bt_del_folder').prop('disabled',false); |
---|
| 184 | $('#bt_add_folder').prop('disabled',false); |
---|
| 185 | $('#bt_rename_folder').prop('disabled',false); |
---|
[6092] | 186 | } |
---|
[6312] | 187 | if(a_response.result.messages) { |
---|
[6316] | 188 | $('#message_id').prop('disabled',false); |
---|
[6312] | 189 | if(a_response.result.messages.length == 1) { |
---|
| 190 | $("#attachment_id").find('option').remove().end().append("<option value='-1'>Selecionar Anexo</option>"); |
---|
| 191 | if(a_response.result.messages[0].msgHasAttachments > 0) { |
---|
[6316] | 192 | $('#attachment_id').prop('disabled',false); |
---|
[6312] | 193 | var attachments = a_response.result.messages[0].msgAttachments; |
---|
[6323] | 194 | var idxFile = 0; |
---|
[6312] | 195 | for (var j in attachments){ |
---|
[6323] | 196 | var value = { ID: attachments[j].pid, |
---|
| 197 | index: idxFile, |
---|
| 198 | name:attachments[j].name, |
---|
| 199 | encoding:attachments[j].encoding |
---|
| 200 | }; |
---|
| 201 | $("#attachment_id").append("<option value='"+$.toJSON(value)+"'>"+attachments[j].name+"</option>"); |
---|
| 202 | idxFile++; |
---|
[6312] | 203 | } |
---|
| 204 | } |
---|
| 205 | else{ |
---|
[6383] | 206 | $('#attachment_id').prop("disabled", true); |
---|
[6312] | 207 | } |
---|
| 208 | } |
---|
| 209 | else{ |
---|
| 210 | $("#message_id").find('option').remove().end().append("<option value='-1'>Selecionar Mensagem</option>"); |
---|
| 211 | for (var j in a_response.result.messages){ |
---|
| 212 | var value = a_response.result.messages[j].msgSubject.length > 20 ? |
---|
| 213 | a_response.result.messages[j].msgSubject.substring(0, 20) : a_response.result.messages[j].msgSubject; |
---|
[6092] | 214 | |
---|
[6312] | 215 | a_response.result.messages[j].msgBodyResume = (a_response.result.messages[j].msgBodyResume); |
---|
| 216 | $("#message_id").append("<option value='"+a_response.result.messages[j].msgID+"'>"+ |
---|
| 217 | value+"</option>"); |
---|
| 218 | } |
---|
[6092] | 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
[6383] | 222 | $('#sel_catalog').find('option').remove().end().append("<option value='-1'>Selecionar Contato</option>"); |
---|
[6092] | 223 | |
---|
[6383] | 224 | if(a_response.result.contacts && a_response.result.contacts.length > 0) { |
---|
| 225 | if(a_response.result.contacts && a_response.result.contacts.length == 1 && a_response.result.contacts[0].contactImagePicture) { |
---|
[6092] | 226 | if(a_response.result.contacts[0].contactImagePicture){ |
---|
| 227 | base64Data = a_response.result.contacts[0].contactImagePicture; |
---|
| 228 | $('#img_photo').attr("src", "data:image/jpg;base64,"+ base64Data); |
---|
| 229 | $('#img_photo').show(); |
---|
| 230 | return; |
---|
| 231 | } |
---|
| 232 | else{ |
---|
| 233 | $('#img_photo').hide(); |
---|
| 234 | } |
---|
| 235 | } |
---|
[6383] | 236 | else{ |
---|
| 237 | for (var j in a_response.result.contacts){ |
---|
| 238 | var value = (a_response.result.contacts[j].contactFullName != null ? a_response.result.contacts[j].contactFullName : "Vazio (ID "+a_response.result.contacts[j].contactID+")"); |
---|
| 239 | $('#sel_catalog').append("<option value='"+a_response.result.contacts[j].contactID+"'>"+ |
---|
| 240 | value+"</option>"); |
---|
| 241 | } |
---|
[6092] | 242 | } |
---|
[6383] | 243 | $('#sel_catalog').prop('disabled',false); |
---|
| 244 | |
---|
[6092] | 245 | } |
---|
| 246 | |
---|
| 247 | if(a_response.result.servers) { |
---|
| 248 | $("#server").find('option').remove().end().append("<option value=''>Selecionar Servidor</option>"); |
---|
| 249 | for (var j in a_response.result.servers){ |
---|
| 250 | $("#server").append("<option value='"+(a_response.result.servers[j].serverUrl+a_response.result.servers[j].serverContext)+"'>"+ |
---|
| 251 | a_response.result.servers[j].serverName+"</option>"); |
---|
| 252 | } |
---|
[6316] | 253 | $('#bt_version').prop('disabled',false); |
---|
| 254 | $('#bt_clear').prop('disabled',false); |
---|
[6092] | 255 | } |
---|
| 256 | |
---|
| 257 | var html = _.jsonreport(a_response.result); |
---|
| 258 | |
---|
| 259 | $('#message').html(html); |
---|
| 260 | } |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | function jExecute(_action){ |
---|
| 264 | var _server = getCookie('server') ? getCookie('server') : ($('#server').val() ? $('#server').val() : null); |
---|
[6383] | 265 | var _contactType = $("input[name='contactType']:checked").val(); |
---|
| 266 | var _contactID = $("#sel_catalog").val(); |
---|
[6092] | 267 | var _search; |
---|
| 268 | var _message; |
---|
| 269 | var _method = "POST"; |
---|
| 270 | |
---|
| 271 | if(_server == null && _action != 'AvailableServers'){ |
---|
| 272 | alert("Nenhum servidor foi definido."); |
---|
| 273 | return; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | |
---|
[6312] | 277 | if(_action == "getAttachment"){ |
---|
| 278 | downloadAttachment(); |
---|
| 279 | return; |
---|
| 280 | } |
---|
| 281 | |
---|
[6383] | 282 | if(_action == "AddFolder" || _action == "DelFolder" || _action == "RenameFolder" || _action == "CleanTrash"){ |
---|
| 283 | if(!confirm("Confirmar esta ação?")) |
---|
| 284 | return; |
---|
| 285 | } |
---|
| 286 | |
---|
[6092] | 287 | switch(_action){ |
---|
| 288 | case 'Mail/Folders': |
---|
| 289 | _search = '#search_folders'; |
---|
| 290 | break; |
---|
[6156] | 291 | case 'AddFolder': |
---|
| 292 | _action = 'Mail/AddFolder'; |
---|
| 293 | break; |
---|
| 294 | case 'DelFolder': |
---|
| 295 | _action = 'Mail/DelFolder'; |
---|
| 296 | break; |
---|
| 297 | case 'RenameFolder': |
---|
| 298 | _action = 'Mail/RenameFolder'; |
---|
| 299 | break; |
---|
[6339] | 300 | case 'Send': |
---|
| 301 | _action = 'Mail/Send'; |
---|
| 302 | break; |
---|
[6092] | 303 | case 'getMessages': |
---|
| 304 | _action = 'Mail/Messages'; |
---|
| 305 | $("#message_id").find('option').remove().end().append("<option value='-1'>Selecionar Mensagem</option>"); |
---|
| 306 | break; |
---|
| 307 | case 'getMessage': |
---|
| 308 | _action = 'Mail/Messages'; |
---|
| 309 | break; |
---|
| 310 | case 'CleanTrash': |
---|
| 311 | _action = 'Mail/CleanTrash'; |
---|
| 312 | break; |
---|
| 313 | case 'SendSupportFeedback': |
---|
| 314 | _action = 'Mail/SendSupportFeedback'; |
---|
| 315 | _message = $('#text_message').val(); |
---|
| 316 | break; |
---|
| 317 | case 'getCatalog': |
---|
| 318 | _action = 'Catalog/Contacts'; |
---|
| 319 | _search = '#search_catalog'; |
---|
[6383] | 320 | $("#sel_catalog").find('option').remove().end().append("<option value='-1'>Selecionar contato</option>"); |
---|
[6092] | 321 | break; |
---|
| 322 | case 'getCatalogPicture': |
---|
| 323 | _action = 'Catalog/ContactPicture'; |
---|
| 324 | break; |
---|
[6311] | 325 | case 'GetMyPicture': |
---|
| 326 | _action = 'Catalog/ContactPicture'; |
---|
[6383] | 327 | _contactID = ""; |
---|
[6311] | 328 | _contactType = '2'; |
---|
| 329 | break; |
---|
[6424] | 330 | case 'getEvents': |
---|
| 331 | _action = 'Calendar/Events'; |
---|
| 332 | break; |
---|
[6092] | 333 | |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | $.ajax({ |
---|
| 337 | type: "POST", |
---|
| 338 | url: "restclient.php", |
---|
| 339 | data: {params: { |
---|
| 340 | user: $('#user').val(), |
---|
| 341 | password: $('#password').val(), |
---|
| 342 | server: _server, |
---|
| 343 | auth: getCookie('auth') != null ? getCookie('auth') : "", |
---|
| 344 | folderID: $('#folder_id').val(), |
---|
| 345 | msgID: $('#message_id').val(), |
---|
[6383] | 346 | contactID: _contactID, |
---|
[6092] | 347 | message: _message, |
---|
| 348 | contactType: _contactType, |
---|
[6156] | 349 | search: $(_search).val(), |
---|
| 350 | newFolderName: $('#new_folder_name').val(), |
---|
[6339] | 351 | msgFrom: $('#msg_from').val(), |
---|
| 352 | msgTo: $('#msg_to').val(), |
---|
| 353 | msgCcTo: $('#msg_cc').val(), |
---|
| 354 | msgBccTo: $('#msg_bcc').val(), |
---|
| 355 | msgReplyTo: $('#msg_replyto').val(), |
---|
| 356 | msgSubject: $('#msg_subject').val(), |
---|
| 357 | msgBody: $('#text_message_body').val(), |
---|
[6424] | 358 | dateStart: $('#events_date_start').val(), |
---|
| 359 | dateEnd: $('#events_date_end').val(), |
---|
| 360 | splitEvent: ($('#events_split_event').attr('checked') ? 1 : 0), |
---|
[6092] | 361 | method: _method |
---|
[6339] | 362 | }, |
---|
[6092] | 363 | action: _action |
---|
| 364 | }, |
---|
| 365 | beforeSend: function() { |
---|
| 366 | clearOut(); |
---|
| 367 | $('#loader_msg').html("Aguarde, solicitando informações ..."); |
---|
| 368 | $('#loader').show(); |
---|
| 369 | } |
---|
| 370 | , |
---|
| 371 | success: function(response) { |
---|
| 372 | dispatch(_action, response, _search); |
---|
| 373 | $('#loader').hide(); |
---|
| 374 | } |
---|
| 375 | , |
---|
| 376 | error: function(response) { |
---|
| 377 | alert("Serviço indisponÃvel"); |
---|
| 378 | $('#loader').hide(); |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | }); |
---|
| 382 | |
---|
| 383 | } |
---|
| 384 | |
---|
[6312] | 385 | function downloadAttachment(){ |
---|
| 386 | var _server = getCookie('server') ? getCookie('server') : ($('#server').val() ? $('#server').val() : null); |
---|
| 387 | var form = document.createElement("form"); |
---|
[6383] | 388 | $(form).prop({"action":_server+"Mail/Attachment","method":"POST"}); |
---|
[6323] | 389 | var attachment = JSON.parse($('#attachment_id').val()); |
---|
[6312] | 390 | var _params = { |
---|
| 391 | auth: getCookie('auth') != null ? getCookie('auth') : "", |
---|
| 392 | folderID: $('#folder_id').val(), |
---|
| 393 | msgID: $('#message_id').val(), |
---|
[6323] | 394 | attachmentID: attachment.ID, |
---|
| 395 | attachmentName: attachment.name, |
---|
| 396 | attachmentIndex: attachment.index, |
---|
| 397 | attachmentEncoding: attachment.encoding |
---|
[6312] | 398 | }; |
---|
| 399 | |
---|
| 400 | $(form).append($(document.createElement('input')).attr( {"name":"params", "value": $.toJSON(_params)})); |
---|
[6315] | 401 | var secretThing = $('<iframe id="IFrameToDownload" style="display:none"></iframe>'); |
---|
[6312] | 402 | $('body').append(secretThing); |
---|
| 403 | $("#IFrameToDownload").contents().find('body').append(form); |
---|
| 404 | $(form).submit(); |
---|
| 405 | } |
---|
| 406 | |
---|
[6092] | 407 | function getCookie(c_name) |
---|
| 408 | { |
---|
| 409 | var i,x,y,ARRcookies=document.cookie.split(";"); |
---|
| 410 | for (i=0;i<ARRcookies.length;i++) |
---|
| 411 | { |
---|
| 412 | x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); |
---|
| 413 | y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); |
---|
| 414 | x=x.replace(/^\s+|\s+$/g,""); |
---|
| 415 | if (x==c_name) |
---|
| 416 | { |
---|
| 417 | if(y == "") |
---|
| 418 | return null; |
---|
| 419 | else |
---|
| 420 | return unescape(y); |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | function setCookie(c_name,value,exdays) |
---|
| 426 | { |
---|
| 427 | var exdate=new Date(); |
---|
| 428 | exdate.setDate(exdate.getDate() + exdays); |
---|
| 429 | var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); |
---|
| 430 | document.cookie=c_name + "=" + c_value; |
---|
| 431 | } |
---|
| 432 | // Reset values |
---|
| 433 | if(getCookie('auth') != null && getCookie('server') != null){ |
---|
[6383] | 434 | invalidateFields("in"); |
---|
[6092] | 435 | } |
---|
[6383] | 436 | else |
---|
| 437 | invalidateFields("out"); |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | function invalidateFields(status){ |
---|
| 441 | |
---|
| 442 | // Text Fields |
---|
| 443 | $('#user').prop("disabled", status == "in"); |
---|
| 444 | $('#password').prop("disabled", status == "in"); |
---|
| 445 | $('#msg_to').prop("disabled", status == "out"); |
---|
| 446 | $('#msg_cc').prop("disabled", status == "out"); |
---|
| 447 | $('#msg_bcc').prop("disabled", status == "out"); |
---|
| 448 | $('#msg_replyto').prop("disabled", status == "out"); |
---|
| 449 | $('#msg_subject').prop("disabled", status == "out"); |
---|
| 450 | $('#msg_attach_1').prop("disabled", status == "out"); |
---|
| 451 | $('#msg_attach_2').prop("disabled", status == "out"); |
---|
| 452 | $('#new_folder_name').prop("disabled", status == "out"); |
---|
| 453 | $('#search_folders').prop("disabled", status == "out"); |
---|
| 454 | $('#search_catalog').prop("disabled", status == "out"); |
---|
| 455 | |
---|
| 456 | // Buttons |
---|
| 457 | $('#bt_servers').prop("disabled", status == "in"); |
---|
| 458 | $('#bt_login').prop("disabled", status == "in"); |
---|
| 459 | $('#bt_version').prop("disabled", status == "out"); |
---|
| 460 | $('#bt_logout').prop("disabled", status == "out"); |
---|
| 461 | $('#bt_listFolders').prop("disabled", status == "out"); |
---|
| 462 | $('#bt_add_folder').prop("disabled", status == "out"); |
---|
| 463 | $('#bt_del_folder').prop("disabled", status == "out"); |
---|
| 464 | $('#bt_rename_folder').prop("disabled", status == "out"); |
---|
| 465 | $('#bt_clear_trash').prop("disabled", status == "out"); |
---|
| 466 | $('#bt_clear').prop("disabled", status == "out"); |
---|
| 467 | $('#bt_sugestao').prop("disabled", status == "out"); |
---|
| 468 | $('#bt_send_msg').prop("disabled", status == "out"); |
---|
| 469 | $('#bt_catalog').prop("disabled", status == "out"); |
---|
| 470 | $('#bt_myPicture').prop("disabled", status == "out"); |
---|
| 471 | $('#bt_error').prop("disabled", status == "out"); |
---|
| 472 | $("input[name='contactType']").prop("disabled", status == "out"); |
---|
| 473 | |
---|
[6092] | 474 | |
---|
[6383] | 475 | // Select Boxes |
---|
| 476 | $('#folder_id').prop("disabled", status == "out"); |
---|
| 477 | $('#message_id').prop("disabled", status == "out"); |
---|
| 478 | $('#attachment_id').prop("disabled", status == "out"); |
---|
| 479 | $('#sel_catalog').prop("disabled", status == "out"); |
---|
| 480 | $('#server').prop("disabled", status == "in"); |
---|
[6316] | 481 | |
---|
[6383] | 482 | // Text Areas |
---|
| 483 | $('#text_message_body').prop("disabled", status == "out"); |
---|
| 484 | $('#text_message').prop("disabled", status == "out"); |
---|
| 485 | } |
---|
[6092] | 486 | </script> |
---|
| 487 | </html> |
---|