[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> |
---|
[6383] | 116 | </DIV> |
---|
| 117 | <DIV style="overflow:auto;height:100%;float:right;width:69%"> |
---|
| 118 | <TABLE> |
---|
| 119 | <TR><TD><b>Resposta JSON-RPC</b> |
---|
[6092] | 120 | <input id="bt_clear" type="button" value="Limpar Saída" onclick="javascript:clearOut()"/> |
---|
[6383] | 121 | </TD></TR> |
---|
| 122 | <TR><TD style="background:#FFF !important;padding:0px;"> |
---|
| 123 | <img id="img_photo" style="display:none;"/> |
---|
| 124 | <div id="message" class="jsonreport"></div> |
---|
| 125 | </TD></TR> |
---|
| 126 | </TABLE> |
---|
| 127 | </DIV> |
---|
[6092] | 128 | </BODY> |
---|
| 129 | <script language="Javascript"> |
---|
| 130 | |
---|
| 131 | function clearOut(){ |
---|
| 132 | $('#message').html(""); |
---|
| 133 | $('#img_photo').hide(); |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | function dispatch(_action, response, _search){ |
---|
| 137 | var a_response = jQuery.parseJSON(response); |
---|
| 138 | if(a_response){ |
---|
| 139 | |
---|
| 140 | if(a_response.result && a_response.result.auth) { |
---|
| 141 | setCookie ("auth", a_response.result.auth); |
---|
| 142 | setCookie ("server", $('#server').val()); |
---|
[6383] | 143 | invalidateFields("in"); |
---|
[6092] | 144 | } |
---|
| 145 | else if(_action == 'Logout' || (a_response.error && a_response.error.code == 7 )) { |
---|
| 146 | clearOut(); |
---|
| 147 | setCookie ("auth", ''); |
---|
| 148 | setCookie ("server", ''); |
---|
[6383] | 149 | invalidateFields("out"); |
---|
[6092] | 150 | } |
---|
| 151 | } |
---|
| 152 | $('#message').append("<BR>"); |
---|
| 153 | if(a_response.error){ |
---|
| 154 | clearOut(); |
---|
| 155 | $('#message').append("<font color='red'>[erro "+a_response.error.code+"] "+a_response.error.message+"</font>"); |
---|
| 156 | return; |
---|
| 157 | } |
---|
| 158 | if(a_response.result){ |
---|
| 159 | if(typeof(a_response.result) != 'object') { |
---|
| 160 | $('#message').append("<font color='green'>"+a_response.result+"</font>"); |
---|
| 161 | return; |
---|
| 162 | } |
---|
| 163 | if(a_response.result.folders) { |
---|
| 164 | $("#folder_id").find('option').remove().end().append("<option value='-1'>Selecionar Pasta</option>"); |
---|
| 165 | for (var j in a_response.result.folders){ |
---|
| 166 | $("#folder_id").append("<option value='"+a_response.result.folders[j].folderID+"'>"+ |
---|
| 167 | a_response.result.folders[j].folderName+"</option>"); |
---|
| 168 | } |
---|
[6316] | 169 | $('#folder_id').prop('disabled',false); |
---|
| 170 | $('#new_folder_name').prop('disabled',false); |
---|
| 171 | $('#bt_del_folder').prop('disabled',false); |
---|
| 172 | $('#bt_add_folder').prop('disabled',false); |
---|
| 173 | $('#bt_rename_folder').prop('disabled',false); |
---|
[6092] | 174 | } |
---|
[6312] | 175 | if(a_response.result.messages) { |
---|
[6316] | 176 | $('#message_id').prop('disabled',false); |
---|
[6312] | 177 | if(a_response.result.messages.length == 1) { |
---|
| 178 | $("#attachment_id").find('option').remove().end().append("<option value='-1'>Selecionar Anexo</option>"); |
---|
| 179 | if(a_response.result.messages[0].msgHasAttachments > 0) { |
---|
[6316] | 180 | $('#attachment_id').prop('disabled',false); |
---|
[6312] | 181 | var attachments = a_response.result.messages[0].msgAttachments; |
---|
[6323] | 182 | var idxFile = 0; |
---|
[6312] | 183 | for (var j in attachments){ |
---|
[6323] | 184 | var value = { ID: attachments[j].pid, |
---|
| 185 | index: idxFile, |
---|
| 186 | name:attachments[j].name, |
---|
| 187 | encoding:attachments[j].encoding |
---|
| 188 | }; |
---|
| 189 | $("#attachment_id").append("<option value='"+$.toJSON(value)+"'>"+attachments[j].name+"</option>"); |
---|
| 190 | idxFile++; |
---|
[6312] | 191 | } |
---|
| 192 | } |
---|
| 193 | else{ |
---|
[6383] | 194 | $('#attachment_id').prop("disabled", true); |
---|
[6312] | 195 | } |
---|
| 196 | } |
---|
| 197 | else{ |
---|
| 198 | $("#message_id").find('option').remove().end().append("<option value='-1'>Selecionar Mensagem</option>"); |
---|
| 199 | for (var j in a_response.result.messages){ |
---|
| 200 | var value = a_response.result.messages[j].msgSubject.length > 20 ? |
---|
| 201 | a_response.result.messages[j].msgSubject.substring(0, 20) : a_response.result.messages[j].msgSubject; |
---|
[6092] | 202 | |
---|
[6312] | 203 | a_response.result.messages[j].msgBodyResume = (a_response.result.messages[j].msgBodyResume); |
---|
| 204 | $("#message_id").append("<option value='"+a_response.result.messages[j].msgID+"'>"+ |
---|
| 205 | value+"</option>"); |
---|
| 206 | } |
---|
[6092] | 207 | } |
---|
| 208 | } |
---|
| 209 | |
---|
[6383] | 210 | $('#sel_catalog').find('option').remove().end().append("<option value='-1'>Selecionar Contato</option>"); |
---|
[6092] | 211 | |
---|
[6383] | 212 | if(a_response.result.contacts && a_response.result.contacts.length > 0) { |
---|
| 213 | if(a_response.result.contacts && a_response.result.contacts.length == 1 && a_response.result.contacts[0].contactImagePicture) { |
---|
[6092] | 214 | if(a_response.result.contacts[0].contactImagePicture){ |
---|
| 215 | base64Data = a_response.result.contacts[0].contactImagePicture; |
---|
| 216 | $('#img_photo').attr("src", "data:image/jpg;base64,"+ base64Data); |
---|
| 217 | $('#img_photo').show(); |
---|
| 218 | return; |
---|
| 219 | } |
---|
| 220 | else{ |
---|
| 221 | $('#img_photo').hide(); |
---|
| 222 | } |
---|
| 223 | } |
---|
[6383] | 224 | else{ |
---|
| 225 | for (var j in a_response.result.contacts){ |
---|
| 226 | var value = (a_response.result.contacts[j].contactFullName != null ? a_response.result.contacts[j].contactFullName : "Vazio (ID "+a_response.result.contacts[j].contactID+")"); |
---|
| 227 | $('#sel_catalog').append("<option value='"+a_response.result.contacts[j].contactID+"'>"+ |
---|
| 228 | value+"</option>"); |
---|
| 229 | } |
---|
[6092] | 230 | } |
---|
[6383] | 231 | $('#sel_catalog').prop('disabled',false); |
---|
| 232 | |
---|
[6092] | 233 | } |
---|
| 234 | |
---|
| 235 | if(a_response.result.servers) { |
---|
| 236 | $("#server").find('option').remove().end().append("<option value=''>Selecionar Servidor</option>"); |
---|
| 237 | for (var j in a_response.result.servers){ |
---|
| 238 | $("#server").append("<option value='"+(a_response.result.servers[j].serverUrl+a_response.result.servers[j].serverContext)+"'>"+ |
---|
| 239 | a_response.result.servers[j].serverName+"</option>"); |
---|
| 240 | } |
---|
[6316] | 241 | $('#bt_version').prop('disabled',false); |
---|
| 242 | $('#bt_clear').prop('disabled',false); |
---|
[6092] | 243 | } |
---|
| 244 | |
---|
| 245 | var html = _.jsonreport(a_response.result); |
---|
| 246 | |
---|
| 247 | $('#message').html(html); |
---|
| 248 | } |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | function jExecute(_action){ |
---|
| 252 | var _server = getCookie('server') ? getCookie('server') : ($('#server').val() ? $('#server').val() : null); |
---|
[6383] | 253 | var _contactType = $("input[name='contactType']:checked").val(); |
---|
| 254 | var _contactID = $("#sel_catalog").val(); |
---|
[6092] | 255 | var _search; |
---|
| 256 | var _message; |
---|
| 257 | var _method = "POST"; |
---|
| 258 | |
---|
| 259 | if(_server == null && _action != 'AvailableServers'){ |
---|
| 260 | alert("Nenhum servidor foi definido."); |
---|
| 261 | return; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | |
---|
[6312] | 265 | if(_action == "getAttachment"){ |
---|
| 266 | downloadAttachment(); |
---|
| 267 | return; |
---|
| 268 | } |
---|
| 269 | |
---|
[6383] | 270 | if(_action == "AddFolder" || _action == "DelFolder" || _action == "RenameFolder" || _action == "CleanTrash"){ |
---|
| 271 | if(!confirm("Confirmar esta ação?")) |
---|
| 272 | return; |
---|
| 273 | } |
---|
| 274 | |
---|
[6092] | 275 | switch(_action){ |
---|
| 276 | case 'Mail/Folders': |
---|
| 277 | _search = '#search_folders'; |
---|
| 278 | break; |
---|
[6156] | 279 | case 'AddFolder': |
---|
| 280 | _action = 'Mail/AddFolder'; |
---|
| 281 | break; |
---|
| 282 | case 'DelFolder': |
---|
| 283 | _action = 'Mail/DelFolder'; |
---|
| 284 | break; |
---|
| 285 | case 'RenameFolder': |
---|
| 286 | _action = 'Mail/RenameFolder'; |
---|
| 287 | break; |
---|
[6339] | 288 | case 'Send': |
---|
| 289 | _action = 'Mail/Send'; |
---|
| 290 | break; |
---|
[6092] | 291 | case 'getMessages': |
---|
| 292 | _action = 'Mail/Messages'; |
---|
| 293 | $("#message_id").find('option').remove().end().append("<option value='-1'>Selecionar Mensagem</option>"); |
---|
| 294 | break; |
---|
| 295 | case 'getMessage': |
---|
| 296 | _action = 'Mail/Messages'; |
---|
| 297 | break; |
---|
| 298 | case 'CleanTrash': |
---|
| 299 | _action = 'Mail/CleanTrash'; |
---|
| 300 | break; |
---|
| 301 | case 'SendSupportFeedback': |
---|
| 302 | _action = 'Mail/SendSupportFeedback'; |
---|
| 303 | _message = $('#text_message').val(); |
---|
| 304 | break; |
---|
| 305 | case 'getCatalog': |
---|
| 306 | _action = 'Catalog/Contacts'; |
---|
| 307 | _search = '#search_catalog'; |
---|
[6383] | 308 | $("#sel_catalog").find('option').remove().end().append("<option value='-1'>Selecionar contato</option>"); |
---|
[6092] | 309 | break; |
---|
| 310 | case 'getCatalogPicture': |
---|
| 311 | _action = 'Catalog/ContactPicture'; |
---|
| 312 | break; |
---|
[6311] | 313 | case 'GetMyPicture': |
---|
| 314 | _action = 'Catalog/ContactPicture'; |
---|
[6383] | 315 | _contactID = ""; |
---|
[6311] | 316 | _contactType = '2'; |
---|
| 317 | break; |
---|
[6092] | 318 | |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | $.ajax({ |
---|
| 322 | type: "POST", |
---|
| 323 | url: "restclient.php", |
---|
| 324 | data: {params: { |
---|
| 325 | user: $('#user').val(), |
---|
| 326 | password: $('#password').val(), |
---|
| 327 | server: _server, |
---|
| 328 | auth: getCookie('auth') != null ? getCookie('auth') : "", |
---|
| 329 | folderID: $('#folder_id').val(), |
---|
| 330 | msgID: $('#message_id').val(), |
---|
[6383] | 331 | contactID: _contactID, |
---|
[6092] | 332 | message: _message, |
---|
| 333 | contactType: _contactType, |
---|
[6156] | 334 | search: $(_search).val(), |
---|
| 335 | newFolderName: $('#new_folder_name').val(), |
---|
[6339] | 336 | msgFrom: $('#msg_from').val(), |
---|
| 337 | msgTo: $('#msg_to').val(), |
---|
| 338 | msgCcTo: $('#msg_cc').val(), |
---|
| 339 | msgBccTo: $('#msg_bcc').val(), |
---|
| 340 | msgReplyTo: $('#msg_replyto').val(), |
---|
| 341 | msgSubject: $('#msg_subject').val(), |
---|
| 342 | msgBody: $('#text_message_body').val(), |
---|
[6092] | 343 | method: _method |
---|
[6339] | 344 | }, |
---|
[6092] | 345 | action: _action |
---|
| 346 | }, |
---|
| 347 | beforeSend: function() { |
---|
| 348 | clearOut(); |
---|
| 349 | $('#loader_msg').html("Aguarde, solicitando informações ..."); |
---|
| 350 | $('#loader').show(); |
---|
| 351 | } |
---|
| 352 | , |
---|
| 353 | success: function(response) { |
---|
| 354 | dispatch(_action, response, _search); |
---|
| 355 | $('#loader').hide(); |
---|
| 356 | } |
---|
| 357 | , |
---|
| 358 | error: function(response) { |
---|
| 359 | alert("Serviço indisponÃvel"); |
---|
| 360 | $('#loader').hide(); |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | }); |
---|
| 364 | |
---|
| 365 | } |
---|
| 366 | |
---|
[6312] | 367 | function downloadAttachment(){ |
---|
| 368 | var _server = getCookie('server') ? getCookie('server') : ($('#server').val() ? $('#server').val() : null); |
---|
| 369 | var form = document.createElement("form"); |
---|
[6383] | 370 | $(form).prop({"action":_server+"Mail/Attachment","method":"POST"}); |
---|
[6323] | 371 | var attachment = JSON.parse($('#attachment_id').val()); |
---|
[6312] | 372 | var _params = { |
---|
| 373 | auth: getCookie('auth') != null ? getCookie('auth') : "", |
---|
| 374 | folderID: $('#folder_id').val(), |
---|
| 375 | msgID: $('#message_id').val(), |
---|
[6323] | 376 | attachmentID: attachment.ID, |
---|
| 377 | attachmentName: attachment.name, |
---|
| 378 | attachmentIndex: attachment.index, |
---|
| 379 | attachmentEncoding: attachment.encoding |
---|
[6312] | 380 | }; |
---|
| 381 | |
---|
| 382 | $(form).append($(document.createElement('input')).attr( {"name":"params", "value": $.toJSON(_params)})); |
---|
[6315] | 383 | var secretThing = $('<iframe id="IFrameToDownload" style="display:none"></iframe>'); |
---|
[6312] | 384 | $('body').append(secretThing); |
---|
| 385 | $("#IFrameToDownload").contents().find('body').append(form); |
---|
| 386 | $(form).submit(); |
---|
| 387 | } |
---|
| 388 | |
---|
[6092] | 389 | function getCookie(c_name) |
---|
| 390 | { |
---|
| 391 | var i,x,y,ARRcookies=document.cookie.split(";"); |
---|
| 392 | for (i=0;i<ARRcookies.length;i++) |
---|
| 393 | { |
---|
| 394 | x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); |
---|
| 395 | y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); |
---|
| 396 | x=x.replace(/^\s+|\s+$/g,""); |
---|
| 397 | if (x==c_name) |
---|
| 398 | { |
---|
| 399 | if(y == "") |
---|
| 400 | return null; |
---|
| 401 | else |
---|
| 402 | return unescape(y); |
---|
| 403 | } |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | function setCookie(c_name,value,exdays) |
---|
| 408 | { |
---|
| 409 | var exdate=new Date(); |
---|
| 410 | exdate.setDate(exdate.getDate() + exdays); |
---|
| 411 | var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); |
---|
| 412 | document.cookie=c_name + "=" + c_value; |
---|
| 413 | } |
---|
| 414 | // Reset values |
---|
| 415 | if(getCookie('auth') != null && getCookie('server') != null){ |
---|
[6383] | 416 | invalidateFields("in"); |
---|
[6092] | 417 | } |
---|
[6383] | 418 | else |
---|
| 419 | invalidateFields("out"); |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | function invalidateFields(status){ |
---|
| 423 | |
---|
| 424 | // Text Fields |
---|
| 425 | $('#user').prop("disabled", status == "in"); |
---|
| 426 | $('#password').prop("disabled", status == "in"); |
---|
| 427 | $('#msg_to').prop("disabled", status == "out"); |
---|
| 428 | $('#msg_cc').prop("disabled", status == "out"); |
---|
| 429 | $('#msg_bcc').prop("disabled", status == "out"); |
---|
| 430 | $('#msg_replyto').prop("disabled", status == "out"); |
---|
| 431 | $('#msg_subject').prop("disabled", status == "out"); |
---|
| 432 | $('#msg_attach_1').prop("disabled", status == "out"); |
---|
| 433 | $('#msg_attach_2').prop("disabled", status == "out"); |
---|
| 434 | $('#new_folder_name').prop("disabled", status == "out"); |
---|
| 435 | $('#search_folders').prop("disabled", status == "out"); |
---|
| 436 | $('#search_catalog').prop("disabled", status == "out"); |
---|
| 437 | |
---|
| 438 | // Buttons |
---|
| 439 | $('#bt_servers').prop("disabled", status == "in"); |
---|
| 440 | $('#bt_login').prop("disabled", status == "in"); |
---|
| 441 | $('#bt_version').prop("disabled", status == "out"); |
---|
| 442 | $('#bt_logout').prop("disabled", status == "out"); |
---|
| 443 | $('#bt_listFolders').prop("disabled", status == "out"); |
---|
| 444 | $('#bt_add_folder').prop("disabled", status == "out"); |
---|
| 445 | $('#bt_del_folder').prop("disabled", status == "out"); |
---|
| 446 | $('#bt_rename_folder').prop("disabled", status == "out"); |
---|
| 447 | $('#bt_clear_trash').prop("disabled", status == "out"); |
---|
| 448 | $('#bt_clear').prop("disabled", status == "out"); |
---|
| 449 | $('#bt_sugestao').prop("disabled", status == "out"); |
---|
| 450 | $('#bt_send_msg').prop("disabled", status == "out"); |
---|
| 451 | $('#bt_catalog').prop("disabled", status == "out"); |
---|
| 452 | $('#bt_myPicture').prop("disabled", status == "out"); |
---|
| 453 | $('#bt_error').prop("disabled", status == "out"); |
---|
| 454 | $("input[name='contactType']").prop("disabled", status == "out"); |
---|
| 455 | |
---|
[6092] | 456 | |
---|
[6383] | 457 | // Select Boxes |
---|
| 458 | $('#folder_id').prop("disabled", status == "out"); |
---|
| 459 | $('#message_id').prop("disabled", status == "out"); |
---|
| 460 | $('#attachment_id').prop("disabled", status == "out"); |
---|
| 461 | $('#sel_catalog').prop("disabled", status == "out"); |
---|
| 462 | $('#server').prop("disabled", status == "in"); |
---|
[6316] | 463 | |
---|
[6383] | 464 | // Text Areas |
---|
| 465 | $('#text_message_body').prop("disabled", status == "out"); |
---|
| 466 | $('#text_message').prop("disabled", status == "out"); |
---|
| 467 | } |
---|
[6092] | 468 | </script> |
---|
| 469 | </html> |
---|