Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var is_open = 0;
- var has_text = [false, false, true, true, true, true];
- function open_close(n) {
- var was_open = (n == is_open);
- var will_show_text = (has_text[n-1] && !was_open); // must have text and needs to have been closed before
- var base_opacity = will_show_text ? 0.3 : 1;
- // hide all
- for(var i=0; i<is_open.length; ++i) {
- document.getElementById('text'+(i+1)).style.visibility = 'hidden';
- document.getElementById(i+1).style.opacity = base_opacity;
- is_open[i] = false;
- }
- if (will_show_text) {
- document.getElementById('text'+n)).style.visibility = 'visible';
- document.getElementById(n).style.opacity = '1';
- is_open[n-1] = true;
- }
- }
- function myFunction() { open_close(1); }
- function myFunction2() { open_close(2); }
- function myFunction3() { open_close(3); }
- function myFunction4() { open_close(4); }
- function myFunction5() { open_close(5); }
- function myFunction6() { open_close(6); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement