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-NZ/javascript/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/jackjohn/public_html/shopsite-images/en-NZ/javascript/power_edit.js
//////////////////////////////////////////////////////////////////////////////////
//
// database_fields: select box on the left.
//
// saved_fields: select box on the right where selected database fields are
// added.
//
// edit_fields: hidden field used to pass along the field numbers of the
// selected fields for saving in the AA file as a comma-delimited string.
//
// save_attributes: holds the name to be saved in the AA file for the
// currently selected attributes.
//
// saved_attributes: select list of names for saved attributes.
//
// last_used_attributes: hidden field that holds the name to be saved in
// the AA file for the last used attributes.
//
// save_as_option: checkbox option to save the currently selected
// attributes.
//
// save_as_name: input text field in which the name is entered for saving
// the currently selected attributes in the AA file.
//
//////////////////////////////////////////////////////////////////////////////////

function power_edit(dbname)
{
  var edit_fields = document.getElementById('edit_fields');
  var saved_fields = document.getElementById('saved_fields').options;
  var saved_attributes = document.getElementById('saved_attributes');
  var fields = '';
  var i;

  add_fields();
  
  if (saved_fields.length == 0)
  {
    alert(make_selection_msg);
    return false;
  }

  if (saved_attributes != null)
  {
    var save_attributes = document.getElementById('save_attributes');
    var last_used_attributes = document.getElementById('last_used_attributes');

    var save_as_option = document.getElementById('save_as');
    var save_as_name = document.getElementById('save_as_name');
    var selection_methods = document.getElementsByName('selection_methods');

    var index = saved_attributes.selectedIndex;

    if (index > 0)
    {
      if (selection_methods[1].checked)  // last used
      {
        var attributes_name = saved_attributes.options[index].value;
        last_used_attributes.value = attributes_name;
      }
    }

    if (save_as_option.checked)
    {
      var names = saved_attributes.options;
      var save_as = save_as_name.value;

      if (save_as.length == 0)
      {
        if (index > 0)
          save_as_name.value = saved_attributes.options[index].text;
        else
        {
          alert(enter_save_as_name);
          save_as_name.focus();
          return false;
        }
      }

      if (names.length > 0)
      {
        for (i = 1; i < names.length; i++)
        {
          if (i != index)
          {
            var name_parts = names[i].value.split('@');
          
            if (save_as.toLowerCase() == name_parts[1].toLowerCase())
            {
              if (confirm(overwrite_existing_attributes) == false)
                return false;
            }
          }
        }
      }

      save_attributes.value = save_as_name.value;

      if (selection_methods[1].checked)  // last used
        last_used_attributes.value = dbname + '@' + save_as_name.value;
    }
  }

  for (i = 0; i < saved_fields.length; i++)
  {
    if (i > 0)
      fields += ',';

    fields += saved_fields[i].value;
  }

  edit_fields.value = fields;
  return true;
}

function add_multiple(dbname, name_fnum)
{
  var database_fields = document.getElementById('database_fields').options;
  var saved_fields = document.getElementById('saved_fields').options;
  var save_as_option = document.getElementById('save_as');
  var fieldname, fieldnum;
  var i;

  for (i = 0; i < saved_fields.length; i++)
  {
    if (Number(saved_fields[i].value) == name_fnum)
      break;
  }

  if (i == saved_fields.length)
  {
    fieldname = database_fields[0].text;
    fieldnum  = database_fields[0].value;
    saved_fields[i] = new Option(fieldname, fieldnum, false, false);
  }

  return power_edit(dbname);
}

function selection_changed(select_list)
{
  var save_as = document.getElementById('save_as');
  var save_as_name = document.getElementById('save_as_name');
  var saved_fields = document.getElementById('saved_fields');

  saved_fields.options.length = 0;

  if (select_list.selectedIndex > 0)
    get_attributes(select_list);

  save_as_name.value = '';
  save_as.checked = false;

  reset_placeholder();
}

function save_changes()
{
  var saved_attributes = document.getElementById('saved_attributes');
  var save_as_option = document.getElementById('save_as');

  if (saved_attributes != null)
  {
    if (saved_attributes.selectedIndex > 0)
    {
      save_as_option.checked = true;
      reset_placeholder();
    }
  }
}

function reset_placeholder()
{
  var save_as_option = document.getElementById('save_as');
  var save_as_name = document.getElementById('save_as_name');
  var saved_attributes = document.getElementById('saved_attributes');
  var text, i;

  if (save_as_option.checked)
  {
    if ((i = saved_attributes.selectedIndex) > 0)
    {
      text = saved_attributes.options[i].text;
      text += '  (' + enter_another_name.toLowerCase();
      text += ')';
    }
    else
      text = enter_a_name.toLowerCase();
  }
  else
    text = '';

  save_as_name.placeholder = text;
}

