Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.25 KB | None | 0 0
  1. <script>
  2.  
  3. /* Form-option class controls the swatchOpts; it's an array because of ClassName, so it's 0-based.
  4. 0-3: Hinge Size - 4.5 x 4, 4.5 x 4.5, 5 x 4.5, 5 x 5
  5. 4-12: Finishes - USP, US10B, US32D, US3, US4, US10, US10B, US26D, and US26.
  6.  
  7. A value of 'none' makes the options disappear; a value of 'inline-block' makes them appear in their normal orientation.
  8. */
  9.  
  10. var swatchOpt = document.getElementsByClassName('form-option');
  11. var radioOpt = document.getElementsByClassName('form-label');
  12.  
  13. /* Define radio buttons. */
  14. var ballBearing = document.getElementById('attribute_185');
  15. var plainBearing = document.getElementById('attribute_186');
  16.  
  17. var standardWeight = document.getElementById('attribute_139');
  18. var heavyWeight = document.getElementById('attribute_140');
  19.  
  20. var standardPin = document.getElementById('attribute_165');
  21. var nonRemovablePin = document.getElementById('attribute_161');
  22.  
  23. /* Deselect all radio buttons from previous options. */
  24. function removeOptions() {
  25. ballBearing.checked = false;
  26. plainBearing.checked = false;
  27. standardWeight.checked = false;
  28. heavyWeight.checked = false;
  29. standardPin.checked = false;
  30. nonRemovablePin.checked = false;
  31. swatchOpt[4].selected = false;
  32. swatchOpt[5].selected = false;
  33. swatchOpt[6].selected = false;
  34. swatchOpt[7].selected = false;
  35. swatchOpt[8].selected = false;
  36. swatchOpt[9].selected = false;
  37. swatchOpt[10].selected = false;
  38. swatchOpt[11].selected = false;
  39. swatchOpt[12].selected = false;
  40. }
  41.  
  42. swatchOpt[0].onclick = function () { // 4.5 x 4 - only two options: Ball Bearing, Standard Weight, Standard Pin + NRP, US26D
  43. removeOptions();
  44. swatchOpt[0].selected = true;
  45. radioOpt[2].style.display = 'inline-block';
  46. radioOpt[3].style.display = 'none';
  47.  
  48. radioOpt[5].style.display = 'inline-block';
  49. radioOpt[6].style.display = 'none'
  50.  
  51. radioOpt[8].style.display = 'inline-block';
  52. radioOpt[9].style.display = 'none';
  53.  
  54. swatchOpt[4].style.display = 'none';
  55. swatchOpt[5].style.display = 'none';
  56. swatchOpt[6].style.display = 'none';
  57. swatchOpt[7].style.display = 'none';
  58. swatchOpt[8].style.display = 'none';
  59. swatchOpt[9].style.display = 'none';
  60. swatchOpt[10].style.display = 'none';
  61. swatchOpt[11].style.display = 'inline-block';
  62. swatchOpt[12].style.display = 'none';
  63. }
  64.  
  65. swatchOpt[1].onclick = function () { // 4.5 x 4.5 - ball/plain, both weights, both pins, all finishes... display EVERYTHING at first.
  66. removeOptions();
  67. radioOpt[2].style.display = 'inline-block';
  68. radioOpt[3].style.display = 'inline-block';
  69. swatchOpt[1].selected = true;
  70.  
  71. if (swatchOpt[1].selected) { // If 4.5 x 4.5 is selected...
  72. ballBearing.onclick = function () { // Nothing changes with a ball bearing selection. Move to the next option.
  73. standardWeight.style.display = 'inline-block';
  74. heavyWeight.style.display = 'inline-block';
  75. radioOpt[5].style.display = 'inline-block';
  76. radioOpt[6].style.display = 'inline-block';
  77.  
  78. standardPin.style.display = 'inline-block';
  79. nonRemovablePin.style.display = 'inline-block';
  80. radioOpt[8].style.display = 'inline-block';
  81. radioOpt[9].style.display = 'inline-block';
  82.  
  83. swatchOpt[4].style.display = 'inline-block';
  84. swatchOpt[5].style.display = 'inline-block';
  85. swatchOpt[6].style.display = 'inline-block';
  86. swatchOpt[7].style.display = 'inline-block';
  87. swatchOpt[8].style.display = 'inline-block';
  88. swatchOpt[9].style.display = 'inline-block';
  89. swatchOpt[10].style.display = 'inline-block';
  90. swatchOpt[11].style.display = 'inline-block';
  91. swatchOpt[12].style.display = 'inline-block';
  92.  
  93. console.log('Ball Bearing Clicked.');
  94. console.log('Swatch 1 selected:' + swatchOpt[1].selected);
  95. console.log('Swatch 2 selected:' + swatchOpt[2].selected);
  96.  
  97. if (ballBearing.checked = true) { // If ball bearing is selected with 4.5 x 4.5...
  98.  
  99. standardWeight.onclick = function () { // ...picking a standard weight keeps all finishes intact and NRP intact. Do nothing.
  100. standardWeight.style.display = 'inline-block';
  101. heavyWeight.style.display = 'inline-block';
  102. radioOpt[5].style.display = 'inline-block';
  103. radioOpt[6].style.display = 'inline-block';
  104.  
  105. standardPin.style.display = 'inline-block';
  106. nonRemovablePin.style.display = 'inline-block';
  107. radioOpt[8].style.display = 'inline-block';
  108. radioOpt[9].style.display = 'inline-block';
  109.  
  110. swatchOpt[4].style.display = 'inline-block';
  111. swatchOpt[5].style.display = 'inline-block';
  112. swatchOpt[6].style.display = 'inline-block';
  113. swatchOpt[7].style.display = 'inline-block';
  114. swatchOpt[8].style.display = 'inline-block';
  115. swatchOpt[9].style.display = 'inline-block';
  116. swatchOpt[10].style.display = 'inline-block';
  117. swatchOpt[11].style.display = 'inline-block';
  118. swatchOpt[12].style.display = 'inline-block';
  119.  
  120. console.log('Standard weight clicked after ball bearing is selected in swatch 2.');
  121.  
  122. if (standardWeight.checked = true) { // If standard weight is selected w/ ball bearing and 4.5 x 4.5x...
  123. standardPin.onclick = function() { // ...picking a standard pin leaves you with all nine finishes. Do nothing. Everything is selectable.
  124. swatchOpt[4].style.display = 'inline-block';
  125. swatchOpt[5].style.display = 'inline-block';
  126. swatchOpt[6].style.display = 'inline-block';
  127. swatchOpt[7].style.display = 'inline-block';
  128. swatchOpt[8].style.display = 'inline-block';
  129. swatchOpt[9].style.display = 'inline-block';
  130. swatchOpt[10].style.display = 'inline-block';
  131. swatchOpt[11].style.display = 'inline-block';
  132. swatchOpt[12].style.display = 'inline-block';
  133. }
  134.  
  135. nonRemovablePin.onclick = function () { // ...picking a NRP leaves you with five options for finish: USP, US10B (both variants), US26D, US32D - remove the rest.
  136. swatchOpt[4].style.display = 'inline-block';
  137. swatchOpt[5].style.display = 'inline-block';
  138. swatchOpt[6].style.display = 'inline-block';
  139. swatchOpt[7].style.display = 'none';
  140. swatchOpt[8].style.display = 'none';
  141. swatchOpt[9].style.display = 'none';
  142. swatchOpt[10].style.display = 'inline-block';
  143. swatchOpt[11].style.display = 'inline-block';
  144. swatchOpt[12].style.display = 'none';
  145. }
  146. }
  147. }
  148.  
  149. heavyWeight.onclick = function () { // ...picking a heavy weight leaves only three finishes: US10B, US26D, US32D - remove the rest.
  150. swatchOpt[4].style.display = 'none';
  151. swatchOpt[5].style.display = 'inline-block';
  152. swatchOpt[6].style.display = 'inline-block';
  153. swatchOpt[7].style.display = 'none';
  154. swatchOpt[8].style.display = 'none';
  155. swatchOpt[9].style.display = 'none';
  156. swatchOpt[10].style.display = 'none';
  157. swatchOpt[11].style.display = 'inline-block';
  158. swatchOpt[12].style.display = 'none';
  159.  
  160. if (heavyWeight.checked = true) { // If heavy weight is selected with ball bearing and 4.5 x 4.5...
  161. standardPin.onclick = function() { // ...picking a standard pin leaves you two options for finish: US26D/US32D
  162. swatchOpt[4].style.display = 'none';
  163. swatchOpt[5].style.display = 'none';
  164. swatchOpt[6].style.display = 'inline-block';
  165. swatchOpt[7].style.display = 'none';
  166. swatchOpt[8].style.display = 'none';
  167. swatchOpt[9].style.display = 'none';
  168. swatchOpt[10].style.display = 'none';
  169. swatchOpt[11].style.display = 'inline-block';
  170. swatchOpt[12].style.display = 'none';
  171. }
  172.  
  173. nonRemovablePin.onclick = function() { //... picking a NRP leaves you with three options for finish: US10B, US26D, US32D
  174. swatchOpt[4].style.display = 'none';
  175. swatchOpt[5].style.display = 'inline-block';
  176. swatchOpt[6].style.display = 'inline-block';
  177. swatchOpt[7].style.display = 'none';
  178. swatchOpt[8].style.display = 'none';
  179. swatchOpt[9].style.display = 'none';
  180. swatchOpt[10].style.display = 'none';
  181. swatchOpt[11].style.display = 'inline-block';
  182. swatchOpt[12].style.display = 'none';
  183. }
  184. }
  185. }
  186. }
  187. }
  188.  
  189. plainBearing.onclick = function () { // plain bearing removes all but two products: standard weight, standard pin or NRP, in US26D.
  190. standardWeight.style.display = 'inline-block';
  191. heavyWeight.style.display = 'none';
  192. radioOpt[5].style.display = 'inline-block';
  193. radioOpt[6].style.display = 'none'
  194.  
  195. standardPin.style.display = 'inline-block';
  196. nonRemovablePin.style.display = 'inline-block';
  197. radioOpt[8].style.display = 'inline-block';
  198. radioOpt[9].style.display = 'inline-block';
  199.  
  200. swatchOpt[4].style.display = 'none';
  201. swatchOpt[5].style.display = 'none';
  202. swatchOpt[6].style.display = 'none';
  203. swatchOpt[7].style.display = 'none';
  204. swatchOpt[8].style.display = 'none';
  205. swatchOpt[9].style.display = 'none';
  206. swatchOpt[10].style.display = 'none';
  207. swatchOpt[11].style.display = 'inline-block';
  208. swatchOpt[12].style.display = 'none';
  209.  
  210. if (plainBearing.checked = true) { // After checking plain bearing, keep everything hidden.
  211. standardWeight.onclick = function () {
  212. heavyWeight.style.display = 'none';
  213. radioOpt[5].style.display = 'inline-block';
  214. radioOpt[6].style.display = 'none'
  215.  
  216. standardPin.style.display = 'inline-block';
  217. nonRemovablePin.style.display = 'inline-block';
  218. radioOpt[8].style.display = 'inline-block';
  219. radioOpt[9].style.display = 'inline-block';
  220.  
  221. swatchOpt[4].style.display = 'none';
  222. swatchOpt[5].style.display = 'none';
  223. swatchOpt[6].style.display = 'none';
  224. swatchOpt[7].style.display = 'none';
  225. swatchOpt[8].style.display = 'none';
  226. swatchOpt[9].style.display = 'none';
  227. swatchOpt[10].style.display = 'none';
  228. swatchOpt[11].style.display = 'inline-block';
  229. swatchOpt[12].style.display = 'none';
  230.  
  231. if (standardWeight.checked = true) { // Only choices left are standard pin or removable pin.
  232. standardPin.onclick = function () {
  233. swatchOpt[4].style.display = 'none';
  234. swatchOpt[5].style.display = 'none';
  235. swatchOpt[6].style.display = 'none';
  236. swatchOpt[7].style.display = 'none';
  237. swatchOpt[8].style.display = 'none';
  238. swatchOpt[9].style.display = 'none';
  239. swatchOpt[10].style.display = 'none';
  240. swatchOpt[11].style.display = 'inline-block';
  241. swatchOpt[12].style.display = 'none';
  242. }
  243.  
  244. nonRemovablePin.onclick = function() {
  245. swatchOpt[4].style.display = 'none';
  246. swatchOpt[5].style.display = 'none';
  247. swatchOpt[6].style.display = 'none';
  248. swatchOpt[7].style.display = 'none';
  249. swatchOpt[8].style.display = 'none';
  250. swatchOpt[9].style.display = 'none';
  251. swatchOpt[10].style.display = 'none';
  252. swatchOpt[11].style.display = 'inline-block';
  253. swatchOpt[12].style.display = 'none';
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }
  261.  
  262. standardWeight.onclick = function () {
  263. console.log('Clicked.');
  264. console.log('Swatch 1 selected:' + swatchOpt[1].selected);
  265. console.log('Swatch 2 selected:' + swatchOpt[2].selected);
  266. }
  267.  
  268. swatchOpt[2].onclick = function () { // 5 x 4.5 - ball bearing, both weights possible, both pins, US26D and US32D
  269. removeOptions();
  270. swatchOpt[2].selected = true;
  271.  
  272. radioOpt[2].style.display = 'inline-block';
  273. if (swatchOpt[2].selected) { // If standard weight is selected with 5 x 4.5 + ball bearing, all options remain selectable regardless of choice.
  274. standardWeight.onclick = function () {
  275. alert("hinge size 2 + weight!");
  276. console.log('Clicked.');
  277. console.log('Swatch 1 selected:' + swatchOpt[1].selected);
  278. console.log('Swatch 2 selected:' + swatchOpt[2].selected);
  279. }
  280. }
  281.  
  282. radioOpt[3].style.display = 'none';
  283.  
  284. radioOpt[5].style.display = 'inline-block';
  285. radioOpt[6].style.display = 'inline-block';
  286.  
  287. radioOpt[8].style.display = 'inline-block';
  288. radioOpt[9].style.display = 'inline-block';
  289.  
  290. swatchOpt[4].style.display = 'none';
  291. swatchOpt[5].style.display = 'none';
  292. swatchOpt[6].style.display = 'inline-block';
  293. swatchOpt[7].style.display = 'none';
  294. swatchOpt[8].style.display = 'none';
  295. swatchOpt[9].style.display = 'none';
  296. swatchOpt[10].style.display = 'none';
  297. swatchOpt[11].style.display = 'inline-block';
  298. swatchOpt[12].style.display = 'none';
  299. }
  300.  
  301. swatchOpt[3].onclick = function () { // 5 x 5 - only one option: Ball Bearing, Heavy Weight, Standard Pin, US26D
  302. removeOptions();
  303. radioOpt[2].style.display = 'inline-block';
  304. radioOpt[3].style.display = 'none';
  305.  
  306. radioOpt[5].style.display = 'none';
  307. radioOpt[6].style.display = 'inline-block';
  308.  
  309. radioOpt[8].style.display = 'inline-block';
  310. radioOpt[9].style.display = 'none';
  311.  
  312. swatchOpt[4].style.display = 'none';
  313. swatchOpt[5].style.display = 'none';
  314. swatchOpt[6].style.display = 'none';
  315. swatchOpt[7].style.display = 'none';
  316. swatchOpt[8].style.display = 'none';
  317. swatchOpt[9].style.display = 'none';
  318. swatchOpt[10].style.display = 'none';
  319. swatchOpt[11].style.display = 'inline-block';
  320. swatchOpt[12].style.display = 'none';
  321. }
  322.  
  323. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement