Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 19th, 2012  |  syntax: JavaScript  |  size: 2.81 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // JavaScript Document
  2. $.noConflict();
  3. jQuery(document).ready(function($) {
  4.        
  5.         //global variable declaration
  6.         var vars = {"11" : "abxy", "8" : "battery", "7" : "bottomtrim", "6" : "bumpers", "4" : "dpad", "10" : "other", "9" : "rol", "2" : "shell", "3" : "thumbsticks", "5" : "triggers"};
  7.         var current = {};
  8.         //end of global variables
  9.        
  10.         //this builds the image of the controller on the page
  11.         function build(image, value, optionid){
  12.        
  13.                 type = vars[optionid];
  14.                 current[type] = value;
  15.                 type = type.substring(0,4);
  16.                 $("[id=" + type + "]").html("<img src='" + image + "' />");
  17.                
  18.         }
  19.         //end of build function
  20.        
  21.         function parseid(id){
  22.                 // this just takes "select" and whatnot out of the option      
  23.                 id = id.replace("options[", "");
  24.                 id = id.replace("]", "");
  25.                 return id;
  26.         }
  27.        
  28.        
  29.         //facebook stuffs
  30.         function modal_fade_out(){
  31.                 $("#modal_background").fadeOut();
  32.                 $("#modal_content").fadeOut();         
  33.         }
  34.        
  35.         $("#modal_background").live('click', function(){
  36.                 modal_fade_out();
  37.         });
  38.        
  39.         function fb_share(){
  40.                
  41.                 uniqueid = Math.floor((Math.random()*10000000000)+1);
  42.                 current["id"] = uniqueid;
  43.                 $.ajax({
  44.                         url: "/imagemerge/imagemerge.php",
  45.                         data: current,
  46.                         type: 'post'
  47.                 }).done(function(){
  48.                         $("#compiled_picture").html("<img src='/imagemerge/" + uniqueid + ".png' id='compiled_picture_img' />");
  49.                 });
  50.                 $("#modal_background").fadeIn();
  51.                 $("#modal_content").fadeIn();  
  52.         }
  53.        
  54.         function fb_share_final(){
  55.                 var message = $("#facebook_share_text").val();
  56.                 $.post("/imagemerge/fbshare.php", { "id": uniqueid, "message": message });
  57.         }
  58.         // end of facebook stuffs
  59.        
  60.                                                                
  61.         //this loads if the img element is on the page
  62.         if($('.product-img-box').length){
  63.                 $('.product-img-box').prepend("<div id='shel' class='replace_div'><img src='/imagemerge/basecontrollershell.png' /></div>");
  64.                 $('.product-img-box').prepend("<div id='abxy' class='replace_div'></div>");
  65.                 $('.product-img-box').prepend("<div id='bott' class='replace_div'></div>");
  66.                 $('.product-img-box').prepend("<div id='bump' class='replace_div'></div>");
  67.                 $('.product-img-box').prepend("<div id='dpad' class='replace_div'></div>");
  68.                 $('.product-img-box').prepend("<div id='rols' class='replace_div'></div>");
  69.                 $('.product-img-box').prepend("<div id='thum' class='replace_div'></div>");
  70.         }
  71.         //end of image thingy
  72.        
  73.         //these two controll the changing of options
  74.         $('select').change(function(){
  75.                 optionid = parseid($(this).attr("id"));
  76.                 value = $(this).val();
  77.                 image = $(this).prev().attr("bigimgpath")
  78.                 build(image, value, optionid);
  79.         });
  80.        
  81.         $('input').change(function(){
  82.                 optionid = parseid($(this).attr("name"));
  83.                 id = $(this).val();
  84.                 image = $(this).prev().attr("bigimgpath")
  85.                 build(image, id, optionid);                                    
  86.         });
  87.         // end of changing options
  88.        
  89.         //scrollfollow stuff- add later
  90.        
  91.         //end of scrollfollow stuff    
  92.  
  93. });