|
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/www/shopsite-images/en-AU/javascript/images/ |
Upload File : |
function form_element(element_id)
{
return document.getElementById(element_id);
}
function check_radio_button(id, num)
{
var button = form_element(id + '_' + num);
if (button != null)
button.checked = true;
}
function remove_quotes(value)
{
var parts, i, n;
if (value.indexOf('"') >= 0)
{
parts = value.split('"');
n = parts.length;
value = parts[0];
for (i = 1; i < n; i++)
value += parts[i];
}
return value;
}
function update_image_alt(image)
{
var size, id;
for (size = 0; size < 4; size++)
{
id = image + ':url_' + size;
if (form_element(id) != null)
update_image_tag(image, size);
}
}
function update_image_tag(image, size)
{
var url, alt, width, height, border, vspace, hspace, other;
var field, id, tag;
id = image + ':url_' + size;
url = form_element(id).value;
id = image + ':width_' + size;
width = form_element(id).value;
id = image + ':height_' + size;
height = form_element(id).value;
id = image + ':border_' + size;
border = form_element(id).value;
id = image + ':vspace_' + size;
vspace = form_element(id).value;
id = image + ':hspace_' + size;
hspace = form_element(id).value;
id = image + ':other_' + size;
other = form_element(id).value;
id = image + ':alt_0';
field = form_element(id);
alt = remove_quotes(field.value);
field.value = alt;
tag = '<img src="' + url + '"';
if (alt.length > 0)
tag += ' alt="' + alt + '"';
if (width.length > 0)
tag += ' width="' + width + '"';
if (height.length > 0)
tag += ' height="' + height + '"';
if (border.length > 0)
tag += ' border="' + border + '"';
if (vspace.length > 0)
tag += ' vspace="' + vspace + '"';
if (hspace.length > 0)
tag += ' hspace="' + hspace + '"';
if (other.length > 0)
tag += ' ' + other;
id = image + ':image_tag_' + size;
form_element(id).value = tag + '>';
}
function check_resize_percent(image)
{
var id, resize_percent;
id = image + ':image_resize_percent';
resize_percent = form_element(id);
if (!resize_percent.disabled)
{
if (resize_percent.value > 100)
{
alert(images_cannot_be_made_larger);
resize_percent.value = 100;
resize_percent.focus();
return false;
}
}
return true;
}
function check_resize_dimensions(image)
{
var image_width, image_height;
var image_resize_width, image_resize_height;
var id;
id = image + ':image_width';
image_width = form_element(id);
id = image + ':image_height';
image_height = form_element(id);
id = image + ':image_resize_width';
image_resize_width = form_element(id);
id = image + ':image_resize_height';
image_resize_height = form_element(id);
if (!image_resize_width.disabled)
{
if (Number(image_resize_width.value) > Math.max(Number(image_width.value), 0))
{
alert(images_cannot_be_made_larger);
image_resize_width.value = image_width.value;
image_resize_width.focus();
return false;
}
if (Number(image_resize_height.value) > Math.max(Number(image_height.value), 0))
{
alert(images_cannot_be_made_larger);
image_resize_height.value = image_height.value;
image_resize_height.focus();
return false;
}
}
return true;
}
function validate(nimages)
{
var image, image_name, rename_to, alt;
var renaming = false;
var id;
for (image = 0; image < nimages; image++)
{
id = image + ':alt_0';
alt = form_element(id);
alt.value = remove_quotes(alt.value);
}
for (image = 0; image < nimages; image++)
{
if (check_resize_percent(image) == false)
return false;
if (check_resize_dimensions(image) == false)
return false;
}
for (image = 0; image < nimages; image++)
{
id = image + ':image_rename_to';
rename_to = form_element(id);
if (check_filename(rename_to) == false)
{
rename_to.focus();
return false;
}
id = image + ':image_name';
image_name = form_element(id).value;
if ((i = image_name.lastIndexOf('.')) > 0)
image_name = image_name.slice(0, i);
if (image_name != rename_to.value)
renaming = true;
}
if (renaming)
return confirm_rename();
else
return true;
}
function check_filename(filename)
{
if (filename.value.match(/[^a-zA-Z0-9\-._]/g) != null)
{
alert(enter_valid_file_name + ' ' + valid_file_name_chars);
filename.focus();
return false;
}
if (filename.value.charAt(0) == '.')
{
alert(cannot_begin_with_dot);
filename.focus();
return false;
}
return true;
}
function confirm_rename()
{
return confirm(confirm_rename_msg);
}