if (app.selection.length == 0 || !app.selection[0].hasOwnProperty('baseline'))
exit();
var doc = app.activeDocument;
var cr_name = 'Seitenverweis';
var myHLdest = myDisplayDialog(doc);
var sel = app.selection[0];
// Prüfung Vorhandensein von Querverweisformat
var cr_format = doc.crossReferenceFormats.itemByName(cr_name);
if (cr_format == null)
{
cr_format = doc.crossReferenceFormats.add({name:cr_name});
// cr_format.buildingBlocks.add({blockType:BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK, customText: '–'});
cr_format.buildingBlocks.add({blockType:BuildingBlockTypes.PAGE_NUMBER_BUILDING_BLOCK});
}
// Quelle des Querverweises hinzufügen
var cr_source = doc.crossReferenceSources.add({sourceText: sel.insertionPoints.firstItem(), appliedFormat: cr_format});
// Querverweis von Quelle zu Ziel hinzufügen
app.documents.firstItem().hyperlinks.add(cr_source, myHLdest);
function myDisplayDialog(doc){
var myFieldWidth = 120;
var hl_destinations = doc.hyperlinkTextDestinations.everyItem().name;
var myDialog = app.dialogs.add({name:"Querverweise"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Hyperlinkziel:", minWidth:myFieldWidth});
}
with(dialogColumns.add()){
var mySourceDropdown = dropdowns.add({stringList:hl_destinations, selectedIndex:hl_destinations.length-1});
}
}
}
var myResult = myDialog.show();
if(myResult == true){
var the_hldest =doc.hyperlinkTextDestinations.item(mySourceDropdown.selectedIndex);
myDialog.destroy();
}
else{
myDialog.destroy()
exit();
}
return the_hldest;
}