function get_attributes(select_list)
{
  var form, name, url;
  var i;

  if ((i = select_list.selectedIndex) > 0)
  {
    form = document.getElementById('pe_form');
    name = select_list.options[i].value;

    url = form.action + '?get_power_edit_fields=';
    url += encodeURIComponent(name);
    url += "&sid=" + Math.random();

    xmlHttp = GetXmlHttpObject();
    xmlHttp.onreadystatechange = load_attributes;
    xmlHttp.open("GET", url, false); // synchronous
    xmlHttp.send(null);
  }
}

function load_attributes()
{
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
  {
    var response = xmlHttp.responseText;
    var saved_fields = document.getElementById('saved_fields');
    
    if (response.length > 0)
    {
      var fields = response.split('\n');
      var field, fieldnum, fieldname;
      var i;

      for (i = 0; i < fields.length; i++)
      {
        field = fields[i].split('|');
        fieldnum = field[0];
        fieldname = field[1];

        saved_fields[i] = new Option(fieldname, fieldnum, false, false);
      }
    }
  }
}

function delete_attributes()
{
  var saved_attributes = document.getElementById('saved_attributes');
  var form, name, url;
  var i;

  if ((i = saved_attributes.selectedIndex) > 0)
  {
    if (confirm(are_you_sure))
    {
      form = document.getElementById('pe_form');
      name = saved_attributes.options[i].value;

      url = form.action + '?delete_power_edit_attributes=';
      url += encodeURIComponent(name);
      url += "&sid=" + Math.random();

      xmlHttp = GetXmlHttpObject();
      xmlHttp.onreadystatechange = attributes_deleted;
      xmlHttp.open("GET", url, false); // synchronous
      xmlHttp.send(null);
    }
  }

  return false;
}

function attributes_deleted()
{
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
  {
    var response = xmlHttp.responseText;

    if (response == 'deleted')
    {
      var save_as_option = document.getElementById('save_as');
      var save_as_name = document.getElementById('save_as_name');
      var saved_attributes = document.getElementById('saved_attributes');
      var i = saved_attributes.selectedIndex;

      var fields = document.getElementById('saved_fields').options;
      fields.length = 0;

      saved_attributes.options[i] = null;
      saved_attributes.selectedIndex = -1;

      save_as_name.value = '';
      save_as_option.checked = false;
    }
  }
}

function add_fields()
{
  var from = document.getElementById('database_fields').options;
  var to = document.getElementById('saved_fields').options;
  var fieldname, fieldnum;
  var fields_added = false;
  var k = to.length;
  var i, j;

  for (i = 0; i < from.length; i++)
  {
    if (from[i].selected == true)
    {
      fieldname = from[i].text;
      fieldnum  = from[i].value;

      // don't add duplicate fieldnums
      for (j = 0; j < k; j++)
      {
        if (to[j].value == fieldnum)
          break;
      }
      
      if (j == k)
        to[k++] = new Option(fieldname, fieldnum, false, false);

      from[i].selected = false;
      fields_added = true;
    }
  }

  if (fields_added)
    save_changes();

  return false;
}

function remove_fields()
{
  var fields = document.getElementById('saved_fields').options;
  var fields_removed = false;
  var i;

  for (i = fields.length - 1; i >= 0; i--)
  {
    if (fields[i].selected == true)
    {
      fields[i] = null;
      fields_removed = true;
    }
  }

  if (fields_removed)
    save_changes();

  return false;
}

function move_field(fields_list, incr)
{
  var fields = document.getElementById(fields_list);
  var options = fields.options;
  var text, value;
  var i, j, n;

  i = fields.selectedIndex;
  if (i >= 0)
  {
    j = i + incr;
    n = options.length;

    if ((incr < 0 && j < 0) || (incr > 0 && j >= n))
      return false;

    text = options[j].text;
    value = options[j].value;
    options[j].text = options[i].text;
    options[j].value = options[i].value;
    options[i].text = text;
    options[i].value = value;

    options[i].selected = false;
    options[j].selected = true;
  }

  save_changes();
  return false;
}

function expand(name)
{
  var box = document.getElementById(name);
  var width = box.style.width;

  width = width.split('p', 1);
  width = Number(width) + 20;
  box.style.width = width + 'px';
  return false;
}

var xmlHttp = null;

function GetXmlHttpObject()
{
  try
  {
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    try
    {
      xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
    }
    catch(e)
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }

  return xmlHttp;
}


haha - 2025