ots/frontend/application.js

1 line
2.1 KiB
JavaScript
Raw Permalink Normal View History

'use strict';(function(){var a,b,c,d,e,f,g,h,i,j,k;i=null,b=function(){var a;return a=$('#formCreateSecret').find('textarea').val(),i=Math.random().toString(36).substring(2),a=GibberishAES.enc(a,i),$.ajax('api/create',{method:'post',data:{secret:a},dataType:'json',statusCode:{201:h,400:k,500:k,404:function a(){return h({secret_id:'foobar'})}}}),!1},c=function(){return $('#notfound').show()},d=function(){var a;if(a=window.location.hash,0!==a.length)return $('#cardNewSecret').hide(),$('#cardSecretURL').hide(),$('#notfound').hide(),$('#somethingwrong').hide(),$('#cardReadSecretPre').show()},g=function(){var a,b,d;return a=window.location.hash,a=decodeURIComponent(a),d=a.split('|'),2===d.length&&(a=d[0],i=d[1]),b=a.substring(1),$.ajax('api/get/'+b,{dataType:'json',statusCode:{404:c,200:j}})},e=function(){return $('#formCreateSecret').bind('submit',b),$('#newSecret, .navbar-brand').bind('click',f),$(window).bind('hashchange',d),$('#revealSecret').bind('click',g),a()},f=function(){return location.href=location.href.split('#')[0],!1},a=function(){return $('textarea').each(function(){var a,b,c,d=this;return c=this,b=function(){return c.style.height=d.scrollHeight+'px'},a=function(){return window.setTimeout(b,0)},c.setAttribute('style','height: '+this.scrollHeight+'px; min-height: '+this.scrollHeight+'px; overflow-y:hidden;'),$(c).on('change',b).on('cut',a).on('paste',a).on('drop',a).on('keydown',a)})},h=function(a){var b,c;return b=a.secret_id,null!==i&&(b=b+'|'+i),c=location.href.split('#')[0]+'#'+b,$('#cardNewSecret').hide(),$('#cardReadSecretPre').hide(),$('#cardSecretURL').show(),$('#cardSecretURL').find('input').val(c),$('#cardSecretURL').find('input').focus(),$('#cardSecretURL').find('input').select(),i=null},j=function(a){var b;return b=a.secret,null!==i&&(b=GibberishAES.dec(b,i)),$('#cardNewSecret').hide(),$('#cardSecretURL').hide(),$('#notfound').hide(),$('#somethingwrong').hide(),$('#cardReadSecretPre').hide(),$('#cardReadSecret').show(),$('#cardReadSecret').find('textarea').val(b),$('#cardReadSecret').find('textarea').trigger('change')},k=function(){return $('#somethingwrong').show()},$(function(){return e(),d()})}).call(void 0);