Prv8 Shell
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4
System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64
User : jackjohn ( 502)
PHP Version : 5.3.17
Disable Function : NONE
Directory :  /home/jackjohn/public_html/shopsite-images/en-ZA/javascript/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/jackjohn/public_html/shopsite-images/en-ZA/javascript/wizard.js
//var currency_symbol = "$";

/*function sorting_hat(id, name, column) {
  var html = 
  "<li>"+
  "<input type=text name=page_"+id+"_name class='item_name' id='item_"+id+"_name' value='"+name+"' placeholder='Type page name here'>" +
  "<a class='edit_link_page' id='edit_"+id+"_page'></a>"+
  "<a class='delete_link_page' id='delete_"+id+"_page'></a>"+
  "</li>";
  $('#column_'+column).append(html);
}*/

/*$(document).ready(function() {
  done_loading = true;
});*/

function loaded() {
  done_loading = true;
  $('div.fixed_next').css({'display':'block'});
}

function make_page_html(p) {
  var html = 
  "<li>"+
  "<input type=text name=page_"+p.id+"_name class='item_name' id='item_"+p.id+"_name' value=\""+p.name.replace(/"/g, "&quot;")+"\" placeholder='Type page name here'>" +
  "<a class='edit_link_page' id='edit_"+p.id+"_page'></a>"+
  "<a class='delete_link_page' id='delete_"+p.id+"_page'></a>"+
  "<input type=hidden value=\""+p.content.replace(/"/g, "&quot;")+"\" id='item_"+p.id+"_content' name='page_"+p.id+"_content'>"+
  "</li>";
  return html;
}

function print_pages() {
  $.each(pages, function(i, p) {
    html = make_page_html(p);
    
    
    $('#column_'+p.nav_loc).append(html);
    
  }); 
}

function dispatch_products(selector) {
  var products_json = JSON.stringify(products).replace(/&/g, "__AMP__").replace(/'/g, "__APS__");;
  var html = "<input type='hidden' name='products_json' value='"+products_json+"'>";
  $(selector).append(html);
}

$(function($) {
  var tmp;
  form_parm1 = "missing";
  if ($('#form_parm1').length > 0)
    form_parm1 = $('#form_parm1').val();
  max_existing_id = 0;
  if(tmp=document.querySelector('#max_existing_id'))
    max_existing_id = parseInt(tmp.value);

  loaded();
  ok_to_submit = true;

  $(document).on('click','a.step_clicker',function() {
    var next_step_id = parseInt($(this).attr('id').substring(12));
    sessionStorage.removeItem('step_'+next_step_id+'_visited');
  });

  var current_screen = $('#current_screen').val();




  if (current_screen == 'publish' || current_screen == 'done') {
    //$('body').append("<div id='masking_overlay'></div>");
    if (pathway == 'standard') {
      if (current_screen == 'publish') {
        instruction = "Almost done! Any time you make changes to your store the \"Publish Changes\" button will display. Click it now to complete your store setup.";
        $('div#nav_publish').tutorial({instruction: instruction});
      }
      else {
        instruction = "Click the \"View Site\" button to open a new browser window (or tab) and go to your web site.";
        $('div#nav_viewsite').tutorial({instruction: instruction});

        $(document).on('click','#nav_viewsite a',function() {
          $.tutorial.remove();
          $('#shopsitelogo').tutorial({instruction: "Click the ShopSite logo to go to your dashboard. It works from anywhere in ShopSite.", css: {'background-color':'white'}});

        });
      }

    } else if (pathway == 'orderanywhere' || window.innerWidth <= 767) {
      if (current_screen == 'done') {
        $('#shopsitelogo').tutorial({instruction: "Click the ShopSite logo to go to your dashboard. It works from anywhere in ShopSite.", css: {'background-color':'white'}, pathway:"OA"});
      }
    } else {

      link = $("#mh4 .l1:contains('Social Media')");
      $(link).parent().find('.l2_list').css({'display':'block'});
      $(link).closest('tr').find('.cl').innerHTML = collapse;

      wp_link = $("#m4 .l2:contains('WordPress')");
      instruction = 'The setup is complete. Click on the "WordPress" link to the left to go to WordPress configuration.';

      $('#mh4').css({'visibility':'visible', 'z-index':'1001'});
      $('#nav_icon_m4').css({'z-index':'1001', 'position':'relative'});

      $(wp_link).tutorial({instruction: instruction, placement: 'right', css: {'text-decoration':'underline'}, instructionCss: {'border':'1px solid #DFDFDF'}});


    }



  }

  if (current_screen == 'products' || current_screen == 'pages') {





    $('html').bind('keypress', function(e)
    {
      if(e.keyCode == 13)
      {
        c = $("*:focus");
        if (c.hasClass('item_name')) {
          c.focusout();
          return false;
        }
      }
    });

    $(document).on('click','#button_next_alone, .destination',function() {
      if (!done_loading)
        return false;
      /*if ($('#current_screen').val() == 'products') {
        dispatch_products('#products');
        return true;
        }*/


    });





  }

  if (current_screen == 'welcome') {
    $( "form" ).validate({
      rules: {
        StoreName: {
          required: true
        },

        mystore: {
          required: true,
          url:true
        },
      },
      messages: {
        mystore: {
          url: "Please enter a valid full URL, such as http://example.com"
        }
      }
    });



    $(document).on('click','#upload_logo_dispatch',function() {$('#upload_logo').click();});

    /*uploading logo in welcome screen*/
    $(document).on('change','#upload_logo',function() {
      var file = $(this).val();
      if (file.length) {
        if (file.search(/\.jpg|.png|.gif/i) != file.length-4)
          alert("Image extension has to be .jpg, .png, or .gif");
        else {
          var options = {
            target: '#logo',
            success: function(responseText, statusText, xhr, $form) { 
              $('body').css({cursor: 'default'});
              $('#remove_logo').css({display: 'inline'});
            },
            async: false,
            forceSync: true
          }

          $(this).wrap('<form enctype="multipart/form-data" action="wizard.cgi?ajax=upload_logo" method=post></form>');
          $('body').css({cursor: 'progress'});
          $(this).parent().ajaxSubmit(options);

          $(this).unwrap();
        }
      }
    });

    $(document).on('click','#remove_logo',function() {
      $.ajax({
        async: true,
        data: "ajax=remove_logo",
        url: "wizard.cgi",
        success: 
        function(data) {
          $('#remove_logo').css({display: 'none'});
          $('#logo > img').remove();
        }
      });
    });
  }

  if (current_screen == 'path_select') {
    $('#nav_logo img').css({cursor: 'pointer'});
    $(document).on('click','#nav_logo img',function() {
      c = confirm("Are you sure you want to skip the wizard?");
      if (c == false)
        return false;
      window.location.replace("start.cgi?from_wizard=1");
      //document.location.href
    });
  }

  if (current_screen == 'buttons') {

    $(document).on('click','.upload_button_dispatch',function() {$(this).next().click();});

    if ($('.selected_buttons').length == 0) {
      $('#shopsite_buttons li').first().addClass('selected_buttons');
    }


    $(document).on('click','#upload_wrapper, #text_buttons, #button_list > li',function() {
      $('.selected_buttons').removeClass('selected_buttons');
      $(this).addClass('selected_buttons');
    });


    $(document).on('change','#ADC_button_upload, #VC_button_upload',function() {
      var file = $(this).val();
      if (file.length) {
        if (file.search(/\.jpg|.png|.gif/i) != file.length-4)
          alert("Button extension has to be .jpg, .png, or .gif");
        else {
          if ($(this).attr('id') == 'ADC_button_upload')
            var target = '#ADC_button';
          else
            var target = '#VC_button';
          var options = {
            target: target,
            success: function(responseText, statusText, xhr, $form) { 
              if (target == '#ADC_button')
                $('#ADC_upload_error').remove();
              else
                $('#VC_upload_error').remove();
            },
            async: false,
            forceSync: true
          }

          $(this).wrap('<form enctype="multipart/form-data" action="themes.cgi?ajax=upload_button" method=post></form>');
          $(this).parent().ajaxSubmit(options);
          $(this).unwrap();
        }
      }
    });


    $(document).on('click','#button_next_alone, .destination',function() {
      if (!done_loading)
        return false;
      ok_to_submit = true;
      /*if ($('#upload_wrapper').hasClass('selected_buttons')) {
        var html = 
        "<input type=hidden name=button_type value=upload>" + 
        "<input type=hidden name=ADC_button val='"+ $('#ADC_button > img').get(0).src + "'>" +
        "<input type=hidden name=VC_button val='"+ $('#VC_button > img').get(0).src + "'>";
        } else {
        var html = 
        "<input type=hidden name=button_type value=shopsite>" + 
        "<input type=hidden name=themeName val='" + $('.selected_buttons > .theme_name_input').val() + "'>";

        //"<input type=hidden name=themeFile val='" + $('.selected_buttons > .layout_name_input').attr('id') + "'>" +
        }
        $('form').append(html);*/

        if ($('#upload_wrapper').hasClass('selected_buttons')) {
          if ($('#ADC_button img').length == 0) {
            if ($('#ADC_upload_error').length == 0) 
              $('#ADC_button').after("<label class=error id=ADC_upload_error style='display:inline;'>Please upload Add to Cart button image</label>");
            ok_to_submit = false;
          }

          /*if ($('#VC_button img').length == 0) {
            if ($('#VC_upload_error').length == 0)
            $('#VC_button').after("<label class=error id=VC_upload_error style='display:inline;'>Please upload View Cart button image</label>");
            ok_to_submit = false;
            }*/

            if (!ok_to_submit) {

              return false;
            }

            $('#button_type').val('upload');
            $('#ADC_button_inp').val( $('#ADC_button > img').get(0).src);
            //$('#VC_button_inp').val( $('#VC_button > img').get(0).src);
        } else {
          $('#button_type').val('shopsite');
          $('#themeName').val( $('.selected_buttons > .theme_name_input').val());
        }

        return true;


    });


  }


  if (current_screen == 'themes') {
    $(document).on('click','#show_more_themes',function() {
      $('.show_more_themes_wrapper').css({display:'none'});
      $('#more_theme_header').css('cursor','default').show().next().show();
      $(document).off('click','.more_themes');
      $(window).scrollTop($('#more_theme_header').offset().top-200);
    });

    $(document).on('click','#button_next_alone, .destination',function() {
      if (!done_loading)
        return false;
      if ($('.selected_layout').length == 0 && $('#current_theme').length == 0) {
        alert("Please select a theme for your store");
        ok_to_submit = false;
        return false;
      }

      $('#themeFile').val(state.selected_file);
      $('#themeName').val(state.selected_theme);

      return true;
    });
  }

  $(document).on('click','#button_next_alone',function() {
    if (!done_loading)
      return false;
    $('#destination').remove();
  });

  /*this event must be last*/
  $(document).on('click','.destination',function() {
    if (ok_to_submit) {
      destination = $(this).html();
      if ($('#destination').length == 0)
        $('form').append("<input type=hidden id=destination name=destination value='"+destination+"'>");
      else
        $('#destination').val(destination);
      $('form').submit();
    }
    else
      ok_to_submit = true;
  });
});

var max_existing_id = parseInt($('#max_existing_id').val());
function init_page_stuff(sortable) {
  var max_id = parseInt($('#max_id').val());
  
   $(document).on('click', '.add_page_clicker', function() {
    if (page_limit != 0 && ($('.item_name').length >= page_limit)) {
      alert('Your store is limited to '+page_limit+' pages. Delete some pages before adding new ones.');
      return;
    }
   
    max_id = max_id+1;
    id = max_id;
    var column_id = parseInt($(this).attr('id').substring(9));
    //sorting_hat(id, "", column_id);
    add_page(id, "", "", column_id);
    html = make_page_html(pages["page_"+id]);
    $('#column_'+column_id).append(html);
    
    
    $('#max_id').val(max_id);
  });
  
  $('#top_menu_list').val('');
  //$('#left_menu_list').val('');
  
  function create_nav_lists() {
    $('#top_menu_list').val('');
    //$('#left_menu_list').val('');
    $('#column_1').children().each(function() {
      var id = parseInt($(this).find('input').attr('id').substring(5));
      $('#top_menu_list').val($('#top_menu_list').val() + "," + id);
    });
    
    
    
    /*$('#column_2').children().each(function() {
      var id = parseInt($(this).find('input').attr('id').substring(5));
      $('#left_menu_list').val($('#left_menu_list').val() + "," + id);
    });*/
  }
  
  $('form').submit(function() {
    create_nav_lists();
  });
  
  
  
  
  $.receiveMessage(  function(e){  /*alert( e.data );*/
    var img = $(document.createElement('img'));
    img.attr('src', e.data);
    //var prev_width = $(document).width() / 2;
    //var prev_height = $(document).height() / 2;
    
    
    $(img).css("width", "100%" );
    $(img).css("height","auto" );
    //$('body').append(img);
    $('#preview').html(img);
    loaded();

 });

  
  //user clicked "update preview"
  $(document).on('click', '#update_preview', function() {
    $('#preview').html('Loading...');
    create_nav_lists();
    var request = $('form').serialize();

    //send a signal to update shopsite database and nav menu files with configuration from current screen
    //alert("yoyo");
    $.ajax({
          
          async: false,
          data: request+"&ajax=update_preview",
          url: "wizard.cgi",
          success: 
            //database has been updated. Reload the iframe to re-generate preview.
            function(data) {
                //document.getElementById('ifr').contentWindow.location.reload(true);
                
                $('#ifr').attr('src', $('#preview_url').val());
                //alert("iframe reloaded");
                $("#ifr").on('load',function (){
                  //iframe has been reloaded. Send a signal to undo database and nav menu changes.
                  $.ajax({
                    async: true,
                    data: "ajax=undo_preview_update_changes",
                    url: "wizard.cgi"
                  });
                  
                  $("#ifr").off('load');
                });
                
            }
              
              
        });
    
  });
  
  
  if (sortable) {
  
    $('.column').sortable({
      revert: 200,
      delay: 100,
      opacity: 0.8,
      containment: 'document',
      items: 'li',
      placeholder: 'placeholder',
      forcePlaceholderSize: true,
      scrollSpeed:10
    });
  } else {
    $('ul.column li').css({'cursor':'default'});
  }
    
  
  
  $('body').append("<div id='real_preview_holder'><iframe id='ifr'></iframe></div>");
  $('#update_preview').click();
  
  
  
}
  

function parallel_call(url,mode) {
  //alert(url);
  //start a parallel call to other url
  //console.log("parallel call to |"+url);
  if (mode == 'products')
    start_loading();
  $.ajax({
    async: false,
    url: url,
    success: function (data) {
      if (mode == 'pages') {
        var request = "ajax=display_default_pages"
        $.ajax({
                async: true,
                data: request,
                url: "wizard.cgi",
                success: 
                        function(data) {
                          $('.loading').replaceWith(data);
                          max_id = parseInt($('#max_id').val());
                          max_existing_id = parseInt($('#max_existing_id').val());
                          //alert("pc "+max_id+" "+max_existing_id);
                        }
              });
      }
      
      if (mode == 'products') {
        //console.log("success");
        
        
        //load_products();
        var request = "ajax=preprocess_uploaded&pathway="+pathway+("&form_parm1="+form_parm1);
        $.ajax({
          async: true,
          data: request,
          url: "pageprod_ajax.cgi",
          success: 
            function(data) {
              /*$('.loading').replaceWith(data);
              max_id = parseInt($('#max_id').val());
              max_existing_id = parseInt($('#max_existing_id').val());
              $("body").css("cursor", "default");*/
              finish_loading();
              products_ready = 1;
            }
        });
      }
      
      
      if (mode == 'publish') {
        //alert(data);
      }
    }
          
  });
}

/*function resize_default_images() {
  var request = "ajax=resize_default_images"
  $("body").css("cursor", "progress");
  $.ajax({
    async: true,
    data: request,
    url: "wizard.cgi",
    success: 
      function(data) {
              //alert(data);
              var request = "ajax=display_default_products"
              $.ajax({
                async: true,
                data: request,
                url: "wizard.cgi",
                success: 
                        function(data) {
                          $('.loading').replaceWith(data);
                          max_id = parseInt($('#max_id').val());
                          max_existing_id = parseInt($('#max_existing_id').val());
                          $("body").css("cursor", "default");
                        }
              });
          }
  });
}*/



haha - 2025