-1

I got an requirement to find out if content in text frame got changed or not through action script. Till now i am comparing with my server side data to check content from indesign document text frame, but now i would like to check if any default flag there to avoid server side call.

  • You can either use InDesign's track changes feature, or you could save a checksum of the contents of the text frame client side and compare the checksum each time to see if it has changed. – Josh Voigts Aug 29 '16 at 14:48
  • Thanks for your comment @JoshVoigts. It works for me and i struck at how to clear all the changes com.adobe.indesign.Changes on clicking button... – Dileep Kumar Kottakota Sep 15 '16 at 05:56

1 Answers1

1

Track changes seems the way to go indeed. An alternative might be to use idle events to monitor stories changes. Basically what Josh just suggested.

#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 );
   }
  }
 }
}
Loic
  • 2,173
  • 10
  • 13