Mercurial > hg > rc1
comparison plugins/enigma/enigma.min.js @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 window.rcmail&&rcmail.addEventListener("init",function(a){"settings"==rcmail.env.task?(rcmail.gui_objects.keyslist&&(rcmail.keys_list=new rcube_list_widget(rcmail.gui_objects.keyslist,{multiselect:!0,draggable:!1,keyboard:!1}),rcmail.keys_list.addEventListener("select",function(a){rcmail.enigma_keylist_select(a)}).addEventListener("keypress",function(a){rcmail.enigma_keylist_keypress(a)}).init().focus(),rcmail.enigma_list(),rcmail.register_command("firstpage",function(a){return rcmail.enigma_list_page("first")}), | |
2 rcmail.register_command("previouspage",function(a){return rcmail.enigma_list_page("previous")}),rcmail.register_command("nextpage",function(a){return rcmail.enigma_list_page("next")}),rcmail.register_command("lastpage",function(a){return rcmail.enigma_list_page("last")})),"plugin.enigmakeys"==rcmail.env.action&&(rcmail.register_command("search",function(a){return rcmail.enigma_search(a)},!0),rcmail.register_command("reset-search",function(a){return rcmail.enigma_search_reset(a)},!0),rcmail.register_command("plugin.enigma-import", | |
3 function(){rcmail.enigma_import()},!0),rcmail.register_command("plugin.enigma-import-search",function(){rcmail.enigma_import_search()},!0),rcmail.register_command("plugin.enigma-key-export",function(){rcmail.enigma_export()}),rcmail.register_command("plugin.enigma-key-export-selected",function(){rcmail.enigma_export(!0)}),rcmail.register_command("plugin.enigma-key-import",function(){rcmail.enigma_key_import()},!0),rcmail.register_command("plugin.enigma-key-delete",function(a){return rcmail.enigma_delete()}), | |
4 rcmail.register_command("plugin.enigma-key-create",function(a){return rcmail.enigma_key_create()},!0),rcmail.register_command("plugin.enigma-key-save",function(a){return rcmail.enigma_key_create_save()},!0),rcmail.addEventListener("responseafterplugin.enigmakeys",function(){rcmail.enable_command("plugin.enigma-key-export",0<rcmail.env.rowcount)}),rcmail.gui_objects.importform&&($("#rcmimportsearch").keydown(function(a){if(13==a.which)return rcmail.enigma_import_search(),!1}),$('input[type="button"]:first').focus()))): | |
5 "mail"==rcmail.env.task&&("compose"==rcmail.env.action&&(rcmail.addEventListener("beforesend",function(a){rcmail.enigma_beforesend_handler(a)}).addEventListener("beforesavedraft",function(a){rcmail.enigma_beforesavedraft_handler(a)}),$("input,label",$("#enigmamenu")).mouseup(function(a){a.stopPropagation()}),$("a.button.enigma").prop("tabindex",$("#messagetoolbar > a:first").prop("tabindex"))),$.each(["encrypt","sign"],function(){rcmail.env["enigma_force_"+this]&&$('[name="_enigma_'+this+'"]').prop("checked", | |
6 !0)}),rcmail.env.enigma_password_request&&rcmail.enigma_password_request(rcmail.env.enigma_password_request))});rcube_webmail.prototype.enigma_key_import=function(){this.enigma_loadframe("&_action=plugin.enigmakeys&_a=import")};rcube_webmail.prototype.enigma_key_create=function(){this.enigma_loadframe("&_action=plugin.enigmakeys&_a=create")}; | |
7 rcube_webmail.prototype.enigma_key_create_save=function(){var a=[],b=$("#key-pass").val();var c=$("#key-pass-confirm").val();var d=$("#key-size").val();$('[name="identity[]"]:checked').each(function(){a.push(this.value)});if(!b||!c)return alert(this.get_label("enigma.formerror"));if(b!=c)return alert(this.get_label("enigma.passwordsdiffer"));if(!a.length)return alert(this.get_label("enigma.noidentselected"));if(window.openpgp&&window.crypto&&(window.crypto.getRandomValues||window.crypto.subtle)){var e= | |
8 this.set_busy(!0,"enigma.keygenerating");c={numBits:d,userId:a,passphrase:b};openpgp.generateKeyPair(c).then(function(a){rcmail.http_post("plugin.enigmakeys",{_a:"import",_keys:a.privateKeyArmored,_generated:1,_passwd:b,_keyid:a.key.primaryKey.fingerprint},e)},function(a){rcmail.set_busy(!1,null,e);rcmail.display_message(rcmail.get_label("enigma.keygenerateerror"),"error")})}else rcmail.display_message(rcmail.get_label("enigma.keygennosupport"),"error")}; | |
9 rcube_webmail.prototype.enigma_key_create_success=function(){parent.rcmail.enigma_list(1)};rcube_webmail.prototype.enigma_delete=function(){var a=this.keys_list.get_selection();if(a.length&&confirm(this.get_label("enigma.keyremoveconfirm"))){var b=this.display_message(this.get_label("enigma.keyremoving"),"loading");this.http_post("plugin.enigmakeys",{_a:"delete",_keys:a},b)}}; | |
10 rcube_webmail.prototype.enigma_export=function(a){var b=!1,c=this.keys_list;a=a?c.get_selection().join(","):"*";var d={_keys:a};if(a.length){"*"==a?b=!0:$.each(c.get_selection(),function(){if((flags=$(c.rows[this].obj).data("flags"))&&0<=flags.indexOf("p"))return b=!0,!1});if(b)return this.show_popup_dialog(this.get_label("enigma.keyexportprompt"),this.get_label("enigma.exportkeys"),[{text:this.get_label("enigma.onlypubkeys"),click:function(a){rcmail.enigma_export_submit(d);$(this).remove()}},{text:this.get_label("enigma.withprivkeys"), | |
11 click:function(a){d._priv=1;rcmail.enigma_export_submit(d);$(this).remove()}}],{width:400});this.enigma_export_submit(d)}}; | |
12 rcube_webmail.prototype.enigma_export_submit=function(a){var b="keyexport-"+(new Date).getTime(),c=$("<form>").attr({target:b,method:"post",style:"display:none",action:"?_action=plugin.enigmakeys&_task=settings&_a=export"});b=$("<iframe>").attr({name:b,style:"display:none"});c.append($("<input>").attr({name:"_token",value:this.env.request_token}));$.each(a,function(a,b){c.append($("<input>").attr({name:a,value:b}))});b.appendTo(document.body);c.appendTo(document.body).submit()}; | |
13 rcube_webmail.prototype.enigma_import=function(){var a,b,c="keyexport-"+(new Date).getTime(),d=$("<iframe>").attr({name:c,style:"display:none"});if(a=this.gui_objects.importform)(b=document.getElementById("rcmimportfile"))&&!b.value?alert(this.get_label("selectimportfile")):(b=this.set_busy(!0,"importwait"),d.appendTo(document.body),$(a).attr({target:c,action:this.add_url(a.action,"_unlock",b)}).submit())}; | |
14 rcube_webmail.prototype.enigma_import_search=function(){var a;this.gui_objects.importform&&(a=$("#rcmimportsearch").val())&&this.enigma_find_publickey(a)};rcube_webmail.prototype.enigma_keylist_select=function(a){var b=a.get_single_selection(),c;b&&(c="&_action=plugin.enigmakeys&_a=info&_id="+b);this.enigma_loadframe(c);this.enable_command("plugin.enigma-key-delete","plugin.enigma-key-export-selected",0<a.selection.length)}; | |
15 rcube_webmail.prototype.enigma_keylist_keypress=function(a){a.modkey!=CONTROL_KEY&&(a.key_pressed==a.DELETE_KEY||a.key_pressed==a.BACKSPACE_KEY?this.command("plugin.enigma-key-delete"):33==a.key_pressed?this.command("previouspage"):34==a.key_pressed&&this.command("nextpage"))}; | |
16 rcube_webmail.prototype.enigma_loadframe=function(a){var b;if(b=this.get_frame_window(this.env.contentframe))a?(this.env.frame_lock=this.set_busy(!0,"loading"),b.location.href=this.env.comm_path+"&_framed=1"+a):(b.location&&0>b.location.href.indexOf(this.env.blankpage)&&(b.location.href=this.env.blankpage),this.env.frame_lock&&this.set_busy(!1,null,this.env.frame_lock))}; | |
17 rcube_webmail.prototype.enigma_search=function(a){!a&&this.gui_objects.qsearchbox&&(a=this.gui_objects.qsearchbox.value);if(a||this.env.search_request){a={_a:"search",_q:a};var b=this.set_busy(!0,"searching");this.env.current_page=1;this.enigma_loadframe();this.enigma_clear_list();this.http_post("plugin.enigmakeys",a,b)}return!1}; | |
18 rcube_webmail.prototype.enigma_search_reset=function(a){a=this.env.search_request;this.reset_qsearch();a&&(this.enigma_loadframe(),this.enigma_clear_list(),this.enigma_list());return!1}; | |
19 rcube_webmail.prototype.enigma_list=function(a,b){if(this.is_framed())return parent.rcmail.enigma_list(a,b);var c={_a:"list"},d=this.set_busy(!0,"loading");this.env.current_page=a?a:1;this.env.search_request&&(c._q=this.env.search_request);a&&(c._p=a);this.enigma_clear_list(b);this.http_post("plugin.enigmakeys",c,d)}; | |
20 rcube_webmail.prototype.enigma_list_page=function(a){"next"==a?a=this.env.current_page+1:"last"==a?a=this.env.pagecount:"prev"==a&&1<this.env.current_page?a=this.env.current_page-1:"first"==a&&1<this.env.current_page&&(a=1);this.enigma_list(a)};rcube_webmail.prototype.enigma_clear_list=function(a){!1!==a&&this.enigma_loadframe();this.keys_list&&this.keys_list.clear(!0);this.enable_command("plugin.enigma-key-delete","plugin.enigma-key-delete-selected",!1)}; | |
21 rcube_webmail.prototype.enigma_add_list_row=function(a){if(!this.gui_objects.keyslist||!this.keys_list)return!1;var b=this.keys_list,c="message"+(this.gui_objects.keyslist.tBodies[0].rows.length%2?" even":" odd"),d=document.createElement("tr"),e=document.createElement("td");d.id="rcmrow"+a.id;d.className=c;a.flags&&$(d).data("flags",a.flags);e.innerHTML=a.name;d.appendChild(e);b.insert_row(d)};rcube_webmail.prototype.enigma_beforesend_handler=function(a){this.env.last_action="send";this.enigma_compose_handler(a)}; | |
22 rcube_webmail.prototype.enigma_beforesavedraft_handler=function(a){this.env.last_action="savedraft";this.enigma_compose_handler(a)};rcube_webmail.prototype.enigma_compose_handler=function(a){var b=this.gui_objects.messageform;$("#enigmamenu input").each(function(){var a=this.id+"_cpy",d=$("#"+a);d.length||(d=$(this).clone(),d.prop({id:a,type:"hidden"}).appendTo(b));d.val(this.checked?"1":"")});"savedraft"==this.env.last_action&&$('input[name="_enigma_sign"]',b).val(0)}; | |
23 rcube_webmail.prototype.enigma_import_attachment=function(a){var b=this.set_busy(!0,"loading");this.http_post("plugin.enigmaimport",{_uid:this.env.uid,_mbox:this.env.mailbox,_part:a},b);return!1}; | |
24 rcube_webmail.prototype.enigma_password_request=function(a){if(a&&a.keyid){var b=this,c=this.get_label("enigma.enterkeypass"),d=$('<div class="prompt">'),e=$('<div class="message">').appendTo(d),f=$("<input>").attr({type:"password",size:30}).keypress(function(a){13==a.which&&(b.is_framed()?window.parent.$:$)(".ui-dialog-buttonpane button.mainaction:visible").click()}).appendTo(d);a.key=a.keyid;8<a.keyid.length&&(a.keyid=a.keyid.substr(a.keyid.length-8));$.each(["keyid","user"],function(){c=c.replace("$"+ | |
25 this,a[this])});e.text(c);this.show_popup_dialog(d,this.get_label("enigma.enterkeypasstitle"),[{text:this.get_label("save"),"class":"mainaction",click:function(c){c.stopPropagation();c=b.is_framed()?window.parent.$:$;a.password=f.val();a.password?(b.enigma_password_submit(a),c(this).remove()):f.focus()}},{text:this.get_label("cancel"),click:function(a){var c=b.is_framed()?window.parent.$:$;a.stopPropagation();c(this).remove()}}],{width:400});this.is_framed()&&parent.rcmail.message_list&&parent.rcmail.message_list.blur()}}; | |
26 rcube_webmail.prototype.enigma_password_submit=function(a){var b;if("compose"==this.env.action&&!a["compose-init"])return this.enigma_password_compose_submit(a);if("plugin.enigmakeys"==this.env.action&&(b=this.gui_objects.importform))return $('input[name="_keyid"]',b).length||$(b).append($("<input>").attr({type:"hidden",name:"_keyid",value:a.key})).append($("<input>").attr({type:"hidden",name:"_passwd",value:a.password})),this.enigma_import();var c=a.nolock?null:this.set_busy(!0,"loading");b=$("<form>").attr({method:"post", | |
27 action:a.action||location.href,style:"display:none"}).append($("<input>").attr({type:"hidden",name:"_keyid",value:a.key})).append($("<input>").attr({type:"hidden",name:"_passwd",value:a.password})).append($("<input>").attr({type:"hidden",name:"_token",value:this.env.request_token})).append($("<input>").attr({type:"hidden",name:"_unlock",value:c}));$.each(a,function(a,c){0==a.indexOf("input")&&b.append($("<input>").attr({type:"hidden",name:a.substring(5),value:c}))});a.iframe&&(a="enigma_frame_"+(new Date).getTime(), | |
28 $("<iframe>").attr({style:"display:none",name:a}).appendTo(document.body),b.attr("target",a));b.appendTo(document.body).submit()}; | |
29 rcube_webmail.prototype.enigma_password_compose_submit=function(a){var b=this.gui_objects.messageform;$('input[name="_keyid"]',b).length?($('input[name="_keyid"]',b).val(a.key),$('input[name="_passwd"]',b).val(a.password)):$(b).append($("<input>").attr({type:"hidden",name:"_keyid",value:a.key})).append($("<input>").attr({type:"hidden",name:"_passwd",value:a.password}));this.submit_messageform("savedraft"==this.env.last_action)}; | |
30 rcube_webmail.prototype.enigma_key_not_found=function(a){return this.show_popup_dialog(a.text,a.title,[{text:a.button,click:function(b){$(this).remove();rcmail.enigma_find_publickey(a.email)}}],{width:400,dialogClass:"error"})}; | |
31 rcube_webmail.prototype.enigma_find_publickey=function(a){this.mailvelope_search_pubkeys([a],function(a){},function(a){var b=rcmail.set_busy(!0,"enigma.importwait");a={_a:"import",_keys:a};"plugin.enigmakeys"==rcmail.env.action&&(a._refresh=1);rcmail.http_post("plugin.enigmakeys",a,b)})}; |