javascript - How to determine whether the content in text frame of in design document changed through java script or action script? -
i got requirement find out if content in text frame got changed or not through action script. till comparing server side data check content indesign document text frame, check if default flag there avoid server side call.
track changes seems way go indeed. alternative might use idle events monitor stories changes. josh 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 made on story "+id+" @ "+(new date()) ); db[id] = st.contents; } else { $.writeln ( "no changes made story "+id ); } } } }
Comments
Post a Comment