cypherine

mainscript.js

Jan 19th, 2022 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.  
  3.     function ImageSwitcher(choices, i) {
  4.         i = 0;
  5.        
  6.         this.Next = function() {
  7.             hide_current_image();
  8.             show_next_image();
  9.         }
  10.        
  11.         var hide_current_image = function() {
  12.             if(choices){
  13.                 choices[i].style.visibility = "hidden";
  14.                 i += 1;
  15.             }
  16.         }
  17.         var show_next_image = function() {
  18.             if(choices){
  19.                 if(i == (choices.length)) {
  20.                     i = 0;
  21.                 }
  22.                 choices[i].style.visibility = "visible";
  23.             }
  24.         }
  25.     }
  26.      
  27.         var pants = $(".pant");
  28.         var shirts = $(".shirt");
  29.         var backgrounds = $(".bg");
  30.    
  31.         var shirt_picker = new ImageSwitcher(shirts);
  32.         document.getElementById("shirt_button").onclick = function() { shirt_picker.Next(); };
  33.        
  34.         var pants_picker = new ImageSwitcher(pants);
  35.         document.getElementById("pant_button").onclick = function() {pants_picker.Next(); };
  36.        
  37.         var bg_picker = new ImageSwitcher(backgrounds);
  38.         document.getElementById("bg_button").onclick = function() {bg_picker.Next(); };
  39.    
  40.     });
  41.    
  42.       $("#shirt_button").click(function(){
  43.       $("#shirt-menu").css("visibility", "visible"); });
  44.  
  45.  
  46.  
  47.       Choice ();
  48.  
  49. /* Refresh */
  50.  
  51. function refreshPage(){
  52.     window.location.reload();
  53. }
  54.  
Add Comment
Please, Sign In to add comment