status is set to Spiked or Filed.Then, the function skeleton is as follows:
function msoxd__status::OnAfterChange(eventObj)
{
if(eventObj.Operation == "Insert" && eventObj.Site.text == "Filed")
{
// code here
}
if(eventObj.Operation == "Insert" && eventObj.Site.text == "Spiked")
{
// code here
}
}
Depending on the status of the story, some action is applied. If the status is Spiked, you have to update the modificationTime element with the current time. This can be done by simply changing the element content for all meta elements with status equal to Spiked:
if(eventObj.Operation == "Insert" && eventObj.Site.text == "Embargoed")
{
var objMetaNodes = XDocument.DOM.selectNodes("//meta");
for (var i = 0; i < objMetaNodes.length; i++)
{
UpdateModificationTime(objMetaNodes.item(i));
}
}
UpdateModificationTime is a custom function that selects the modificationTime node and sets the current date and time:
function UpdateModificationTime(metaNode)
{
var modTime = metaNode.selectSingleNode("modificationTime");
modTime.nodeTypedValue = GetCurrentDateTime();
}
function GetCurrentDateTime()
{
var now = new Date();
return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" +
now.getDate() + "T" + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
}
If the story is accepted (status = Filed), you have to compute more information. Some of these, as you will see later, depend on database content.