"use strict";
(function() {
// Defined here so that code-completion works, but values set in inventory_js.jsp
var CONSTANTS = {
layersv2: {
DOLL_LAYER_TOPS: -1,
DOLL_LAYER_DRESSES: -1,
DOLL_LAYER_JACKET: -1,
DOLL_LAYER_SKIRTS: -1,
DOLL_LAYER_PANTS: -1,
DOLL_LAYER_SWIMWEAR: -1,
DOLL_LAYER_JEWELRY: -1,
DOLL_LAYER_HATS: -1,
DOLL_LAYER_BAGS: -1,
DOLL_LAYER_GLASSES: -1,
DOLL_LAYER_OTHER: -1,
DOLL_LAYER_HAIR_BACK: -1,
DOLL_LAYER_MAKE_UP: -1,
DOLL_LAYER_BODY: -1,
DOLL_LAYER_EYES: -1,
DOLL_LAYER_FACE: -1,
DOLL_LAYER_HAIR_JD: -1
},
types: {
POOR: -1,
NORMAL: -1,
SPECIAL: -1,
UNIQUE: -1,
DIAMOND: -1
},
values: {
MAX_WORN_ITEMS: -1
},
currentAccount: 0,
isMember : false,
auctionsForAll: false,
userTradingV2: false,
validated:false,
modellevel:0,
outfitsaved:true,
queryTypes: {
MY_AUCTIONS: -1,
MY_BIDS: -1
}
};var createInventoryController = (function() {
var itemMergeProperties = {
isDiamondItem: function() {
return this.quality == CONSTANTS.types.DIAMOND;
},
getUiid: function() {
return this.colors[this.selectedPalette ? this.selectedPalette : this.palette][this.hasBackUiid() ? "backuiid" : "uiid"];
},
isHair:function(){
return this.layer == CONSTANTS.layersv2.DOLL_LAYER_HAIR_BACK || this.layer == CONSTANTS.layersv2.DOLL_LAYER_HAIR_JD;
},
hasBackUiid:function(){
return this.layer == CONSTANTS.layersv2.DOLL_LAYER_HAIR_BACK;
},
isSkinFunc:function(){
return this.layer == CONSTANTS.layersv2.DOLL_LAYER_BODY;
},
isFaceFunc:function(){
return this.layer == CONSTANTS.layersv2.DOLL_LAYER_FACE;
},
isEyesFunc:function(){
return this.layer == CONSTANTS.layersv2.DOLL_LAYER_EYES;
},
isTop:function(){
}
};
/**
*
* @param $inventoryRoot
* @param inventoryDao
*/
var InventoryController = function($inventoryRoot, inventoryDao, outfitGridUi, avatarUi, basketUi, basket, context, unixTime, accountMoney) {
this._$root = $inventoryRoot;
this._dao = inventoryDao;
this._outfitControllersByUiid = {};
this._basket = basket;
this._outfitGridUi = outfitGridUi;
this._avatarUi = avatarUi;
this._basketUi = basketUi;
this._context = context;
this._unixTime = unixTime;
this.visitingWardrobe = 0;
this._accountMoney = accountMoney;
this._loadItemsTimeoutId = null;
this._buyConfirmed = false;
this._giftBuyParams = null;
this._querytype = null;
};
InventoryController.prototype = {
initEvents: function() {
var _this = this,
$root = this._$root,
position = -1,
auctionedItemUi = null,
myAccount = $root.find(".modelName").text();
this._basketUi.init(this._basket, this._accountMoney, this);
this._avatarUi.init(this._basket);
// Set up yourModel box max size and listen for window.resize events
$(window)
.on("resize", function() {
_this.updateSize();
}).trigger("resize")
.on("scroll", (function() {
var
isMobile = isMobileDevice(),
$window = $(window),
$yourModel = $root.find(".yourModel"),
$navigationParent = $root.find(".navigationParent"),
filtersHeight = 64, // 44 is the height of the filters we collapse on the front page.
yourModelStartOffsetTop = $navigationParent.offset().top + filtersHeight + $navigationParent.outerHeight(true);
if (isMobile) {
return function() {
var
scrollTop = $window.scrollTop(),
offset = $yourModel.offset();
offset.top = Math.max(yourModelStartOffsetTop, scrollTop);
$yourModel.offset(offset);
};
} else {
return function() {
var
scrollTop = $window.scrollTop(),
offset = $yourModel.offset();
if (scrollTop > yourModelStartOffsetTop) {
$yourModel.css({
"position": "fixed",
"left": $navigationParent.offset().left,
"top": 0
});
} else {
$yourModel.css({
"position": "absolute",
"left":"auto",
"top": "auto"
});
}
};
}
})());
$root
.find(".itemGrid").on("click.InventoryController", ".itemWindow, .ribbon, .expires", function() {
var itemDisplay = $(this).parent(),
ctrl = itemDisplay.data("ui").getOutfit().controller;
if(ctrl.isSelected()) {
_this._basket.removeOutfit(itemDisplay.data("ui").getOutfit());
CONSTANTS.outfitsaved = false;
} else {
_this._basket.add(itemDisplay.data("ui").getOutfit());
CONSTANTS.outfitsaved = false;
}
ctrl.setSelected(!ctrl.isSelected());
position = _this._basket.getSelectedItem();
var avatarSlider = $("#avatarSlider");
_this.updateSlider(position,avatarSlider);
_this.updateYourModelSize();
}).end()
.find(".itemGrid").on("click.InventoryController", ".itemDisplay .colorPicker li", function() {
var
$this = $(this),
paletteIndex = $this.data("paletteindex"),
$itemDisplay = $this.closest(".itemDisplay"),
outfitUi = $itemDisplay.data("ui"),
outfitController = outfitUi.getOutfit().controller;
$this.addClass("selected").siblings("li").removeClass("selected");
outfitController.setPalette(paletteIndex);
outfitUi.refresh();
}).end()
.find(".filterNavigator").on("click.InventoryController", ".filterNavigator > .checkbox, .dropdown li:not(.selected)", function() {
// On filter change, load items
if(this.parentNode.id == "brandFilter" && _this._context.context == "0"){
console.log("item changing",this,this.parentNode,_this._context);
if(this.dataset.value == "4"){
$root.find("#contextNavigator .communityContextButton").addClass("selected").siblings().removeClass("selected");
} else {
$root.find("#contextNavigator .shopContextButton").addClass("selected").siblings().removeClass("selected");
}
}
setTimeout(function() {
_this.loadItems();
}, 10);
}).end()
.find(".filterNavigator").on("keypress.InventoryController", "#priceMinFilter, #priceMaxFilter", function() {
// On filter change, load items
setTimeout(function() {
_this.loadItems();
}, 10);
}).end()
.on("click.InventoryController", ".basketItem", function(){
var selected = _this.selectBasketItem($(this)),
avatarSlider = $("#avatarSlider");
if(selected){
var selectedItem = $(this).data("ui").item;
position = $.inArray(selectedItem, _this._basket.getItems());
_this._basket.setSelectedItem(position);
} else {
position = -1;
}
_this.updateSlider(position,avatarSlider);
})
.on("click.InventoryController", ".removeAllButton", function(){
_this._basket.clearBasket();
_this.updateYourModelSize();
CONSTANTS.outfitsaved = false;
})
.on("click.InventoryController", ".unlockAllButton", function(){
var items = _this._basket.getItems();
var skinPalette;
for(var i = 0; i < items.length; i++) {
var item = items[i];
if(item.isSkin) {
skinPalette = item.faceIndex === 0 ? item.palette : item.faceIndex;
}
}
for(var j = 0; j < items.length; j++) {
var item = items[j];
var paletteIndex = item.palette;
var correctUiid = item.uiid;
if (item.colors && item.colors.length > paletteIndex && item.colors[paletteIndex].uiid && !item.isFace) {
correctUiid = item.colors[paletteIndex].uiid;
}
if(item.isFace && skinPalette) {
correctUiid = item.colors[skinPalette].uiid;
}
var basketItem = $('.basketItem').has('.basketDiv .basketImg img[src*="/item/' + correctUiid + '"]');
var basketLockBtn = basketItem.find(".basketLockBtn");
var basketDelBtn = basketItem.find(".basketDelBtn");
if (basketLockBtn.length && basketLockBtn.hasClass('locked')) {
basketLockBtn.removeClass("locked");
basketDelBtn.removeClass("disabled");
}
}
})
.on("click.InventoryController",".tagAllButton",function(){
showStdDialog(DIALOG.MANAGE_ITEM_TAGS,'&item=all&q=1&itemImg=0&id=0');
})
.on("tinyscroll.InventoryController", "#avatarSlider", function(){
if(position == -1) return; // Item is not selected (and slider should not be visible)
var thumb = $(this).find(".thumb"),
top = parseInt(thumb.css("top").replace('px','')),
thumbHeight = parseInt(thumb.css("height").replace('px','')),
sliderHeight = parseInt(thumb.closest(".track").css("height").replace('px','')),
sliderValue = 1 - ((top+(thumbHeight/2))/sliderHeight),
basketSize = _this._basket.getBasketCount(),
basketPosition = _this.getBasketPosition(sliderValue,basketSize);
if(basketPosition != position) {
_this._basket.setSelectedItem(basketPosition); // used for marking the right selected item when rendering again
_this._basket.reorderItems(position,basketPosition);
position = basketPosition; // Used for keeping the updated position of the selected item in the InvCtrl
}
})
.on("click.InventoryController", "#qualityFilter li", function(event) {
var
$this = $(this),
val = $this.data("value"),
diamonds = $this.is(".diamonds"),
$gomoney = $("#gomoneyFilter"),
$diamond = $("#diamondFilter");
$gomoney.toggleClass("selected", !diamonds || val === -1);
$diamond.toggleClass("selected", diamonds || val === -1);
$gomoney.add($diamond).toggleClass("disabled", val !== -1);
})
.on("click.InventoryController", "#avatarSliderBox .arrowButton", function(event) {
CONSTANTS.outfitsaved = false;
var
$button = $(this),
up = $button.hasClass("up"),
$slider = $("#avatarSlider"),
basket = _this._basket;
if (up) {
if(basket.getSelectedItem() < basket.getBasketCount()-1){
basket.setSelectedItem(basket.getSelectedItem()+1);
basket.reorderItems(position,position+1);
position = position +1;
_this.updateSlider(position,$slider);
}
} else {
if(basket.getSelectedItem() > 0){
basket.setSelectedItem(basket.getSelectedItem()-1);
basket.reorderItems(position,position-1);
position = position -1;
_this.updateSlider(position,$slider);
}
}
})
.on("click.InventoryController", ".basketDelBtn", function(){
var item = $(this).closest(".basketItem").data("ui").item,
avatarSlider = $("#avatarSlider");
_this._basket.removeItem(item);
CONSTANTS.outfitsaved = false;
if(item.outfit)item.outfit.controller.setSelected(false);
position = _this._basket.getSelectedItem();
_this.updateSlider(position,avatarSlider);
_this.updateYourModelSize();
return false;
})
.on("click.InventoryController", ".basketLockBtn", function(){
var delBtn = $(this).closest(".basketItem").find(".basketDelBtn");
var isLocked = this.classList.contains("locked");
if(!isLocked) {
this.classList.add("locked");
delBtn.addClass("disabled");
} else {
this.classList.remove("locked");
delBtn.removeClass("disabled");
}
return false;
})
.on("click.InventoryController", "#layerNavigator > *", function(event) {
if(_this._context.isFrontpage()) {
_this.ensureShopContext();
}
var
$e = $(this),
layerGroup = $e.data("layer-group");
$e.addClass("selected")
.siblings().removeClass("selected").end()
.closest("#layerNavigationBox").find(".layerGroup").removeClass("visible").filter(".layerGroup." + layerGroup).addClass("visible");
})
.on("click.InventoryController", "#layerNavigationBox .layerButton", function(event,overrideClearFilter) {
var $e = $(this).addClass("selected");
$("#subLayerNavigator .layerButton").not($e).removeClass("selected");
var communityTabSelected = document.querySelector(".communityContextButton.selected");
if(!overrideClearFilter)_this._clearFilter();
if(communityTabSelected){
$root.find("#brandFilter li[data-value='4']").addClass("selected");
}
_this.loadItems();
})
.on("click.InventoryController", "#contextNavigator > *", function(event, overrideClearFilter) {
$(this).addClass("selected").siblings().removeClass("selected");
var context = $(this).attr("data-context");
var prevContext = $root.attr("data-context");
var communityShop = this.classList.contains("communityContextButton");
if((prevContext == "0" || prevContext == "6") && context == "0"){
overrideClearFilter = true;
}
if(communityShop) {
_this._clearFilter();
overrideClearFilter = true;
$root.find("#brandFilter li[data-value='4']").addClass("selected");
} else {
$root.find("#brandFilter .selected").removeClass("selected");
}
//Set info link
var infoLinkPageId = 204;
if(context == 0 || context == 6){
infoLinkPageId = 204; // Shop && shop frontpage
}else if(context == 1 || context == 4){
infoLinkPageId = CONSTANTS.auctionsForAll?217:205; //own && other wardrobe
}else if(context == 2 || context == 5){
infoLinkPageId = 206; //own && other wishlist
}else if(context == 3){
infoLinkPageId = CONSTANTS.auctionsForAll?213:197; //auction
}
$root.find(".infoLink").find("a").attr("href","/support/page.jsp?id="+infoLinkPageId);
$root.attr("data-context", context);
if(context == 1 && _this._context.isOtherWardrobe()) context = 4; // If you are visiting a wardrobe, then choose context 4 (otherWardrobe) instead of context 1 (ownWardrobe)
else if(context == 2 && _this._context.isOtherWishlist()) context = 5; // If you are visiting a wishlist, then choose context 5 (otherWishlist) instead of context 2 (ownWishlist)
else {
$root.find(".deleteSearchModelButton").addClass("disabled");
$root.find(".modelName").text(myAccount);
_this.visitingWardrobe = 0; // If leaving wishlist
}
_this.setContext(context);
$("#layerNavigator > .default").trigger("click", overrideClearFilter);
_this.updateYourModelSize();
})
;
$root.on("click.InventoryController", ".searchModelButton", function() {
if(_this._context.isWardrobe() || _this._context.isOtherWardrobe) {
wardrobeSearch();
}
else if(_this._context.isWishlist() || _this._context.isOtherWishlist()) {
wishlistSearch();
}
})
.on("click.InventoryController", ".deleteSearchModelButton", function() {
_this.visitingWardrobe = 0;
var context = $root.find("#contextNavigator").children(".selected").attr("data-context");
_this.setContext(context);
$(this).addClass("disabled");
$root.find(".modelName").text(myAccount);
_this.loadItems();
});
$root.on("click.InventoryController", ".basketBuyButton", function() {
var items = _this._basket.getItems();
_this.buyItems(items);
});
$root.on("click.InventoryController", ".basketGiftButton", function() {
var items = _this._basket.getItems();
_this.buyGiftItems(items);
});
$root.on("click.InventoryController", ".button.basketWishButton", function(event) {
var items = _this._basket.getItems();
_this.wishItems(items);
});
$root.on("click.InventoryController", ".dressupDoll", function(event) {
var items = _this._basket.getItems();
_this.dressupDoll(items);
});
$root.on("click.InventoryController", ".clearOwned", function(event) {
_this._dao.clearOwnedFromWishlist();
_this.loadItems();
});
$root.on("click.InventoryController",".saveLook", function(event) {
_this.showSaveLookDialog();
return false;
});
$root.on("click.InventoryController",".suggestLook",function(event){
_this.showSuggestLookDialog();
return false;
});
$root.on("click.InventoryController", ".deleteBtn", function(event) {
var $button = $(this);
_this.removeFromWardrobe($button.closest(".itemDisplay").data("ui"));
return false;
});
$root.on("click.InventoryController", ".editInAdminTool", function(event) {
var $button = $(this);
var url = _this._context.getStagingServerUrl() + "admin/supermodel_res/itemnew/item.jsp?uiid="+$button.closest(".itemDisplay").data("ui").getOutfit().items[0].uiid;
window.open(url, "_edit_item").focus();
return false;
});
$root.on("click.InventoryController", ".auctionButton.enabled", function(event) {
var $button = $(this);
_this.showAuctionDialog($button.closest(".itemDisplay").data("ui"),0);
return false;
});
$root.on("click.InventoryController", ".tagsButton.enabled", function(event) {
var $button = $(this);
_this.showTagsDialog($button.closest(".itemDisplay").data("ui"));
return false;
});
if(CONSTANTS.userTradingV2){
$root.on("click.InventoryController", ".tradeButton.enabled", function(event) {
var $button = $(this);
_this.showTradeDialog($button.closest(".itemDisplay").data("ui"),0);
return false;
});
$root.on("click.InventoryController",".cancelButton", function(event){
var $button = $(this),
ui = $button.closest(".itemDisplay").data("ui");
var uiid = ui.getOutfit().items[0].uiid;
var accountid = CONSTANTS.currentAccount;
confirmbox({ msg: CONSTANTS.isMember?Wtt.get(20617):Wtt.get(20616), onok: function() {
window.inventoryController.tradeItem(0,uiid,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,-1,true,accountid,null,ui);
}, oncancel: function(){return false;}});return false;
});
}
$root.on("click.InventoryController", ".editButton.enabled", function(event) {
var $button = $(this),
ui = $button.closest(".itemDisplay").data("ui"),
price = ui.getOutfit().items[0].price;
_this.showAuctionDialog(ui,price);
return false;
});
$root.on("click.InventoryController", ".bidButton.enabled", function() {
var $button = $(this),
ui = $button.closest(".itemDisplay").data("ui"),
item = ui.getOutfit().items[0];
_this.auctionedItemUi = ui;
$button.removeClass("enabled").addClass("disabled");
var onOk = function() {
_this.auctionItem(0,item.price,item.getUiid(),0,0,item.seller);
};
var onCancel = function() {
$button.removeClass("disabled").addClass("enabled");
};
confirmbox({msg: Wtt.get(item.isDiamondItem()?20182:20188).replace("$PRICE$",item.price), onok: onOk, oncancel: onCancel});
return false;
});
$root.on("click.InventoryController", ".wish", function() {
var $button = $(this),
outfit = $button.closest(".itemDisplay").data("ui").getOutfit();
$button.toggleClass("wishable");
var wishing = !$button.is(".wishable");
_this.wishItem(outfit,wishing);
return false;
});
$root.on("click.InventoryController",".settings-icon",function(e,target){
var $navigator = $root.find(".filterNavigator");
$navigator.toggleClass("settings-open");
if($navigator.hasClass("settings-open")) {
var $settingscontainer = $("
");
$navigator.append($settingscontainer);
//rename tag
var $renameBtn = $('Rename tag');
$renameBtn.on("click",function(){
showStdDialog(DIALOG.RENAME_ITEM_TAG,'');
});
$settingscontainer.append($renameBtn);
//tag order:
var $tagOrder = $('');
if(window.preferences.sortTagsAlph){
$tagOrder.toggleClass("option1");
$tagOrder.toggleClass("option2");
}
$tagOrder.on("click",function(){
$tagOrder.toggleClass("option1");
$tagOrder.toggleClass("option2");
window.preferences.sortTagsAlph = !window.preferences.sortTagsAlph;
_this.persistSettings();
});
$settingscontainer.append($tagOrder);
//search option:
var $searchOptions = $('');
if(window.preferences.searchTagSpecific){
$searchOptions.toggleClass("option1");
$searchOptions.toggleClass("option2");
}
$searchOptions.on("click",function(){
$searchOptions.toggleClass("option1");
$searchOptions.toggleClass("option2");
window.preferences.searchTagSpecific = !window.preferences.searchTagSpecific;
_this.persistSettings();
if($navigator[0].querySelectorAll(".tagContainer span").length >= 2){
window.setTimeout(function(){
_this.doLoadItems();
})
}
});
$settingscontainer.append($searchOptions);
//preview
var $preview = $('Show item preview✔
');
if(window.preferences.showPreview){
$preview.toggleClass("selected",true);
}
$preview.on("click",function(){
$preview.toggleClass("selected");
window.preferences.showPreview = !window.preferences.showPreview;
_this.persistSettings();
});
$settingscontainer.append($preview);
} else {
$navigator.find("#settingscontainer").remove();
}
});
// $root.on("click.InventoryController", ".toTopButton", function() {
// $(this).parent().first().scrollTop();
// return false;
// });
// $root.on("click.InventoryController", ".hideFilter .hideButton", function() {
// var $button = $(this);
// $button.parent().siblings(".filters").toggleClass("hidden",3000);
// $root.find(".filterNavigator").toggleClass("filtersHidden",3000);
// $root.find(".yourModel").toggleClass("filtersHidden",3000);
// });
},
compareOutfits: function(items) {
var currentItems = this._basket.getItems();
if(!CONSTANTS.outfitsaved) {
var matchFound = false;
if(items.length === currentItems.length) {
for (var i = 0; i < currentItems.length; i++) {
if (items[i].uiid !== currentItems[i].uiid) {
matchFound = false;
break;
}
matchFound = true;
}
} else {
return false;
}
return matchFound;
} else {
return true;
}
},
getQueryType: function(){
return this._querytype;
},
getSkinIndex:function(){
return this._avatarUi.getSkinIndex();
},
getBasketPosition:function(sliderValue,basketSize){
return Math.min(Math.floor(sliderValue*basketSize),basketSize-1);
},
getSliderValue:function(basketPosition,basketSize,sliderSize,thumbSize){
if(basketSize == 1) return (sliderSize/2)-(thumbSize/2);
return (sliderSize/basketSize)*basketPosition+(sliderSize/(2*basketSize))-(thumbSize/2);
},
updateSlider:function(position,$avatarSlider){
if(position != -1) {
var basketSize = this._basket.getBasketCount(),
thumbSize = $avatarSlider.find('.thumb').css('height').replace('px',''),
sliderSize = $avatarSlider.find('.track').css('height').replace('px',''),
sliderValue = this.getSliderValue(basketSize-position-1,basketSize,sliderSize,thumbSize);
// Adjust the slider
$avatarSlider.find(".thumb").css('top',sliderValue);
CONSTANTS.outfitsaved = false;
}
},
selectBasketItem:function($basketItem){
if($basketItem.find(".basketDiv").hasClass("basketSelected")){
$basketItem.find(".basketDiv").removeClass("basketSelected");
return false;
} else {
$basketItem.find(".basketDiv").addClass("basketSelected").parent().siblings().find(".basketDiv").removeClass("basketSelected");
return true;
}
},
loadItems: function(doneFn) {
var self = this;
if((this._context.isWardrobe() || this._context.isWishlist()) && CONSTANTS.currentAccount == 0){
var url = document.location.href;
showStdDialog(DIALOG.GENERIC_NOT_LOGGED_IN, "&redirecturl=" + url);
//Accessing wardrobe without being logged in.
}
if(this._loadItemsTimeoutId != null) {
clearTimeout(this._loadItemsTimeoutId);
}
this._loadItemsTimeoutId = setTimeout(function(){self.doLoadItems(doneFn);}, 200);
},
doLoadItems: function(doneFn) {
var self = this;
var filter = self._readFilterFromDom();
this._$root.find("#uiids").val(""); // After reading the items from the DOM (in case there are any) remove them, so we can interact with the filters properly.
var requestId = new Date().getTime();
this._loadItemsRequestId = requestId;
var $loadingTarget = this._$root.find(".itemBrowser").addClass("loading");
this._dao.createItemStream(
filter,
// On success
function(itemStream) {
if(self._loadItemsRequestId > requestId){
return;
}
if(self._context.isWardrobe()) {
self._$root.find(".unlockAllButton").css("display", "inline-block");
self._$root.find(".tagAllButton").css("display", "inline-block");
} else {
self._$root.find(".unlockAllButton").css("display", "none");
self._$root.find(".tagAllButton").css("display", "none");
}
var outfitStream = self._createOutfitStream(itemStream);
self._outfitGridUi.setOutfitStream(outfitStream);
self.linkWornItemsToWardrobeItems();
$loadingTarget.removeClass("loading");
if ($.isFunction(doneFn)) {
doneFn(outfitStream);
}
},
function(status,errorMsg) {
$loadingTarget.removeClass("loading");
if(status > 30 && status < 35) self.showMsgBox(errorMsg);
else self.showErrorBox(errorMsg);
},
requestId);
},
updateSize: function() {
this.updateYourModelSize();
// $browser.tinyscrollbar_update();
// var
// $outfitList = $root.find(".outfitList");
//
// $outfitList.height(function() {
// var
// $this = $(this),
// listNextSiblingsHeight = (function() {
// var r = 0;
// $this.nextAll().each(function() {
// r += $(this).outerHeight(true);
// });
//
// return r;
// })();
//
// return yourModelMaxHeight - $this.position().top - listNextSiblingsHeight - ($this.outerHeight(true) - $this.height());
// });
//
// $outfitList.find(".slider").tinyscrollbar_update();
},
updateYourModelSize: function() {
var
$root = this._$root,
windowHeight = $(window).height(),
$yourModel = $root.find(".yourModel"),
yourModelTopOffset = $yourModel.position().top,
contextAdjustment = (!this._context.isWardrobe() && !this._context.isOtherWardrobe() && !this._context.isAuction()?120:this._context.isAuction()?0:80),
yourModelMinHeight = parseInt($yourModel.css("min-height")) + contextAdjustment,
yourModelBasketItemsHeight = $yourModel.find(".basketItem").sum(function() { return $(this).outerHeight(true); }),
yourModelOuterHeight = $yourModel.outerHeight(true),
yourModelHeight = $yourModel.height(),
yourModelPaddingHeight = (yourModelOuterHeight - yourModelHeight),
yourModelMaxHeight = Math.min(
yourModelMinHeight + yourModelBasketItemsHeight,
windowHeight - yourModelPaddingHeight),
yourModelNewHeight = Math.max(yourModelMinHeight, yourModelMaxHeight);
$yourModel.height(yourModelNewHeight-(this._context.isWardrobe() && !this._context.isOtherWardrobe()? 10:0));
$root.find(".itemBrowser").css("min-height", yourModelNewHeight + yourModelPaddingHeight);
var $scrollpane = $yourModel.find(".scrollpane");
(function(jScrollPane, iScroll) {
if (jScrollPane) {
jScrollPane.reinitialise();
} else if (iScroll) {
iScroll.refresh();
}
})($scrollpane.data("jsp"), $scrollpane.data("iScroll"));
},
linkWornItemsToWardrobeItems:function(){
if(this._context.isWardrobe()){
var items = this._basket.getItems(),
_this = this;
for(var i = 0, l = items.length; i 0) {
updateMoneyDelta(-gmPaid);
this._accountMoney.deductMoney(gmPaid);
}
if(dPaid > 0) {
updateDiamondsDelta(-dPaid);
this._accountMoney.deductDiamonds(dPaid);
}
if(vPaid > 0) {
updateVoucherDelta(-vPaid);
this._accountMoney.deductVoucher(vPaid);
}
},
validateDressUp : function(items) {
var _this = this;
var itemCount = _this._getNonBodyPartItemCount(items);
if(itemCount > CONSTANTS.values.MAX_WORN_ITEMS) {
var text = items.length > 1 ? window.Wtt.get(20074) : window.Wtt.get(20075);
text = text.replace("$MAX_ITEMS$", CONSTANTS.values.MAX_WORN_ITEMS).replace("$NUM_ITEMS$", itemCount - CONSTANTS.values.MAX_WORN_ITEMS);
_this.showMsgBox(text);
return false;
}
var coversBreasts = false;
var coversCrotch = false;
// Check to see if model is decent
$.map(items, function(item) {
coversBreasts |= item.coversBreasts;
coversCrotch |= item.coversCrotch;
});
if(!coversBreasts) {
_this.showMsgBox(window.Wtt.get(20076));
return false;
}
if(!coversCrotch) {
_this.showMsgBox(window.Wtt.get(20077));
return false;
}
return true;
},
dressupDoll: function(items) {
var _this = this;
if(!_this.validateDressUp(items)){
return;
}
var skinPalette;
for(var i = 0; i < items.length; i++) {
var item = items[i];
if(item.isSkin) {
skinPalette = item.faceIndex === 0 ? item.palette : item.faceIndex;
}
}
var buyParams = $.map(items, function(v) {
var paletteIndex = v.palette;
var correctUiid = v.uiid;
if (v.colors && v.colors.length > paletteIndex && v.colors[paletteIndex].uiid && !v.isFace) {
correctUiid = v.colors[paletteIndex].uiid;
}
if(v.isFace && skinPalette) {
correctUiid = v.colors[skinPalette].uiid;
}
var basketItem = $('.basketItem').has('.basketDiv .basketImg img[src*="/item/' + correctUiid + '"]');
var basketLockBtn = basketItem.find(".basketLockBtn");
var isLocked = basketLockBtn.length && basketLockBtn.hasClass('locked');
return {
internalId: v.internalId,
locked: isLocked
};
});
var onsuccess = function(response) {
_this.showMsgBox(window.Wtt.get(17608));
};
this._dao.dressupDoll(buyParams, onsuccess, this._standardErrorHandler());
},
removeFromWardrobe: function(ui) {
var items = ui.getOutfit().items;
var buyParams = $.map(items, function(v) {
return {internalId: v.internalId};
});
var _this = this;
var onOk = function() {
var onsuccess = function(response) {
if(response.msg != null && response.msg.length > 0) {
_this.showMsgBox(response.msg);
}
ui.getElement().fadeOut(1000);
_this._basket.removeOutfit(ui.getOutfit());
_this.updateYourModelSize();
};
_this._dao.removeFromWardrobe(buyParams, onsuccess, _this._standardErrorHandler());
};
confirmbox({msg: Wtt.get(16653), onok:onOk});
},
showAuctionDialog:function(ui,price){
var item = ui.getOutfit().items[0],
_this = this,
palette = item.layer == CONSTANTS.layersv2.DOLL_LAYER_FACE?(_this._basketUi.skinIndex):(!!item.selectedPalette?item.selectedPalette:item.palette),
uiid = (item.layer == CONSTANTS.layersv2.DOLL_LAYER_EYES?item.eyeShapes[_this._basketUi.eyeIndex].uiid : palette >= item.colors.length ? "" : item.colors[palette]["uiid"]);
_this.auctionedItemUi = ui;
showStdDialog(DIALOG.AUCTION_ITEM,'&item=' + item.getUiid() + "&itemImg=" + uiid + '&diamond=' +item.isDiamondItem()+'&price=' + price);
},
showTagsDialog:function(ui){
var item = ui.getOutfit().items[0],
_this = this,
palette = item.layer == CONSTANTS.layersv2.DOLL_LAYER_FACE?(_this._basketUi.skinIndex):(!!item.selectedPalette?item.selectedPalette:item.palette),
uiid = (item.layer == CONSTANTS.layersv2.DOLL_LAYER_EYES?item.eyeShapes[_this._basketUi.eyeIndex].uiid : palette >= item.colors.length ? "" : item.colors[palette]["uiid"]);
_this.auctionedItemUi = ui;
showStdDialog(DIALOG.MANAGE_ITEM_TAGS,'&item=' + item.getUiid() + "&itemImg=" + uiid+"&id="+item.internalId+"&q="+item.quality);
},
showTradeDialog:function(ui,price){
var item = ui.getOutfit().items[0],
_this = this,
palette = item.layer == CONSTANTS.layersv2.DOLL_LAYER_FACE?(_this._basketUi.skinIndex):(!!item.selectedPalette?item.selectedPalette:item.palette),
uiid = (item.layer == CONSTANTS.layersv2.DOLL_LAYER_EYES?item.eyeShapes[_this._basketUi.eyeIndex].uiid : palette >= item.colors.length ? "" : item.colors[palette]["uiid"]);
_this.auctionedItemUi = ui;
if(CONSTANTS.modellevel < 6){
messagebox({msg:Wtt.get(20686)});
} else if(CONSTANTS.validated){
showStdDialog(DIALOG.TRADE_ITEM,'&item=' + item.getUiid() + "&itemImg=" + uiid +'&config=12'); //config 12 = ModelSearchPanelConfigs.INVENTORY_TRADE_SEARCH
} else {
showStdDialog(DIALOG.EMAIL_VALIDATION,'');
}
},
showSaveLookDialog:function(){
showStdDialog(DIALOG.SAVE_YOUR_LOOK,'', null, null);
},
showSuggestLookDialog:function(){
showStdDialog(DIALOG.SUGGEST_LOOK,'',null,null);
},
saveLook:function(name){
var _this = this;
var items = _this._basket.getItems();
if(!_this.validateDressUp(items)){
return;
}
var buyParams = $.map(items, function(v) {
return {iid: v.internalId};
});
var onsuccess = function(response) {
if(response.msg != null && response.msg.length > 0) {
_this.showMsgBox(response.msg);
}
if(response.status == 0){
PANELFACTORY.closePanel();
}
};
this._dao.saveLook(buyParams, name, onsuccess, this._standardErrorHandler());
},
suggestLook:function(name,price){
var _this = this;
var items = _this._basket.getItems();
if(!_this.validateDressUp(items)){
return;
}
var buyParams = $.map(items, function(v) {
return {iid: v.internalId};
});
var onsuccess = function(response) {
if(response.msg != null && response.msg.length > 0) {
_this.showMsgBox(response.msg);
}
if(response.status == 0){
PANELFACTORY.closePanel();
}
};
this._dao.suggestLook(buyParams, this.visitingWardrobe, name, price, onsuccess, this._standardErrorHandler());
},
auctionItem:function(duration,price,uiid,editing,cancel,seller){
var _this = this,
ui = _this.auctionedItemUi,
item = ui.getOutfit().items[0];
if(item.getUiid() != uiid){
return;
}
var requestParam = {internalId: item.internalId, price: price, duration: duration, editing: editing, cancelling: cancel, seller: parseInt(seller)};
var onsuccess = function(response) {
if(response.msg != null && response.msg.length > 0) {
if(response.status != 0) _this.showMsgBox(response.msg);
}
ui.updateAuction(price,duration,cancel,seller);
if(seller > 0){ // This means someone is placing a bid
_this.updateTopBar(!item.isDiamondItem()?price:0, item.isDiamondItem()?price:0, false);
}
};
_this._dao.auctionItem(requestParam, onsuccess, _this._standardErrorHandler());
},
tradeItem:function(buyer,uiid,mygomoney,mydiamonds,myvipdays,mygreetings,gomoneyprice,diamondprice,vipdays,greetings,itemone,itemtwo,itemthree,ditemone,ditemtwo,ditemthree,cancel,seller,customtext,_ui){
var _this = this;
var ui = _this.auctionedItemUi;
if(ui == undefined){ui = _ui;}
var item = ui.getOutfit().items[0];
var requestParam = {internalId: item.internalId,
mygomoney: mygomoney,
mydiamonds: mydiamonds,
myvipdays: myvipdays,
mygreetings: mygreetings,
buyer: buyer,
gomoneyprice: gomoneyprice,
diamondprice: diamondprice,
vipdays: vipdays,
greetings: greetings,
cancelling: cancel,
seller: parseInt(seller),
itemone: itemone,
itemtwo: itemtwo,
itemthree: itemthree,
ditemone:ditemone,
ditemtwo:ditemtwo,
ditemthree:ditemthree
};
var onsuccess = function(response) {
if(response.msg != null && response.msg.length > 0) {
if(response.status != 0) _this.showMsgBox(response.msg);
}
if(response.status == 0){
_this.showMsgBox(response.msg);
PANELFACTORY.closePanel();
}
ui.updateTrade(buyer,cancel);
};
_this._dao.tradeItem(requestParam, onsuccess, _this._standardErrorHandler());
},
wishItem:function(outfit,wishing){
delete this._outfitControllersByUiid[outfit.uiid]
var _this = this;
var items = $.map(outfit.items, function(v) {
var uiid = !v.isFaceFunc() && !v.isSkinFunc()?v.getUiid():v.uiid;
return uiid;
});
var onsuccess = function(response) {
for (var i = 0, l = outfit.items.length; i li.selected").trigger("click");
},
getOutfitController: function(outfit) {
var outfitControllersByUiid = this._outfitControllersByUiid;
var outfitController = null;
if (outfit.uiid) {
outfitController = outfitControllersByUiid[outfit.uiid];
}
if (!outfitController) {
outfitController = createOutfitController(this, outfit);
if (outfit.uiid) {
outfitControllersByUiid[outfit.uiid] = outfitController;
}
}
else {
outfitController.outfit = outfit;
}
return outfitController;
},
showMsgBox: function(msg) {
messagebox({msg: msg});
},
showErrorBox: function(msg) {
errorbox({msg: msg});
},
_createOutfitStream: function(itemStream) {
var self = this;
return $.extend(itemStream, {
getOutfits: function(from, to, doneFn, errorFn) {
this.getItems(
from,
to,
function(items) {
var color = self._$root.find("#colorFilter .selected").data("value");
var colorSearch = color != undefined?color != 0:false;
var outfits = $.map(items, function(item) {
var
outfitItems = item.items,
outfit = createOutfit(outfitItems,item.mannequinId),
controller = self.getOutfitController(outfit);
if (item.palette) {
controller.setPalette(item.palette);
}
outfit.mannequin = item.mannequin;
outfit.jdMannequin = item.jdMannequin;
outfit.controller = controller;
// Add methods to the item object
$.each(outfitItems, function(i, v) {
$.extend(v, itemMergeProperties);
});
if(colorSearch) outfit.controller.resetPalette();
return outfit;
});
if ($.isFunction(doneFn)) {
doneFn(outfits);
}
},
errorFn);
}
});
},
_clearFilter: function() {
var
$root = this._$root,
queryElement = $root.find("#subLayerNavigator .layerButton.selected");
$root.find("#qualityFilter .selected").removeClass("selected");
$root.find("#colorFilter .selected").removeClass("selected");
$root.find("#tagFilter .selected").removeClass("selected");
$root.find("#priceMinFilter").val("");
$root.find("#priceMaxFilter").val("");
$root.find("#brandFilter .selected").removeClass("selected");
$root.find("#otherFilters .selected").removeClass("selected");
$root.find("#sortFilter .selected").removeClass("selected");
$root.find("#gomoneyFilter").addClass("selected");
$root.find("#gomoneyFilter").removeClass("disabled");
$root.find("#diamondFilter").addClass("selected");
$root.find("#diamondFilter").removeClass("disabled");
$root.find("#uiids").val("");
},
_readFilterFromDom: function() {
var
$root = this._$root,
queryElement = $root.find("#subLayerNavigator .layerButton.selected");
if (queryElement.length == 0) {
queryElement = $root.find("#layerNavigator .layerButton.selected");
}
var
querytype = queryElement.attr("querytype"),
quality = $root.find("#qualityFilter .selected").data("value"),
color = $root.find("#colorFilter .selected").data("value"),
priceMin = $root.find("#priceMinFilter").val(),
priceMax = $root.find("#priceMaxFilter").val(),
brand = $root.find("#brandFilter .selected").data("value"),
otherFilter = $root.find("#otherFilters .selected").data("value"),
sorting = $root.find("#sortFilter .selected").data("value"),
goMoney = $root.find("#gomoneyFilter").is(".selected"),
diamonds = $root.find("#diamondFilter").is(".selected"),
context = this._context.context,
visitingWardrobe = this.visitingWardrobe,
uiids = $root.find("#uiids").val();
var tagfilter = document.querySelector("#tagFilter");
var tag = (!!tagfilter) ? tagfilter.dataset.tags : 0;
this._querytype = querytype;
return {
querytype:querytype,
quality:quality,
color:color,
priceMin:priceMin,
priceMax:priceMax,
brand:brand,
other:otherFilter,
sorting:sorting,
goMoney:goMoney,
diamonds:diamonds,
context:context,
visitingWardrobe:visitingWardrobe,
uiids:uiids,
tags:tag
};
},
_standardErrorHandler: function(onErrorFn) {
var _this = this;
return function(httpStatusCode, response) {
if(response == null) {
if(httpStatusCode == 401) { // unauthorised
_this.showErrorBox(window.Wtt.get(8750));
}
else {
_this.showErrorBox(window.Wtt.get(8511));
}
}
else {
_this.showErrorBox(response.msg);
}
if(onErrorFn) {
onErrorFn();
}
}
},
_getNonBodyPartItemCount: function(items){
if(!items || !items.length){
return 0;
}
var itemCount = 0;
items.forEach(function(item){
if(item.layer != CONSTANTS.layersv2.DOLL_LAYER_FACE && item.layer != CONSTANTS.layersv2.DOLL_LAYER_BODY && item.layer != CONSTANTS.layersv2.DOLL_LAYER_EYES){
itemCount++;
}
});
return itemCount;
},
manageTags : function(uiid, myTags,itemTags, itemArray){
var _this = this;
var onOk = function(){
_this._context.myTags = myTags;
}
if(uiid && uiid != "all") {
var ui = _this.auctionedItemUi,
item = ui.getOutfit().items[0];
if (item.getUiid() != uiid) {
return;
}
this._dao.postTagChanges(item.internalId, myTags, itemTags, onOk);
} else {
this._dao.postTagChanges(itemArray, myTags, itemTags, onOk);
}
},
persistSettings : function(){
$.ajax({
type: "POST",
url: "/shopping/action/settings",
data: jQuery.param(window.preferences)
});
}
};
return function($root, inventoryDao, itemGridUi, avatarUi, basketUi, basket, context, unixTime, accountMoney) {
return new InventoryController($root, inventoryDao, itemGridUi, avatarUi, basketUi, basket, context, unixTime, accountMoney);
};
})();
var createInventoryDao = (function() {
var BASE_URL = "/shopping/action/";
var _createItemStream = (function() {
var STREAM_DELTA = 24*4;
var ItemStream = function(filter, length, initialItems, streamId) {
this._filter = filter;
this.length = length;
this.items = initialItems || [];
this.streamId = streamId;
};
ItemStream.prototype = {
getItems: function(from, to, doneFn, errorFn) {
to = Math.min(this.length, to);
if (this.items.length > to) {
var items = this.items.slice(from, to);
doneFn(items);
} else {
if (from >= this.length) {
if ($.isFunction(doneFn)) {
doneFn([]);
}
return;
}
var unknownFrom = this.items.length;
var params = {
from: unknownFrom,
to: Math.max(to, unknownFrom + STREAM_DELTA),
fetchMoreItems: true
};
var _this = this;
$.getJSON(BASE_URL + "search", params)
.done(function(result, textStatus, jqXHR) {
if (result.status === 0) {
result = result.json;
var items = result.list;
var itemAvailability = result.itemAvailabilityList; // gets list of item availability from response body - either empty or filled!
var itemOwned = result.itemOwnedList;
var wishableItems = result.isWishable;
if (context.isShop()) { // check if the user is in the shop
result.list.forEach(function(item, index) {
var items = item.items;
if (items.length > 1) { //skipping first 4 results if it happens to be an outfit mannequin with many items
var remainingItems = result.list.slice(4);
remainingItems.forEach(function(subItem) { // get your hands in the actual items
if (itemAvailability) {
subItem.inStock = Boolean(itemAvailability[index]); // set the item's inStock value to true (1) or false (0) depending on their corresponding number
}
});
} else if (items.length === 1 && index >= 4) { // when there is only one item and it's after the first 4 items (not part of an outfit)
if (itemAvailability) {
items[0].inStock = Boolean(itemAvailability[index - 4]); // if there are the 4 mannequins, set the inStock of the last 4 items in the list because it's the shop, they should always be in stock
}
}
});
} else { // if not in shop, do the same but don't do the skip because there are no mannequins/whole outfits in for example the wishlist
result.list.forEach(function(item, index) {
var items = item.items;
items.forEach(function(subItem) {
if (itemAvailability) {
subItem.inStock = Boolean(itemAvailability[index]);
}
if(context.isAuction() || context.isOtherWardrobe()) {
if (itemOwned) {
subItem.owned = itemOwned[index];
}
if (wishableItems) {
subItem.wishable = Boolean(wishableItems[index]);
}
}
});
});
}
_this.items.splice.apply(_this.items, [unknownFrom, 0].concat(items));
var returnItems = _this.items.slice(from, to);
if ($.isFunction(doneFn)) {
if(_this.streamId != window.inventoryController._loadItemsRequestId){
return;
}
doneFn(returnItems);
}
} else {
if ($.isFunction(errorFn)) {
errorFn(result.status,result.msg);
}
}
})
.fail(function() {
if ($.isFunction(errorFn)) {
errorFn();
}
});
}
}
};
return function(filter, doneFn, errorFn, streamId, currentId) {
filter.from = 0;
filter.to = STREAM_DELTA;
$.getJSON(BASE_URL + "search", filter)
.done(function(result, textStatus, jqXHR) {
if (result.status > 0) { // trying to access someone elses wardrobe or wishlist without the correct access
if ($.isFunction(errorFn)) {
errorFn(result.status, result.msg);
}
}
result = result.json;
var itemAvailability = result.itemAvailabilityList; // gets list of item availability from response body - either empty or filled!
var itemOwned = result.itemOwnedList;
var wishableItems = result.isWishable;
if (context.isShop()) { // check if the user is in the shop
result.list.forEach(function(item, index) {
var items = item.items;
if (items.length > 1) { //skipping first 4 results if it happens to be an outfit mannequin with many items
var remainingItems = result.list.slice(4);
remainingItems.forEach(function(subItem) { // get your hands in the actual items
if (itemAvailability) {
subItem.inStock = Boolean(itemAvailability[index]); // set the item's inStock value to true (1) or false (0) depending on their corresponding number
}
});
} else if (items.length === 1 && index >= 4) { // when there is only one item and it's after the first 4 items (not part of an outfit)
if (itemAvailability) {
items[0].inStock = Boolean(itemAvailability[index - 4]); // if there are the 4 mannequins, set the inStock of the last 4 items in the list because it's the shop, they should always be in stock
}
}
});
} else { // if not in shop, do the same but don't do the skip because there are no mannequins/whole outfits in for example the wishlist
result.list.forEach(function(item, index) {
var items = item.items;
items.forEach(function(subItem) {
if (itemAvailability) {
subItem.inStock = Boolean(itemAvailability[index]);
}
if(context.isAuction() || context.isOtherWardrobe()) {
if (itemOwned) {
subItem.owned = itemOwned[index];
}
if (wishableItems) {
subItem.wishable = Boolean(wishableItems[index]);
}
}
});
});
}
var itemStream = new ItemStream(filter, result.listSize, result.list, streamId, currentId);
if ($.isFunction(doneFn)) {
doneFn(itemStream);
}
})
.fail(function() {
if ($.isFunction(errorFn)) {
errorFn(1,Wtt.get(8511));
}
});
};
})();
// ctor
var InventoryDao = function() {
};
// prototype
InventoryDao.prototype = {
/**
*
* @param filter
*/
createItemStream: function(filter, doneFn, errorFn, streamId, currentId) {
_createItemStream(filter, doneFn, errorFn, streamId, currentId);
},
/**
* Get a list of items that match a filter from the server.
* @return a jqxhr object on which to add listeners
*/
getItems: function(filter) {
var url = BASE_URL + "search";
var params = filter;
return $.getJSON(url, params);
},
/**
* Buy the specified items.
*/
buyItems: function(items, onSuccess, onError) {
var url = BASE_URL + "buy";
var params = {
giftReceiverAccountId: 0,
items:items
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
buyGifts: function(recipientAccountId, items, onSuccess, onError) {
var url = BASE_URL + "buy";
var params = {
giftReceiverAccountId: recipientAccountId,
items: items
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
addToWishlist: function(items, onSuccess, onError) {
var url = BASE_URL + "wishlist";
var params = {
action: "add",
uiids: items
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
removeFromWishlist: function(items, onSuccess, onError) {
var url = BASE_URL + "wishlist";
var params = {
action: "remove",
uiids: items
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
clearOwnedFromWishlist: function(onSuccess, onError) {
var url = BASE_URL + "wishlist";
var params = {
action: "ownedItemClearing",
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
dressupDoll: function(items, onSuccess, onError) {
var url = BASE_URL + "dressup";
var params = {
items: items
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
CONSTANTS.outfitsaved = true;
},
removeFromWardrobe: function(items, onSuccess, onError) {
var url = BASE_URL + "wardrobe";
var params = {
items: items
};
$.postJSON(url, params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
auctionItem:function(param,onSuccess,onError){
var url = BASE_URL + "auction";
$.postJSON(url, param).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
tradeItem:function(param,onSuccess,onError){
var url = BASE_URL + "trade";
$.postJSON(url, param).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
saveLook:function(items, name, onSuccess, onError){
var url = BASE_URL + "savelook";
var params = {
name: name,
accountid: 0,
price: -1,
items: items
};
$.postJSON(url,params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
suggestLook:function(items, accountid, name, price, onSuccess, onError){
var url = BASE_URL + "savelook";
var params = {
name: name,
accountid: accountid,
price: price,
items: items
};
$.postJSON(url,params).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
},
postTagChanges:function(uiidOrIds, myTags,itemTags,onOk) {
var params;
if(uiidOrIds && uiidOrIds.length){
var params = {
itemIds: uiidOrIds,
myTags: myTags,
itemTags: itemTags
}
} else {
var params = {
uiid: uiidOrIds,
myTags: myTags,
itemTags: itemTags
}
}
$.postJSON(BASE_URL+"tag", params).done(this.handleDone(onOk, false)).fail(this.handleFail(false));
},
// bidOnAuction:function(param,onSuccess,onError){
// var url = BASE_URL + "auction_bid";
// $postJSON(url,param).done(this.handleDone(onSuccess, onError)).fail(this.handleFail(onError));
// },
handleDone: function(onSuccess, onError) {
return function(response) {
switch (response.status) {
case 0:
if ($.isFunction(onSuccess)) {
onSuccess(response);
}
break;
default:
// Error
if ($.isFunction(onError)) {
onError(200, response); // http OK, but error from client
}
break;
}
}
},
handleFail: function(onError) {
return function(jqxhr) {
if ($.isFunction(onError)) {
onError(jqxhr.status, null); // http error
}
}
}
};
return function() {
return new InventoryDao();
};
})();/**
* Get an outfit with these items.
* If called again with the same items, the same outfit is returned.
*/
var createOutfit = (function() {
var Outfit = function(uiid, items) {
this.uiid = uiid;
this.items = items;
};
Outfit.prototype = {
};
var outfitsByUiid = {};
return function(items,mannequinId) {
var uiid = (function() {
var uiids = [];
$.each(items, function(i, v) {
uiids.push(v.uiid);
// To avoid using the same uiids as the shop items (since that will cause the selected palette to be carried over to the wardrobe and etc.) we add an extra identifier
if(v.internalId) uiids.push(v.internalId); // Added for wardrobe items
else if(mannequinId) uiids.push(mannequinId); // Added for mannequin items
else if(v.accountid) uiids.push(v.accountid); // Added for wishlist items
});
return uiids.join('');
})();
// var outfit = outfitsByUiid[uiid];
// if (!outfit) {
var outfit = new Outfit(uiid, items);
// outfitsByUiid[uiid] = outfit;
// }
return outfit;
};
})();var createOutfitController = (function() {
var OutfitController = function(inventoryController, outfit) {
this.outfit = outfit;
this.events = createEventManager(["selected"]);
this._inventoryController = inventoryController;
this._selected = false;
this._selectedPalette = null;
};
OutfitController.prototype = {
buy: function() {
},
setSelected: function(selected) {
var oldValue = this._selected;
this._selected = selected;
this.events.fire( { oldValue: oldValue, newValue: selected } );
},
isSelected: function() {
return this._selected;
},
setPalette: function(paletteId) {
this._selectedPalette = paletteId;
var items = this.outfit.items;
for (var i = 0, l = items.length; i < l; i++){
items[i].selectedPalette = this._selectedPalette;
}
},
resetPalette: function(){
var items = this.outfit.items, lowestPalette = 0;
for (var i = 0, l = items.length; i < l; i++){
lowestPalette =items[i].palette;
}
this._selectedPalette = lowestPalette;
},
setWishable:function(wishable){
var items = this.outfit.items;
for (var i = 0, l = items.length; i < l; i++){
items[i].wishable = wishable;
}
this.events.fire();
},
getPalette: function() {
return (this._selectedPalette !== null) ? this._selectedPalette : this.outfit.items[0].palette;
}
};
return function(inventoryController, outfit) {
return new OutfitController(inventoryController, outfit);
};
})();/**
* Get an outfit with these items.
* If called again with the same items, the same outfit is returned.
*/
var createOutfit = (function() {
var Outfit = function(uiid, items) {
this.uiid = uiid;
this.items = items;
};
Outfit.prototype = {
};
var outfitsByUiid = {};
return function(items,mannequinId) {
var uiid = (function() {
var uiids = [];
$.each(items, function(i, v) {
uiids.push(v.uiid);
// To avoid using the same uiids as the shop items (since that will cause the selected palette to be carried over to the wardrobe and etc.) we add an extra identifier
if(v.internalId) uiids.push(v.internalId); // Added for wardrobe items
else if(mannequinId) uiids.push(mannequinId); // Added for mannequin items
else if(v.accountid) uiids.push(v.accountid); // Added for wishlist items
});
return uiids.join('');
})();
// var outfit = outfitsByUiid[uiid];
// if (!outfit) {
var outfit = new Outfit(uiid, items);
// outfitsByUiid[uiid] = outfit;
// }
return outfit;
};
})();var
MANNEQUIN_SIZE_LARGE = 370 + 14,
MANNEQUIN_SIZE_SMALL = 240 + 14,
BANNER_HEIGHT = 103;
var createOutfitGridUi = (function() {
var
ITEMS_PER_ROW = 4,
BANNER_FREQUENCY = 12, // Rows between banners
BANNER_HEIGHT = 90+16+13, // banner + add-tag + margin-top
LIST_STREAM_ITEMCOUNT = 24*4;
var OutfitGridUi = function($scroll,$grid,context,underwear, unixTime, accountMoney, $bannerHtml) {
this._$scroll = $scroll;
this._$grid = $grid;
this._outfitStream = null;
this._uis = [];
this._underwear = underwear;
this._context = context;
this._unixTime = unixTime;
this._accountMoney = accountMoney;
this._banners = (function() {
var banners = [];
for (var i = 0; i < 10; ++i) {
banners.push($bannerHtml.clone());
}
return banners;
})();
this._listMinimumHeight = 0;
var self = this;
$grid.on("infinityListUpdate", function() {
$grid.find("li.itemDisplay").removeClass("firstInRow").filter(function(i) {
return (i) % 4 === 0;
}).addClass("firstInRow");
});
this._listItemProducer = {
getTotalHeight: function() {
return this._listHeight || self._listMinimumHeight;
},
getItems: function(fromPx, deltaPx, rowWidth, doneFn) {
var outfitStream = self._outfitStream;
if (!outfitStream) {
doneFn({
topMargin:0,
items:[]
});
return;
}
var producer = this;
if (!this._listHeight) {
this._listHeight = self._listMinimumHeight;
}
var uis = self._uis;
var outfitCount = outfitStream.length;
var firstIndex = -1, lastIndex = -1, toPx = fromPx + deltaPx;
var
px = 0,
topMargin = 0;
for (var i = 0, l = outfitCount; i < l && (firstIndex === -1 || lastIndex === -1); i += ITEMS_PER_ROW) {
var rowHeight = 0;
var rowNumber = Math.floor(i / ITEMS_PER_ROW);
for (var j = i, k = i + ITEMS_PER_ROW; j < k && j < outfitCount; ++j) {
rowHeight = Math.max(
rowHeight,
uis[j] ? uis[j].getHeight() : MANNEQUIN_SIZE_SMALL); // Unknown height, assume small
}
if (rowNumber > 0 && rowNumber % BANNER_FREQUENCY === 0) {
rowHeight += BANNER_HEIGHT;
}
px += rowHeight;
if (firstIndex === -1 && px > fromPx) {
firstIndex = i;
topMargin = px - rowHeight;
}
if (lastIndex === -1 && px > toPx) {
lastIndex = i + ITEMS_PER_ROW;
}
}
if (lastIndex === -1) {
lastIndex = uis.length;
}
// Stuff to be executed after delayed outfit loading.
var complete = function() {
// Update this._listHeight to account for newly loaded items
var totalListHeight = Math.floor((outfitStream.length - uis.length) / ITEMS_PER_ROW) * MANNEQUIN_SIZE_SMALL; // Initialize with the estimated height of unknown rows
for (var i = 0, l = uis.length; i < l; i += ITEMS_PER_ROW) {
var rowHeight = 0;
for (var j = i, k = i + ITEMS_PER_ROW; j < k && j < uis.length; ++j) {
rowHeight = Math.max(rowHeight, uis[j].getHeight());
}
totalListHeight += rowHeight;
}
// Read out html elements from the uis, add banners and return that list.
uis = uis.slice(firstIndex, lastIndex);
var uiElements = $.map(uis, function(v) {
v.load();
return v.getElement();
});
// Insert banner tags in uiElements
var bannerIndices = [];
for (var i = 0, l = uiElements.length; i < l; ++i) {
var rowNumber = Math.floor((firstIndex + i) / ITEMS_PER_ROW);
if (rowNumber > 0 && i % ITEMS_PER_ROW === 0 && rowNumber % BANNER_FREQUENCY === 0) {
bannerIndices.push(i);
totalListHeight += BANNER_HEIGHT;
}
}
producer._listHeight = totalListHeight;
for (var i = 0, l = bannerIndices.length; i < l; ++i) {
var index = bannerIndices[i];
var bannerIndex = (((firstIndex + index) / ITEMS_PER_ROW / BANNER_FREQUENCY) - 1) % self._banners.length;
var banner = self._banners[bannerIndex];
banner.attr("banner-index", bannerIndex);
// We've moved the indexes, so add the amount we've moved (i) to index
uiElements.splice(i + index, 0, banner);
}
if ($.isFunction(doneFn)) {
doneFn({
topMargin: topMargin,
items: uiElements
});
}
};
if (lastIndex > uis.length) {
// Load additional outfits
self._outfitStream.getOutfits(
uis.length,
lastIndex + 1,
function(outfits) {
var newUis = $.map(outfits, function(v) {
return createOutfitGridEntryUi(v, self._context, self._underwear, self._unixTime, self._accountMoney);
});
$.merge(uis, newUis);
complete();
},
function(errorMsg) {
log.error(errorMsg);
});
} else {
complete();
}
}
};
this._infinityList = createInfinityList($scroll, $grid, this._listItemProducer, "scroll", function() {
return $(this).scrollTop();
});
setInterval(function(){
self._$grid.find(".itemDisplay").each(function(){
$(this).data("ui").updateAuctionTimer();
})
},30000);
// this._outfitUiByUiid = {};
};
OutfitGridUi.prototype = {
/**
* @param outfitList an object with a getOutfits(from, to, callback) function and a length property
*/
setOutfitStream: function(outfitStream) {
if (!outfitStream) {
throw { message: "outfitStream is not defined." };
}
var _this = this;
var cbId = new Date().getTime();
this._setOutfitStream_cbId = cbId;
outfitStream.getOutfits(0, LIST_STREAM_ITEMCOUNT, function(outfits) {
if (cbId !== _this._setOutfitStream_cbId) {
return;
}
_this._uis = [];
_this._$grid.scrollTop(0);
_this._outfitStream = outfitStream;
var uis = $.map(outfits, function(v) {
return createOutfitGridEntryUi(v, _this._context,_this._underwear,_this._unixTime,_this._accountMoney);
});
var rowCount = Math.floor(outfitStream.length / ITEMS_PER_ROW);
var bannerCount = Math.floor(rowCount / BANNER_FREQUENCY);
_this._listMinimumHeight = (rowCount * MANNEQUIN_SIZE_SMALL) + (bannerCount * BANNER_HEIGHT);
_this._uis = uis;
_this._infinityList.update(true);
});
if(CONSTANTS.auctionsForAll && outfitStream.length < 1){ // If no items were found, show message box
var querytype = window.inventoryController.getQueryType();
if(querytype == CONSTANTS.queryTypes.MY_AUCTIONS || querytype == CONSTANTS.queryTypes.MY_BIDS){
_this._infinityList.replaceContent(_this.createMessageBoxElement());
}
}
},
createMessageBoxElement: function(){
var context = this._context,
headerWtt = context.isWardrobe()?20185:20183,
bodyWtt = context.isWardrobe()?CONSTANTS.isMember?20186:20187:20184,
html = "" +
" " +
"
" +
" " + Wtt.get(bodyWtt) + "" +
"
" +
"
";
return html;
},
findAndSetItemOwned: function (item) {
item.owned[item.selectedPalette] = true;
var $elements = $(".itemImages.front img:not(.underwear)");
$elements.each(function (i, element) {
var $element = $(element);
var uiid = item.uiid;
if($element.context.dataset.lazySrc.endsWith(uiid)) {
if (item.owned != undefined && item.owned[item.selectedPalette]) {
$element.parent().parent().parent().find(".owned").html("Owned");
} else {
$element.parent().parent().parent().find(".owned").empty();
}
}
});
},
// setOutfits: function(outfits) {
// this._uis = [];
// this._$grid.scrollTop(0);
// var _this = this;
// var uis = $.map(outfits, function(v) {
// return createOutfitGridEntryUi(v, _this._context,_this._underwear,_this._unixTime,_this._accountMoney);
// });
//
// var rowCount = Math.floor(uis.length / ITEMS_PER_ROW);
// var totalHeight = 0;
// for (var i = 0, l = uis.length; i < l; i += ITEMS_PER_ROW) {
// var h = 0;
//
// for (var j = i, k = i + ITEMS_PER_ROW; j < k && j < l; ++j) {
// h = Math.max(h, uis[j].getHeight());
// }
//
// totalHeight += h;
// }
//
// var bannerHeight = Math.floor(rowCount / BANNER_FREQUENCY) * BANNER_HEIGHT;
//
// this._totalListHeight = totalHeight + bannerHeight;
// this._uis = uis;
// this._infinityList.update(true);
// },
setContext: function(context) {
this._context = context;
}
// _getOutfitGridEntryUi: function(outfit) {
// var uiid = outfit.uiid;
//
// var ui = this._outfitUiByUiid[uiid];
//
// if (!ui) {
// ui = createOutfitGridEntryUi(outfit);
// this._outfitUiByUiid[uiid] = ui;
// } else {
// ui.reload();
// }
//
// return ui;
// }
};
return function($scroll, $grid, context, underwear, unixTime, accountMoney, bannerHtmlList) {
return new OutfitGridUi($scroll, $grid, context, underwear, unixTime, accountMoney, bannerHtmlList);
};
})();
var createOutfitGridEntryUi = (function() {
function getImageSdnUrl(uiid) {
// var sdnPrefix = uiid==undefined?"e":uiid[0];
return "/item/" + uiid;
}
function createImageElement(item, paletteId, back) {
var
uiid = (paletteId >= item.colors.length ? "" : item.colors[paletteId][back ? "backuiid" : "uiid"])+(back?"?back":""),
src = getImageSdnUrl(uiid),
pos = back ? item.positionBack : item.position;
// return $("
").attr("data-lazy-src", src).attr("onload",function(){item2(this);}).data("item",item).css({
return $("
").attr("data-lazy-src", src).data("item",item).css({
left:pos.x,
top:pos.y,
width:pos.w,
height:pos.h
});
}
function createEyeImageElement(item) {
var
uiid = item.eyeShapes[7].uiid, // the mannequins behind the eyes have faceshape of imageid 9
src = getImageSdnUrl(uiid),
pos = item.eyeShapes[7].position;
return $("
").attr("data-lazy-src", src).data("item",item).css({
left:pos.x,
top:pos.y,
width:pos.w,
height:pos.h
});
}
function htmlContextMenu(context) {
var html = "";
var options = [];
if(context.isWardrobe()) {
options.push({ myclass: "deleteBtn", name: window.Wtt.get(17430)});
}
// todo uncomment
// if(context.isUserAdmin() || context.isUserEmployee()) {
// options.push({myclass: "editInAdminTool", name: "admin-edit"})
// }
if(options.length == 1 && options[0].myclass == "deleteBtn") {
html = ""
} else if(options.length > 0) {
html =
"";
}
return html;
}
function getWttTimeIntervalString(string, selector, value){
var timeSelector = selector=='h'?TIME_WTTS[0] + ' ':selector=='m'?TIME_WTTS[1]:'';
return value + ' ' + timeSelector;
}
function formatExpiresTime(expires,unixTime,shortText){
var interval = expires-unixTime.getUnixTime(),
tempInterval = interval,
timeString = '',
l = 0;
if (interval >= 60*60) { // hours
l = parseInt(tempInterval / (60*60));
timeString += getWttTimeIntervalString(timeString, 'h', l);
tempInterval -= l * (60*60);
if (shortText)
return timeString;
}
if (interval >= 60) { // minutes
l = parseInt(tempInterval / 60);
timeString += getWttTimeIntervalString(timeString, 'm', l);
tempInterval -= l * 60;
if (shortText)
return timeString;
}
if (interval < 60){
timeString += getWttTimeIntervalString(timeString, 'm', '<1');
}
return timeString;
}
function createColorMenu(outfit,context) {
if(!context.isShop()){
return "";
}
var items = outfit.items;
if (items.length === 0) {
throw "No items in outfit?!";
}
if (items.length > 1) {
return "";
}
var
item = items[0],
colors = item.colors,
colorCount = colors.length;
if (colorCount < 2) {
return "";
}
if(item.isFaceFunc()){
return "";
}
var
lineLength = colorCount < 4
? colorCount
: Math.ceil(Math.sqrt(colorCount)),
selectedPalette = outfit.controller.getPalette();
var html = [""];
for (var i = 0; i < colorCount; ++i) {
if (i > 0 && i % lineLength === 0) {
html.push("
");
}
var color = colors[i];
html.push("");
}
html.push("
");
return html.join("");
}
function createOutfitElement(outfitUi) {
var
outfit = outfitUi._outfit,
outfitController = outfit.controller,
selected = outfitController.isSelected(),
paletteId = outfitController.getPalette(),
mannequinStyle = outfitUi._mannequinStyle,
context = outfitUi._context,
underwear = outfitUi._underwear;
var coversBreasts = outfit.items.length == 1 && outfit.items[0].coversBreasts;
var coversCrotch = outfit.items.length == 1 && outfit.items[0].coversCrotch;
var
html = "" +
"" +
"
" +
"
" +
"
" +
"
" +
"
" +
"
" +
"
" +
"" +
"" +
"" +
"
" +
htmlContextMenu(context) +
(!context.isWardrobe() ? "
":"") +
(coversBreasts?"
":"")+
(coversCrotch?"
":"")+
createColorMenu(outfit,context) +
"
" +
"
" +
"
" +
"
" +
"
" +
(context.showOriginalPrice() ? " " : "") +
" " +
" " +
" " +
" "+
" " +
"
" +
"
" +
"
" +
"
" +
(CONSTANTS.userTradingV2?"
":"")+
"
"+
"
" +
"",
$html = $(html),
$imgBox = $html.find(".itemImages.front"),
$imgBoxBack = $html.find(".itemImages.back");
var
price = 0,
diamondPrice = 0,
origPrice = 0,
origDiamondPrice = 0,
quality = 0,
layer = 0,
brand = "",
ribbon = 0,
expires = 0,
isBidable = false,
isWishable = true,
discount = false,
isJd = false,
isGd = false,
isGoDesigner = false,
outOfStock = false,
showPrice = true,
canSeeCurrentBid = false,
isCurrentBuyer = false,
maxBidReached = false,
isCurrentSeller = false,
sellerName = "",
auctionable = false,
isDiamondItem = false,
isInTrade = false,
isOwned = false
;
var items = outfit.items;
var outfitSkinIndex = 0;
var top = true, bottom = true;
for (var i = 0, l = items.length; i < l; ++i) {
if(items[i].coversBreasts) top = false;
if(items[i].coversCrotch) bottom = false;
outfitSkinIndex = outfitSkinIndex>0?outfitSkinIndex:items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_BODY?(items[i].faceIndex+items[i].palette):0;
}
for (var i = 0, l = items.length; i < l; ++i) { // todo loop is not needed, an outfit is never on auction
var
item = items[i],
hasBack = !!item.positionBack,
isSkinByLayer = item.layer == CONSTANTS.layersv2.DOLL_LAYER_BODY,
isFaceByLayer = item.layer == CONSTANTS.layersv2.DOLL_LAYER_FACE,
isEyesByLayer = item.layer == CONSTANTS.layersv2.DOLL_LAYER_EYES;
isJd |= outfit.mannequin?outfit.jdMannequin:item.jdItem;
isGd |= item.gdItem;
isGoDesigner |= item.goDesignerItem;
// If the item is a mannequin, just use the item.palette
if(isFaceByLayer){
var faceIndex = window.inventoryController.getSkinIndex();
createImageElement(item, outfit.mannequin?outfitSkinIndex:faceIndex, false).appendTo($imgBox);
if(!outfit.mannequin) outfit.controller.setPalette(faceIndex);
}else if(isEyesByLayer && !outfit.mannequin){
createEyeImageElement(item).appendTo($imgBox);
}
else {
createImageElement(item, outfit.mannequin?item.palette:paletteId, false).appendTo($imgBox);
}
if (hasBack) {
createImageElement(item, outfit.mannequin?item.palette:paletteId, true).appendTo($imgBoxBack);
} if(isSkinByLayer) {
if(top)createImageElement(underwear[0],0,false).addClass("underwear").appendTo($imgBox);
if(bottom)createImageElement(underwear[1],0,false).addClass("underwear").appendTo($imgBox);
}
var unixTime = outfitUi._unixTime;
isCurrentBuyer = item.currentBuyer == CONSTANTS.currentAccount;
isCurrentSeller = item.seller == CONSTANTS.currentAccount;
isInTrade = item.isInTrade && isCurrentSeller;
canSeeCurrentBid = isCurrentSeller || isCurrentBuyer;
price += ((outfit.mannequin && !item.isDiamondItem()) || !outfit.mannequin)?parseInt(context.isAuction() && canSeeCurrentBid?item.origPrice:item.price):0;
diamondPrice += outfit.mannequin && item.isDiamondItem()?parseInt(context.isAuction() && canSeeCurrentBid?item.origPrice:item.price):0;
origPrice += ((outfit.mannequin && !item.isDiamondItem()) || !outfit.mannequin)?parseInt(item.origPrice):0;
origDiamondPrice += outfit.mannequin && item.isDiamondItem()?parseInt(item.origPrice):0;
quality = Math.max(item.quality, quality);
layer = item.layer;
brand = item.brand ? item.brand : brand;
isOwned = item.owned == undefined || outfit.mannequin ? false : (context.isAuction() || context.isOtherWardrobe() ? item.owned : item.owned[item.palette]);
ribbon = (item.ribbon == 5 && !isInTrade)||(item.ribbon==4&&outfit.mannequin)? ribbon : Math.max(item.ribbon, ribbon); // If it's on a mannequin, don't show the new ribbon (Miia doesn't like the blue on blue)
expires = item.expires;
var
accountMoney = outfitUi._accountMoney,
canAffordGomoney = (quality != 4?accountMoney.moneyCanAfford(price):true),
canAffordDiamonds = (quality == 4?accountMoney.diamondsCanAfford(price):true),
canAuction = item.auctionable && CONSTANTS.userTradingV2 && context.isWardrobe(),
canEdit = (item.editable && (context.isWardrobe() || context.isAuction()) && isCurrentSeller),
showExpires = (expires>0 && expires > unixTime.getUnixTime());
maxBidReached = item.maxBidReached;
discount = (origPrice+origDiamondPrice) != (price+diamondPrice) && !context.isWardrobe() && !context.isOtherWardrobe() && !context.isAuction();
isBidable = !isCurrentBuyer && !isCurrentSeller && canAffordGomoney && canAffordDiamonds && (context.isOtherWardrobe() || context.isAuction()) && price > 0 && !maxBidReached;
isWishable = item.wishable == undefined?true: context.isAuction() ? item.wishable : item.wishable[item.palette];
outOfStock = !item.inStock && (!context.isWardrobe() && !context.isOtherWardrobe() && !context.isAuction());
showPrice = price>0 && !outOfStock;
sellerName = item.sellerName;
auctionable = item.auctionable;
isDiamondItem = item.isDiamondItem();
}
$html
.addClass("man"+mannequinStyle)
.toggleClass("jd", !!isJd)
.toggleClass("gd", !!isGd)
.toggleClass("goDesigner", !!isGoDesigner)
.addClass("quality" + (outfit.mannequin?5:quality)) // If it's a mannequin, use quality5 background (blue)
.toggleClass("selected", selected)
.attr("data-layer", layer)
.find(".price").text(showPrice?price:(outOfStock && (!context.isWardrobe() || !context.isOtherWardrobe))? Wtt.get(17621):"").toggleClass("sale",discount).end()
.find(".mPrice").text(diamondPrice != 0?diamondPrice:"").css("display",diamondPrice != 0?"inline-block":"none").toggleClass("sale",discount).end()
.find(".currency.maPrice").toggleClass("disabled",diamondPrice == 0).css("display",diamondPrice != 0?"inline-block":"none").toggleClass("sale",discount).addClass("diamond").end()
.find(".currency.dPrice").toggleClass("diamond",quality == CONSTANTS.types.DIAMOND && diamondPrice == 0).toggleClass("disabled",!showPrice).toggleClass("sale",discount).end()
.find(".editButton").text((!isInTrade && price>0 && (context.isWardrobe() || (context.isAuction() && isCurrentSeller)))?Wtt.get(17623):"").toggleClass("enabled",canEdit).attr("title",canEdit?"":Wtt.get(17469)).end()
.find(".bidButton").text((!isInTrade && price>0 && (context.isOtherWardrobe() || (context.isAuction() && !isCurrentSeller )))?Wtt.get(17622):"").toggleClass("enabled",isBidable).attr("title",isCurrentBuyer?Wtt.get(17470):maxBidReached ? Wtt.get(16822) : !canAffordGomoney?Wtt.get(17471):!canAffordDiamonds?Wtt.get(17606):"").end()
.find(".origPrice").text(!discount || outOfStock ? "" : origPrice).end()
.find(".origmPrice").text(!discount || outOfStock ? "" : origDiamondPrice).css("display",(!discount || outOfStock || !showPrice || origDiamondPrice == diamondPrice)?"none":"inline-block").end()
.find(".currency.orgPrice").toggleClass("diamond",quality == CONSTANTS.types.DIAMOND && diamondPrice == 0).toggleClass("disabled",!discount || outOfStock || !showPrice).end()
.find(".currency.origmaPrice").addClass("diamond").css("display",(!discount || outOfStock || !showPrice || origDiamondPrice == diamondPrice)?"none":"inline-block").end()
.find(".quality").text(Wtt.get(QUALITY_WTTS[quality])).css("display",outfit.mannequin?"none":"block").end()
.find(".brand").text(brand).css("display",outfit.mannequin?"none":"block").end()
.find(".ribbon").addClass("ribbon" + ribbon).end()
.find(".owned").html(isOwned ? "Owned" : "").end()
.find(".expires").text(showExpires?formatExpiresTime(expires,unixTime,false):"").toggleClass("enabled",expires>0).end()
.find(".wish").toggleClass("wishable",isWishable).end()
.find(".sellerName").text(sellerName!= undefined?(Wtt.get(17620) + ": " + sellerName):"").end()
.find(".tagsButton").text(context.isWardrobe()?"Manage tags":"").toggleClass("enabled",context.isWardrobe()).end();
if(CONSTANTS.userTradingV2){
$html
.find(".auctionButton").text(!isInTrade&&(price==0 && context.isWardrobe())?Wtt.get(17624):"").toggleClass("enabled",canAuction).attr("title",!isInTrade&&!auctionable?Wtt.get(17472):"").end()
.find( ".tradeButton" ).text(!isInTrade&&(price==0 && context.isWardrobe())?Wtt.get(20602):"").toggleClass("enabled",canAuction).attr("title",!isInTrade&&!auctionable?Wtt.get(20603):"").end()
.find(".cancelButton" ).text(isInTrade&&context.isWardrobe()?Wtt.get(20615):"");
} else {
$html
.find(".auctionButton").text((price==0 && context.isWardrobe())?Wtt.get(17624):"").toggleClass("enabled",canAuction).attr("title",!auctionable?Wtt.get(17472):CONSTANTS.isMember||(CONSTANTS.auctionsForAll && !isDiamondItem)?"":Wtt.get(CONSTANTS.auctionsForAll?20098:17595)).end();
}
return $html;
}
function calculateMannequinStyle(outfit) { // Returns mannequin style integer. 0 is full mannequin, 1 is upper half, etc. See comment in inventory_css.jsp for full style list
if (outfit.mannequin)
return 0;
var items = outfit.items;
var minY = 300, maxY = 0;
for (var i = 0, l = items.length; i < l; ++i) { // Find the y coordinates the item is spanning over
var item = items[i];
var pos = item.position;
if (pos.y < minY)
minY = pos.y;
if (pos.y+pos.h > maxY)
maxY = pos.y+pos.h;
if (item.positionBack) {
var posBack = item.positionBack;
if (posBack.y < minY)
minY = posBack.y;
if (posBack.y+posBack.h > maxY)
maxY = posBack.y+posBack.h;
}
}
if (items.length==1) { // If single item is eyes/face/makeup then try to fit on head mannequin
var layer = items[0].layer;
if (layer==CONSTANTS.layersv2.DOLL_LAYER_EYES ||
layer==CONSTANTS.layersv2.DOLL_LAYER_FACE ||
layer==CONSTANTS.layersv2.DOLL_LAYER_MAKE_UP) {
if (maxY > 120)
return 0; // Full mannequin (large display)
if (maxY > 85)
return 1; // Upper half mannequin
return 5; // Head mannequin for makeup, eyes and head
}
}
if (minY > 47 && maxY <= 200)
return 4; // Middle mannequin (torso)
if (maxY <= 165)
return 1; // Upper half mannequin
if (minY > 300-165)
return 2; // Feet mannequin
if (maxY < 279 && minY >= 114)
return 3; // Lower half mannequin (legs)
return 0; // Full mannequin (large display)
}
// Constructor
var OutfitGridEntryUi = function(outfit, context, underwear, unixTime, accountMoney) {
if (!outfit) {
throw "outfit is not defined.";
}
this._outfit = outfit;
this._$element = null;
this._loaded = false;
this._underwear = underwear;
this._mannequinStyle = calculateMannequinStyle(outfit);
this._context = context;
this._accountMoney = accountMoney;
this._unixTime = unixTime;
this._setupListeners();
};
// Members
OutfitGridEntryUi.prototype = {
load: function(doneFn) {
if (this._loaded) {
if ($.isFunction(doneFn)) {
doneFn();
}
} else {
this.reload(doneFn);
}
},
reload: function(doneFn) {
this._loaded = true;
var $element = this.getElement();
var $imgs = $element.find(".itemWindow img");
var imgsLoaded = 0;
var hasFailed = false;
var onImgEvent = function() {
if (++imgsLoaded === $imgs.length) {
$element.removeClass("loading")
.toggleClass("loaded", !hasFailed).toggleClass("error", hasFailed);
if ($.isFunction(doneFn)) {
doneFn();
}
}
};
var onImgLoaded = function() {
onImgEvent();
};
var onImgError = function() {
hasFailed = true;
onImgEvent();
};
$element.addClass("loading");
$.each($imgs, function(i, img) {
var $img = $(img);
var src = $img.data("lazy-src");
var loader = new Image();
loader.onload = onImgLoaded;
loader.onerror = onImgError;
loader.onabort = onImgError;
loader.src = src;
// $img.on("load", onImgLoaded);
$img.attr("src", src);
});
},
/**
* @return a jQuery object
*/
getElement: function() {
if (!this._$element) {
this._$element = createOutfitElement(this).data("ui", this);
}
return this._$element;
},
recreateElement:function(){
var newElement = createOutfitElement(this).data("ui",this);
newElement.toggleClass("firstInRow", this._$element.hasClass("firstInRow"));
this._$element.replaceWith(newElement);
this._$element = newElement;
},
getWidth: function() {
if (!this._width) {
this._width = parseInt(this.getElement().css("width"));
}
return this._width;
},
updateAuctionTimer:function(){
var item = this._outfit.items[0];
this.getElement().find(".expires.enabled").text(formatExpiresTime(item.expires,this._unixTime,false));
},
// Todo: move to OutfitController (maybe)
updateAuction:function(price,duration,cancel,seller){
var item = this._outfit.items[0];
var context = this._context;
if(seller > 0){ // This is when the user bid on the item
item.currentBuyer = CONSTANTS.currentAccount;
item.origPrice = price; // Set the original price (the current bid) to the bid that was just made
}
else if(cancel){ // This is when it was cancelled
item.price = 0;
item.editable = false;
item.expires = 0;
item.auctionable = true;
item.ribbon = 0;
} else { // This is when it's created or edited
item.seller = CONSTANTS.currentAccount;
item.price = price;
/**
* Auctioned items under auction context are different then auction items under wardrobe content.
* Since auction items are available for all, and wardrobe items are personal, there is origPrice on auction item to indicate the current bid.
* The origPrice is what the seller sees under the Auction tab
*/
if(context.isAuction()) item.origPrice = price;
item.ribbon = 3; // 3 is auction, sorry for magic numbers Laurent.
item.editable = true;
if(!!duration && duration != 0) item.expires = this._unixTime.getUnixTime()+(duration*3600);
}
this.recreateElement();
this.reload();
},
updateTrade:function(buyer,cancel){
var item = this._outfit.items[0];
var context = this._context;
if(cancel){
item.price = 0;
item.editable = false;
item.expires = 0;
item.auctionable = true;
item.ribbon = 0;
item.isInTrade = false;
} else {
item.currentBuyer = buyer;
item.seller = CONSTANTS.currentAccount;
item.ribbon = 5;
item.editable = false;
item.auctionable = false;
item.isInTrade = true;
}
this.recreateElement();
this.reload();
},
updateFacePalette:function(faceIndex){
if(this._outfit.mannequin) return;
this._outfit.controller.setPalette(faceIndex);
// this._outfit.items[0].palette = faceIndex;
this.recreateElement();
this.reload();
},
getHeight: function() {
// Return height + top and bottom margins
return this._mannequinStyle==0 ? MANNEQUIN_SIZE_LARGE : MANNEQUIN_SIZE_SMALL;
},
refresh: function() {
var
outfitCtrl = this._outfit.controller,
items = outfitCtrl.outfit.items,
$element = this.getElement();
$element.toggleClass("selected", outfitCtrl.isSelected());
var onWishlist = context.isLoggedIn();
// Refresh images with new uiids
var selectedPalette = outfitCtrl.getPalette();
var outfitSkinIndex = 0;
$element.find(".itemImages.front img:not(.underwear)").each(function(i) {
if(items[i] != undefined){
outfitSkinIndex = outfitSkinIndex>0?outfitSkinIndex:items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_BODY?(items[i].faceIndex+items[i].palette):0;
var uiid = items[i].colors[(outfitCtrl.outfit.mannequin && items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_FACE)
?outfitSkinIndex
:(items[i].colors.length-1Owned");
} else {
$element.find(".owned").text("");
}
}
if (items[i].wishable != undefined) onWishlist = onWishlist && !items[i].wishable[selectedPalette]; // This is to ensure that this only true if all items are on your wishlist, otherwise allow for wishing.
}
});
if(!context.isAuction()) $element.find(".wish").toggleClass("wishable",!onWishlist);
$element.find(".itemImages.back img").each(function(i) {
var $item = $(this).data("item"),
uiid = $item.colors[($item.colors.length-1 paletteIndex && lockedItem.colors[paletteIndex].uiid && !lockedItem.isFace) {
correctUiid = lockedItem.colors[paletteIndex].uiid;
}
if(lockedItem.isFace && skinPalette) {
correctUiid = lockedItem.colors[skinPalette].uiid;
} else if(lockedItem.isFace && !skinPalette) {
// check basket items for the skin if no skin was locked
for(var k = 0; k < this._wornItems.length; k++) {
var wornItem = this._wornItems[k];
if(wornItem.isSkin) {
var rightPalette = wornItem.faceIndex === 0 ? wornItem.palette : wornItem.faceIndex;
correctUiid = lockedItem.colors[rightPalette].uiid;
}
}
}
var basketItem = $('.basketItem').has('.basketDiv .basketImg img[src*="/item/' + correctUiid + '"]');
var basketLockBtn = basketItem.find(".basketLockBtn");
var basketDelBtn = basketItem.find(".basketDelBtn");
basketLockBtn.addClass("locked");
basketDelBtn.addClass("disabled");
}
},
add:function(outfit){
var lockedItems = this.getLockedItems(this._items[this.context]);
for(var i = 0, l = outfit.items.length; i < l; i++){
var item = outfit.items[i];
item.selectedPalette = outfit.items.length > 1 || item.colors.length-1 < outfit.controller.getPalette()? item.palette : outfit.controller.getPalette();
item.outfit = outfit; // Add the outfit to the item, so we can deselect the outfit when the item is removed.
this._items[this.context].push(item);
this._selectedItem[this.context] = $.inArray(item, this._items[this.context]); // The added item is the selectedItem
}
this.lockItemsAgain(lockedItems);
this.events.fire();
},
removeOutfit:function(outfit){
var lockedItems = this.getLockedItems(this._items[this.context]);
var _this = this;
for(var i = 0, l = outfit.items.length; i < l; i++){
var index = _this.findIndexOfUiid(outfit.items[i].uiid);//$.inArray(outfit.items[i], this._items[this.context]);
if(index != -1) {
if(this._selectedItem[this.context] == index) this._selectedItem[this.context] = -1; // If we are removing the selected item, set the selected item to -1
if(this._selectedItem[this.context] > index) this._selectedItem[this.context]--; // If we are removing an item positioned on the list before the selected item, update the selectedItem index
this._items[this.context].splice(index,1);
}
}
this.lockItemsAgain(lockedItems);
this.events.fire();
},
// Reorders the item on oldPosition into newPosition and subsequently pushes the rest of the items.
reorderItems:function(oldPosition,newPosition){
var items = this._items[this.context];
var lockedItems = this.getLockedItems(items);
var tmp = items[oldPosition];
items.splice(oldPosition,1); // remove item we want to reorder
items.splice(newPosition,0,tmp); // insert it and push the other items
this.lockItemsAgain(lockedItems);
this.events.fire();
},
setContext:function(context){
this.context = context;
this.events.fire();
},
removeItem:function(item){
var lockedItems = this.getLockedItems(this._items[this.context]);
var index = $.inArray(item, this._items[this.context]);
if(index != -1) {
if(this._selectedItem[this.context] == index) this._selectedItem[this.context] = -1; // If we are removing the selected item, set the selected item to -1
if(this._selectedItem[this.context] > index) this._selectedItem[this.context]--; // If we are removing an item positioned on the list before the selected item, update the selectedItem index
this._items[this.context].splice(index,1);
}
this.lockItemsAgain(lockedItems);
this.events.fire();
},
findIndexOfUiid:function(uiid){
var _this = this;
for(var i = 0, l = _this._items[_this.context].length; i paletteIndex && existingItem.colors[paletteIndex].uiid && !existingItem.isFace) {
correctUiid = existingItem.colors[paletteIndex].uiid;
}
if(existingItem.isFace && skinPalette) {
correctUiid = existingItem.colors[skinPalette].uiid;
} else if(existingItem.isFace && !skinPalette) {
// check basket items for the skin if no skin was locked
for(var k = 0; k < this._wornItems.length; k++) {
var wornItem = this._wornItems[k];
if(wornItem.isSkin) {
var rightPalette = wornItem.faceIndex === 0 ? wornItem.palette : wornItem.faceIndex;
correctUiid = existingItem.colors[rightPalette].uiid;
}
}
}
var basketItem = $('.basketItem').has('.basketDiv .basketImg img[src*="/item/' + correctUiid + '"]');
var basketLockBtn = basketItem.find(".basketLockBtn");
if (basketLockBtn.length && basketLockBtn.hasClass('locked')) {
lockedItems.push(existingItem);
}
}
return lockedItems;
},
lockItemsAgain:function(items) {
setTimeout(function () {
var skinPalette;
for(var i = 0; i < items.length; i++) {
var item = items[i];
if(item.isSkin) {
skinPalette = item.faceIndex === 0 ? item.palette : item.faceIndex;
}
}
for (var j = 0; j < items.length; j++) {
var keptItem = items[j];
var paletteIndex = keptItem.palette;
var correctUiid = keptItem.uiid;
if (keptItem.colors && keptItem.colors.length > paletteIndex && keptItem.colors[paletteIndex].uiid && !keptItem.isFace) {
correctUiid = keptItem.colors[paletteIndex].uiid;
}
if(keptItem.isFace && skinPalette) {
correctUiid = keptItem.colors[skinPalette].uiid;
} else if(keptItem.isFace && !skinPalette) {
// check basket items for the skin if no skin was locked
for(var k = 0; k < this._wornItems.length; k++) {
var wornItem = this._wornItems[k];
if(wornItem.isSkin) {
var rightPalette = wornItem.faceIndex === 0 ? wornItem.palette : wornItem.faceIndex;
correctUiid = keptItem.colors[rightPalette].uiid;
}
}
}
var keptBasketItem = $('.basketItem').has('.basketDiv .basketImg img[src*="/item/' + correctUiid + '"]');
var keptBasketLockBtn = keptBasketItem.find(".basketLockBtn");
var keptBasketDelBtn = keptBasketItem.find(".basketDelBtn");
if (keptBasketLockBtn.length) {
keptBasketLockBtn[0].classList.add("locked");
keptBasketDelBtn[0].classList.add("disabled");
}
}
}, 5); //needs this timeout or else it's "too fast" and wont relock items.
},
getBasketCount:function(){
return this._items[this.context].length;
},
getItems:function(){
return this._items[this.context];
},
setSelectedItem:function(selected){
this._selectedItem[this.context] = selected;
},
getSelectedItem:function(){
return this._selectedItem[this.context];
}
};
return function(wornClothing, lockedItems) {
return new Basket(wornClothing, lockedItems);
};
})();var createBasketUi = (function(){
var BasketUi = function($basket, avatarItems, primordalItems){
this.basket = null;
this._$basket = $basket;
this._$list = $basket.find(".outfitList ul");
this._$totals = $basket.find(".outfitTotalPrice");
this._$tools = $basket.find(".outfitTools");
this._$scroll = $basket.find(".outfitList .scrollpane");
this._inventoryController = null;
this.context = 0;
this.accountMoney = null;
this.skinIndex = 0
this.eyeIndex = 0;
this.avatarItems = avatarItems;
this.primordalItems = primordalItems;
};
BasketUi.prototype = {
refresh: function(){
var
$basket = this._$basket,
$list = this._$list,
$totals = this._$totals,
$tools = this._$tools,
uis = [],
items = this.basket.getItems();
var currentSkin = null,
currentFace = null,
primordal = this.primordalItems,
avatarItems = this.avatarItems;
for (var i = items.length-1; i >= 0; i--){
if (items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_BODY && !currentSkin) currentSkin = items[i];
if (items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_FACE && !currentFace) currentFace = items[i];
}
if(this.context != 1){
if(!currentSkin){
for (var i = avatarItems.length-1; i >= 0; i--){
if (avatarItems[i].layer == CONSTANTS.layersv2.DOLL_LAYER_BODY && !currentSkin) currentSkin = avatarItems[i];
if (avatarItems[i].layer == CONSTANTS.layersv2.DOLL_LAYER_FACE && !currentFace) currentFace = avatarItems[i];
}
}
if(!currentSkin){
for (var i = primordal.length-1; i >= 0; i--){
if (primordal[i].layer == CONSTANTS.layersv2.DOLL_LAYER_BODY && !currentSkin) currentSkin = primordal[i];
if (primordal[i].layer == CONSTANTS.layersv2.DOLL_LAYER_FACE && !currentFace) currentFace = primordal[i];
}
}
}
this.skinIndex = currentSkin?currentSkin.faceIndex + currentSkin.palette:0;
this.eyeIndex = currentFace?currentFace.eyeIndex:0;
for (var i = items.length-1; i >= 0; i--){
var ui = createBasketEntryUi(items[i],i==this.basket.getSelectedItem(),this);
uis.push(ui.getElement());
}
$list.empty();
$list.append.apply($list,uis);
$basket.toggleClass("basketClear", items.length === 0);
var goMoney = 0, diamonds = 0;
for(var i = 0, l = items.length; i"];
for (var i = 0; i < colorCount; ++i) {
if (i > 0 && i % lineLength === 0) {
html.push("
");
}
var color = colors[i];
html.push("");
}
html.push("
");
return html.join("");
},
getHtml:function(){
var item = this.item,
palette = item.layer == CONSTANTS.layersv2.DOLL_LAYER_FACE?(this.basket.skinIndex):(!!item.selectedPalette?item.selectedPalette:item.palette),
uiid = (item.layer == CONSTANTS.layersv2.DOLL_LAYER_EYES?item.eyeShapes[this.basket.eyeIndex].uiid : palette >= item.colors.length ? "" : item.colors[palette]["uiid"]),
sdnPrefix = uiid[0],
src = "/item/" + uiid,
img = $(" ").append($("
").attr("src",src)),
delBtn = $("").addClass("basketDelBtn"),
// color = $(this.createColorPicker()),//$("").addClass("basketPalette").css("background-color","#" + item.colors[palette]["hex"]),
price = $("").text(this.basket.context!=1 && this.basket.context!=3?item.inStock?item.price:Wtt.get(17621):"").addClass("basketPrice").append(""),
$html = $("").addClass("basketItem").data("ui",this),
lockBtn = $("").addClass("basketLockBtn").attr("title", Wtt.get(21295));
$html
.find(".basketDiv")
.append(img)
.append(delBtn)
.append(lockBtn)
// .append(color)
.append(price)
.addClass("quality" + item.quality)
.find(".currency").toggleClass("diamond",item.quality == CONSTANTS.types.DIAMOND);
if(this.selected) $html.find(".basketDiv").addClass("basketSelected");
if(this.basket.context !== "1") {
$html.find(".basketLockBtn").remove();
} else {
$html.find(".basketDelBtn").css("margin", "5px 3px 0");
}
if (lockBtn.hasClass("locked")) {
$html.find(".basketDelBtn").remove();
}
return $html;
}
};
return function(item,selected,basket){
return new BasketEntryUi(item,selected,basket);
};
})();var createAvatarUi = (function(){
var AvatarUi = function($box, defaultItems, primordalItems){
this._$box = $box;
this.basket = null;
this.defaultItems = defaultItems;
this.primordalItems = primordalItems;
this.context = 0;
this.skinIndex = undefined;
this.eyeIndex = 0;
};
AvatarUi.prototype = {
refresh: function(){
var $box = this._$box,
skin = true,face = true,top = true,bottom=true,eyes=true,hair=true,
currentSkin = null,
currentFace = null,
_this = this;
$box.find(".backElements").empty();
$box.find(".frontElements").empty();
var items = this.basket.getItems();
for (var i = 0, l = items.length; i < l; i++){ // First run through basket and check which default items needs to be drawn
if(items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_EYES) eyes = false;
if(items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_FACE) {
face = false;
currentFace = items[i];
}
if(items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_BODY) {
skin = false;
currentSkin = items[i];
}
if(items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_HAIR_BACK || items[i].layer == CONSTANTS.layersv2.DOLL_LAYER_HAIR_JD) hair = false;
if(items[i].coversBreasts) top = false;
if(items[i].coversCrotch) bottom = false;
}
if(this.context != 1){
var defaults = this.defaultItems;
for (var i = 0, l = defaults.length; i Use Avatar Items
for (var i = 0, l = defaults.length; i Use Primordal Items
for (var i = 0, l = primordal.length; i").css({position:"absolute",left:pos.x,top:pos.y,width:pos.w,height:pos.h,zIndex:this._index,backgroundImage:'url('+src+')'});
},
getFaceElementHtml:function(index){
var item = this._item,
palette = this.skinIndex != undefined ?this.skinIndex:item.palette,
uiid = item.colors[palette]["uiid"],
sdnPrefix = uiid[0],
src = "/item/" + uiid,
pos = item.position;
return $("").css({position:"absolute",left:pos.x,top:pos.y,width:pos.w,height:pos.h,zIndex:50,backgroundImage:'url('+src+')'});
},
getBackElementHtml:function(index){
var item = this._item,
palette = !!item.selectedPalette?item.selectedPalette:item.palette,
uiid = item.colors[palette]["uiid"],
sdnPrefix = uiid[0],
src = "/item/" + uiid,
pos = item.position;
return $("").css({position:"absolute",left:pos.x,top:pos.y,width:pos.w,height:pos.h,zIndex:50,backgroundImage:'url('+src+')'});
},
getFrontElementHtml:function(){
var item = this._item,
palette = !!item.selectedPalette?item.selectedPalette:item.palette,
uiid = item.colors[palette]["uiid"],
sdnPrefix = uiid[0],
src = "/item/" + uiid,
pos = item.position;
return $("").css({position:"absolute",left:pos.x,top:pos.y,width:pos.w,height:pos.h,zIndex:100,backgroundImage:'url('+src+')'});
},
getEyeElementHtml: function() {
var item = this._item,
uiid = item.eyeShapes[this.eyeIndex].uiid,
sdnPrefix = uiid[0],
src = "/item/" + uiid,
pos = item.eyeShapes[this.eyeIndex].position;
return $("").css({position:"absolute",left:pos.x,top:pos.y,width:pos.w,height:pos.h,zIndex:51,backgroundImage:'url('+src+')',backgroundRepeat: 'no-repeat'});
}
};
return function(item,$box,i,skinIndex,eyeIndex){
var avatar = new AvatarEntryUi(item,$box,i,skinIndex,eyeIndex);
avatar.appendItem();
};
})();window.Wtt = window.Wtt || {
get: function(wttId) {
return this[wttId].wtt;
},
getJsFriendly: function(wttId) {
return this[wttId].wttJsFriendly;
},
install: function(wtts,javafriendlyWtts) {
for (var id in wtts) {
this[id] = {};
this[id].wtt = wtts[id];
this[id].wttJsFriendly = javafriendlyWtts[id]
}
}
};window.createEventManager = (function() {
var Event = function(manager, name) {
this.name = name;
this._manager = manager;
this._listeners = [];
};
Event.prototype = {
listen: function(fn) {
if (!$.isFunction(fn)) {
throw "fn is not a function.";
}
this._listeners.push(fn);
},
fire: function(args) {
args = args || {};
args.name = this.name;
var ls = this._listeners;
for (var i = 0, l = ls.length; i < l; ++i) {
ls[i](args);
}
this._manager.fire(args);
}
};
var EventManager = function(eventNames) {
for (var n in eventNames) {
this[n] = new Event(this, n);
}
this._listeners = [];
};
EventManager.prototype = {
/**
* Listen to all events
* @param fn
*/
listen: function(fn) {
if (!$.isFunction(fn)) {
throw "fn is not a function.";
}
this._listeners.push(fn);
},
fire: function(args) {
var ls = this._listeners;
for (var i = 0, l = ls.length; i < l; ++i) {
ls[i](args);
}
}
};
return function(eventNames) {
return new EventManager(eventNames);
};
})();var log = (function() {
var logMsg = function(type, msg) {
if (window.console && typeof window.console[type] === "function") {
window.console[type](msg);
}
};
return {
debugEnabled:false,
info: function(msg) {
logMsg("info", msg);
},
debug: function(msg) {
if (this.debugEnabled) {
logMsg("debug", msg);
}
},
error: function(msg) {
logMsg("error", msg);
}
}
})();(function() {
var InfinityList = function($scrollElement, $listContainer, itemProducer, eventName, getScrollTopFn) {
this._$scroll = $scrollElement;
this._$list = $listContainer;
this._producer = itemProducer;
this._lastPos = 0;
this._viewHeight = $scrollElement.height();
this._contentHeight = this._viewHeight * 6;
this.updateDeltaDistance = this._viewHeight;
// Prepare content in $listContainer.
this._$spacer = $("").css({"position": "relative", "width": "100%", "height": 0}).appendTo($listContainer);
this._$content = $("").css({"position": "absolute", "width": "100%"}).appendTo($listContainer);
// Set up events.
var self = this;
eventName = eventName || "scroll";
this._getScrollTop = getScrollTopFn || function() {
return $(this).scrollTop();
};
var updateTimerId = null;
$scrollElement.on(eventName, function(event) {
if (updateTimerId) {
clearTimeout(updateTimerId)
}
// update could be a long process, so set it on a small timeout to allow other stuff to execute first, like moving the avatar down..
updateTimerId = setTimeout(function() {
self.update();
}, 10);
});
this.update(true);
};
InfinityList.prototype = {
update: function(updateContent) {
var
lastPos = this._lastPos,
$scroll = this._$scroll,
$list = this._$list,
updateDelta = this.updateDeltaDistance,
scrollTop = this._getScrollTop.call($scroll);
// Only update the content if we've scrolled past the delta
updateContent = updateContent || Math.abs(scrollTop - lastPos) > updateDelta;
// if (window.console && window.console.info) {
// window.console.info("scrollTop " + scrollTop + ", updateDelta " + updateDelta + ", updateContent " + updateContent);
// }
if (updateContent) {
scrollTop = Math.floor(scrollTop / updateDelta) * updateDelta;
var
$content = this._$content,
$spacer = this._$spacer,
producer = this._producer,
listTotalHeight = producer.getTotalHeight(),
viewHeight = this._viewHeight,
contentHeight = this._contentHeight,
topMargin = Math.max(0, Math.min(listTotalHeight - contentHeight, Math.max(0, scrollTop - contentHeight / 2 - (viewHeight / 2)))),
contentWidth = $content.width(),
bottomMargin = listTotalHeight - topMargin - contentHeight;
if (bottomMargin >= 0 || topMargin === 0) {
producer.getItems(topMargin, contentHeight, contentWidth, function(producerResult) {
var $items = producerResult.items;
topMargin = producerResult.topMargin || topMargin;
$content.css("top", topMargin).children().detach();
if ($.isArray($items)) {
$.fn.append.apply($content, $items);
} else {
$content.append($items);
}
$spacer.height(producer.getTotalHeight());
});
}
this._lastPos = scrollTop;
$list.trigger("infinityListUpdate");
}
},
replaceContent: function($html){
var $content = this._$content;
$content.empty();
$content.append($html);
}
};
/**
*
* @param $listContainer
*/
window.createInfinityList = function($scrollElement, $listContainer, itemProducer, eventName, getScrollTopFn) {
return new InfinityList($scrollElement, $listContainer, itemProducer, eventName, getScrollTopFn);
};
})();
log.debugEnabled = false;
var QUALITY_WTTS = {"0":15841,"1":10510,"2":10511,"3":15840,"4":16058};
window.Wtt.install({"7526":"Shops","7533":"Wardrobe","10478":"Wish list","15837":"Auctions and trades","17430":"delete","17469":"You can't edit this auction - somebody has already bid on it","17470":"You have already bid on this item","17471":"You don't have enough goMoney to bid on this item","17472":"This item can never be auctioned","17606":"You don't have enough Diamonds to bid on this item","17607":"You don't have enough goMoney and Diamonds to buy these items. Please remove some items from your basket and try again.","17595":"Only VIPs can auction items","17567":"You do not have enough Diamonds to complete the purchase. Please remove Diamond items from your basket and try again.","17568":"You don't have enough goMoney to buy these items. Please remove some items from your basket and try again.","8750":"You must be logged in to use this feature.","8511":"An error has occurred. Please try again later.","10552":"Buy cancelled - not enough goMoney!","17608":"Your new look was saved. You are ready to go and show it off. :)","16653":"Are you sure you want to delete this item from your wardrobe? You can't get it back.","16901":"Are you sure you want to bid $PRICE$?","17618":"Gift","17620":"Seller","17621":"Out of stock","17622":"bid","17623":"edit","17624":"Auction","20067":"Are you sure you want to buy these items?","20066":"Some of the items you tried to buy are no longer available.","20076":"You still need something to cover your chest!","20077":"You still need something to cover your crotch!","20074":"You're wearing too many items! You can wear $MAX_ITEMS$ items - if you remove $NUM_ITEMS$ items, you're good to go! :)","20075":"You're wearing too many items! You can wear $MAX_ITEMS$ items - if you remove $NUM_ITEMS$ item, you're good to go! :)","20098":"Only VIP's can auction Diamond items","20159":"Wanna know more about auctions? Check the help page.","20182":"Are you sure you want to bid $PRICE$ Diamonds?","20183":"You don't have any bids","20184":"Check out auctions and place a bid! :)","20185":"You're not auctioning anything","20186":"To start an auction, find the item in your wardrobe and click \"auction\". :)","20187":"To start an auction, find the item in your wardrobe and click \"auction\". Remember that you can only start one auction a day!","20188":"Are you sure you want to bid $PRICE$ goMoney?","20205":"Are you sure you want to cancel this auction? Even a cancelled auction counts as your daily auction.","20206":"Are you sure you want to cancel this auction?","16822":"Oops! Items can't get more expensive than this. You can't bid on this item anymore!","20602":"Trade","20603":"This item can never be traded","20615":"Cancel trade","20616":"Are you sure you want to cancel this trade? Even a cancelled trade counts towards your daily limit.","20617":"Are you sure you want to cancel this trade?","20686":"Oops! You have to be level 6 or above to trade items.
\r\nYou can get more fame for example from games and greetings.
","21295":"Lock this item to prevent it being removed when using \"remove all\"","15840":"Basic","15841":"Good","10510":"Special","10511":"Unique","16058":"Diamond"}, {"7526":"Shops","7533":"Wardrobe","10478":"Wish list","15837":"Auctions and trades","17430":"delete","17469":"You can\\'t edit this auction - somebody has already bid on it","17470":"You have already bid on this item","17471":"You don\\'t have enough goMoney to bid on this item","17472":"This item can never be auctioned","17606":"You don\\'t have enough Diamonds to bid on this item","17607":"You don\\'t have enough goMoney and Diamonds to buy these items. Please remove some items from your basket and try again.","17595":"Only VIPs can auction items","17567":"You do not have enough Diamonds to complete the purchase. Please remove Diamond items from your basket and try again.","17568":"You don\\'t have enough goMoney to buy these items. Please remove some items from your basket and try again.","8750":"You must be logged in to use this feature.","8511":"An error has occurred. Please try again later.","10552":"Buy cancelled - not enough goMoney!","17608":"Your new look was saved. You are ready to go and show it off. :)","16653":"Are you sure you want to delete this item from your wardrobe? You can\\'t get it back.","16901":"Are you sure you want to bid $PRICE$?","17618":"Gift","17620":"Seller","17621":"Out of stock","17622":"bid","17623":"edit","17624":"Auction","20067":"Are you sure you want to buy these items?","20066":"Some of the items you tried to buy are no longer available.","20076":"You still need something to cover your chest!","20077":"You still need something to cover your crotch!","20074":"You\\'re wearing too many items! You can wear $MAX_ITEMS$ items - if you remove $NUM_ITEMS$ items, you\\'re good to go! :)","20075":"You\\'re wearing too many items! You can wear $MAX_ITEMS$ items - if you remove $NUM_ITEMS$ item, you\\'re good to go! :)","20098":"Only VIP\\'s can auction Diamond items","20159":"Wanna know more about auctions? Check the help page.","20182":"Are you sure you want to bid $PRICE$ Diamonds?","20183":"You don\\'t have any bids","20184":"Check out auctions and place a bid! :)","20185":"You\\'re not auctioning anything","20186":"To start an auction, find the item in your wardrobe and click \\\"auction\\\". :)","20187":"To start an auction, find the item in your wardrobe and click \\\"auction\\\". Remember that you can only start one auction a day!","20188":"Are you sure you want to bid $PRICE$ goMoney?","20205":"Are you sure you want to cancel this auction? Even a cancelled auction counts as your daily auction.","20206":"Are you sure you want to cancel this auction?","16822":"Oops! Items can\\'t get more expensive than this. You can\\'t bid on this item anymore!","20602":"Trade","20603":"This item can never be traded","20615":"Cancel trade","20616":"Are you sure you want to cancel this trade? Even a cancelled trade counts towards your daily limit.","20617":"Are you sure you want to cancel this trade?","20686":"Oops! You have to be level 6 or above to trade items.
\\nYou can get more fame for example from games and greetings.
","21295":"Lock this item to prevent it being removed when using \\\"remove all\\\"","15840":"Basic","15841":"Good","10510":"Special","10511":"Unique","16058":"Diamond"});
var TIME_WTTS = ['h','min'];
// Init of CONSTANTS.layersv2
CONSTANTS.layersv2.DOLL_LAYER_TOPS = 4;
CONSTANTS.layersv2.DOLL_LAYER_DRESSES = 15;
CONSTANTS.layersv2.DOLL_LAYER_JACKET = 8;
CONSTANTS.layersv2.DOLL_LAYER_SKIRTS = 3;
CONSTANTS.layersv2.DOLL_LAYER_PANTS = 16;
CONSTANTS.layersv2.DOLL_LAYER_SWIMWEAR = 17;
CONSTANTS.layersv2.DOLL_LAYER_JEWELRY = 10;
CONSTANTS.layersv2.DOLL_LAYER_HATS = 12;
CONSTANTS.layersv2.DOLL_LAYER_BAGS = 6;
CONSTANTS.layersv2.DOLL_LAYER_GLASSES = 11;
CONSTANTS.layersv2.DOLL_LAYER_OTHER = 18;
CONSTANTS.layersv2.DOLL_LAYER_HAIR_BACK = 1;
CONSTANTS.layersv2.DOLL_LAYER_MAKE_UP = 9;
CONSTANTS.layersv2.DOLL_LAYER_BODY = 0;
CONSTANTS.layersv2.DOLL_LAYER_EYES = 14;
CONSTANTS.layersv2.DOLL_LAYER_FACE = 2;
CONSTANTS.layersv2.DOLL_LAYER_HAIR_JD = 19;
// Init of CONSTANTS.types
CONSTANTS.types.POOR = 3;
CONSTANTS.types.NORMAL = 0;
CONSTANTS.types.SPECIAL = 1;
CONSTANTS.types.UNIQUE = 2;
CONSTANTS.types.DIAMOND = 4;
// Init
CONSTANTS.values.MAX_WORN_ITEMS = 30;
// todo should be moved to context
CONSTANTS.currentAccount = 0;
CONSTANTS.isMember = false;
CONSTANTS.auctionsForAll = true;
CONSTANTS.userTradingV2 = true;
CONSTANTS.validated = false;
CONSTANTS.modellevel = 0
CONSTANTS.queryTypes.MY_AUCTIONS = 28;
CONSTANTS.queryTypes.MY_BIDS = 30;
var context = {
context: 6,
isShop: function() {
return this.context == 0;
},
isWardrobe: function() {
return this.context == 1;
},
isWishlist: function() {
return this.context == 2;
},
isAuction: function() {
return this.context == 3;
},
isOtherWardrobe:function(){
return this.context == 4;
},
isOtherWishlist:function(){
return this.context == 5;
},
isFrontpage:function(){
return this.context == 6;
},
showDelete: function() {
return this.isWardrobe() || this.isWishlist();
},
setContext: function(context) {
this.context = context;
},
showOriginalPrice: function() {
return this.isShop() || this.isWishlist();
},
isUserEmployee : function() {
return false;
},
isUserAdmin : function() {
return false;
},
getStagingServerUrl: function() {
return "staging.gosupermodel.com";
},
isLoggedIn: function() {
return false;
},
myTags : []
};
window.preferences = {
showPreview:true,
sortTagsAlph:false,
searchTagSpecific:false
};
var accountMoney = {
money : -1,
diamonds : -1,
voucher : -1,
moneyCanAfford:function(price){
if(this.money == -1) return true; // User is not logged in, so we don't want the price to turn up red.
return price <= this.money;
},
diamondsCanAfford:function(price){
if(this.diamonds == -1) return true; // User is not logged in, so we don't want the price to turn up red.
return price <= this.diamonds;
},
voucherCanAfford:function(price){
if(this.voucher == -1) return true;
return price <= this.voucher + this.money;
},
deductMoney:function(delta){
this.money -= delta;
},
deductDiamonds:function(delta){
this.diamonds -= delta;
},
deductVoucher:function(delta){
this.voucher -= delta;
}
};
var unixTime = {
initTimestamp : new Date().getTime() / 1000,
serverTime: 1752204748,
getUnixTime:function(){
var now = new Date().getTime() / 1000;
return this.serverTime + (now-this.initTimestamp);
},
getDateTimeFormatted:function(time){
var date = new Date(time*1000);
return ''+date.getDate()+'/'+date.getMonth()+' - ' + date.getHours() + ":"+ date.getMinutes() + ':'+date.getSeconds();
}
};
$(document).ready(function() {
$('#avatarSlider').tinyscrollbar({size:242, sizethumb:34});
var isMobile = isMobileDevice();
if (isMobile) {
$.getScript("/scripts/iscroll/iscroll.js").done(function() {
var
$scroll = $(".outfitList .scrollpane"),
iscroll = new iScroll($scroll.get(0), {
hideScrollbar: false,
hScrollbar: false,
useTranslateZ: false
});
$scroll.data("iScroll", iscroll);
});
} else {
$.getScript("/scripts/jquery/jquery.jscrollpane.min.js").done(function() {
$(".outfitList .scrollpane").jScrollPane({
animateScroll: true
});
});
}
$("body").on("click", ".dropdown", function() {
var $this = $(this);
$(this).toggleClass("active");
$(".dropdown").not($this).removeClass("active");
});
// Init dropdowns and checkboxes
$(".inventory")
.on("click", ".dropdown li", function(e) {
$(this).addClass("selected").siblings(".selected").removeClass("selected");
})
.on("click", ".checkbox:not(.disabled)", function(e) {
var $this = $(this);
if ($this.siblings(".checkbox.selected:not(.disabled)").length > 0) {
$this.toggleClass("selected");
}
});
var $bannerHtml = $("");
var inventoryController = createInventoryController(
$(".inventory"),
createInventoryDao(),
createOutfitGridUi($(window), $(".itemGrid"), context,[{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"mJabzu_ljpEqlEyPkArAn","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":false,"coversBreasts":true,"eyeIndex":0,"position":{"h":34,"w":37,"x":36,"y":72},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"mJabzu_ljpEqlEyPkArAn","hex":"ffffff"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":4},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"cWSc2u4-P-0PyG9BYzXbh","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":true,"coversBreasts":false,"eyeIndex":0,"position":{"h":28,"w":41,"x":25,"y":121},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"cWSc2u4-P-0PyG9BYzXbh","hex":"000080"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":16}],unixTime,accountMoney, $bannerHtml),
createAvatarUi($(".avatar"),[{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":true,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"DwMmJlciCqPXmBiiArsCx","ribbon":0,"origPrice":299,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":45,"w":35,"x":35,"y":24},"quality":2,"price":299,"userDesignItem":false,"colors":[{"uiid":"DwMmJlciCqPXmBiiArsCx","hex":"f6d6b0"},{"uiid":"RoK3zIgk5LZoFgFR2mp5o","hex":"e9bb7f"},{"uiid":"gO2oqZxuSeycdG4xaMlal","hex":"d7a145"},{"uiid":"mlWxGxMCGaJBmJo2I0Irb","hex":"d2910f"},{"uiid":"pbGaCYIONFh8jgUHGZoRe","hex":"955e16"},{"uiid":"tyLcMwJe_Fg2N-HacCD5Y","hex":"7a5722"},{"uiid":"f6PCyY-hymbfZ8ReRxgHz","hex":"734a2b"},{"uiid":"5Rb800j0R551Zw98N_yUy","hex":"432304"},{"uiid":"a15HBOGPsZWN7nGm8eo-X","hex":"f7e7d4"},{"uiid":"WJshk2A4Fsd6pWfNDl2rh","hex":"ecd1ae"},{"uiid":"AQfyRKp3pZZoF8hD4G_RV","hex":"2ce2ab"},{"uiid":"zlm1HMDybJqMVPBcGx0C_","hex":"3b59bd"},{"uiid":"Aq3TLZ8TDtW7ydf2IlUBo","hex":"6016d0"},{"uiid":"DZc-jdZptatXW2pfJkJGf","hex":"58e94e"},{"uiid":"TGiQXvM5JfxTWNkCZnUfb","hex":"e4ad40"},{"uiid":"hidMypO4cm41b4-5qBd9P","hex":"fcd9a5"},{"uiid":"u__Mt8dNa2KiqbqVwrj5D","hex":"763d12"},{"uiid":"nHBXbjoz6A1Elpmjz7TZC","hex":"000000"},{"uiid":"FUd8dNow05LDm3Amh2UgX","hex":"f7d7b7"},{"uiid":"dBdQxL-gPYE8ncf7HPMBj","hex":"000000"},{"uiid":"jdqYOG7hdAayIHfiMmRlU","hex":"902df3"},{"uiid":"YwfmZA4D5Cd8HN3TZc_La","hex":"a42fb6"},{"uiid":"d3RE7xI-hOfN3uTjZdhxU","hex":"e444ef"},{"uiid":"vEehgyepQsCMJTR9tllXb","hex":"fa7923"},{"uiid":"hidMQpOdcm41b0fQocOyC","hex":"f2c738"},{"uiid":"TGiQcvMeJfxTWFnP0YWNY","hex":"149db9"},{"uiid":"VOcS5KKVex26Zmf8jeaS_","hex":"000000"},{"uiid":"c60VeVJ4yB8ZqvFm4jZkV","hex":"000000"},{"uiid":"_UH-EFnxCjXjwK0r_ZVqq","hex":"808000"},{"uiid":"n_rVOkSl-PPTZO4vS6dut","hex":"723b05"},{"uiid":"LLARQOdCjXEMmvy90H-Px","hex":"000000"},{"uiid":"tyLccwJ5_Fg2Nf-CECiHK","hex":"000000"},{"uiid":"NNGXICIzib6Bl-1q9C-Cg","hex":"00ff00"},{"uiid":"11a3jo_7bbgkvVkIikQdf","hex":"e589cd"},{"uiid":"5dxcyblN8p8MF_IZg_r3S","hex":"e68aa0"},{"uiid":"vcj416YNd6yrR2yHq5Wo9","hex":"e6a38a"},{"uiid":"5IJjDzKTVDIuV69xMY1Z9","hex":"e6d18a"},{"uiid":"IbdvDfDX3EUPboppL91LA","hex":"cee68a"},{"uiid":"hmhn3cbB_HiVxBJS4wMRD","hex":"a0e68a"},{"uiid":"T84aMSSnJwGViFR4E1ho5","hex":"8ae6a3"},{"uiid":"5tlfrpaRRheujhI5CknSw","hex":"8ae6d1"},{"uiid":"uyIo0sN1BGegMlhcc4Qf_","hex":"8acee6"},{"uiid":"BK44ptqe1XEIvV9E-Z-8X","hex":"8aa0e6"},{"uiid":"ExbZtFWfpCgRFDHMDbw2C","hex":"a38ae6"},{"uiid":"W7OVAK9eZgVqQ5ShCXkZk","hex":"d18ae6"},{"uiid":"7X-SodEUiXsg6lhhNXawF","hex":"e6e6e6"},{"uiid":"0yhS8WlTWVDl3dyIrdCDQ","hex":"abcdd1"},{"uiid":"LE92nls3-lPRMXtpl2hEL","hex":"acbbd2"},{"uiid":"KxXBNSNDy8AfQXbH3brA9","hex":"b0acd2"},{"uiid":"k_94fslwIln4dAlJQ5kOv","hex":"c3acd2"},{"uiid":"a23vMywndD1JG527xtsCs","hex":"d2acce"},{"uiid":"iAGbxHjWClgDghAwg63ty","hex":"d2acbb"},{"uiid":"l9sdviC9MD61EXeII-w3I","hex":"d2b0ac"},{"uiid":"oRjwn33pQhUf9MQoNTw4Q","hex":"d2c3ac"},{"uiid":"dZf0ThzwO6XBdN28N3GRH","hex":"ced2ac"},{"uiid":"Qeybv0FJy7A8-jH1F_I8u","hex":"bbd2ac"},{"uiid":"chHOSrCT1_NXfLIMo6MSS","hex":"acd2b0"},{"uiid":"4A87lXtZkFLQSidgipn6o","hex":"acd2c3"},{"uiid":"chtjxuS_QrkdoLIMo6MSS","hex":"d2d2d2"},{"uiid":"DiMBOKtjPiDr_Sj3jTJrU","hex":"000000"},{"uiid":"9CYeSZ-f3vQUZ1iB_woT6","hex":"000000"},{"uiid":"zUuHtdpQnpYQmaFPUuF9f","hex":"000000"},{"uiid":"aFei_A6UpPI3X5ZM5dCD_","hex":"000000"},{"uiid":"TElCVKJRPSLVdK9jfDL-L","hex":"000000"},{"uiid":"Sytns-lKmtlNq0rScd7Ks","hex":"000000"},{"uiid":"oFRYUPFALykhU8-cAOQ7-","hex":"000000"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":2},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":true,"jdItem":false,"gdItem":false,"uiid":"gO39g30DYjwA_G4xaMlal","ribbon":0,"origPrice":10,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":206,"w":119,"x":7,"y":69},"quality":2,"price":10,"userDesignItem":false,"colors":[{"uiid":"gO39g30DYjwA_G4xaMlal","hex":"f6d6b0"},{"uiid":"R7i8qkFaB96uUrIHOgBrl","hex":"e9bb7f"},{"uiid":"-AsqPMq_6QOZNgTzaYbL2","hex":"d7a145"},{"uiid":"_RSahbedhxuwMjvU1PvRT","hex":"d2910f"},{"uiid":"XvUapTjVZtpF_7IG1RTjQ","hex":"955e16"},{"uiid":"RoCgr0BN1tk1dgFR2mp5o","hex":"7a5722"},{"uiid":"lQD6gVXnyA1uZ_QX7-HfB","hex":"734a2b"},{"uiid":"4L-yQgYK_ohZwoCmqx9lJ","hex":"432304"},{"uiid":"LM69a1hWSOhZwChr0O_fo","hex":"f7e7d4"},{"uiid":"NlThxYxb8ZBt_krQnk5S5","hex":"ecd1ae"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":0},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"B_UnBpxcJfWkVao0VRryz","positionBack":{"h":103,"w":25,"x":23,"y":25},"ribbon":0,"origPrice":4,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":57,"w":43,"x":30,"y":18},"quality":4,"price":4,"userDesignItem":false,"colors":[{"backuiid":"B_UnBpxcJfWkVao0VRryz","uiid":"Q4X-fnCy-7QSMI2StuUbd","hex":"f5edd7"},{"backuiid":"2KmeyALMLjRongXwbv8aI","uiid":"7-TErcMCX93uh7P16EBUA","hex":"e64117"},{"backuiid":"Zj2NW9gXnSLOUbAGZ_WQa","uiid":"Rs2x7W76T6G0c8K52QxFp","hex":"f5d65a"},{"backuiid":"PvRNXqJo4wZexgUySMK5H","uiid":"_rbF8flctFxhj4f3tTv2X","hex":"552910"},{"backuiid":"HmkYR8gjeujErZrZfjNCW","uiid":"IMFwMLLOf17OzaGkBjJiu","hex":"171b41"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":1},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"mJabzu_ljpEqlEyPkArAn","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":false,"coversBreasts":true,"eyeIndex":0,"position":{"h":34,"w":37,"x":36,"y":72},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"mJabzu_ljpEqlEyPkArAn","hex":"ffffff"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":4},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"cWSc2u4-P-0PyG9BYzXbh","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":true,"coversBreasts":false,"eyeIndex":0,"position":{"h":28,"w":41,"x":25,"y":121},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"cWSc2u4-P-0PyG9BYzXbh","hex":"000080"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":16}],[{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":true,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"DwMmJlciCqPXmBiiArsCx","ribbon":0,"origPrice":299,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":45,"w":35,"x":35,"y":24},"quality":2,"price":299,"userDesignItem":false,"colors":[{"uiid":"DwMmJlciCqPXmBiiArsCx","hex":"f6d6b0"},{"uiid":"RoK3zIgk5LZoFgFR2mp5o","hex":"e9bb7f"},{"uiid":"gO2oqZxuSeycdG4xaMlal","hex":"d7a145"},{"uiid":"mlWxGxMCGaJBmJo2I0Irb","hex":"d2910f"},{"uiid":"pbGaCYIONFh8jgUHGZoRe","hex":"955e16"},{"uiid":"tyLcMwJe_Fg2N-HacCD5Y","hex":"7a5722"},{"uiid":"f6PCyY-hymbfZ8ReRxgHz","hex":"734a2b"},{"uiid":"5Rb800j0R551Zw98N_yUy","hex":"432304"},{"uiid":"a15HBOGPsZWN7nGm8eo-X","hex":"f7e7d4"},{"uiid":"WJshk2A4Fsd6pWfNDl2rh","hex":"ecd1ae"},{"uiid":"AQfyRKp3pZZoF8hD4G_RV","hex":"2ce2ab"},{"uiid":"zlm1HMDybJqMVPBcGx0C_","hex":"3b59bd"},{"uiid":"Aq3TLZ8TDtW7ydf2IlUBo","hex":"6016d0"},{"uiid":"DZc-jdZptatXW2pfJkJGf","hex":"58e94e"},{"uiid":"TGiQXvM5JfxTWNkCZnUfb","hex":"e4ad40"},{"uiid":"hidMypO4cm41b4-5qBd9P","hex":"fcd9a5"},{"uiid":"u__Mt8dNa2KiqbqVwrj5D","hex":"763d12"},{"uiid":"nHBXbjoz6A1Elpmjz7TZC","hex":"000000"},{"uiid":"FUd8dNow05LDm3Amh2UgX","hex":"f7d7b7"},{"uiid":"dBdQxL-gPYE8ncf7HPMBj","hex":"000000"},{"uiid":"jdqYOG7hdAayIHfiMmRlU","hex":"902df3"},{"uiid":"YwfmZA4D5Cd8HN3TZc_La","hex":"a42fb6"},{"uiid":"d3RE7xI-hOfN3uTjZdhxU","hex":"e444ef"},{"uiid":"vEehgyepQsCMJTR9tllXb","hex":"fa7923"},{"uiid":"hidMQpOdcm41b0fQocOyC","hex":"f2c738"},{"uiid":"TGiQcvMeJfxTWFnP0YWNY","hex":"149db9"},{"uiid":"VOcS5KKVex26Zmf8jeaS_","hex":"000000"},{"uiid":"c60VeVJ4yB8ZqvFm4jZkV","hex":"000000"},{"uiid":"_UH-EFnxCjXjwK0r_ZVqq","hex":"808000"},{"uiid":"n_rVOkSl-PPTZO4vS6dut","hex":"723b05"},{"uiid":"LLARQOdCjXEMmvy90H-Px","hex":"000000"},{"uiid":"tyLccwJ5_Fg2Nf-CECiHK","hex":"000000"},{"uiid":"NNGXICIzib6Bl-1q9C-Cg","hex":"00ff00"},{"uiid":"11a3jo_7bbgkvVkIikQdf","hex":"e589cd"},{"uiid":"5dxcyblN8p8MF_IZg_r3S","hex":"e68aa0"},{"uiid":"vcj416YNd6yrR2yHq5Wo9","hex":"e6a38a"},{"uiid":"5IJjDzKTVDIuV69xMY1Z9","hex":"e6d18a"},{"uiid":"IbdvDfDX3EUPboppL91LA","hex":"cee68a"},{"uiid":"hmhn3cbB_HiVxBJS4wMRD","hex":"a0e68a"},{"uiid":"T84aMSSnJwGViFR4E1ho5","hex":"8ae6a3"},{"uiid":"5tlfrpaRRheujhI5CknSw","hex":"8ae6d1"},{"uiid":"uyIo0sN1BGegMlhcc4Qf_","hex":"8acee6"},{"uiid":"BK44ptqe1XEIvV9E-Z-8X","hex":"8aa0e6"},{"uiid":"ExbZtFWfpCgRFDHMDbw2C","hex":"a38ae6"},{"uiid":"W7OVAK9eZgVqQ5ShCXkZk","hex":"d18ae6"},{"uiid":"7X-SodEUiXsg6lhhNXawF","hex":"e6e6e6"},{"uiid":"0yhS8WlTWVDl3dyIrdCDQ","hex":"abcdd1"},{"uiid":"LE92nls3-lPRMXtpl2hEL","hex":"acbbd2"},{"uiid":"KxXBNSNDy8AfQXbH3brA9","hex":"b0acd2"},{"uiid":"k_94fslwIln4dAlJQ5kOv","hex":"c3acd2"},{"uiid":"a23vMywndD1JG527xtsCs","hex":"d2acce"},{"uiid":"iAGbxHjWClgDghAwg63ty","hex":"d2acbb"},{"uiid":"l9sdviC9MD61EXeII-w3I","hex":"d2b0ac"},{"uiid":"oRjwn33pQhUf9MQoNTw4Q","hex":"d2c3ac"},{"uiid":"dZf0ThzwO6XBdN28N3GRH","hex":"ced2ac"},{"uiid":"Qeybv0FJy7A8-jH1F_I8u","hex":"bbd2ac"},{"uiid":"chHOSrCT1_NXfLIMo6MSS","hex":"acd2b0"},{"uiid":"4A87lXtZkFLQSidgipn6o","hex":"acd2c3"},{"uiid":"chtjxuS_QrkdoLIMo6MSS","hex":"d2d2d2"},{"uiid":"DiMBOKtjPiDr_Sj3jTJrU","hex":"000000"},{"uiid":"9CYeSZ-f3vQUZ1iB_woT6","hex":"000000"},{"uiid":"zUuHtdpQnpYQmaFPUuF9f","hex":"000000"},{"uiid":"aFei_A6UpPI3X5ZM5dCD_","hex":"000000"},{"uiid":"TElCVKJRPSLVdK9jfDL-L","hex":"000000"},{"uiid":"Sytns-lKmtlNq0rScd7Ks","hex":"000000"},{"uiid":"oFRYUPFALykhU8-cAOQ7-","hex":"000000"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":2},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":true,"jdItem":false,"gdItem":false,"uiid":"gO39g30DYjwA_G4xaMlal","ribbon":0,"origPrice":10,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":206,"w":119,"x":7,"y":69},"quality":2,"price":10,"userDesignItem":false,"colors":[{"uiid":"gO39g30DYjwA_G4xaMlal","hex":"f6d6b0"},{"uiid":"R7i8qkFaB96uUrIHOgBrl","hex":"e9bb7f"},{"uiid":"-AsqPMq_6QOZNgTzaYbL2","hex":"d7a145"},{"uiid":"_RSahbedhxuwMjvU1PvRT","hex":"d2910f"},{"uiid":"XvUapTjVZtpF_7IG1RTjQ","hex":"955e16"},{"uiid":"RoCgr0BN1tk1dgFR2mp5o","hex":"7a5722"},{"uiid":"lQD6gVXnyA1uZ_QX7-HfB","hex":"734a2b"},{"uiid":"4L-yQgYK_ohZwoCmqx9lJ","hex":"432304"},{"uiid":"LM69a1hWSOhZwChr0O_fo","hex":"f7e7d4"},{"uiid":"NlThxYxb8ZBt_krQnk5S5","hex":"ecd1ae"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":0},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"B_UnBpxcJfWkVao0VRryz","positionBack":{"h":103,"w":25,"x":23,"y":25},"ribbon":0,"origPrice":4,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":57,"w":43,"x":30,"y":18},"quality":4,"price":4,"userDesignItem":false,"colors":[{"backuiid":"B_UnBpxcJfWkVao0VRryz","uiid":"Q4X-fnCy-7QSMI2StuUbd","hex":"f5edd7"},{"backuiid":"2KmeyALMLjRongXwbv8aI","uiid":"7-TErcMCX93uh7P16EBUA","hex":"e64117"},{"backuiid":"Zj2NW9gXnSLOUbAGZ_WQa","uiid":"Rs2x7W76T6G0c8K52QxFp","hex":"f5d65a"},{"backuiid":"PvRNXqJo4wZexgUySMK5H","uiid":"_rbF8flctFxhj4f3tTv2X","hex":"552910"},{"backuiid":"HmkYR8gjeujErZrZfjNCW","uiid":"IMFwMLLOf17OzaGkBjJiu","hex":"171b41"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":1},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"mJabzu_ljpEqlEyPkArAn","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":false,"coversBreasts":true,"eyeIndex":0,"position":{"h":34,"w":37,"x":36,"y":72},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"mJabzu_ljpEqlEyPkArAn","hex":"ffffff"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":4},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"cWSc2u4-P-0PyG9BYzXbh","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":true,"coversBreasts":false,"eyeIndex":0,"position":{"h":28,"w":41,"x":25,"y":121},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"cWSc2u4-P-0PyG9BYzXbh","hex":"000080"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":16}]),
createBasketUi($(".yourModel"),[{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":true,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"DwMmJlciCqPXmBiiArsCx","ribbon":0,"origPrice":299,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":45,"w":35,"x":35,"y":24},"quality":2,"price":299,"userDesignItem":false,"colors":[{"uiid":"DwMmJlciCqPXmBiiArsCx","hex":"f6d6b0"},{"uiid":"RoK3zIgk5LZoFgFR2mp5o","hex":"e9bb7f"},{"uiid":"gO2oqZxuSeycdG4xaMlal","hex":"d7a145"},{"uiid":"mlWxGxMCGaJBmJo2I0Irb","hex":"d2910f"},{"uiid":"pbGaCYIONFh8jgUHGZoRe","hex":"955e16"},{"uiid":"tyLcMwJe_Fg2N-HacCD5Y","hex":"7a5722"},{"uiid":"f6PCyY-hymbfZ8ReRxgHz","hex":"734a2b"},{"uiid":"5Rb800j0R551Zw98N_yUy","hex":"432304"},{"uiid":"a15HBOGPsZWN7nGm8eo-X","hex":"f7e7d4"},{"uiid":"WJshk2A4Fsd6pWfNDl2rh","hex":"ecd1ae"},{"uiid":"AQfyRKp3pZZoF8hD4G_RV","hex":"2ce2ab"},{"uiid":"zlm1HMDybJqMVPBcGx0C_","hex":"3b59bd"},{"uiid":"Aq3TLZ8TDtW7ydf2IlUBo","hex":"6016d0"},{"uiid":"DZc-jdZptatXW2pfJkJGf","hex":"58e94e"},{"uiid":"TGiQXvM5JfxTWNkCZnUfb","hex":"e4ad40"},{"uiid":"hidMypO4cm41b4-5qBd9P","hex":"fcd9a5"},{"uiid":"u__Mt8dNa2KiqbqVwrj5D","hex":"763d12"},{"uiid":"nHBXbjoz6A1Elpmjz7TZC","hex":"000000"},{"uiid":"FUd8dNow05LDm3Amh2UgX","hex":"f7d7b7"},{"uiid":"dBdQxL-gPYE8ncf7HPMBj","hex":"000000"},{"uiid":"jdqYOG7hdAayIHfiMmRlU","hex":"902df3"},{"uiid":"YwfmZA4D5Cd8HN3TZc_La","hex":"a42fb6"},{"uiid":"d3RE7xI-hOfN3uTjZdhxU","hex":"e444ef"},{"uiid":"vEehgyepQsCMJTR9tllXb","hex":"fa7923"},{"uiid":"hidMQpOdcm41b0fQocOyC","hex":"f2c738"},{"uiid":"TGiQcvMeJfxTWFnP0YWNY","hex":"149db9"},{"uiid":"VOcS5KKVex26Zmf8jeaS_","hex":"000000"},{"uiid":"c60VeVJ4yB8ZqvFm4jZkV","hex":"000000"},{"uiid":"_UH-EFnxCjXjwK0r_ZVqq","hex":"808000"},{"uiid":"n_rVOkSl-PPTZO4vS6dut","hex":"723b05"},{"uiid":"LLARQOdCjXEMmvy90H-Px","hex":"000000"},{"uiid":"tyLccwJ5_Fg2Nf-CECiHK","hex":"000000"},{"uiid":"NNGXICIzib6Bl-1q9C-Cg","hex":"00ff00"},{"uiid":"11a3jo_7bbgkvVkIikQdf","hex":"e589cd"},{"uiid":"5dxcyblN8p8MF_IZg_r3S","hex":"e68aa0"},{"uiid":"vcj416YNd6yrR2yHq5Wo9","hex":"e6a38a"},{"uiid":"5IJjDzKTVDIuV69xMY1Z9","hex":"e6d18a"},{"uiid":"IbdvDfDX3EUPboppL91LA","hex":"cee68a"},{"uiid":"hmhn3cbB_HiVxBJS4wMRD","hex":"a0e68a"},{"uiid":"T84aMSSnJwGViFR4E1ho5","hex":"8ae6a3"},{"uiid":"5tlfrpaRRheujhI5CknSw","hex":"8ae6d1"},{"uiid":"uyIo0sN1BGegMlhcc4Qf_","hex":"8acee6"},{"uiid":"BK44ptqe1XEIvV9E-Z-8X","hex":"8aa0e6"},{"uiid":"ExbZtFWfpCgRFDHMDbw2C","hex":"a38ae6"},{"uiid":"W7OVAK9eZgVqQ5ShCXkZk","hex":"d18ae6"},{"uiid":"7X-SodEUiXsg6lhhNXawF","hex":"e6e6e6"},{"uiid":"0yhS8WlTWVDl3dyIrdCDQ","hex":"abcdd1"},{"uiid":"LE92nls3-lPRMXtpl2hEL","hex":"acbbd2"},{"uiid":"KxXBNSNDy8AfQXbH3brA9","hex":"b0acd2"},{"uiid":"k_94fslwIln4dAlJQ5kOv","hex":"c3acd2"},{"uiid":"a23vMywndD1JG527xtsCs","hex":"d2acce"},{"uiid":"iAGbxHjWClgDghAwg63ty","hex":"d2acbb"},{"uiid":"l9sdviC9MD61EXeII-w3I","hex":"d2b0ac"},{"uiid":"oRjwn33pQhUf9MQoNTw4Q","hex":"d2c3ac"},{"uiid":"dZf0ThzwO6XBdN28N3GRH","hex":"ced2ac"},{"uiid":"Qeybv0FJy7A8-jH1F_I8u","hex":"bbd2ac"},{"uiid":"chHOSrCT1_NXfLIMo6MSS","hex":"acd2b0"},{"uiid":"4A87lXtZkFLQSidgipn6o","hex":"acd2c3"},{"uiid":"chtjxuS_QrkdoLIMo6MSS","hex":"d2d2d2"},{"uiid":"DiMBOKtjPiDr_Sj3jTJrU","hex":"000000"},{"uiid":"9CYeSZ-f3vQUZ1iB_woT6","hex":"000000"},{"uiid":"zUuHtdpQnpYQmaFPUuF9f","hex":"000000"},{"uiid":"aFei_A6UpPI3X5ZM5dCD_","hex":"000000"},{"uiid":"TElCVKJRPSLVdK9jfDL-L","hex":"000000"},{"uiid":"Sytns-lKmtlNq0rScd7Ks","hex":"000000"},{"uiid":"oFRYUPFALykhU8-cAOQ7-","hex":"000000"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":2},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":true,"jdItem":false,"gdItem":false,"uiid":"gO39g30DYjwA_G4xaMlal","ribbon":0,"origPrice":10,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":206,"w":119,"x":7,"y":69},"quality":2,"price":10,"userDesignItem":false,"colors":[{"uiid":"gO39g30DYjwA_G4xaMlal","hex":"f6d6b0"},{"uiid":"R7i8qkFaB96uUrIHOgBrl","hex":"e9bb7f"},{"uiid":"-AsqPMq_6QOZNgTzaYbL2","hex":"d7a145"},{"uiid":"_RSahbedhxuwMjvU1PvRT","hex":"d2910f"},{"uiid":"XvUapTjVZtpF_7IG1RTjQ","hex":"955e16"},{"uiid":"RoCgr0BN1tk1dgFR2mp5o","hex":"7a5722"},{"uiid":"lQD6gVXnyA1uZ_QX7-HfB","hex":"734a2b"},{"uiid":"4L-yQgYK_ohZwoCmqx9lJ","hex":"432304"},{"uiid":"LM69a1hWSOhZwChr0O_fo","hex":"f7e7d4"},{"uiid":"NlThxYxb8ZBt_krQnk5S5","hex":"ecd1ae"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":0},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"B_UnBpxcJfWkVao0VRryz","positionBack":{"h":103,"w":25,"x":23,"y":25},"ribbon":0,"origPrice":4,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":57,"w":43,"x":30,"y":18},"quality":4,"price":4,"userDesignItem":false,"colors":[{"backuiid":"B_UnBpxcJfWkVao0VRryz","uiid":"Q4X-fnCy-7QSMI2StuUbd","hex":"f5edd7"},{"backuiid":"2KmeyALMLjRongXwbv8aI","uiid":"7-TErcMCX93uh7P16EBUA","hex":"e64117"},{"backuiid":"Zj2NW9gXnSLOUbAGZ_WQa","uiid":"Rs2x7W76T6G0c8K52QxFp","hex":"f5d65a"},{"backuiid":"PvRNXqJo4wZexgUySMK5H","uiid":"_rbF8flctFxhj4f3tTv2X","hex":"552910"},{"backuiid":"HmkYR8gjeujErZrZfjNCW","uiid":"IMFwMLLOf17OzaGkBjJiu","hex":"171b41"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":1},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"mJabzu_ljpEqlEyPkArAn","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":false,"coversBreasts":true,"eyeIndex":0,"position":{"h":34,"w":37,"x":36,"y":72},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"mJabzu_ljpEqlEyPkArAn","hex":"ffffff"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":4},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"cWSc2u4-P-0PyG9BYzXbh","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":true,"coversBreasts":false,"eyeIndex":0,"position":{"h":28,"w":41,"x":25,"y":121},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"cWSc2u4-P-0PyG9BYzXbh","hex":"000080"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":16}],[{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":true,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"DwMmJlciCqPXmBiiArsCx","ribbon":0,"origPrice":299,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":45,"w":35,"x":35,"y":24},"quality":2,"price":299,"userDesignItem":false,"colors":[{"uiid":"DwMmJlciCqPXmBiiArsCx","hex":"f6d6b0"},{"uiid":"RoK3zIgk5LZoFgFR2mp5o","hex":"e9bb7f"},{"uiid":"gO2oqZxuSeycdG4xaMlal","hex":"d7a145"},{"uiid":"mlWxGxMCGaJBmJo2I0Irb","hex":"d2910f"},{"uiid":"pbGaCYIONFh8jgUHGZoRe","hex":"955e16"},{"uiid":"tyLcMwJe_Fg2N-HacCD5Y","hex":"7a5722"},{"uiid":"f6PCyY-hymbfZ8ReRxgHz","hex":"734a2b"},{"uiid":"5Rb800j0R551Zw98N_yUy","hex":"432304"},{"uiid":"a15HBOGPsZWN7nGm8eo-X","hex":"f7e7d4"},{"uiid":"WJshk2A4Fsd6pWfNDl2rh","hex":"ecd1ae"},{"uiid":"AQfyRKp3pZZoF8hD4G_RV","hex":"2ce2ab"},{"uiid":"zlm1HMDybJqMVPBcGx0C_","hex":"3b59bd"},{"uiid":"Aq3TLZ8TDtW7ydf2IlUBo","hex":"6016d0"},{"uiid":"DZc-jdZptatXW2pfJkJGf","hex":"58e94e"},{"uiid":"TGiQXvM5JfxTWNkCZnUfb","hex":"e4ad40"},{"uiid":"hidMypO4cm41b4-5qBd9P","hex":"fcd9a5"},{"uiid":"u__Mt8dNa2KiqbqVwrj5D","hex":"763d12"},{"uiid":"nHBXbjoz6A1Elpmjz7TZC","hex":"000000"},{"uiid":"FUd8dNow05LDm3Amh2UgX","hex":"f7d7b7"},{"uiid":"dBdQxL-gPYE8ncf7HPMBj","hex":"000000"},{"uiid":"jdqYOG7hdAayIHfiMmRlU","hex":"902df3"},{"uiid":"YwfmZA4D5Cd8HN3TZc_La","hex":"a42fb6"},{"uiid":"d3RE7xI-hOfN3uTjZdhxU","hex":"e444ef"},{"uiid":"vEehgyepQsCMJTR9tllXb","hex":"fa7923"},{"uiid":"hidMQpOdcm41b0fQocOyC","hex":"f2c738"},{"uiid":"TGiQcvMeJfxTWFnP0YWNY","hex":"149db9"},{"uiid":"VOcS5KKVex26Zmf8jeaS_","hex":"000000"},{"uiid":"c60VeVJ4yB8ZqvFm4jZkV","hex":"000000"},{"uiid":"_UH-EFnxCjXjwK0r_ZVqq","hex":"808000"},{"uiid":"n_rVOkSl-PPTZO4vS6dut","hex":"723b05"},{"uiid":"LLARQOdCjXEMmvy90H-Px","hex":"000000"},{"uiid":"tyLccwJ5_Fg2Nf-CECiHK","hex":"000000"},{"uiid":"NNGXICIzib6Bl-1q9C-Cg","hex":"00ff00"},{"uiid":"11a3jo_7bbgkvVkIikQdf","hex":"e589cd"},{"uiid":"5dxcyblN8p8MF_IZg_r3S","hex":"e68aa0"},{"uiid":"vcj416YNd6yrR2yHq5Wo9","hex":"e6a38a"},{"uiid":"5IJjDzKTVDIuV69xMY1Z9","hex":"e6d18a"},{"uiid":"IbdvDfDX3EUPboppL91LA","hex":"cee68a"},{"uiid":"hmhn3cbB_HiVxBJS4wMRD","hex":"a0e68a"},{"uiid":"T84aMSSnJwGViFR4E1ho5","hex":"8ae6a3"},{"uiid":"5tlfrpaRRheujhI5CknSw","hex":"8ae6d1"},{"uiid":"uyIo0sN1BGegMlhcc4Qf_","hex":"8acee6"},{"uiid":"BK44ptqe1XEIvV9E-Z-8X","hex":"8aa0e6"},{"uiid":"ExbZtFWfpCgRFDHMDbw2C","hex":"a38ae6"},{"uiid":"W7OVAK9eZgVqQ5ShCXkZk","hex":"d18ae6"},{"uiid":"7X-SodEUiXsg6lhhNXawF","hex":"e6e6e6"},{"uiid":"0yhS8WlTWVDl3dyIrdCDQ","hex":"abcdd1"},{"uiid":"LE92nls3-lPRMXtpl2hEL","hex":"acbbd2"},{"uiid":"KxXBNSNDy8AfQXbH3brA9","hex":"b0acd2"},{"uiid":"k_94fslwIln4dAlJQ5kOv","hex":"c3acd2"},{"uiid":"a23vMywndD1JG527xtsCs","hex":"d2acce"},{"uiid":"iAGbxHjWClgDghAwg63ty","hex":"d2acbb"},{"uiid":"l9sdviC9MD61EXeII-w3I","hex":"d2b0ac"},{"uiid":"oRjwn33pQhUf9MQoNTw4Q","hex":"d2c3ac"},{"uiid":"dZf0ThzwO6XBdN28N3GRH","hex":"ced2ac"},{"uiid":"Qeybv0FJy7A8-jH1F_I8u","hex":"bbd2ac"},{"uiid":"chHOSrCT1_NXfLIMo6MSS","hex":"acd2b0"},{"uiid":"4A87lXtZkFLQSidgipn6o","hex":"acd2c3"},{"uiid":"chtjxuS_QrkdoLIMo6MSS","hex":"d2d2d2"},{"uiid":"DiMBOKtjPiDr_Sj3jTJrU","hex":"000000"},{"uiid":"9CYeSZ-f3vQUZ1iB_woT6","hex":"000000"},{"uiid":"zUuHtdpQnpYQmaFPUuF9f","hex":"000000"},{"uiid":"aFei_A6UpPI3X5ZM5dCD_","hex":"000000"},{"uiid":"TElCVKJRPSLVdK9jfDL-L","hex":"000000"},{"uiid":"Sytns-lKmtlNq0rScd7Ks","hex":"000000"},{"uiid":"oFRYUPFALykhU8-cAOQ7-","hex":"000000"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":2},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":true,"jdItem":false,"gdItem":false,"uiid":"gO39g30DYjwA_G4xaMlal","ribbon":0,"origPrice":10,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":206,"w":119,"x":7,"y":69},"quality":2,"price":10,"userDesignItem":false,"colors":[{"uiid":"gO39g30DYjwA_G4xaMlal","hex":"f6d6b0"},{"uiid":"R7i8qkFaB96uUrIHOgBrl","hex":"e9bb7f"},{"uiid":"-AsqPMq_6QOZNgTzaYbL2","hex":"d7a145"},{"uiid":"_RSahbedhxuwMjvU1PvRT","hex":"d2910f"},{"uiid":"XvUapTjVZtpF_7IG1RTjQ","hex":"955e16"},{"uiid":"RoCgr0BN1tk1dgFR2mp5o","hex":"7a5722"},{"uiid":"lQD6gVXnyA1uZ_QX7-HfB","hex":"734a2b"},{"uiid":"4L-yQgYK_ohZwoCmqx9lJ","hex":"432304"},{"uiid":"LM69a1hWSOhZwChr0O_fo","hex":"f7e7d4"},{"uiid":"NlThxYxb8ZBt_krQnk5S5","hex":"ecd1ae"}],"inStock":true,"brand":"by goSupermodel","goDesignerItem":false,"layer":0},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"B_UnBpxcJfWkVao0VRryz","positionBack":{"h":103,"w":25,"x":23,"y":25},"ribbon":0,"origPrice":4,"faceIndex":0,"coversCrotch":false,"coversBreasts":false,"eyeIndex":0,"position":{"h":57,"w":43,"x":30,"y":18},"quality":4,"price":4,"userDesignItem":false,"colors":[{"backuiid":"B_UnBpxcJfWkVao0VRryz","uiid":"Q4X-fnCy-7QSMI2StuUbd","hex":"f5edd7"},{"backuiid":"2KmeyALMLjRongXwbv8aI","uiid":"7-TErcMCX93uh7P16EBUA","hex":"e64117"},{"backuiid":"Zj2NW9gXnSLOUbAGZ_WQa","uiid":"Rs2x7W76T6G0c8K52QxFp","hex":"f5d65a"},{"backuiid":"PvRNXqJo4wZexgUySMK5H","uiid":"_rbF8flctFxhj4f3tTv2X","hex":"552910"},{"backuiid":"HmkYR8gjeujErZrZfjNCW","uiid":"IMFwMLLOf17OzaGkBjJiu","hex":"171b41"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":1},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"mJabzu_ljpEqlEyPkArAn","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":false,"coversBreasts":true,"eyeIndex":0,"position":{"h":34,"w":37,"x":36,"y":72},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"mJabzu_ljpEqlEyPkArAn","hex":"ffffff"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":4},{"isInTrade":false,"addedToShop":0,"leavingShop":0,"palette":0,"isFace":false,"isSkin":false,"jdItem":false,"gdItem":false,"uiid":"cWSc2u4-P-0PyG9BYzXbh","ribbon":0,"origPrice":0,"faceIndex":0,"coversCrotch":true,"coversBreasts":false,"eyeIndex":0,"position":{"h":28,"w":41,"x":25,"y":121},"quality":0,"price":0,"userDesignItem":false,"colors":[{"uiid":"cWSc2u4-P-0PyG9BYzXbh","hex":"000080"}],"inStock":false,"brand":"by goSupermodel","goDesignerItem":false,"layer":16}]),
createBasket([], []),
context,
unixTime,
accountMoney);
inventoryController.initEvents();
window.inventoryController = inventoryController;
window.addEventListener("beforeunload", function (e) {
if(window.inventoryController._context.isWardrobe()) {
if (!window.inventoryController.compareOutfits([])) {
e.preventDefault();
cancel_loading_panel();
e.returnValue = "Are you sure you want to leave the wardrobe - you have unsaved changes";
}
}
});
//init tag input
$(".input.tags input").on("input",function(){
var inputField = this;
var tagFilter = inputField.parentElement.querySelector("#tagFilter");
var html = 'AllUn-tagged items';
var added = 0;
for(var i = 0; i < context.myTags.length&&added<10; i++){
if(context.myTags[i].toLowerCase().startsWith(inputField.value.toLowerCase())){
html += ''+context.myTags[i]+'';
added++;
if(added==10){
html += '...';
}
}
}
tagFilter.innerHTML = html;
tagFilter.classList.toggle("active",true);
}).on("blur",function(e){
var inputField = this;
var tagFilter = inputField.parentElement.querySelector("#tagFilter");
tagFilter.classList.remove("active");
inputField.value= "";
});
$(".input.tags").on("touch mousedown",function(e){
var tagFilter = this.querySelector("#tagFilter");
if(e.target.nodeName != "INPUT") {
e.preventDefault();
e.stopPropagation();
var tag = e.target.dataset.value;
if(!tag){return;}
var tagContainer = this.querySelector(".tagContainer");
var selectedTags = tagFilter.dataset.tags;
if (e.target.classList.contains("tag")){
e.target.remove();
var tagValue = '';
var currentTags = tagContainer.querySelectorAll(".tag");
currentTags.forEach(function(element){
var tag = element.dataset.value;
if(tagValue.length > 0){
tagValue = tagValue + ',';
}
tagValue = tagValue + tag;
});
tagFilter.dataset.tags = tagValue;
window.inventoryController.loadItems();
}else if(tag == "0"){
tagFilter.dataset.tags = tag;
tagContainer.innerHTML = "";
tagFilter.classList.remove("active");
this.querySelector("input").value = "";
window.inventoryController.loadItems();
} else if(tag == "-1"){
tagFilter.dataset.tags = tag;
tagContainer.innerHTML = "Un-tagged items";
tagFilter.classList.remove("active");
this.querySelector("input").value = "";
window.inventoryController.loadItems();
} else if(!selectedTags || selectedTags == "-1"){
tagFilter.dataset.tags = tag;
tagContainer.innerHTML = ""+tag+"";
window.inventoryController.loadItems();
} else {
var alreadyChosen = false;
var currentTags = tagContainer.querySelectorAll(".tag");
currentTags.forEach(function(element){
if(element.dataset.value == tag){
alreadyChosen = true;
}
});
if(!alreadyChosen && currentTags.length < 5){
tagContainer.innerHTML = tagContainer.innerHTML+""+tag+"";
tagFilter.dataset.tags = selectedTags+','+tag;
window.inventoryController.loadItems();
}
}
return false;
}
});
});
})();