SHARE
TWEET

Untitled

a guest Jan 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function process_step_1() {
  2.     "use strict";
  3.  
  4.     document.getElementById('step-1').style.display = 'none';
  5.     document.getElementById('step-2').style.display = 'block';
  6. }
  7.  
  8. function process_step_2() {
  9.     "use strict";
  10.  
  11.     var logo = [];
  12.  
  13.     var logos = document.getElementsByName('logo');
  14.     var logos_length = logos.length;
  15.  
  16.     for (var i = 0; i < logos_length; i++) {
  17.         if (logos[i].type === 'radio' && logos[i].checked === true) {
  18.             logo.push(logos[i].value);
  19.         }
  20.     }
  21.  
  22.     if (logo.length <= 0) {
  23.         alert('Nepasirinktas marškinėlių paveikslėlis.');
  24.     } else {
  25.         document.getElementById('step-2').style.display = 'none';
  26.         document.getElementById('step-3').style.display = 'block';
  27.  
  28.         document.getElementById('display-logo').innerHTML = '<img src="' + logo + '" alt="Marškinėlio objektas" id="t-shirt-logo">';
  29.     }
  30. }
  31.  
  32. function step_back_2() {
  33.     "use strict";
  34.  
  35.     document.getElementById('step-1').style.display = 'block';
  36.     document.getElementById('step-2').style.display = 'none';
  37. }
  38.  
  39. function t_shirt_color(color) {
  40.     "use strict";
  41.  
  42.     var result;
  43.  
  44.      /*
  45.      if (color == '#FFFFFF') {
  46.  
  47.         result = '1';
  48.     } else if (color == '#999999') {
  49.         result = '2';
  50.     } else if (color == '#77D3F2') {
  51.         result = '3';
  52.     } else if (color == '#000000') {
  53.         result = '4';
  54.     } else {
  55.         result = '1';
  56.     }
  57.  
  58.     */
  59.  
  60.     switch (color) {
  61.         case '#FFFFFF':
  62.             result = '1';
  63.             console.log(result);
  64.             break;
  65.         case '#999999':
  66.             result = '2';
  67.             console.log(result);
  68.             break;
  69.         case '#77D3F2':
  70.             result = '3';
  71.             console.log(result);
  72.             break;
  73.         case '#000000':
  74.             result = '4';
  75.             console.log(result);
  76.             break;
  77.         default:
  78.             result = '1';
  79.             console.log(result);
  80.             break;
  81.     }
  82.  
  83.  
  84.     return parseInt(result);
  85. }
  86.  
  87. function t_shirt_gender(gender) {
  88.     "use strict";
  89.  
  90.     var result;
  91.  
  92.     switch (gender) {
  93.         case 'Moteris':
  94.             result = 'female';
  95.             break;
  96.         case 'Vyras':
  97.             result = 'male';
  98.             break;
  99.         default:
  100.             result = 'male';
  101.             break;
  102.     }
  103.  
  104.     return result;
  105. }
  106.  
  107. function process_step_3() {
  108.     "use strict";
  109.  
  110.     var color = [];
  111.  
  112.     var colors = document.getElementsByName('color');
  113.     var colors_length = colors.length;
  114.  
  115.     for (var i = 0; i < colors_length; i++) {  //neprotinga kurtis kintamaji ir saugoti jame masyvo ilgi. Kadangi JS viskas yra objektas, galima iskarto naudoti metoda. Siuo atvej colors.length
  116.         if (colors[i].type === 'radio' && colors[i].checked === true) {
  117.             color.push(colors[i].value);
  118.         }
  119.     }
  120.  
  121.     var gender = document.getElementById('gender');
  122.     var size = document.getElementById('size');
  123.  
  124.     if (color.length <= 0) {
  125.         alert('Nepasirinkta marškinėlių spalva.');
  126.     } else if (gender.value === 'false') {
  127.         alert('Nepasirinkta marškinėlių lytis.');
  128.     } else if (size.value === 'false') {
  129.         alert('Nepasirinktas marškinėlių dydis.');
  130.     } else {
  131.         console.log(color);
  132.         document.getElementById('step-3').style.display = 'none';
  133.         document.getElementById('step-4').style.display = 'block';
  134.  
  135.         document.getElementById('display-t-shirt').innerHTML = '<img src="images/clothes/' + t_shirt_gender(gender.value) + '/' + t_shirt_color(color[0]) + '.png" alt="Marškinėlis">'; //tavo switch klaida cia. Paaiskinsiu per pamoka
  136.         document.getElementById('display-color').innerHTML = '<div id="style-5" style="background: ' + color + ';">';
  137.         document.getElementById('display-gender').innerHTML = gender.value;
  138.         document.getElementById('display-size').innerHTML = size.value;
  139.     }
  140. }
  141.  
  142. function step_back_3() {
  143.     "use strict";
  144.  
  145.     document.getElementById('step-2').style.display = 'block';
  146.     document.getElementById('step-3').style.display = 'none';
  147. }
  148.  
  149. function step_back_4() {
  150.     "use strict";
  151.  
  152.     document.getElementById('step-3').style.display = 'block';
  153.     document.getElementById('step-4').style.display = 'none';
  154. }
  155.  
  156. window.onload = function() {
  157.     let resize_logo = document.getElementById('resize-logo');
  158.  
  159.     resize_logo.oninput = function() {
  160.         var logo = document.getElementById('t-shirt-logo');
  161.  
  162.         var logo_current_width = logo.naturalWidth;
  163.         var logo_current_height = logo.naturalHeight;
  164.  
  165.         var logo_resize_percentage = document.getElementById('resize-logo').value;
  166.  
  167.         if (logo_resize_percentage < 20) {
  168.             logo_resize_percentage = 20;
  169.         }
  170.  
  171.         var logo_width = (logo_current_width * logo_resize_percentage) / 100;
  172.         var logo_height = (logo_current_height * logo_resize_percentage) / 100;
  173.  
  174.         logo.style.width = logo_width + 'px';
  175.         logo.style.height = logo_height + 'px';
  176.     }
  177.  
  178.     let move_logo_to_top = document.getElementById('logo-top-position');
  179.  
  180.     move_logo_to_top.oninput = function() {
  181.         var logo_top_position = document.getElementById('logo-top-position').value;
  182.  
  183.         document.getElementById('t-shirt-logo').style.marginBottom = logo_top_position + 'px';
  184.     }
  185.  
  186.     let move_logo_to_left = document.getElementById('logo-left-position');
  187.  
  188.     move_logo_to_left.oninput = function() {
  189.         var logo_left_position = document.getElementById('logo-left-position').value;
  190.  
  191.         document.getElementById('t-shirt-logo').style.marginRight = logo_left_position + 'px';
  192.     }
  193.  
  194.     let move_logo_to_right = document.getElementById('logo-right-position');
  195.  
  196.     move_logo_to_right.oninput = function() {
  197.         var logo_right_position = document.getElementById('logo-right-position').value;
  198.  
  199.         document.getElementById('t-shirt-logo').style.marginLeft = logo_right_position + 'px';
  200.     }
  201.  
  202.     let move_logo_to_bottom = document.getElementById('logo-bottom-position');
  203.  
  204.     move_logo_to_bottom.oninput = function() {
  205.         var move_logo_to_bottom = document.getElementById('logo-bottom-position').value;
  206.  
  207.         document.getElementById('t-shirt-logo').style.marginTop = move_logo_to_bottom + 'px';
  208.     }
  209. }
  210.  
  211. function submit_form() {
  212.     document.getElementById('multiphase').method = 'POST';
  213.     document.getElementById('multiphase').action = '';
  214.     document.getElementById('multiphase').submit();
  215. }
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