# targetengine "storiesChanges"
main();
function main()
{
var db = {};
var myIdleTask = app.idleTasks.item("checkStories");
if ( !myIdleTask.isValid ) {
myIdleTask = app.idleTasks.add({name:"checkStories", sleep:100});
myIdleTask.addEventListener(IdleEvent.ON_IDLE,onIdleEventHandler, false);
}
function onIdleEventHandler(myIdleEvent)
{
var doc = app.properties.activeDocument;
if ( !doc ) {
db = {}
return;
}
var sts = doc.stories, st, id;
var n = sts.length;
while ( n-- ) {
st = sts[n];
id = st.id;
if ( !db[id] ) {
$.writeln ("Storing "+id );
db[id] = st.contents;
}
else if ( db[id]!=st.contents ) {
$.writeln ( "Some changes were made on story "+id+" at "+(new Date()) );
db[id] = st.contents;
}
else {
$.writeln ( "No changes were made for story "+id );
}
}
}
}
1条答案
按热度按时间kr98yfug1#
跟踪变化看起来确实可行。另一种选择可能是使用空闲事件来监控故事的变化。基本上就是Josh刚才建议的。