ablanco/yith-library-web-client

View on GitHub
yithwebclient/static/js/prod/yith-1.0.0.min.js

Summary

Maintainability
A
0 mins
Test Coverage
/* yith-library-web-client 2014-02-15 - AGPLv3 License */

!function(){"use strict";window.Yith=Ember.Application.create({}),Yith.deferReadiness(),Yith.Router.map(function(){this.resource("passwords",{path:"/"},function(){this.route("new"),this.resource("password",{path:":password_id"})})}),Yith.PasswordsIndexRoute=Ember.Route.extend({model:function(){return this.store.find("password")},enter:function(){$("#top-bar").removeClass("hide")}}),Yith.PasswordsNewRoute=Ember.Route.extend({model:function(){return this.store.createRecord("password")},enter:function(){$("#top-bar").addClass("hide"),$("#advanced-options").addClass("hide")}}),Yith.PasswordRoute=Ember.Route.extend({model:function(a){return this.store.find("password",a.password_id)},enter:function(){$("#top-bar").addClass("hide"),$("#advanced-options").addClass("hide");var a=this.get("controller");a&&a.set("modifySecret",!1)}}),$(document).ready(function(){var a,b;b=function(a){$("#loading .progress .bar").css("width",a+"%")},$.ajax("/token",{success:function(a){window.yithAccessCode=a.access_code,b(100),Yith.advanceReadiness(),$("#loading").remove()},error:function(){$("#error").find(".access").removeClass("hide"),$("#error").modal({keyboard:!1,backdrop:"static"}),setTimeout(function(){window.open("/","_self")},4e3)}}),a=$("#credits"),a.modal({show:!1}),$("#creditsButton").click(function(){a.modal("show")}),b(60)})}(),function(){"use strict";Yith.SettingsObject=Ember.Object.extend({disableCountdown:!1,rememberMaster:!1,masterPassword:void 0,passGenUseSymbols:!0,passGenUseNumbers:!0,passGenUseChars:!0,passGenLength:20,passGenCharset:Ember.computed(function(){var a,b="";for(a=33;127>a;a+=1)a>=33&&48>a&&this.passGenUseSymbols?b+=String.fromCharCode(a):a>=48&&58>a&&this.passGenUseNumbers?b+=String.fromCharCode(a):a>=58&&65>a&&this.passGenUseSymbols?b+=String.fromCharCode(a):a>=65&&91>a&&this.passGenUseChars?b+=String.fromCharCode(a):a>=91&&97>a&&this.passGenUseSymbols?b+=String.fromCharCode(a):a>=97&&123>a&&this.passGenUseChars?b+=String.fromCharCode(a):a>=123&&127>a&&this.passGenUseSymbols&&(b+=String.fromCharCode(a));return b}).property("passGenUseChars","passGenUseNumbers","passGenUseSymbols")}),Yith.settings=Yith.SettingsObject.create()}(),function(){"use strict";Yith.Password=DS.Model.extend({account:DS.attr(),creation:DS.attr(),expiration:DS.attr(),lastModification:DS.attr(),notes:DS.attr(),owner:DS.attr(),secret:DS.attr(),service:DS.attr(),tags:DS.attr()}),Yith.PasswordAdapter=DS.RESTAdapter.extend({host:yithServerHost,ajax:function(a,b,c){return a+="?client_id="+yithClientId,void 0===c&&(c={}),c.headers={Authorization:"Bearer "+yithAccessCode},this._super(a,b,c)},didError:function(){$("#error").modal({keyboard:!1,backdrop:"static"}),$("#error").find(".failure").removeClass("hide"),setTimeout(function(){window.open("/list","_self")},4e3),this._super.apply(this,arguments)}})}(),function(){"use strict";Yith.ControllersUtils={oneDayInMilliseconds:864e5,daysLeft:function(a,b){var c=(new Date).getTime(),d=c-a,e=Math.round(d/Yith.ControllersUtils.oneDayInMilliseconds);return b-e}},Yith.PasswordInListController=Ember.ObjectController.extend({daysLeft:Ember.computed(function(){return Yith.ControllersUtils.daysLeft(this.get("creation"),this.get("expiration"))}).property("creation","expiration"),expirationClass:Ember.computed(function(){var a="badge ",b=this.get("daysLeft");return a+=b>30?"badge-success":b>7?"badge-warning":"badge-important"}).property("daysLeft")}),Yith.PasswordsIndexController=Ember.ArrayController.extend({activeFilters:[],processedPasswordList:Ember.computed(function(){var a,b=this.activeFilters,c=this;return a=this.toArray().sort(function(a,b){var c=a.get("service"),d=b.get("service"),e=0;return c?d?(c=c.toLowerCase(),d=d.toLowerCase(),c>d?e=1:d>c&&(e=-1),e):1:-1}),b.length>0&&(a=a.filter(function(a){var c=a.get("tags");return c=c||[],b.every(function(a){return c.some(function(b){return a.trim()===b.trim()})})})),a.map(function(a){var b=Yith.PasswordInListController.create();return b.set("model",a),b.set("container",c.container),b.set("list_controller",c),b})}).property("@each","activeFilters.@each"),allTags:Ember.computed(function(){var a=new Ember.Set;return this.forEach(function(b){var c=b.get("tags");void 0!==c&&null!==c&&a.addEach(c)}),a=a.toArray().sort(function(a,b){return a.localeCompare(b)})}).property("@each.tags"),activateFilter:function(a){var b=new Ember.Set(this.activeFilters);b.push(a),this.set("activeFilters",b.toArray())},deactivateFilter:function(a){var b=new Ember.Set(this.activeFilters);b.remove(a),this.set("activeFilters",b.toArray())}}),Yith.PasswordsNewController=Ember.ObjectController.extend({modifySecret:!0,expirationActive:!1,provisionalTags:[],savingEvent:"didCreate",needs:["PasswordsIndex"],init:function(){var a,b;this._super(),a=function(a){a.get("expiration")>0?a.set("expirationActive",!0):a.set("expirationActive",!1)},this.addObserver("expiration",this,a),b=function(a){var b=new Ember.Set(a.get("tags"));a.set("provisionalTags",b.toArray())},this.addObserver("tags",this,b)},expirationDisabled:Ember.computed(function(){return!this.get("expirationActive")}).property("expirationActive"),expirationToggle:function(){this.set("expirationActive",!this.get("expirationActive"))},addProvisionalTags:function(a){var b=new Ember.Set(this.get("provisionalTags"));a=a.map(function(a){return a.trim()}),b.addEach(a.filter(function(a){return a.length>0})),this.set("provisionalTags",b.toArray())},removeTag:function(a){var b=new Ember.Set(this.get("provisionalTags"));b.remove(a),this.set("provisionalTags",b.toArray())},validateSecretChecker:function(a){var b=a.find("#edit-secret1"),c=b.val()===a.find("#edit-secret2").val(),d=!1;return""!==b.val()?(b.parents("#secret-group").removeClass("error").find(".help-block.req").hide(),d=!0):b.parents("#secret-group").addClass("error").find(".help-block.req").show(),c?(b.parents("#secret-group").find(".help-block.match").hide(),d&&b.parents("#secret-group").removeClass("error")):b.parents("#secret-group").addClass("error").find(".help-block.match").show(),c&&d},validateRequired:function(a){return""!==a.val()?(a.parents(".control-group").removeClass("error"),a.next().hide(),!0):(a.parents(".control-group").addClass("error"),a.next().show(),!1)},checkEmptiness:function(){this.validateRequired($("#edit-service"))},validate:function(a){var b=this.validateRequired(a.find("#edit-service"));return this.get("modifySecret")&&(b=this.validateSecretChecker(a)&&b),b},getFormData:function(a,b){var c=a.find("#edit-enable-expiration:checked").length>0,d=new Date,e={creation:b};return e.service=a.find("#edit-service").val(),e.account=a.find("#edit-account").val().trim(),e.lastModification=d.getTime(),c?(e.expiration=d.getTime()+parseInt(a.find("#edit-expiration").val(),10)*Yith.ControllersUtils.oneDayInMilliseconds,e.expiration=Math.round((e.expiration-b)/Yith.ControllersUtils.oneDayInMilliseconds)):e.expiration=0,e.notes=a.find("#edit-notes").val(),""===e.notes&&delete e.notes,e.tags=this.get("provisionalTags"),this.get("modifySecret")&&(e.secret=a.find("#edit-secret1").val()),e},saveData:function(a){var b=this.get("model");b.one(this.get("savingEvent"),this,function(){this.transitionToRoute("/")}),b.setProperties(a),b.save()},save:function(a){if(this.validate(a)){var b,c=this.getFormData(a,(new Date).getTime()),d=this;b=function(a){delete c.secret,a&&(c.secret=a),d.saveData(c),c=null},void 0!==c.secret?Yith.ViewsUtils.askMasterPassword(function(a){var d;try{d=Yith.ViewsUtils.cipher(a,c.secret)}catch(e){return!1}return c.secret=null,b(d),!0}):b()}},cancelNewPassword:function(){this.get("model").deleteRecord(),this.transitionToRoute("/")}}),Yith.PasswordController=Yith.PasswordsNewController.extend({modifySecret:!1,savingEvent:"didUpdate",daysLeft:Ember.computed(function(){var a="";return this.get("expirationActive")&&(a=Yith.ControllersUtils.daysLeft(this.get("creation"),this.get("expiration"))),a}).property("creation","expiration"),deletePassword:function(){var a=this,b=$("#confirm-modal");return b.modal({show:!1}),b.find("#confirm-delete").off("click").on("click",function(c){c.preventDefault(),c.stopPropagation();var d=a.get("model");d.one("didDelete",a,function(){this.transitionToRoute("/")}),d.deleteRecord(),d.save(),b.modal("hide")}),b.modal("show"),!1}})}(),function(){"use strict";Yith.ViewsUtils={askMasterPassword:function(a,b){var c,d,e,f=void 0===Yith.ViewsUtils.masterModal;if(f&&(Yith.ViewsUtils.masterModal=$("#master"),Yith.ViewsUtils.masterModal.modal({show:!1})),d=Yith.ViewsUtils.masterModal.find("#master-password"),e=Yith.ViewsUtils.masterModal.find("#new-master-password"),f&&(c=function(a){var b=a.keyCode||a.which;13===b&&Yith.ViewsUtils.masterModal.find("#master-done").trigger("click")},d.keypress(function(a){Yith.ViewsUtils.masterModal.find("#master-error").hide(),c(a)}),e.keypress(function(a){c(a)}),Yith.ViewsUtils.masterModal.on("shown",function(){Yith.ViewsUtils.masterModal.find("#master-error").hide().end().find("#master-password").focus()}),Yith.ViewsUtils.masterModal.on("hidden",function(){d.val(""),e.val("")})),Yith.ViewsUtils.masterModal.find("#master-done").off("click").on("click",function(b){b.preventDefault(),b.stopPropagation();var c=a(d.val(),e.val());c?(Yith.settings.get("rememberMaster")&&""!==d.val()&&(Yith.settings.set("masterPassword",d.val()),setTimeout(function(){Yith.settings.set("masterPassword",void 0)},3e5)),Yith.ViewsUtils.masterModal.modal("hide"),d.val(""),e.val("")):Yith.ViewsUtils.masterModal.find("#master-error").show().end().find("#master-password").focus().select()}),b)Yith.ViewsUtils.masterModal.find(".change-master").show();else if(Yith.ViewsUtils.masterModal.find(".change-master").hide(),Yith.settings.get("rememberMaster")&&void 0!==Yith.settings.get("masterPassword"))return void a(Yith.settings.get("masterPassword"));Yith.ViewsUtils.masterModal.modal("show")},cipher:function(a,b,c){var d,e=Yith.ViewsUtils.passwordIndexController().get("model");if(!e.isLoaded)throw Yith.ViewsUtils.masterModal.modal("hide"),$("#error").modal({keyboard:!1,backdrop:"static"}),$("#error").find(".failure").removeClass("hide"),setTimeout(function(){window.open("/list","_self")},4e3),"The model isn't loaded";return e.objectAt(0)&&e.objectAt(0).get("id")&&!c&&sjcl.decrypt(a,e.objectAt(0).get("secret")),d=sjcl.encrypt(a,b),a=null,d},decipher:function(a,b){var c=null;return null!==b&&void 0!==b&&(c=sjcl.decrypt(a,b)),a=null,c},passwordIndexController:function(){return Yith.__container__.lookup("controller:passwords.index")}},Yith.DisableCountdownButton=Ember.View.extend({tagName:"button",classNames:["btn"],click:function(a){var b=$(a.target);b.toggleClass("active"),Yith.settings.set("disableCountdown",b.hasClass("active"))}}),Yith.RememberMasterButton=Ember.View.extend({tagName:"button",classNames:["btn"],click:function(a){var b=$(a.target);b.toggleClass("active"),Yith.settings.set("rememberMaster",b.hasClass("active")),Yith.settings.get("rememberMaster")||Yith.settings.set("masterPassword",void 0)}}),Yith.ShowAdvancedButton=Ember.View.extend({tagName:"button",classNames:["btn"],click:function(a){var b=$("#advanced-options");$(a.target).toggleClass("active"),b.hasClass("hide")?b.removeClass("hide").addClass("row"):b.removeClass("row").addClass("hide")}}),Yith.ServerPreferencesButton=Ember.View.extend({tagName:"button",classNames:["btn","pull-right"],click:function(){window.open(yithServerHost+"/preferences","_blank")}}),Yith.ChangeMasterButton=Ember.View.extend({tagName:"button",classNames:["btn"],click:function(a){a.preventDefault(),a.stopPropagation();var b=Yith.ViewsUtils.passwordIndexController();b.objectAt(0)&&Yith.ViewsUtils.askMasterPassword(function(a,c){try{Yith.ViewsUtils.decipher(a,b.objectAt(0).get("secret"))}catch(d){return!1}return b.forEach(function(b){var d=Yith.ViewsUtils.decipher(a,b.get("secret"));d=Yith.ViewsUtils.cipher(c,d,!0),b.set("secret",d),d=null,b.save()}),a=null,c=null,!0},!0)}}),Yith.PasswordLengthInput=Ember.View.extend({tagName:"input",attributeBindings:["type","min","step","value"],type:"number",min:0,step:1,value:20,classNames:["span2"],change:function(a){Yith.settings.set("passGenLength",parseInt($(a.target).val(),10))}}),Yith.ServiceButton=Ember.View.extend({tagName:"button",classNames:["btn btn-info"],click:function(a){var b=this;Yith.ViewsUtils.askMasterPassword(function(c){var d,e=$(a.target).parents("tr"),f=e.find("td:first-child input"),g=e.find("td:first-child span"),h=g.next(),i=b.get("controller").get("secret");try{i=Yith.ViewsUtils.decipher(c,i)}catch(j){return!1}return c=null,f.val(i).show().focus().select(),i=null,Yith.settings.get("disableCountdown")?(h.off("click"),h.click(function(){f.hide().attr("value",""),h.hide()}),h.show()):(g.text("5"),g.show(),d=setInterval(function(){g.text(parseInt(g.text(),10)-1)},1e3),setTimeout(function(){clearInterval(d),f.hide().attr("value",""),g.hide()},5500)),!0})}}),Yith.TagButton=Ember.View.extend({tagName:"span",classNames:["label","pointer"],click:function(){var a=this.get("controller");a.activateFilter||(a=a.get("list_controller")),a.activateFilter(this.$().text().trim())}}),Yith.FilterButton=Yith.TagButton.extend({click:function(){this.get("controller").deactivateFilter(this.$().text().trim())}}),Yith.NotesButton=Ember.View.extend({tagName:"button",classNames:["btn","notes"],didInsertElement:function(){var a=this.get("controller").get("notes");a?this.$().popover({placement:"left",title:"Notes",content:a}):this.$().addClass("disabled")}}),Yith.SecretGroup=Ember.View.extend({templateName:"secret-group",checkerList:[],validateSecret:function(){for(var a=this.$().parents("form"),b=this;this.get("checkerList").length>0;)clearTimeout(this.get("checkerList").pop());this.get("checkerList").push(setTimeout(function(){b.get("controller").validateSecretChecker(a)},500))},initStrengthMeter:function(a){var b=this.$().find("#edit-secret1"),c=this;b.length>0?b.pwstrength({ui:{viewports:{progress:this.$().find("#strength-meter .progressbar"),verdict:this.$().find("#strength-meter .verdict")},bootstrap2:!0}}):a&&setTimeout(function(){c.initStrengthMeter(!0)},100)},bindValidation:function(a){var b=this.$().find(".edit-secret"),c=this;b.length>0?b.on("keyup",function(){c.validateSecret()}):a&&setTimeout(function(){c.bindValidation(!0)},100)},didInsertElement:function(){var a=this;this.initStrengthMeter(!1),this.bindValidation(!1),this.$().find("#show-secret-group").on("click",function(b){b.preventDefault(),b.stopPropagation(),a.get("controller").set("modifySecret",!0),a.bindValidation(!0),a.initStrengthMeter(!0)})}}),Yith.GenerateSecretButton=Ember.View.extend({tagName:"button",classNames:["btn"],click:function(a){a.preventDefault(),a.stopPropagation();var b,c,d="",e=Yith.settings.get("passGenCharset"),f=Yith.settings.get("passGenLength");for(c=0;f>c;c+=1)b=Math.floor(Math.random()*e.length),d+=e.charAt(b);this.$().parent().find("#edit-secret2").val(d).end().find("#edit-secret1").val(d).trigger("keyup"),d=null}}),Yith.TagsInput=Ember.View.extend({templateName:"tags-input",addTag:function(){var a=this.$().find("input").val().split(",");this.get("controller").addProvisionalTags(a),this.$().find("input").val("")},didInsertElement:function(){var a=this;this.$().find("input").typeahead({items:3,source:function(){var a=Yith.ViewsUtils.passwordIndexController();return a.get("allTags")}}),this.$().find("button").on("click",function(b){b.preventDefault(),b.stopPropagation(),a.addTag()})}}),Yith.SaveButton=Ember.View.extend({tagName:"button",classNames:["btn","btn-primary"],click:function(a){a.preventDefault(),a.stopPropagation(),this.get("controller").save(this.$().parents("form"))}})}();
//# sourceMappingURL=yith-1.0.0.min.map