????
Current Path : /home2/morganrand/backup.morganrand.com/centerpiece-designer/js/ |
Current File : /home2/morganrand/backup.morganrand.com/centerpiece-designer/js/main.js |
var canvas; //Will be linked to the canvas in our index.html page var stage; //Is the equivalent of stage in AS3 and we'll add "children" to it var colorObjects; // array of objects of color var settingObjects; var limitDisabled; var isLimitAdded; var limitClicks; var signUpMessageScreen; var controlPanel; var controlPanelBgColor = "#454545"; var menuButtonSelectedColor = "#fff"; var menuButtonUpColor = "#ccc"; var menuButtonOverColor = "#fff"; var pompomLayersIndexArray = ["111111111111", "221111222112", "132311223123","233142141234","352144521312","415324326156"]; var pompomLayersSeqence = "135624789"; var tasselLayersIndexArray = ["111111", "122112", "123132","123412","123451","123456"]; //var candyValidCombinationsCode = ["100","130","140","150","200","230","250","300","310","320","400","410","500","510","520","110","330","550","600","700","800"]; var pompomMenuButtons; var tasselMenuButtons; var candyMenuButtons; var ribbonMenuButtons; var baseMenuButtons; var selectedMenuButtonId; var selectedMenuType; var selectedMenuColors; var layerImages; var scl = 0; function main() { canvas = document.getElementById('cnvDesigner'); stage = new createjs.Stage(canvas); //setMenuArrays(); setupMenuArraysJS(); //setupUi(); $(window).resize(resizeDesignerCanvas); resizeDesignerCanvas(); } function setupUi() { // creating preview Container layerImages = []; for(var i = 0; i < 58; i++) { $("#color-holder").append('<a href="javascript:;" id="csBox'+i+'" class="cp-box" data-toggle="tooltip" style="background-color:#fff;" onclick="onBtnColorClickJs(event, '+"'"+'csBox'+i+"'"+')"></a>\n'); } $('[data-toggle="tooltip"]').tooltip(); pompomMenuButtons = []; tasselMenuButtons = []; candyMenuButtons = []; ribbonMenuButtons = []; baseMenuButtons = []; if(settingObjects.defaultColorUrl) { setUrlToColors(settingObjects.defaultColorUrl); } else { setColorObjectForMenu(pompomMenuButtons, 0, colorObjects["POM"][0], "POMMenu0"); setColorObjectForMenu(tasselMenuButtons, 0, colorObjects["TAS"][0], "TASMenu0"); setColorObjectForMenu(candyMenuButtons, 0, colorObjects["CAN"][0], "CANMenu0"); setColorObjectForMenu(ribbonMenuButtons, 0, colorObjects["RIB"][0], "RIBMenu0"); setColorObjectForMenu(baseMenuButtons, 0, colorObjects["BAS"][0], "BASMenu0"); } updateLayers(); onMenuButtonClickJs(null, "POMMenu0"); } function onMenuButtonClickJs(event, btnid) { $(".menuButton").removeClass("active"); //$(event.currentTarget).addClass("active"); $("#"+btnid).addClass("active"); selectedMenuButtonId = btnid; var currentMenuType = btnid.substr(0,3); if(selectedMenuType != currentMenuType) { selectedMenuType = currentMenuType; selectedMenuColors = colorObjects[selectedMenuType]; var colorChilds = $("#color-holder").children(".cp-box"); // all childs colorChilds.each(function(i, e) { var $this = $(this); // particular child if(selectedMenuColors[i]) { if(selectedMenuColors[i].swatchImage) { $this.html("<img style='vertical-align:baseline !important;' src='"+selectedMenuColors[i].swatchImage+"'/>"); } $this.show().css("background-color", selectedMenuColors[i].hex).attr('data-original-title', selectedMenuColors[i].name); }else{ $this.hide(); $this.html(""); } }); } } function onMenuButtonDoubleClickJs(btnid) { var clickedMenuType = btnid.substr(0,3); if(selectedMenuType == "CAN") { setColorObjectForMenu(candyMenuButtons, 1, null, "CANMenu1"); } else if(selectedMenuType == "POM") { for(var pi = 1; pi < pompomMenuButtons.length; pi++) { setColorObjectForMenu(pompomMenuButtons, pi, null, "POMMenu"+pi); } } else if(selectedMenuType == "TAS") { for(var ti = 1; ti < tasselMenuButtons.length; ti++) { setColorObjectForMenu(tasselMenuButtons, ti, null, "TASMenu"+ti); } } updateLayers(); stage.update(); } function onBtnColorClickJs(event, btnid) { if(!checkClickLimit()) { return; } if(selectedMenuButtonId) { var currMenuButtonIndex = selectedMenuButtonId.substr(7); var currColorIndex = btnid.substr(5); var currColorObj = selectedMenuColors[currColorIndex]; $("#lastSelectedColorMsg").html("You selected: " + currColorObj.name); if(selectedMenuType == "CAN") { var candyCode1; var candyCode2; if(selectedMenuButtonId == "CANMenu0") { candyCode1 = currColorObj.code; if(candyMenuButtons[1]) { candyCode2 = candyMenuButtons[1].code; } else { candyCode2 = "0"; } } else { candyCode1 = candyMenuButtons[0].code; candyCode2 = currColorObj.code; } if(canCandyColorCodeCombined(candyCode1, candyCode2)) { setColorObjectForMenu(candyMenuButtons, currMenuButtonIndex, currColorObj, selectedMenuButtonId); } } else if(selectedMenuType == "POM") { for(var pi = 0; pi < currMenuButtonIndex; pi++) { if(pompomMenuButtons[pi] == null) { pompomMenuButtons[pi] = currColorObj; setColorObjectForMenu(pompomMenuButtons, pi, currColorObj, "POMMenu"+pi); } } setColorObjectForMenu(pompomMenuButtons, currMenuButtonIndex, currColorObj, selectedMenuButtonId); } else if(selectedMenuType == "TAS") { for(var ti = 0; ti < currMenuButtonIndex; ti++) { if(tasselMenuButtons[ti] == null) { tasselMenuButtons[ti] = currColorObj; setColorObjectForMenu(tasselMenuButtons, ti, currColorObj, "TASMenu"+ti); } } setColorObjectForMenu(tasselMenuButtons, currMenuButtonIndex, currColorObj, selectedMenuButtonId); } else if(selectedMenuType == "RIB") { setColorObjectForMenu(ribbonMenuButtons, currMenuButtonIndex, currColorObj, selectedMenuButtonId); } else if(selectedMenuType == "BAS") { setColorObjectForMenu(baseMenuButtons, currMenuButtonIndex, currColorObj, selectedMenuButtonId); } updateLayers(); stage.update(event); } } function checkClickLimit() { var canClick = true; if(isLimitAdded) { if(limitClicks < 1) { canClick = false; } limitClicks--; if(!canClick) { if(!signUpMessageScreen) { signUpMessageScreen = new LimitMessage(); stage.addChild(signUpMessageScreen); setSignupMessageScale(); stage.update(); } } } return canClick; } function setSignupMessageScale() { if(signUpMessageScreen) { signUpMessageScreen.x = 120*scl; signUpMessageScreen.y = 150*scl; signUpMessageScreen.setScale(scl); } } function setColorObjectForMenu(menuList, menuIndex, colorObj, menuButtonId) { menuList[menuIndex] = colorObj; if(colorObj) { $("#"+menuButtonId).html(colorObj.name); } else { $("#"+menuButtonId).html("[add]"); } } function updateLayers() { var flds = "A10"; var currColorObj; var currBitmap; var currImagePath; // layer 1 - base if(baseMenuButtons[0]) { currColorObj = baseMenuButtons[0]; //currImagePath = flds+"/BAS/" + flds + "BAS000"+ currColorObj.code+"XXXX00.png"; currImagePath = currColorObj.images[0]; loadLayerImage(0, currColorObj.code, currImagePath); } // layer 2 - candies var candySelectedColorNum = 0; var candyColorComb = ""; for (var i = 0; i < candyMenuButtons.length; i++) { if(candyMenuButtons[i]) { candyColorComb = candyColorComb + candyMenuButtons[i].code.substr(0,1); candySelectedColorNum++; } else { candyColorComb = candyColorComb + "0"; } } //console.log("candyColorComb = " + candyColorComb); if(candySelectedColorNum > 0) { candyColorComb = candyColorComb + (candyMenuButtons.length == 1 ? "00" : "0"); var candyColorCodesComb; if(candySelectedColorNum == 1) { currColorObj = candyMenuButtons[0]; candyColorCodesComb = currColorObj.code;//.substr(1); //currImagePath = flds+"/CAN/" + flds + "CAN" + candyColorComb + candyColorCodesComb +"XXXX00.png"; currImagePath = currColorObj.images[0]; } else { /*var candyColorCombType = 0; var firstCandyColorCode = candyMenuButtons[0].code.substr(1); var secondCandyColorCode = candyMenuButtons[1].code.substr(1); switch (parseInt(candyColorComb)) { case 310: case 320: case 410: case 510: case 520: candyColorCombType = 1; break; case 110: var codesFor110 = ["BK","BL","RD","GN","PP","SL"]; for(var i110 = 0; i110 < codesFor110.length; i110++) { if(codesFor110[i] == firstCandyColorCode) { candyColorCombType = 0; break; } else if(codesFor110[i] == secondCandyColorCode) { candyColorCombType = 1; break; } } break; case 330: var codesFor330 = ["WH","LA","LB","PH","LG"]; for(var i330 = 0; i330 < codesFor330.length; i330++) { if(codesFor330[i] == firstCandyColorCode) { candyColorCombType = 0; break; } else if(codesFor330[i] == secondCandyColorCode) { candyColorCombType = 1; break; } } break; case 550: var codesFor550 = ["PP","RD","OR","NA","BK","LA","GN","LY","LP"]; for(var i550 = 0; i550 < codesFor550.length; i550++) { if(codesFor550[i] == firstCandyColorCode) { candyColorCombType = 0; break; } else if(codesFor550[i] == secondCandyColorCode) { candyColorCombType = 1; break; } } break; } //console.log("candyColorComb = " + candyColorComb + " === " + candyColorCombType); if (candyColorCombType == 1) { candyColorCodesComb = secondCandyColorCode +firstCandyColorCode; currImagePath = flds+"/CAN/" + flds + "CAN" + candyColorComb.substr(1,1) + candyColorComb.substr(0,1) + candyColorComb.substr(2) + candyColorCodesComb+"XX00.png"; } else { candyColorCodesComb = firstCandyColorCode +secondCandyColorCode; currImagePath = flds+"/CAN/" + flds + "CAN" + candyColorComb + candyColorCodesComb +"XX00.png"; }*/ var firstCandyColorCode = candyMenuButtons[0].code; var secondCandyColorCode = candyMenuButtons[1].code; var candyCombColorObjects = colorObjects.candyComb; for(var cci = 0; cci < candyCombColorObjects.length; cci++) { var currCombObj = candyCombColorObjects[cci]; if(currCombObj.codes[0] == firstCandyColorCode && currCombObj.codes[1] == secondCandyColorCode) { candyColorCodesComb = firstCandyColorCode +secondCandyColorCode; currImagePath = currCombObj.images[0]; } if(currCombObj.codes[1] == firstCandyColorCode && currCombObj.codes[0] == secondCandyColorCode) { candyColorCodesComb = secondCandyColorCode +firstCandyColorCode; currImagePath = currCombObj.images[0]; } } } // console.log("candyColorCodesComb - " + candyColorCodesComb); loadLayerImage(1, candyColorCodesComb, currImagePath); } // layer 3 - ribbon if(ribbonMenuButtons[0]) { currColorObj = ribbonMenuButtons[0]; //currImagePath = flds+"/RIB/" + flds + "RIB000"+ currColorObj.code+"XXXX00.png"; currImagePath = currColorObj.images[0]; loadLayerImage(2, currColorObj.code, currImagePath); } // layers 4-13 - poms // find number of pompom colors var pompomSelectedColorNum = 0; for (var i = 0; i < pompomMenuButtons.length; i++) { if(pompomMenuButtons[i]) { pompomSelectedColorNum++; } } if(pompomSelectedColorNum > 0) { var currentPompomLayerIndexList = pompomLayersIndexArray[pompomSelectedColorNum-1]; var currentLayerIndexListIndex; var currentPompomLayer; for (var i = 0; i < 9; i++) { currentLayerIndexListIndex = currentPompomLayerIndexList.substr(i,1); currColorObj = pompomMenuButtons[currentLayerIndexListIndex-1]; //currImagePath = flds+"/POM/"+flds+"POM00"+ pompomLayersSeqence.substr(i,1)+currColorObj.code+"XXXX00.png"; currentPompomLayer = parseInt(pompomLayersSeqence.substr(i,1)); currImagePath = currColorObj.images[currentPompomLayer-1]; loadLayerImage(i+3, currColorObj.code, currImagePath); } currentLayerIndexListIndex = currentPompomLayerIndexList.substr(9,1); currColorObj = pompomMenuButtons[currentLayerIndexListIndex-1]; //currImagePath = flds+"/POM/"+flds+"POM010"+ currColorObj.code+"XXXX00.png"; currImagePath = currColorObj.images[9]; loadLayerImage(12, currColorObj.code, currImagePath); } // layer 14-19 - tassels // find number of tassel colors var tasselSelectedColorNum = 0; for (var i = 0; i < tasselMenuButtons.length; i++) { if(tasselMenuButtons[i]) { tasselSelectedColorNum++; } } if(tasselSelectedColorNum > 0) { var currentTasselLayerIndexList = tasselLayersIndexArray[tasselSelectedColorNum-1]; var currentTasselLayerIndexListIndex; for (var i = 0; i < 6; i++) { currentTasselLayerIndexListIndex = currentTasselLayerIndexList.substr(i,1); currColorObj = tasselMenuButtons[currentTasselLayerIndexListIndex-1]; //currImagePath = flds+"/TAS/"+flds+"TAS00"+ (i+1)+currColorObj.code+"XXXX00.png"; currImagePath = currColorObj.images[i]; loadLayerImage(i+13, currColorObj.code, currImagePath); } } generateURL(); } function loadLayerImage(layerIndex, colorCode, imageUrl) { if(!imageUrl) return; if(!layerImages[layerIndex] || layerImages[layerIndex].colorCode != colorCode) { if(layerImages[layerIndex]) { stage.removeChild(layerImages[layerIndex]); } currBitmap = new createjs.Bitmap(imageUrl); currBitmap.scaleX = scl; currBitmap.scaleY = scl; stage.addChildAt(currBitmap, layerIndex); currBitmap.colorCode = colorCode; layerImages[layerIndex] = currBitmap; currBitmap.image.onload = function() { //console.log("currBitmap.image.onload"); stage.update(); } } } function rescaleLayerImages() { if(layerImages && layerImages.length) { var lng = layerImages.length; for(var li = 0; li < lng; li++) { var currBitmap = layerImages[li]; if(currBitmap) { currBitmap.scaleX = scl; currBitmap.scaleY = scl; } } } } function canCandyColorCodeCombined(code1, code2) { var canCombine = false; if(code1 == "0" || code2 == "0") { canCombine = true; } else { var candyCombColorObjects = colorObjects.candyComb; for(var cci = 0; cci < candyCombColorObjects.length; cci++) { var currCombObj = candyCombColorObjects[cci]; if(currCombObj.codes[0] == code1 && currCombObj.codes[1] == code2) { canCombine = true; break; } if(currCombObj.codes[1] == code1 && currCombObj.codes[0] == code2) { canCombine = true; break; } } } return canCombine; } function generateURL() { // initState = "A101IWXXXXXXXXXX400WHXXXXPPXXXXXXXXXXPPGL"; // A102BKRDXXXXXXXX550BKRDXXBKRMBKRMMSMSSLSL - Nitin // 0123456789a123456789b123456789c123456789d // oooN112233445566ccc112233tt2233445566rrbb // ooo - bouquet code (A10) // N - number of pompom colors (1-6) // ccc - candy code // tt - tassel color // rr - ribbon color // bb - base var urlStr = ""; urlStr = urlStr + "A10"; var pompomSelectedColorNum = 0; var pompomStr = ""; for (var i = 0; i < 6; i++) { if(pompomMenuButtons[i]) { pompomSelectedColorNum++; pompomStr = pompomStr + pompomMenuButtons[i].code; } else { pompomStr = pompomStr + "XX"; } } urlStr = urlStr + pompomSelectedColorNum + pompomStr; var candySelectedColorNum = 0; var candyColorComb = ""; for (var i = 0; i < candyMenuButtons.length; i++) { if(candyMenuButtons[i]) { candyColorComb = candyColorComb + candyMenuButtons[i].code.substr(0,1); candySelectedColorNum++; } else { candyColorComb = candyColorComb + "0"; } } if(candySelectedColorNum > 0) { if(candyColorComb.length < 3) { candyColorComb = candyColorComb + (candyColorComb.length == 1 ? "00" : "0"); } var candyColorCodesComb; if(candySelectedColorNum == 1) { currColorObj = candyMenuButtons[0]; candyColorCodesComb = currColorObj.code.substr(1); urlStr = urlStr + candyColorComb + candyColorCodesComb + "XXXX"; } else { var firstCandyColorCode = candyMenuButtons[0].code; var secondCandyColorCode = candyMenuButtons[1].code; var candyCombColorObjects = colorObjects.candyComb; for(var cci = 0; cci < candyCombColorObjects.length; cci++) { var currCombObj = candyCombColorObjects[cci]; if(currCombObj.codes[0] == firstCandyColorCode && currCombObj.codes[1] == secondCandyColorCode) { candyColorCodesComb = firstCandyColorCode.substr(1) + secondCandyColorCode.substr(1); } if(currCombObj.codes[1] == firstCandyColorCode && currCombObj.codes[0] == secondCandyColorCode) { candyColorCodesComb = secondCandyColorCode.substr(1) +firstCandyColorCode.substr(1); } } urlStr = urlStr + candyColorComb + candyColorCodesComb + "XX"; } } else { urlStr = urlStr + "000XXXXXX"; } var tasselSelectedColorNum = 0; var tasselStr = ""; for (var i = 0; i < 6; i++) { if(tasselMenuButtons[i]) { tasselSelectedColorNum++; tasselStr = tasselStr + tasselMenuButtons[i].code; } else { tasselStr = tasselStr + "XX"; } } urlStr = urlStr + tasselStr; if(ribbonMenuButtons[0]) { currColorObj = ribbonMenuButtons[0]; urlStr = urlStr + currColorObj.code; } else { urlStr = urlStr + "XX"; } if(baseMenuButtons[0]) { currColorObj = baseMenuButtons[0]; urlStr = urlStr + currColorObj.code; } else { urlStr = urlStr + "XX"; } try { setGeneratedUrl(urlStr); } catch(err) { console.log("err = " + err); } } function setUrlToColors(urlStr) { // initState = "A101IWXXXXXXXXXX400WHXXXXPPXXXXXXXXXXPPGL"; // A102BKRDXXXXXXXX550BKRDXXBKRMBKRMMSMSSLSL - Nitin // 0123456789a123456789b123456789c123456789d // oooN112233445566ccc112233tt2233445566rrbb // ooo - bouquet code (A10) // N - number of pompom colors (1-6) // ccc - candy code // tt - tassel color // rr - ribbon color // bb - base console.log("urlStr = " + urlStr); var currColorCode; var currColorObj; var pompomColorsStr = urlStr.substr(4,12); for(var pi = 0; pi < 6; pi++) { currColorCode = pompomColorsStr.substr(pi*2, 2); if(currColorCode && currColorCode != "XX") { currColorObj = getColorObjForMenu(colorObjects.POM, currColorCode); setColorObjectForMenu(pompomMenuButtons, pi, currColorObj, "POMMenu"+pi) } } var candyColorNumStr = urlStr.substr(16, 3); var candyColorsStr = urlStr.substr(19, 6); for(var ci = 0; ci < 3; ci++) { currColorCode = candyColorNumStr.substr(ci, 1) + candyColorsStr.substr(ci*2, 2); if(currColorCode && currColorCode != "XX") { currColorObj = getColorObjForMenu(colorObjects.CAN, currColorCode); setColorObjectForMenu(candyMenuButtons, ci, currColorObj, "CANMenu"+ci) } } var tasselColorsStr = urlStr.substr(25,12); for(var ti = 0; ti < 6; ti++) { currColorCode = tasselColorsStr.substr(ti*2, 2); if(currColorCode && currColorCode != "XX") { currColorObj = getColorObjForMenu(colorObjects.TAS, currColorCode); setColorObjectForMenu(tasselMenuButtons, ti, currColorObj, "TASMenu"+ti) } } currColorCode = urlStr.substr(37, 2); if(currColorCode && currColorCode != "XX") { currColorObj = getColorObjForMenu(colorObjects.RIB, currColorCode); setColorObjectForMenu(ribbonMenuButtons, 0, currColorObj, "RIBMenu0"); } currColorCode = urlStr.substr(39, 2); if(currColorCode && currColorCode != "XX") { currColorObj = getColorObjForMenu(colorObjects.BAS, currColorCode); setColorObjectForMenu(baseMenuButtons, 0, currColorObj, "BASMenu0") } } function getColorObjForMenu(colorList, colorCode) { var selectedObj; for(var i = 0; i < colorList.length; i++) { if(colorList[i].code == colorCode) { selectedObj = colorList[i]; break; } } return selectedObj; } function setupMenuArraysJS() { /* */ $.ajax({ //url:'http://demo.imnit.in/cms/service/getdata', url:'/centerpiece_party_favor_designer/cp/service/getdata', success: function(db_data) { getDataResonse(db_data); } }); /**/ /* var temp = '{"pompom":[{"name":"White","code":"WH","color_code":"#FCFBFC","images":["http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_1.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_2.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_3.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_4.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_5.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_6.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_7.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_8.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_9.png","http:\/\/demo.imnit.in\/cms\/AP10\/POM\/white_pom_position_10.png"]},{"name":"Metallic Silver","code":"MS","color_code":"#E7E8F2","images":["","","","","","","","","",""]},{"name":"Iridescent White","code":"IW","color_code":"#f5e3d2","images":["","","","","","","","","",""]},{"name":"Ivory","code":"IV","color_code":"#f2edce","images":["","","","","","","","","",""]},{"name":"Grey","code":"GY","color_code":"#9a91ae","images":["","","","","","","","","",""]},{"name":"Burgundy","code":"BU","color_code":"#5c0108","images":["","","","","","","","","",""]},{"name":"Metallic Burgundy","code":"MY","color_code":"#620108","images":["","","","","","","","","",""]},{"name":"Brown","code":"BR","color_code":"#65272c","images":["","","","","","","","","",""]},{"name":"Cabernet","code":"CA","color_code":"#7d0000","images":["","","","","","","","","",""]},{"name":"Metallic Red","code":"RM","color_code":"#d01529","images":["","","","","","","","","",""]},{"name":"Red","code":"RD","color_code":"#d01529","images":["","","","","","","","","",""]},{"name":"Orange","code":"OR","color_code":"#ff6808","images":["","","","","","","","","",""]},{"name":"Tangerine","code":"TA","color_code":"#ffa172","images":["","","","","","","","","",""]},{"name":"Coral","code":"CO","color_code":"#f25858","images":["","","","","","","","","",""]},{"name":"Fuchsia","code":"FU","color_code":"#ff8cff","images":["","","","","","","","","",""]},{"name":"Metallic Fuchsia","code":"MF","color_code":"#ff21a3","images":["","","","","","","","","",""]},{"name":"Hot Pink","code":"HP","color_code":"#ff46d5","images":["","","","","","","","","",""]},{"name":"Metallic Pink","code":"MK","color_code":"#f288ab","images":["","","","","","","","","",""]},{"name":"Pink","code":"PK","color_code":"#ff8fb2","images":["","","","","","","","","",""]},{"name":"Azalea","code":"AZ","color_code":"#ffb3ca","images":["","","","","","","","","",""]},{"name":"Peach","code":"PH","color_code":"#f2ccc8","images":["","","","","","","","","",""]},{"name":"Metallic Gold","code":"MG","color_code":"#e9de81","images":["","","","","","","","","",""]},{"name":"Light Yellow","code":"LY","color_code":"#fff95a","images":["","","","","","","","","",""]},{"name":"Daffodil Yellow","code":"DA","color_code":"#f5c000","images":["","","","","","","","","",""]},{"name":"Mint","code":"MI","color_code":"#84ce6e","images":["","","","","","","","","",""]},{"name":"Mustard","code":"MU","color_code":"#d9ac25","images":["","","","","","","","","",""]},{"name":"Lime Green","code":"LM","color_code":"#2cd541","images":["","","","","","","","","",""]},{"name":"Metallic Green","code":"MN","color_code":"#3ba758","images":["","","","","","","","","",""]},{"name":"Emerald Green","code":"EM","color_code":"#08115","images":["","","","","","","","","",""]},{"name":"Hunter Green","code":"HU","color_code":"#54939","images":["","","","","","","","","",""]},{"name":"Sage","code":"SA","color_code":"#afceb4","images":["","","","","","","","","",""]},{"name":"Metallic Light Blue","code":"ML","color_code":"#b9e6f5","images":["","","","","","","","","",""]},{"name":"Celedon","code":"CE","color_code":"#beffd6","images":["","","","","","","","","",""]},{"name":"Baby Blue","code":"BB","color_code":"#b9e6f9","images":["","","","","","","","","",""]},{"name":"Aqua","code":"AQ","color_code":"#1fcdc1","images":["","","","","","","","","",""]},{"name":"Seafoam","code":"SF","color_code":"#2fd9eb","images":["","","","","","","","","",""]},{"name":"Turquoise","code":"TU","color_code":"#6c5e3","images":["","","","","","","","","",""]},{"name":"Teal","code":"TL","color_code":"#1ea6a7","images":["","","","","","","","","",""]},{"name":"Metallic Royal Blue","code":"MR","color_code":"#278d9","images":["","","","","","","","","",""]},{"name":"Cornflower","code":"CB","color_code":"#2885d0","images":["","","","","","","","","",""]},{"name":"Royal Blue","code":"RB","color_code":"#1b27b1","images":["","","","","","","","","",""]},{"name":"Navy","code":"NA","color_code":"#121b63","images":["","","","","","","","","",""]},{"name":"Periwinkle","code":"PW","color_code":"#6c6ab9","images":["","","","","","","","","",""]},{"name":"Lavender","code":"LA","color_code":"#c39aff","images":["","","","","","","","","",""]},{"name":"Metallic Purple","code":"MP","color_code":"#d752f4","images":["","","","","","","","","",""]},{"name":"Purple","code":"PP","color_code":"#a33ab4","images":["","","","","","","","","",""]},{"name":"Eggplant","code":"EP","color_code":"#56324d","images":["","","","","","","","","",""]},{"name":"Black","code":"BK","color_code":"#100b17","images":["","","","","","","","","",""]}],"tassels":[{"name":"White","code":"WH","color_code":"#FCFBFC","images":["http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/white_tas_position_1.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/white_tas_position_2.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/white_tas_position_3.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/white_tas_position_4.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/white_tas_position_5.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/white_tas_position_6.png"]},{"name":"Metallic Silver","code":"MS","color_code":"#E7E8F2","images":["http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/metallic_silver_tas_position_1.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/metallic_silver_tas_position_2.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/metallic_silver_tas_position_3.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/metallic_silver_tas_position_4.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/metallic_silver_tas_position_5.png","http:\/\/demo.imnit.in\/cms\/AP10\/TAS\/metallic_silver_tas_position_6.png"]},{"name":"Iridescent White","code":"IW","color_code":"#f5e3d2","images":["","","","","",""]},{"name":"Ivory","code":"IV","color_code":"#f2edce","images":["","","","","",""]},{"name":"Grey","code":"GY","color_code":"#9a91ae","images":["","","","","",""]},{"name":"Burgundy","code":"BU","color_code":"#5c0108","images":["","","","","",""]},{"name":"Metallic Burgundy","code":"MY","color_code":"#620108","images":["","","","","",""]},{"name":"Brown","code":"BR","color_code":"#65272c","images":["","","","","",""]},{"name":"Cabernet","code":"CA","color_code":"#7d0000","images":["","","","","",""]},{"name":"Red","code":"RD","color_code":"#d01529","images":["","","","","",""]},{"name":"Metallic Red","code":"RM","color_code":"#d01529","images":["","","","","",""]},{"name":"Orange","code":"OR","color_code":"#ff6808","images":["","","","","",""]},{"name":"Tangerine","code":"TA","color_code":"#ffa172","images":["","","","","",""]},{"name":"Metallic Copper","code":"MC","color_code":"#f56d00","images":["","","","","",""]},{"name":"Coral","code":"CO","color_code":"#f25858","images":["","","","","",""]},{"name":"Fuchsia","code":"FU","color_code":"#ff8cff","images":["","","","","",""]},{"name":"Metallic Fuchsia","code":"MF","color_code":"#ff21a3","images":["","","","","",""]},{"name":"Hot Pink","code":"HP","color_code":"#ff46d5","images":["","","","","",""]},{"name":"Metallic Pink","code":"MK","color_code":"#f288ab","images":["","","","","",""]},{"name":"Baby Pink","code":"BP","color_code":"#ffcfd6","images":["","","","","",""]},{"name":"Azalea","code":"AZ","color_code":"#ffb3ca","images":["","","","","",""]},{"name":"Peach","code":"PH","color_code":"#f2ccc8","images":["","","","","",""]},{"name":"Metallic Gold","code":"MG","color_code":"#e9de81","images":["","","","","",""]},{"name":"Light Yellow","code":"LY","color_code":"#fff95a","images":["","","","","",""]},{"name":"Daffodil Yellow","code":"DA","color_code":"#f5c000","images":["","","","","",""]},{"name":"Mustard","code":"MU","color_code":"#d9ac25","images":["","","","","",""]},{"name":"Lime Green","code":"LM","color_code":"#2cd541","images":["","","","","",""]},{"name":"Mint","code":"PG","color_code":"#3bff03","images":["","","","","",""]},{"name":"Metallic Green","code":"MN","color_code":"#3ba758","images":["","","","","",""]},{"name":"Hunter Green","code":"HU","color_code":"#54939","images":["","","","","",""]},{"name":"Metallic Light Blue","code":"ML","color_code":"#b9e6f5","images":["","","","","",""]},{"name":"Sage","code":"SA","color_code":"#afceb4","images":["","","","","",""]},{"name":"Celedon","code":"CE","color_code":"#beffd6","images":["","","","","",""]},{"name":"Baby Blue","code":"BB","color_code":"#b9e6f9","images":["","","","","",""]},{"name":"Aqua","code":"AQ","color_code":"#1fcdc1","images":["","","","","",""]},{"name":"Seafoam","code":"SF","color_code":"#2fd9eb","images":["","","","","",""]},{"name":"Turquoise","code":"TU","color_code":"#6c5e3","images":["","","","","",""]},{"name":"Teal","code":"TL","color_code":"#1ea6a7","images":["","","","","",""]},{"name":"Cornflower","code":"CB","color_code":"#2885d0","images":["","","","","",""]},{"name":"Metallic Royal Blue","code":"MR","color_code":"#278d9","images":["","","","","",""]},{"name":"Royal Blue","code":"RB","color_code":"#1b27b1","images":["","","","","",""]},{"name":"Navy","code":"NA","color_code":"#121b63","images":["","","","","",""]},{"name":"Periwinkle","code":"PW","color_code":"#6c6ab9","images":["","","","","",""]},{"name":"Lavender","code":"LA","color_code":"#c39aff","images":["","","","","",""]},{"name":"Metallic Purple","code":"MP","color_code":"#d752f4","images":["","","","","",""]},{"name":"Purple","code":"PP","color_code":"#a33ab4","images":["","","","","",""]},{"name":"Eggplant","code":"EP","color_code":"#56324d","images":["","","","","",""]},{"name":"Black","code":"BK","color_code":"#100b17","images":["","","","","",""]}],"ribbons":[{"name":"White","code":"WH","color_code":"#FCFBFC","images":["http:\/\/demo.imnit.in\/cms\/AP10\/RIB\/white_rib_position_1.png"]},{"name":"Metallic Silver","code":"MS","color_code":"#e7e8f2","images":[]},{"name":"Grey","code":"GY","color_code":"#9a91ae","images":[]},{"name":"Silver","code":"SL","color_code":"#e7e8f2","images":[]},{"name":"Burgundy Dark","code":"BX","color_code":"#570402","images":[]},{"name":"Metallic Burgundy","code":"MY","color_code":"#620108","images":[]},{"name":"Brown","code":"BR","color_code":"#65272c","images":[]},{"name":"Cabernet","code":"CA","color_code":"#7d0000","images":[]},{"name":"Metallic Red","code":"RM","color_code":"#d01529","images":[]},{"name":"Red","code":"RD","color_code":"#d01529","images":[]},{"name":"Orange","code":"OR","color_code":"#ff6808","images":[]},{"name":"Tangerine","code":"TA","color_code":"#ffa172","images":[]},{"name":"Metallic Copper","code":"MC","color_code":"#f56d00","images":[]},{"name":"Fuchsia","code":"FU","color_code":"#ff8cff","images":[]},{"name":"Hot Pink","code":"HP","color_code":"#ff46d5","images":[]},{"name":"Metallic Hot Pink","code":"MH","color_code":"#ff46c8","images":[]},{"name":"Apricot","code":"AP","color_code":"#ff7c7f","images":[]},{"name":"Metallic Pink","code":"MK","color_code":"#f288ab","images":[]},{"name":"Mauve","code":"MO","color_code":"#fed2c0","images":[]},{"name":"Baby Pink","code":"BP","color_code":"#ffcfd6","images":[]},{"name":"Azalea","code":"AZ","color_code":"#ffb3ca","images":[]},{"name":"Peach","code":"PH","color_code":"#f2ccc8","images":[]},{"name":"Eggshell","code":"EG","color_code":"#f2edd0","images":[]},{"name":"Gold","code":"GL","color_code":"#e9de81","images":[]},{"name":"Light Yellow","code":"LY","color_code":"#fff95a","images":[]},{"name":"Daffodil Yellow","code":"DA","color_code":"#f5c000","images":[]},{"name":"Mustard","code":"MU","color_code":"#d9ac25","images":[]},{"name":"Mint","code":"MI","color_code":"#ccf9d8","images":[]},{"name":"Lime Green","code":"LM","color_code":"#2cd541","images":[]},{"name":"Metallic Green","code":"MN","color_code":"#3ba758","images":[]},{"name":"Emerald Green","code":"EM","color_code":"#08115","images":[]},{"name":"Hunter Green","code":"HU","color_code":"#54939","images":[]},{"name":"Metallic Light Blue","code":"ML","color_code":"#b9e6f5","images":[]},{"name":"Light Blue","code":"LB","color_code":"#b9e6f5","images":[]},{"name":"Aqua","code":"AQ","color_code":"#1fcdc1","images":[]},{"name":"Turquoise","code":"TU","color_code":"#6c5e3","images":[]},{"name":"Teal","code":"TL","color_code":"#1ea6a7","images":[]},{"name":"Cornflower","code":"CB","color_code":"#2885d0","images":[]},{"name":"Metallic Royal Blue","code":"MR","color_code":"#278d9","images":[]},{"name":"Royal Blue","code":"RB","color_code":"#1b27b1","images":[]},{"name":"Navy","code":"NA","color_code":"#121b63","images":[]},{"name":"Lavender","code":"LA","color_code":"#c39aff","images":[]},{"name":"Metallic Purple","code":"MP","color_code":"#d752f4","images":[]},{"name":"Purple","code":"PP","color_code":"#a33ab4","images":[]},{"name":"Eggplant","code":"EP","color_code":"#56324d","images":[]},{"name":"Black","code":"BK","color_code":"#100b17","images":[]}],"bases":[{"name":"Gold Base","code":"GL","color_code":"#E4E6A7","images":["http:\/\/demo.imnit.in\/cms\/AP10\/BAS\/gold_base_bas_position_1.png"]},{"name":"Silver Base","code":"SL","color_code":"#edeceb","images":[]},{"name":"White Lace Gold Base","code":"AG","color_code":"#e4e6a7","images":[]},{"name":"White Lace Silver Base","code":"AS","color_code":"#edeceb","images":[]},{"name":"Blue Lace Gold Base","code":"BG","color_code":"#e4e6a7","images":[]},{"name":"Blue Lace Silver Base","code":"BS","color_code":"#edeceb","images":[]},{"name":"Blue Stripes Gold Base","code":"CG","color_code":"#e4e6a7","images":[]},{"name":"Blue Stripes Silver Base","code":"CS","color_code":"#edeceb","images":[]},{"name":"Wanderfuls I Gold Base","code":"DG","color_code":"#e4e6a7","images":[]},{"name":"Wanderfuls I Silver Base","code":"DS","color_code":"#edeceb","images":[]},{"name":"Wanderfuls II Gold Base","code":"EG","color_code":"#e4e6a7","images":[]},{"name":"Wanderfuls II Silver Base","code":"ES","color_code":"#edeceb","images":[]}],"candies":[{"name":"Silver Foil Wrapped Candy","code":"1SL","color_code":"#D2D3DE","images":["http:\/\/demo.imnit.in\/cms\/AP10\/CAN\/silver_foil_wrapped_candy_can_position_1.png"]},{"name":"Gold Foil Wrapped Candy","code":"1GL","color_code":"#DCD2A0","images":["http:\/\/demo.imnit.in\/cms\/AP10\/CAN\/gold_foil_wrapped_candy_can_position_1.png"]},{"name":"Red Foil Wrapped Candy","code":"1RD","color_code":"#d01529","images":[]},{"name":"Blue Foil Wrapped Candy","code":"1BL","color_code":"#121b63","images":[]},{"name":"Purple Foil Wrapped Candy","code":"1PP","color_code":"#ff7dff","images":[]},{"name":"Black Foil Wrapped Candy","code":"1BK","color_code":"#100b17","images":[]},{"name":"Green Foil Wrapped Candy","code":"1GN","color_code":"#3ba758","images":[]},{"name":"Gold Hershey Kisses","code":"2GL","color_code":"#dbd0a5","images":[]},{"name":"Silver Hershey Kisses","code":"2SL","color_code":"#d2d3de","images":[]},{"name":"Lavender Jordan Almonds","code":"3LA","color_code":"#c39aff","images":[]},{"name":"White Jordan Almonds","code":"3WH","color_code":"#fcfbfc","images":[]},{"name":"Pink Jordan Almonds","code":"3PK","color_code":"#ffcfd6","images":[]},{"name":"Light Blue Jordan Almonds","code":"3LB","color_code":"#b9e6f9","images":[]},{"name":"Light Green Jordan Almonds","code":"3LG","color_code":"#2cd541","images":[]},{"name":"Light Yellow Jordan Almonds","code":"3LY","color_code":"#fff95a","images":[]},{"name":"Peach Jordan Almonds","code":"3PH","color_code":"#f2ccc8","images":[]},{"name":"After Dinner Mints","code":"4WH","color_code":"#fafafa","images":[]},{"name":"Light Pink Lentils","code":"5LP","color_code":"#ffcfd6","images":[]},{"name":"Dark Pink Lentils","code":"5DP","color_code":"#ff46d5","images":[]},{"name":"Lavender Lentils","code":"5LA","color_code":"#c39aff","images":[]},{"name":"Purple Lentils","code":"5PP","color_code":"#ff83ff","images":[]},{"name":"Navy Lentils","code":"5NA","color_code":"#121b63","images":[]},{"name":"Green Lentils","code":"5GN","color_code":"#08115","images":[]},{"name":"White Lentils","code":"5WH","color_code":"#fcfcfc","images":[]},{"name":"Black Lentils","code":"5BK","color_code":"#100b17","images":[]},{"name":"Light Yellow Lentils","code":"5LY","color_code":"#fff95a","images":[]},{"name":"Red Lentils","code":"5RD","color_code":"#d01529","images":[]},{"name":"Orange Lentils","code":"5OR","color_code":"#ff3b09","images":[]},{"name":"Fruit Runts","code":"6FR","color_code":"#ff3b09","images":[]},{"name":"Jelly Beans","code":"7JB","color_code":"#e88b86","images":[]},{"name":"Gumballs","code":"8WH","color_code":"#fbfbfb","images":[]}],"combinecandies":[{"name":"Silver Foil Wrapped Candy Gold Foil Wrapped Candy","code1":"1SL","code2":"1GL","color_code1":"#D2D3DE","color_code2":"#DCD2A0","images":["http:\/\/demo.imnit.in\/cms\/AP10\/CAN\/silver_foil_wrapped_candy_gold_foil_wrapped_candy_can_position_1.png"]}],"setting":[{"name":"Click Limit","setting_value":"2"},{"name":"Default Color Setting","setting_value":"A101BUXXXXXXXXXX100SLXXXXWHXXXXXXXXXXWHGL"},{"name":"Sign Up Message","setting_value":"Please login now or create new account to continue"}]}'; getDataResonse(temp); /**/ } function getDataResonse(db_data) { var obj = JSON.parse(db_data); var candyCombArr = []; if(obj.combinecandies) { var combinecandies = obj.combinecandies; for(var i = 0; i < combinecandies.length; i++) { candyCombArr.push({codes:[combinecandies[i].code1, combinecandies[i].code2], images:combinecandies[i].images}); } } colorObjects = {POM:parseColorArray(obj.pompom), TAS:parseColorArray(obj.tassels), CAN:parseColorArray(obj.candies), RIB:parseColorArray(obj.ribbons), BAS:parseColorArray(obj.bases), candyComb:candyCombArr}; settingObjects = {}; var settingObjs = obj.setting; if(settingObjs) { console.log("settingObjs" + settingObjs); for(var si = 0; si < settingObjs.length; si++) { var settingName = settingObjs[si].name; var settingVal = settingObjs[si].setting_value; console.log(settingName); if(settingName == "Click Limit") { settingObjects.clickLimit = settingVal; limitClicks = parseInt(settingVal); if(limitClicks > 0 && !limitDisabled) { isLimitAdded = true; } } if(settingName == "Default Color Setting") { settingObjects.defaultColorUrl = settingVal; } if(settingName == "Sign Up Message") { settingObjects.signUpMessage = settingVal; } } } setupUi(); } function parseColorArray(value) { var pArr = []; if(value) { for(var i = 0; i < value.length; i++) { currColorName = value[i].name; currColorCode = value[i].code; currColorHex = value[i].color_code; pArr.push({code:currColorCode, hex:currColorHex, name:currColorName, images:value[i].images, swatchImage:value[i].color_image}); } } return pArr; } function setMenuArrays() { var txtFile = "WH 252 251 252 White,MS 231 232 242 Metallic Silver,IW 245 227 210 Iridescent White,IV 242 237 206 Ivory,GY 154 145 174 Grey,BU 092 001 008 Burgundy,MY 098 001 008 Metallic Burgundy,BR 101 039 044 Brown,CA 125 000 000 Cabernet,RM 208 021 041 Metallic Red,RD 208 021 041 Red,OR 255 104 008 Orange,TA 255 161 114 Tangerine,CO 242 088 088 Coral,FU 255 140 255 Fuchsia,MF 255 033 163 Metallic Fuchsia,HP 255 070 213 Hot Pink,MK 242 136 171 Metallic Pink,PK 255 143 178 Pink,AZ 255 179 202 Azalea,PH 242 204 200 Peach,MG 233 222 129 Metallic Gold,LY 255 249 090 Light Yellow,DA 245 192 000 Daffodil Yellow,MI 132 206 110 Mint,MU 217 172 037 Mustard,LM 044 213 065 Lime Green,MN 059 167 088 Metallic Green,EM 000 129 021 Emerald Green,HU 005 073 057 Hunter Green,SA 175 206 180 Sage,ML 185 230 245 Metallic Light Blue,CE 190 255 214 Celedon,BB 185 230 249 Baby Blue,AQ 031 205 193 Aqua,SF 047 217 235 Seafoam,TU 006 197 227 Turquoise,TL 030 166 167 Teal,MR 002 120 217 Metallic Royal Blue,CB 040 133 208 Cornflower,RB 027 039 177 Royal Blue,NA 018 027 099 Navy,PW 108 106 185 Periwinkle,LA 195 154 255 Lavender,MP 215 082 244 Metallic Purple,PP 163 058 180 Purple,EP 086 050 077 Eggplant,BK 016 011 023 Black,XXXXX,WH 252 251 252 White,MS 231 232 242 Metallic Silver,IW 245 227 210 Iridescent White,IV 242 237 206 Ivory,GY 154 145 174 Grey,BU 092 001 008 Burgundy,MY 098 001 008 Metallic Burgundy,BR 101 039 044 Brown,CA 125 000 000 Cabernet,RD 208 021 041 Red,RM 208 021 041 Metallic Red,OR 255 104 008 Orange,TA 255 161 114 Tangerine,MC 245 109 000 Metallic Copper,CO 242 088 088 Coral,FU 255 140 255 Fuchsia,MF 255 033 163 Metallic Fuchsia,HP 255 070 213 Hot Pink,MK 242 136 171 Metallic Pink,BP 255 207 214 Baby Pink,AZ 255 179 202 Azalea,PH 242 204 200 Peach,MG 233 222 129 Metallic Gold,LY 255 249 090 Light Yellow,DA 245 192 000 Daffodil Yellow,MU 217 172 037 Mustard,LM 044 213 065 Lime Green,PG 059 255 003 Mint,MN 059 167 088 Metallic Green,HU 005 073 057 Hunter Green,ML 185 230 245 Metallic Light Blue,SA 175 206 180 Sage,CE 190 255 214 Celedon,BB 185 230 249 Baby Blue,AQ 031 205 193 Aqua,SF 047 217 235 Seafoam,TU 006 197 227 Turquoise,TL 030 166 167 Teal,CB 040 133 208 Cornflower,MR 002 120 217 Metallic Royal Blue,RB 027 039 177 Royal Blue,NA 018 027 099 Navy,PW 108 106 185 Periwinkle,LA 195 154 255 Lavender,MP 215 082 244 Metallic Purple,PP 163 058 180 Purple,EP 086 050 077 Eggplant,BK 016 011 023 Black,XXXXX,1SL 210 211 222 Silver Foil Wrapped Candy,1GL 220 210 160 Gold Foil Wrapped Candy,1RD 208 021 041 Red Foil Wrapped Candy,1BL 018 027 099 Blue Foil Wrapped Candy,1PP 255 125 255 Purple Foil Wrapped Candy,1BK 016 011 023 Black Foil Wrapped Candy,1GN 059 167 088 Green Foil Wrapped Candy,2GL 219 208 165 Gold Hershey Kisses,2SL 210 211 222 Silver Hershey Kisses,3LA 195 154 255 Lavender Jordan Almonds,3WH 252 251 252 White Jordan Almonds,3PK 255 207 214 Pink Jordan Almonds,3LB 185 230 249 Light Blue Jordan Almonds,3LG 044 213 065 Light Green Jordan Almonds,3LY 255 249 090 Light Yellow Jordan Almonds,3PH 242 204 200 Peach Jordan Almonds,4WH 250 250 250 After Dinner Mints,5LP 255 207 214 Light Pink Lentils,5DP 255 070 213 Dark Pink Lentils,5LA 195 154 255 Lavender Lentils,5PP 255 131 255 Purple Lentils,5NA 018 027 099 Navy Lentils,5GN 000 129 021 Green Lentils,5WH 252 252 252 White Lentils,5BK 016 011 023 Black Lentils,5LY 255 249 090 Light Yellow Lentils,5RD 208 021 041 Red Lentils,5OR 255 059 009 Orange Lentils,6FR 255 059 009 Fruit Runts,7JB 232 139 134 Jelly Beans,8WH 251 251 251 Gumballs,XXXXX,WH 252 251 252 White,MS 231 232 242 Metallic Silver,GY 154 145 174 Grey,SL 231 232 242 Silver,BX 087 004 002 Burgundy Dark,MY 098 001 008 Metallic Burgundy,BR 101 039 044 Brown,CA 125 000 000 Cabernet,RM 208 021 041 Metallic Red,RD 208 021 041 Red,OR 255 104 008 Orange,TA 255 161 114 Tangerine,MC 245 109 000 Metallic Copper,FU 255 140 255 Fuchsia,HP 255 070 213 Hot Pink,MH 255 070 200 Metallic Hot Pink,AP 255 124 127 Apricot,MK 242 136 171 Metallic Pink,MO 254 210 192 Mauve,BP 255 207 214 Baby Pink,AZ 255 179 202 Azalea,PH 242 204 200 Peach,EG 242 237 208 Eggshell,GL 233 222 129 Gold,LY 255 249 090 Light Yellow,DA 245 192 000 Daffodil Yellow,MU 217 172 037 Mustard,MI 204 249 216 Mint,LM 044 213 065 Lime Green,MN 059 167 088 Metallic Green,EM 000 129 021 Emerald Green,HU 005 073 057 Hunter Green,ML 185 230 245 Metallic Light Blue,LB 185 230 245 Light Blue,AQ 031 205 193 Aqua,TU 006 197 227 Turquoise,TL 030 166 167 Teal,CB 040 133 208 Cornflower,MR 002 120 217 Metallic Royal Blue,RB 027 039 177 Royal Blue,NA 018 027 099 Navy,LA 195 154 255 Lavender,MP 215 082 244 Metallic Purple,PP 163 058 180 Purple,EP 086 050 077 Eggplant,BK 016 011 023 Black,XXXXX,GL 228 230 167 Gold Base,SL 237 236 235 Silver Base,AG 228 230 167 White Lace Gold Base,AS 237 236 235 White Lace Silver Base,BG 228 230 167 Blue Lace Gold Base,BS 237 236 235 Blue Lace Silver Base,CG 228 230 167 Blue Stripes Gold Base,CS 237 236 235 Blue Stripes Silver Base,DG 228 230 167 Wanderfuls I Gold Base,DS 237 236 235 Wanderfuls I Silver Base,EG 228 230 167 Wanderfuls II Gold Base,ES 237 236 235 Wanderfuls II Silver Base,XXXXX"; var str_array = txtFile.split(","); var parsedArray = []; var currParsingArray = []; // parsedArray.push(currParsingArray); for (i = 0; i < str_array.length; i++) { // console.log(i + " - " + str_array[i]); if (str_array[i] == "XXXXX") { console.log(JSON.stringify(currParsingArray)); //console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); parsedArray.push(currParsingArray); currParsingArray = []; } else { var currColorCode; var currColorHex; var currColorName; r = parseInt(str_array[i].substr(4,3),10); currColorHex = "0x"+ (r > 15) ? r.toString(16): "0" + r.toString(16); g = parseInt(str_array[i].substr(8,3),10); currColorHex +=(g > 15) ? g.toString(16): "0" + g.toString(16); b = parseInt(str_array[i].substr(12,3),10); currColorHex +=(b > 15) ? b.toString(16): "0" + b.toString(16); currColorName = str_array[i].substr(16); if (str_array[i].charAt(2) == " ") { currColorCode = str_array[i].substr(0,2); } else { currColorCode = str_array[i].substr(0,3); } currParsingArray.push({code:currColorCode, hex:currColorHex, name:currColorName}) //console.log('{code:"'+currColorCode+'", hex:"'+currColorHex+'", name:"'+currColorName+'"}'); } } //console.log(parsedArray); colorObjects = {POM:parsedArray[0], TAS:parsedArray[1], CAN:parsedArray[2], RIB:parsedArray[3], BAS:parsedArray[4]}; } function resizeDesignerCanvas() { //width="640" height="480" var w = $(window).width(); var iScl; if(w < 640) { var ch = (w * 480)/640; } else { w = 640; ch = 480; } iScl = w/640; if(iScl != scl) { stage.canvas.width = w; stage.canvas.height = ch; scl = iScl; rescaleLayerImages(); setSignupMessageScale(); stage.update(); } }