impress/public/assets/wardrobe-5044ef4334bfa25df92d149e9bda4978.js

1 line
21 KiB
JavaScript
Raw Normal View History

function arraysMatch(e,t){var n;if(!$.isArray(e)||!$.isArray(t))return e==t;n=[];if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)key=typeof e[r]+"~"+e[r],n[key]?n[key]++:n[key]=1;for(var r=0;r<t.length;r++){key=typeof t[r]+"~"+t[r];if(!n[key])return!1;if(n[key]==0)return!1;n[key]--}return!0}function DeepObject(){}function Wardrobe(){function r(){var e,t;this.restricted_zones=[];while((t=this.zones_restrict.indexOf(1,t)+1)!=0)this.restricted_zones.push(t)}function i(e){function n(e){return e[0]+"x"+e[1]}var t=this;this.image_urls_by_size_key={};var r;for(var i=0;i<e.images.length;i++)r=e.images[i],this.image_urls_by_size_key[n(r.size)]=r.url;this.imageURL=function(e){return this.image_urls_by_size_key[n(e)]},this.update=function(e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},this.update(e)}function t(e){i.apply(this,[e]),r.apply(this)}function n(e){i.apply(this,[e])}function s(e){function n(){return t.name.toLowerCase().replace(/ /g,"-").replace(/[^a-z0-9\-]/i,"")}function i(){var e=t.id.toString();return t.hasOwnProperty("name")&&(e+="-"+n()),e}var t=this;this.id=e,this.assets_by_body_id={},this.load_started=!1,this.loaded=!1,this.getAssetsFitting=function(e){return this.assets_by_body_id[e.body_id]||[]},this.hasAssetsFitting=function(e){return typeof t.assets_by_body_id[e.body_id]!="undefined"&&t.assets_by_body_id[e.body_id].length>0},this.couldNotLoadAssetsFitting=function(e){return typeof t.assets_by_body_id[e.body_id]!="undefined"&&t.assets_by_body_id[e.body_id].length==0},this.update=function(e){for(var n in e)e.hasOwnProperty(n)&&n!="id"&&(t[n]=e[n]);r.apply(this),this.loaded=!0},this.getURL=function(){return"/items/"+i()},s.cache[e]=this}function u(e){this.name=e}function a(e){function u(e){t.color_id=e.color_id,t.id=e.id,t.name=e.name,t.pet_state_id=e.pet_state_id,t.starred=e.starred,t.species_id=e.species_id,t.image_versions=e.image_versions,t.image_enqueued=e.image_enqueued,t.image_layers_hash=e.image_layers_hash,t.setWornAndUnwornItemIds(e.worn_and_unworn_item_ids),o=!1}function f(){var e={};return e.name=t.name,e.starred=t.starred,e.worn_and_unworn_item_ids=t.getWornAndUnwornItemIds(),t.pet_state&&(e.pet_state_id=t.pet_state.id),e.anonymous=t.anonymous,e}function h(){var e=[],n=t.worn_items;return t.pet_state&&(n=n.concat(t.pet_state.assets)),$.each(n,function(){e=e.concat(this.restricted_zones)}),e}function p(e){return $.inArray(e,t.closet_items)!=-1}function d(e){return $.inArray(e,t.worn_items)!=-1}function v(e,n,i){var s,o,u,a,f,l=[],c=[];if(e){s=e.getAssetsFitting(t.pet_type).mapProperty("zone_id"),o=s.length;for(var h=0;h<t.worn_items.length;h++){u=t.worn_items[h],a=u.getAssetsFitting(t.pet_type).mapProperty("zone_id"),f=!0;if(u!=e)for(var p=0;p<o;p++)if($.inArray(s[p],a)!=-1){f=!1;break}f&&(l.push(u),c.push(u.id))}t.worn_items=l,r=c,n(t.worn_items)}i()}function m(e,n,r,i,s){(!t.pet_state||!e.ownsPetState(t.pet_state))&&t.setPetStateById(null,r),n(e),g(null,i,s)}function g(e,n,i){t.pet_type&&t.pet_type.loaded&&r.length&&t.pet_type.loadItemAssets(r,function(){v(e,n,i)})}function y(e){t.id=e.id,t.image_versions=e.image_versions,t.image_enqueued=e.image_enqueued,t.image_layers_hash=e.image_layers_hash}function b(e,n,r){$.ajax({url:"/outfits/"+t.id,type:"post",data:{_method:"put",outfit:e},dataType:"json",success:function(e){y(e),a.cache[t.id]=t,n(t)},error:function(e){typeof r!="undefined"&&r(t,$.parseJSON(e.responseText))}})}var t=this,n,r=[],i=[],o=!0;this.setWornAndUnwornItemIds=function(e){this.worn_and_unworn_item_ids=e,r=e.worn,i=e.unworn.concat(e.worn)},typeof e!="undefined"&&u(e),this.closet_items=[],this.worn_items=[],this.anonymous=!1,this.getWornItemIds=function(){return r},this.getClosetItemIds=function(){return i},this.closetItem=function(e,t){p(e)||(this.closet_items.push(e),i.push(e.id),t(this.closet_items))},this.getPetStateId=function(){return typeof t.pet_state_id=="undefined"&&(t.pet_state_id=t.pet_state.id),t.pet_state_id},this.getVisibleAssets=function(){var e,n=h(),r=[];e=this.pet_state?this.pet_state.assets:[];for(var i=0;i<t.worn_items.length;i++)e=e.concat(t.worn_it