function htmlEncode(value) {
return $('
').text(value).html();
}
function htmlDecode(value) {
return $('').html(value).text();
}
$.getScript('http://prodocs4530/forms/js/jSignature.min.js', function () {
$('.signature').jSignature();
});
/**When the page loads, check if the sig data (hidden) field has a value.
If it has a value, decode it and put it in the image, and remove the
signature pad and its buttons.**/
$('.sigCollection').each(function () {
var sigvalue = $(this).find('.sigdata textarea').text();
var sigrovalue = $(this).find('.sigdata .ro').text();
if (sigvalue != '' || sigrovalue != '') {
var decoded = htmlDecode(sigvalue == '' ? sigrovalue : sigvalue);
var $img = $('
');
$img.attr("src", decoded).appendTo($(this).find('.sigimage'));
$(this).find('.sigGroup').remove(); //class added to the signature button and image custom HTML fields.
$(this).find('.sigwarning').hide();
}
});
$('.donebutton').click(function () {
var section = $(this).closest('.sigCollection');
var sigdata = section.find('.signature').jSignature('getData');
section.find('.sigdata textarea').val(htmlEncode(sigdata));
var $img = $('
');
$img.attr("src", section.find('.signature').jSignature('getData')).appendTo(section.find('.sigimage'));
section.find('.sigGroup').remove(); //class added to the signature button and image custom HTML fields.
});
$('.clearbutton').click(function () {
var section = $(this).closest('.sigCollection');
section.find('.signature').jSignature('clear');
});