home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.tcs3.com
/
ftp.tcs3.com.tar
/
ftp.tcs3.com
/
DRIVERS
/
Audio
/
Office2010
/
Office.en-us
/
OfficeLR.cab
/
COLLECTSIGNATURES_INIT.XSN_1033
/
script.js
< prev
next >
Wrap
Text File
|
2009-07-06
|
5KB
|
144 lines
/*
* This file contains functions for data validation and form-level events.
* Because the functions are referenced in the form definition (.xsf) file,
* it is recommended that you do not modify the name of the function,
* or the name and number of arguments.
*
*/
// The following line is created by Microsoft InfoPath to define the prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of Microsoft InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces", ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:o12="http://schemas.microsoft.com/office/2004/7/core" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w12="http://schemas.microsoft.com/office/word/2004/6/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
//</namespacesDefinition>
function AddSigSpotNode(sigspotId, suggSigner, suggSignerEmail)
{
var sigSpotsNode = XDocument.DOM.selectSingleNode("//my:myFields/my:SignatureSpots");
var elemSigSpot = XDocument.DOM.createNode(1, "my:SignatureSpot", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
var attribSigSpotID = XDocument.DOM.createNode(2, "my:SignatureSpotID", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
attribSigSpotID.text = sigspotId;
var attribSuggSigner = XDocument.DOM.createNode(2, "my:SuggestedSigner", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
attribSuggSigner.text = suggSigner;
elemSigSpot.setAttributeNode(attribSigSpotID);
elemSigSpot.setAttributeNode(attribSuggSigner);
var elemAssignee = XDocument.DOM.createNode(1, "my:Assignee", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
if (suggSignerEmail)
{
var elemPerson = XDocument.DOM.createNode(1, "my:Person", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
var elemPersonName = XDocument.DOM.createNode(1, "my:DisplayName", "http://schemas.microsoft.com/office/infopath/2003/myXSD");
elemPersonName.text = suggSignerEmail;
elemPerson.appendChild(elemPersonName);
elemAssignee.appendChild(elemPerson);
}
elemSigSpot.appendChild(elemAssignee);
sigSpotsNode.appendChild(elemSigSpot);
}
function compareSpots(a, b) { return a.SortHint - b.SortHint}
function AddSigSpotNodes()
{
var sigSpotsNode = XDocument.DOM.selectSingleNode("//my:myFields/my:SignatureSpots");
var sigSpotNode = XDocument.DOM.selectSingleNode("//my:myFields/my:SignatureSpots/my:SignatureSpot");
sigSpotsNode.removeChild(sigSpotNode);
var thisDoc = XDocument.Host;
var arrSigLines = null;
var cSigLines = 0;
var iSigLine = 0;
var bIsInfopath = false;
// Word / Excel
if (thisDoc.Signatures)
{
thisDoc.Signatures.Subset = 2; //msoSignatureSubsetSignatureLines;
// Copy all the signature lines into an array.
cSigLines = thisDoc.Signatures.Count;
arrSigLines = new Array(cSigLines);
for (iSigLine = 1; iSigLine <= cSigLines; iSigLine++)
{
arrSigLines[iSigLine] = thisDoc.Signatures(iSigLine);
}
// Now sort the array based on the sort hint
arrSigLines.sort(compareSpots);
}
// InfoPath
else if (thisDoc.View && thisDoc.View.SignatureLines)
{
bIsInfopath = true;
cSigLines = thisDoc.View.SignatureLines.Count;
arrSigLines = new Array(cSigLines);
for (iSigLine = 0; iSigLine < cSigLines; iSigLine++)
{
arrSigLines[iSigLine] = thisDoc.View.SignatureLines[iSigLine];
}
}
for (iSigLine = 0; iSigLine < cSigLines; iSigLine++)
{
var sigspotId;
var suggSigner;
var suggSignerEmail;
var thisSigLine = arrSigLines[iSigLine];
// Word / Excel
if (!bIsInfopath)
{
if (!thisSigLine.IsSignatureLine || (thisSigLine.IsSigned && thisSigLine.IsValid))
continue;
sigspotId = thisSigLine.Setup.Id;
suggSigner = thisSigLine.Setup.SuggestedSigner;
suggSignerEmail = thisSigLine.Setup.SuggestedSignerEmail;
}
// InfoPath
else
{
if (thisSigLine.Signature && thisSigLine.Signature.Status == 1 /* XdSignatureStatus.Valid */)
continue;
sigspotId = iSigLine;
suggSigner = thisSigLine.SuggestedSigner;
suggSignerEmail = thisSigLine.SuggestedSignerEmailAddress;
}
AddSigSpotNode(sigspotId, suggSigner, suggSignerEmail);
}
}
//=======
// The following function handler is created by Microsoft InfoPath.
// Do not modify the name of the function, or the name and number of arguments.
// This function is associated with the following field or group (XPath): /my:myFields/my:CC
// Note: Information in this comment is not updated after the function handler is created.
//=======
function XDocument::OnLoad(eventObj)
{
try
{
AddSigSpotNodes();
}
catch (e)
{
XDocument.UI.Alert(e.message);
}
}