/*
* @Author: vbatushev
* @Date: 2015-11-06 08:23:59
* @Last Modified by: vbatushev
* @Last Modified time: 2015-11-06 21:20:55
*/
#targetengine "session"
app.scriptPreferences.enableRedraw = false;
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
app.activeWindow.addEventListener(LayoutWindow.AFTER_SELECTION_CHANGED, lwAfterSelectionChanged, false);
var vbatushevSelectedPageItem = "";
function lwAfterSelectionChanged(event) {
if (vbatushevSelectedPageItem == "") {
var selectedPageItems = vbatushevSelectedPageItem.split(",");
var arr = [];
for (var a = 0; a < app.selection.length; a++) {
if (isPageItem(app.selection[a])){
var obj = {
item: app.selection[a].toSource(),
id: app.selection[a].id,
type: app.selection[a].getElements()[0].constructor.name
}
arr.push(obj.toSource());
}
}
vbatushevSelectedPageItem = arr.join(";");
} else {
var selectedPageItems = vbatushevSelectedPageItem.split(";");
for (var a = 0; a < selectedPageItems.length; a++) {
var so = new Object(eval(selectedPageItems[a]));
if (!evalObject(so.item)) {
$.writeln("Объект " + so.type + "(" + so.id + ") удален");
}
}
vbatushevSelectedPageItem = "";
}
function evalObject(str) {
try {
eval(str);
return true;
} catch(e) {
return false;
}
}
function isPageItem(obj) {
try {
var id = obj.id;
return true;
} catch(e) {
return false;
}
}
}