SHARE
TWEET

adadadad

NewBleuGuy Mar 21st, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ╔═══╦══╗╔═══╦╗░╔╦═══╦═══╦═══╦════╦═══╦═══╗
  2. ║╔═╗║╔╗║║╔══╣║░║║╔═╗║╔═╗║╔═╗║╔╗╔╗║╔══╩╗╔╗║
  3. ║║░║║╚╝╚╣╚══╣║░║║╚══╣║░╚╣║░║╠╝║║╚╣╚══╗║║║║
  4. ║║░║║╔═╗║╔══╣║░║╠══╗║║░╔╣╚═╝║░║║░║╔══╝║║║║
  5. ║╚═╝║╚═╝║║░░║╚═╝║╚═╝║╚═╝║╔═╗║░║║░║╚══╦╝╚╝║
  6. ╚═══╩═══╩╝░░╚═══╩═══╩═══╩╝░╚╝░╚╝░╚═══╩═══╝
  7. ╔╗╔╗╔╦══╦════╦╗░╔╗░░░░░░░░░░░░░░░░░░░░░░░░
  8. ║║║║║╠╣╠╣╔╗╔╗║║░║║░░░░░░░░░░░░░░░░░░░░░░░░
  9. ║║║║║║║║╚╝║║╚╣╚═╝║░░░░░░░░░░░░░░░░░░░░░░░░
  10. ║╚╝╚╝║║║░░║║░║╔═╗║░░░░░░░░░░░░░░░░░░░░░░░░
  11. ╚╗╔╗╔╬╣╠╗░║║░║║░║║░░░░░░░░░░░░░░░░░░░░░░░░
  12. ░╚╝╚╝╚══╝░╚╝░╚╝░╚╝░░░░░░░░░░░░░░░░░░░░░░░░
  13. ╔═══╦═══╦═══╦═╗░╔╦══╗╔═══╗░░░░░░░░░░░░░░░░
  14. ║╔═╗║╔═╗║╔═╗║║╚╗║║╔╗║║╔═╗║░░░░░░░░░░░░░░░░
  15. ║║░║║╚═╝║║░║║╔╗╚╝║╚╝╚╣║░║║░░░░░░░░░░░░░░░░
  16. ║║░║║╔╗╔╣╚═╝║║╚╗║║╔═╗║║░║║░░░░░░░░░░░░░░░░
  17. ║╚═╝║║║╚╣╔═╗║║░║║║╚═╝║╚═╝║░░░░░░░░░░░░░░░░
  18. ╚═══╩╝╚═╩╝░╚╩╝░╚═╩═══╩═══╝░░░░░░░░░░░░░░░░
  19.  
  20. function tab(tab_name) {
  21.     $$('.tab-selected')[0].className = 'catalog-tab';
  22.     $("tab-" + tab_name).className += ' tab-selected';
  23.     $$('.catalog-selected')[0].className = 'catalogItems';
  24.     $("catalog-" + tab_name).className += ' catalog-selected';
  25. }
  26. function redraw(category_name, item_name) {
  27.     if (category_name == "hat" || category_name == "hair") {
  28.         item_name = (item_name == "None") ? category_name + item_name : item_name;
  29.         $("student-avatar-" + category_name + "-img").src = "/images/avatar/" + item_name + ".png";
  30.     } else {
  31.         if (item_name == 'None') {
  32.             $("student-avatar-" + category_name).style.display = 'none';
  33.         } else {
  34.             $("student-avatar-" + category_name).style.display = 'block';
  35.             $("student-avatar-" + category_name).src = "/images/avatar/" + item_name + ".png";
  36.         }
  37.     }
  38. }
  39. function removalRedraw(category_name) {
  40.     if (category_name == "hat" || category_name == "hair") {
  41.         $("student-avatar-" + category_name + "-img").src = "/images/avatar/" + category_name + "None.png";
  42.     } else {
  43.         $("student-avatar-" + category_name).style.display = 'none';
  44.     }
  45. }
  46.  
  47. function redrawHeader(category_name, item_name) {
  48.     var itemHeaderImage = $$("#header-avatar-" + category_name + " img")[0];
  49.     if (itemHeaderImage != undefined) {
  50.         itemHeaderImage.src = "/images/avatar/" + item_name + ".png";
  51.     } else {
  52.         var url = "/main/Avatar/action/getCategoryHeightWidth/category_name/" + category_name;
  53.         new Ajax.Request(url,{
  54.             method: 'get',
  55.             onComplete: function(response) {
  56.                 var json = response.responseText.evalJSON(true);
  57.                 if (json['avatar_item_category_height'] && json['avatar_item_category_width']) {
  58.                     $("headerAvatar").insert("<div id='header-avatar-" + category_name + "'></div>");
  59.  
  60.                     var imgTag = "<img src='/images/avatar/" + item_name + ".png' ";
  61.                     imgTag += "height='" + (json['avatar_item_category_height'] * 0.5) + "px' ";
  62.                     imgTag += "width='" + (json['avatar_item_category_width'] * 0.5) + "px'>";
  63.                     $("header-avatar-" + category_name).insert(imgTag);
  64.                 }
  65.             }
  66.         });
  67.     }
  68. }
  69.  
  70. function updateOnMouseOut(category_name, item_name) {
  71.     var items = $$(".item-" + category_name);
  72.     for (var i = 0; i < items.length; ++i) {
  73.         items[i].onmouseout = function() {
  74.             redraw(category_name, item_name);
  75.         }
  76.         ;
  77.     }
  78. }
  79. function saveAvatar(category_name, item_name, item_id) {
  80.     var url = "/main/Avatar/action/getAvatarItem/item_id/" + item_id + "/item_name/" + item_name + "/category_name/" + category_name;
  81.     new Ajax.Request(url,{
  82.         method: 'get'
  83.     });
  84.  
  85.     if (category_name == "hat" || category_name == "hair") {
  86.         updateAvatarAndCatalogFunctionCalls(category_name, item_name, item_id);
  87.         setSelectedHatAndHair(category_name, item_name, item_id);
  88.     }
  89.     setCatalogStyleOnItemChange(item_name);
  90.     redraw(category_name, item_name);
  91.     redrawHeader(category_name, item_name);
  92.     updateOnMouseOut(category_name, item_name);
  93. }
  94.  
  95. function showConfirmPopup(item_name) {
  96.     $("confirm-" + item_name).style.display = 'block';
  97.     $("confirm-purchase-background").style.display = 'none';
  98.     spendableStars = $('availableStars').innerHTML;
  99.     if (Number(item_price) <= Number(spendableStars)) {
  100.         $("buy-" + item_name).style.display = 'block';
  101.         $("hasEnough-" + item_name).style.display = 'block';
  102.         $("notEnough-" + item_name).style.display = 'none';
  103.         $("need-stars-" + item_name).style.display = 'none';
  104.     } else {
  105.         $("buy-" + item_name).style.display = 'block';
  106.         $("hasEnough-" + item_name).style.display = 'block';
  107.         $("notEnough-" + item_name).style.display = 'none';
  108.         $("need-stars-" + item_name).style.display = 'none';
  109.     }
  110. }
  111.  
  112. function cancelPopup(item_name) {
  113.     $("confirm-" + item_name).style.display = 'none';
  114.     $("confirm-purchase-background").style.display = 'none';
  115. }
  116.  
  117. function purchase(category_name, item_name, item_id) {
  118.     url = "/main/Avatar/action/getAvatarItem/item_id/" + item_id + "/item_name/" + item_name + "/category_name/" + category_name;
  119.     spendableStars = $('availableStars').innerHTML;
  120.  
  121.     new Ajax.Request(url,{
  122.         method: 'get',
  123.         onComplete: function(response) {
  124.             var json = response.responseText.evalJSON(true);
  125.             if (json['available_stars']) {
  126.                 spendableStars = json['available_stars'];
  127.                 $('availableStars').update(json['available_stars']);
  128.  
  129.                 if ($('spendableStarsTextTotal') && (parseInt(json['available_stars']) != parseInt($('spendableStarsTextTotal').innerHTML))) {
  130.                     playStarAnimation(json['available_stars']);
  131.                 } else if ($('starDisplayCount')) {
  132.                     $('starDisplayCount').update(json['available_stars']);
  133.                 }
  134.             }
  135.  
  136.             if (json['status'] == 'succeeded') {
  137.                 redraw(category_name, item_name);
  138.                 redrawHeader(category_name, item_name);
  139.                 updateOnMouseOut(category_name, item_name);
  140.                 if (category_name == "hat" || category_name == "hair") {
  141.                     updateAvatarAndCatalogFunctionCalls(category_name, item_name, item_id);
  142.                     setSelectedHatAndHair(category_name, item_name, item_id);
  143.                     $("item-" + item_name).href = "javascript:saveAvatar('" + category_name + "', '" + item_id + "');";
  144.                 } else {
  145.                     $("item-" + item_name).href = "javascript:saveAvatar('" + category_name + "', '" + item_name + "', '" + item_id + "');";
  146.                 }
  147.                 setCatalogStyleOnItemChange(item_name);
  148.             }
  149.  
  150.             updateConfirmDialogs(item_name);
  151.         }
  152.     });
  153.  
  154.     cancelPopup(item_name);
  155. }
  156.  
  157. function updateConfirmDialogs(item_name) {
  158.     var confirm_dialogs = $$(".confirm-purchase-dialog");
  159.     for (var i = 0; i < confirm_dialogs.length; ++i) {
  160.         var priceTag = confirm_dialogs[i].select(".confirm-buy-item p span")[0].innerHTML;
  161.         confirm_dialogs[i].select(".confirm-purchase-dialog").innerHTML = parseInt(priceTag) - spendableStars;
  162.         if (parseInt(priceTag) > spendableStars) {
  163.             $$(".cancel")[i].style.display = 'block';
  164.             $$(".buy")[i].style.display = 'block';
  165.           }
  166.     }
  167. }
  168.  
  169. function removeItem(category_name, item_id) {
  170.     var itemImageSelector = "student-avatar-" + category_name;
  171.     itemImageSelector += (category_name == "hat" || category_name == "hair") ? "-img" : "";
  172.     actualItemName = $(itemImageSelector).src;
  173.     actualItemName = actualItemName.substr(actualItemName.lastIndexOf("/") + 1, actualItemName.length);
  174.     actualItemName = actualItemName.substr(0, actualItemName.lastIndexOf("."));
  175.  
  176.     if (item_id) {
  177.         url = "/main/Avatar/action/removeAvatarItem/item_id/" + item_id + "/category_name/" + category_name;
  178.         new Ajax.Request(url,{
  179.             method: 'get'
  180.         });
  181.         removalRedraw(category_name);
  182.         redrawHeader(category_name, category_name + "None");
  183.         updateOnMouseOut(category_name, "None");
  184.  
  185.         setSelectedItemToSaveAvatar(category_name, actualItemName, item_id);
  186.         setSelectedItemsOwned(category_name);
  187.         setSelectedHatAndHair(category_name, null, null);
  188.         $("student-avatar-" + category_name + "-img").up().setAttribute('href', "#");
  189.     }
  190. }
  191.  
  192. function setSelectedHatAndHair(category_name, item_name, item_id) {
  193.     if (category_name == "hat") {
  194.         selectedHatAndHair.hatName = item_name;
  195.         selectedHatAndHair.hatId = item_id;
  196.     } else if (category_name == "hair") {
  197.         selectedHatAndHair.hairName = item_name;
  198.         selectedHatAndHair.hairId = item_id;
  199.     }
  200. }
  201.  
  202. function updateAvatarAndCatalogFunctionCalls(category_name, item_name, item_id) {
  203.     // Set the avatar's hat or hair and corresponding catalog picture to removeItem on click
  204.     $("student-avatar-" + category_name + "-img").up().setAttribute('href', "javascript:saveAvatar('" + category_name + "', '" + item_id + "');");
  205.     $("item-" + item_name).setAttribute('href', "javascript:saveAvatar('" + category_name + "', '" + item_id + "');");
  206.  
  207.     // Set old (currently selected) item to saveAvatar on click
  208.     setSelectedItemToSaveAvatar(category_name, null, null);
  209. }
  210.  
  211. function setSelectedItemToSaveAvatar(category_name, item_name, item_id) {
  212.     var selectedItemInfo = getSelectedItemInfo(category_name);
  213.     item_name = (item_name) ? item_name : selectedItemInfo.item_name;
  214.     item_id = (item_id) ? item_id : selectedItemInfo.item_id;
  215.  
  216.     if (item_name && item_id) {
  217.         // There was a previous item
  218.         $("item-" + item_name).href = "javascript:saveAvatar('" + category_name + "', '" + item_name + "', '" + item_id + "');";
  219.     }
  220. }
  221.  
  222. function getSelectedItemInfo(category_name) {
  223.     if (category_name == "hat") {
  224.         return {
  225.             item_name: selectedHatAndHair.hatName,
  226.             item_id: selectedHatAndHair.hatId
  227.         };
  228.     } else if (category_name == "hair") {
  229.         return {
  230.             item_name: selectedHatAndHair.hairName,
  231.             item_id: selectedHatAndHair.hairId
  232.         };
  233.     } else {
  234.         return {
  235.             item_name: null,
  236.             item_id: null
  237.         };
  238.     }
  239. }
  240.  
  241. function setCatalogStyleOnItemChange(item_name) {
  242.     $("price-tag-" + item_name).addClassName("soldItemPrice");
  243.     $("price-tag-" + item_name).removeClassName("itemPrice");
  244.  
  245.     var allSelected = $$(".catalog-selected .selectedCatalogItem");
  246.     for (var i = 0; i < allSelected.length; ++i) {
  247.         allSelected[i].addClassName("ownedCatalogItem");
  248.         allSelected[i].removeClassName("selectedCatalogItem");
  249.     }
  250.  
  251.     $("item-" + item_name).addClassName("selectedCatalogItem");
  252. }
  253.  
  254. function setSelectedItemsOwned(category_name) {
  255.     var selector = "catalog-" + category_name;
  256.     var allSelected = $(selector).select(".selectedCatalogItem");
  257.     for (var i = 0; i < allSelected.length; ++i) {
  258.         allSelected[i].addClassName("ownedCatalogItem");
  259.         allSelected[i].removeClassName("selectedCatalogItem");
  260.     }
  261. }
  262.  
  263. function finishAvatarVisit() {
  264.     var url = "/main/Avatar/action/finishAvatarVisit";
  265.     new Ajax.Request(url,{
  266.         method: 'get'
  267.     });
  268. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top