#targetengine "session"
main();
function main()
{
mySetup();
mySnippet();
myTeardown();
}
function mySetup()
{
}
function mySnippet()
{
//<fragment>
var myIdleTask = app.idleTasks.add({name:"my_idle_task", sleep:10000});
var onIdleEventListener = myIdleTask.addEventListener("onIdle", onIdleEventHandler, false);
alert("Created idle task " + myIdleTask.name + "; added event listener on " + onIdleEventListener.eventType);
//<fragment>
}
function myTeardown() {
}
//<fragment>
function onIdleEventHandler(myIdleEvent) {
var curLabel = "VISIBILITY";
var curTextFrame = getPageitemFromLabel(curLabel);
if ( curTextFrame != null && curTextFrame.isValid ) {
var curContent = curTextFrame.contents;
if (curContent == "false") {
app.activeDocument.layers.itemByName("Ebene 2").visible = false;
} else {
app.activeDocument.layers.itemByName("Ebene 2").visible = true;
}
return;
}
//Delete idle task by setting its sleep time to zero.
myIdleEvent.parent.sleep = 0;
alert("Nothing to do. Delete idle task.");
}
//<fragment>
// holt die entsprechenden Items von der Musterseite
function getPageitemFromLabel (curLabel) {
var pageItemWithLabel = null;
if (curLabel != null && curLabel != "" && app.documents.length > 0) {
var allPageItems = app.activeDocument.pageItems;
for (var i=0; i<allPageItems.length;i++) {
var curPageItem = allPageItems[i];
var parentName = curPageItem.parent.constructor.name;
if (curPageItem.label == curLabel && (parentName == "Page" || parentName == "Spread" )) {
pageItemWithLabel = curPageItem;
break;
}
}
}
return pageItemWithLabel;
}
... View more