Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- /* Form-option class controls the swatchOpts; it's an array because of ClassName, so it's 0-based.
- 0-3: Hinge Size - 4.5 x 4, 4.5 x 4.5, 5 x 4.5, 5 x 5
- 4-12: Finishes - USP, US10B, US32D, US3, US4, US10, US10B, US26D, and US26.
- A value of 'none' makes the options disappear; a value of 'inline-block' makes them appear in their normal orientation.
- */
- var swatchOpt = document.getElementsByClassName('form-option');
- var radioOpt = document.getElementsByClassName('form-label');
- /* Define radio buttons. */
- var ballBearing = document.getElementById('attribute_185');
- var plainBearing = document.getElementById('attribute_186');
- var standardWeight = document.getElementById('attribute_139');
- var heavyWeight = document.getElementById('attribute_140');
- var standardPin = document.getElementById('attribute_165');
- var nonRemovablePin = document.getElementById('attribute_161');
- /* Deselect all radio buttons from previous options. */
- function removeOptions() {
- ballBearing.checked = false;
- plainBearing.checked = false;
- standardWeight.checked = false;
- heavyWeight.checked = false;
- standardPin.checked = false;
- nonRemovablePin.checked = false;
- swatchOpt[4].selected = false;
- swatchOpt[5].selected = false;
- swatchOpt[6].selected = false;
- swatchOpt[7].selected = false;
- swatchOpt[8].selected = false;
- swatchOpt[9].selected = false;
- swatchOpt[10].selected = false;
- swatchOpt[11].selected = false;
- swatchOpt[12].selected = false;
- }
- swatchOpt[0].onclick = function () { // 4.5 x 4 - only two options: Ball Bearing, Standard Weight, Standard Pin + NRP, US26D
- removeOptions();
- swatchOpt[0].selected = true;
- radioOpt[2].style.display = 'inline-block';
- radioOpt[3].style.display = 'none';
- radioOpt[5].style.display = 'inline-block';
- radioOpt[6].style.display = 'none'
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'none';
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'none';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- swatchOpt[1].onclick = function () { // 4.5 x 4.5 - ball/plain, both weights, both pins, all finishes... display EVERYTHING at first.
- removeOptions();
- radioOpt[2].style.display = 'inline-block';
- radioOpt[3].style.display = 'inline-block';
- swatchOpt[1].selected = true;
- if (swatchOpt[1].selected) { // If 4.5 x 4.5 is selected...
- ballBearing.onclick = function () { // Nothing changes with a ball bearing selection. Move to the next option.
- standardWeight.style.display = 'inline-block';
- heavyWeight.style.display = 'inline-block';
- radioOpt[5].style.display = 'inline-block';
- radioOpt[6].style.display = 'inline-block';
- standardPin.style.display = 'inline-block';
- nonRemovablePin.style.display = 'inline-block';
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'inline-block';
- swatchOpt[4].style.display = 'inline-block';
- swatchOpt[5].style.display = 'inline-block';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'inline-block';
- swatchOpt[8].style.display = 'inline-block';
- swatchOpt[9].style.display = 'inline-block';
- swatchOpt[10].style.display = 'inline-block';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'inline-block';
- console.log('Ball Bearing Clicked.');
- console.log('Swatch 1 selected:' + swatchOpt[1].selected);
- console.log('Swatch 2 selected:' + swatchOpt[2].selected);
- if (ballBearing.checked = true) { // If ball bearing is selected with 4.5 x 4.5...
- standardWeight.onclick = function () { // ...picking a standard weight keeps all finishes intact and NRP intact. Do nothing.
- standardWeight.style.display = 'inline-block';
- heavyWeight.style.display = 'inline-block';
- radioOpt[5].style.display = 'inline-block';
- radioOpt[6].style.display = 'inline-block';
- standardPin.style.display = 'inline-block';
- nonRemovablePin.style.display = 'inline-block';
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'inline-block';
- swatchOpt[4].style.display = 'inline-block';
- swatchOpt[5].style.display = 'inline-block';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'inline-block';
- swatchOpt[8].style.display = 'inline-block';
- swatchOpt[9].style.display = 'inline-block';
- swatchOpt[10].style.display = 'inline-block';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'inline-block';
- console.log('Standard weight clicked after ball bearing is selected in swatch 2.');
- if (standardWeight.checked = true) { // If standard weight is selected w/ ball bearing and 4.5 x 4.5x...
- standardPin.onclick = function() { // ...picking a standard pin leaves you with all nine finishes. Do nothing. Everything is selectable.
- swatchOpt[4].style.display = 'inline-block';
- swatchOpt[5].style.display = 'inline-block';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'inline-block';
- swatchOpt[8].style.display = 'inline-block';
- swatchOpt[9].style.display = 'inline-block';
- swatchOpt[10].style.display = 'inline-block';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'inline-block';
- }
- nonRemovablePin.onclick = function () { // ...picking a NRP leaves you with five options for finish: USP, US10B (both variants), US26D, US32D - remove the rest.
- swatchOpt[4].style.display = 'inline-block';
- swatchOpt[5].style.display = 'inline-block';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'inline-block';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- }
- }
- heavyWeight.onclick = function () { // ...picking a heavy weight leaves only three finishes: US10B, US26D, US32D - remove the rest.
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'inline-block';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- if (heavyWeight.checked = true) { // If heavy weight is selected with ball bearing and 4.5 x 4.5...
- standardPin.onclick = function() { // ...picking a standard pin leaves you two options for finish: US26D/US32D
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- nonRemovablePin.onclick = function() { //... picking a NRP leaves you with three options for finish: US10B, US26D, US32D
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'inline-block';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- }
- }
- }
- }
- plainBearing.onclick = function () { // plain bearing removes all but two products: standard weight, standard pin or NRP, in US26D.
- standardWeight.style.display = 'inline-block';
- heavyWeight.style.display = 'none';
- radioOpt[5].style.display = 'inline-block';
- radioOpt[6].style.display = 'none'
- standardPin.style.display = 'inline-block';
- nonRemovablePin.style.display = 'inline-block';
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'inline-block';
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'none';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- if (plainBearing.checked = true) { // After checking plain bearing, keep everything hidden.
- standardWeight.onclick = function () {
- heavyWeight.style.display = 'none';
- radioOpt[5].style.display = 'inline-block';
- radioOpt[6].style.display = 'none'
- standardPin.style.display = 'inline-block';
- nonRemovablePin.style.display = 'inline-block';
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'inline-block';
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'none';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- if (standardWeight.checked = true) { // Only choices left are standard pin or removable pin.
- standardPin.onclick = function () {
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'none';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- nonRemovablePin.onclick = function() {
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'none';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- }
- }
- }
- }
- }
- }
- standardWeight.onclick = function () {
- console.log('Clicked.');
- console.log('Swatch 1 selected:' + swatchOpt[1].selected);
- console.log('Swatch 2 selected:' + swatchOpt[2].selected);
- }
- swatchOpt[2].onclick = function () { // 5 x 4.5 - ball bearing, both weights possible, both pins, US26D and US32D
- removeOptions();
- swatchOpt[2].selected = true;
- radioOpt[2].style.display = 'inline-block';
- if (swatchOpt[2].selected) { // If standard weight is selected with 5 x 4.5 + ball bearing, all options remain selectable regardless of choice.
- standardWeight.onclick = function () {
- alert("hinge size 2 + weight!");
- console.log('Clicked.');
- console.log('Swatch 1 selected:' + swatchOpt[1].selected);
- console.log('Swatch 2 selected:' + swatchOpt[2].selected);
- }
- }
- radioOpt[3].style.display = 'none';
- radioOpt[5].style.display = 'inline-block';
- radioOpt[6].style.display = 'inline-block';
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'inline-block';
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'inline-block';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- swatchOpt[3].onclick = function () { // 5 x 5 - only one option: Ball Bearing, Heavy Weight, Standard Pin, US26D
- removeOptions();
- radioOpt[2].style.display = 'inline-block';
- radioOpt[3].style.display = 'none';
- radioOpt[5].style.display = 'none';
- radioOpt[6].style.display = 'inline-block';
- radioOpt[8].style.display = 'inline-block';
- radioOpt[9].style.display = 'none';
- swatchOpt[4].style.display = 'none';
- swatchOpt[5].style.display = 'none';
- swatchOpt[6].style.display = 'none';
- swatchOpt[7].style.display = 'none';
- swatchOpt[8].style.display = 'none';
- swatchOpt[9].style.display = 'none';
- swatchOpt[10].style.display = 'none';
- swatchOpt[11].style.display = 'inline-block';
- swatchOpt[12].style.display = 'none';
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement