This repository has been archived by the owner on Jul 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
MPO-Importer.jsx
2882 lines (2188 loc) · 78.8 KB
/
MPO-Importer.jsx
1
// #targetengine "jm-2014";// var thelinkbuttonfile;(function (thisObj) { // You must copy the file "glue code.jsx" from the XML Rules folder // (inside the Scripts folder inside your InDesign folder) // to the folder meta below the older containing this script, // or provide a full path to the file in the next line. // Copyright (C) 2011 - 2013 Fabian "fabiantheblind" Morón Zirfas // http://www.the-moron.net // info [at] the - moron . net // MPO IMPORTER V 0.4.2 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/. /** * * @todo Move Data-Processing to own function */ // #include "./meta/Info.jsx"; // // // // // GLOBAL var mpo_data = { "version": "0.4.2", "uuid": guid(), "mode": null, "xmlexist": false, "rmvxml": true, "DEBUG": false, "dummy": null, "usedummy": true, "greps" : {"comment":"Changes the price -- to –","fw":"(\\d)\\,--","ct":"$1,–"} };/** * This is from build link button * @type {Object} */ var obj = {};obj.DEBUG = false;obj.WARNINGS = true;/********************************************** * */ var uuid = mpo_data.uuid; var DEBUG = mpo_data.DEBUG; // var keepon = false; // keepon = include("/meta/glue code.jsx"); // if (!keepon) return; #include "./meta/glue code.jsx"; #include "./meta/dummy.jsx"; mpo_data.dummy = dummy; // keepon = include("/meta/dummy.jsx"); // if (!keepon) return; // ------------ END OF INLCUDE ------------ main(); function main() { // Check for a document var myDoc = null; try { myDoc = app.activeDocument; } catch (e) { alert( "No no no, you have no document.\nMaybe you should drink some coffee" ); return; } if (myDoc.xmlElements[0].xmlElements.length > 0){ // this asumes that there is a XML structure // lets see how this works out mpo_data.xmlexist = true; mpo_data.rmvxml = false; } var numOfItems; var myDate = new Date(); var myLogFile = null; try { myLogFile = myGetFileName(); } catch (e) { alert("You need to save your document"); myDoc.save(); myDoc = app.activeDocument; var myLogFile = myGetFileName(); } /** * Get the dummy if it not exists create it */ if(Folder(myDoc.filePath + "/files").exists){ }else{ var folder = new Folder(myDoc.filePath + "/files"); folder.create(); } if (File(myDoc.filePath + "/files/dummy.jpg").exists) { mpo_data.dummy = File(myDoc.filePath + "/files/dummy.jpg"); } else { mpo_data.dummy = File(myDoc.filePath + "/files/dummy.jpg"); mpo_data.dummy.encoding = "BINARY"; mpo_data.dummy.open("w"); mpo_data.dummy.write(dummy); mpo_data.dummy.close(); } // alert(mpo_data.dummy.name); // ------------ start cleaning simple ui ------------ var myFileContent = "" + mpo_data.uuid; //= myLogFile.read(); var myErrorLog = myFileContent + "\n" + "Starting Log file at " + myDate + "\n"; var myItemsList = []; var myList; var myPageName; var myPage; // with(myDoc){ myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS; myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS; myDoc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; // } makeMetaStyle(myDoc); // var myParStyles = makeParstylesArray(myDoc); // var myCharStyles = makeCharstylesArray(myDoc); myList = myDoc.pages.everyItem().name; myErrorLog = myErrorLog + "Got these Pages: " + myList.toString() + "\n"; // set the XMLImport preferences prcs_xmlImportPref(myDoc); var simpleDialog = app.dialogs.add({ name: "Import Modes", canCancel: true }); // var modeDropdown = 0; // with(simpleDialog){ //Add a dialog column. var sdiag_column1 = simpleDialog.dialogColumns.add(); // var sdiag_row1 = sdiag_column1.dialogRows.add(); // with(dialogColumns.add()){ // with(dialogRows.add()){ var modeDropdown = sdiag_column1.dropdowns.add({ stringList: ["Quick And Dirty", "Advanced", "Xml Import Only", "Place all Prices", "Place all Tables","Build Link Button" ], selectedIndex: 0, minWidth: 75 }); // } // end of first row // with(dialogRows.add()){ var xmlExistChkBx = sdiag_column1.checkboxControls.add({ checkedState: mpo_data.xmlexist, staticLabel: "xml structure exists" }); // } // end of second row // with(dialogRows.add()){ var xmlRmvChkBx = sdiag_column1.checkboxControls.add({ checkedState: mpo_data.rmvxml, staticLabel: "remove xml @ end" }); var dummyChkBx = sdiag_column1.checkboxControls.add({ checkedState: true, staticLabel: "use dummies" }); dummyChkBx.checkedState = mpo_data.usedummy; // } // end of third row // } // end of first column // with(dialogColumns.add()){ // var gutter = staticTexts.add({staticLabel:" ",minWidth:25}); // } // } // end of -->with(simpleDialog) // var dialog = build_simple_dialog(); // ------------ cleaned simple ui 2013 ------------ //Display the fist dialog box. // if(dialog.show() === true){ // } if (simpleDialog.show() === true) { // newsimpleDialog // true means quick and dirty // false means advanced mpo_data.mode = modeDropdown.selectedIndex; mpo_data.xmlexist = xmlExistChkBx.checkedState; mpo_data.rmvxml = xmlRmvChkBx.checkedState; mpo_data.usedummy = dummyChkBx.checkedState; simpleDialog.destroy(); // alert("DEBUG: "+mpo_data.mode +" "+mpo_data.xmlexist ); var myRoot; if ((myDoc.xmlElements[0].xmlElements.length > 0) && (mpo_data.xmlexist === false)) { var res = confirm( "There is already a xml structure. Should I remove it?\nIf not this process will be stopped" ); if (res === true) { myDoc.xmlElements.everyItem().remove(); } else { return; } } if (!mpo_data.xmlexist) { // alert("DEBUG: xml does not exist call the import"); try { var myXMLFile = getxmlfiles();// File.openDialog("Choose your .xml file"); myErrorLog = myErrorLog + "Got this xml file: " + myXMLFile.displayName .toString() + "\n"; myRoot = myDoc.importXML(myXMLFile); } catch (e) { alert("ERROR: :( Sorry, your XML Document seems broken.\n" + e); try { myXMLFile.execute(); } catch (_e) {} myErrorLog = myErrorLog + e.toString() + "\n"; exit(); } try { mapManually(myDoc); } catch (e) { alert( "ERROR: :( Sorry, you don't have the right styles in your document\nit will look wired\n" + e); myErrorLog = myErrorLog + e.toString() + "\n"; } // Count all items in. // this isnt essential for the script numOfItems = prcs_countItems(myDoc); myErrorLog = myErrorLog + "Got " + myList.toString() + " items in this xml \n"; try { prcs_makeAttributesFromInfo(myDoc); } catch (e) { alert( "ERROR: No i could not make your Attributes for processing the xml " + e); myErrorLog = myErrorLog + e.toString() + "\n"; exit(); } try { prcs_sortGroups(myDoc); } catch (e) { alert("ERROR: Could not move Elements to group" + e); myErrorLog = myErrorLog + e.toString() + "\n"; exit(); } try { // first we move the normal ones to the front than the focus small stays at end prcs_sortInGroupByPriority(myDoc); } catch (e) { alert("ERROR: Could not move the normal Elements in group" + e); myErrorLog = myErrorLog + e.toString() + "\n"; exit(); } try { prcs_makeImgElement(myDoc); } catch (e) { alert( "ERROR: Could not move the image Elements into new Element group" + e); myErrorLog = myErrorLog + e.toString() + "\n"; exit(); } try { prcs_makeItemList(myDoc); } catch (e) { alert( "ERROR: Could not make the list of items. the single import wont work" + e); myErrorLog = myErrorLog + e.toString() + "\n"; exit(); } // ------------------------- // From here on it does something on the page } // end of xmlimport into the doc //if it already exist the whole thing got skipped } else { // if the user pressed cancel // stop the whole thing simpleDialog.destroy(); return; } var myItemsListElement = myDoc.xmlElements.item(0).xmlElements.item( "itemsList"); for (var i = 0; i < myItemsListElement.xmlElements.length; i++) { myItemsList[i] = myItemsListElement.xmlElements.item(i).markupTag.name; } myUI(myDoc, myPage, myPageName, myList, myItemsList, myErrorLog, myLogFile, mpo_data.mode); } // end of mainfunction getxmlfiles() { var doc; // this will be the document try { doc = app.activeDocument; // get the acitve document } catch (e) { // oh oh no active doc alert("You have no document open!\n" + e); return; } var folder = Folder(doc.filePath); // get the folder var files = folder.getFiles(); var filelist = []; var nameslist = []; for (var i = 0; i < files.length; i++) { var file = files[i]; if (file.name.split('.').pop() === 'xml') { itis = true; filelist.push(file); } } filelist.sort(function(a, b) { a = new Date(a.created); b = new Date(b.created); return a>b ? -1 : a<b ? 1 : 0; }); for(var j = 0; j < filelist.length;j++){ var f = filelist[j]; nameslist.push(f.name); } nameslist.push("other location..."); var xmldiag = app.dialogs.add({ name: "XML Files next to your doc", canCancel: true }); var xmldiag_column1 = xmldiag.dialogColumns.add(); // var sdiag_row1 = sdiag_column1.dialogRows.add(); // with(dialogColumns.add()){ // with(dialogRows.add()){ var xmlFilesDropDown = xmldiag_column1.dropdowns.add({ stringList: nameslist, selectedIndex: nameslist.length - 2, minWidth: 350 }); var xmlfile = null; if (xmldiag.show() === true) { var gotthefile = false; if (xmlFilesDropDown.selectedIndex == nameslist.length - 1) { xmlfile = File.openDialog("Choose your .xml file"); if (xmlfile === null) { return; } } else { gotthefile = true; xmlfile = filelist[xmlFilesDropDown.selectedIndex]; } xmldiag.destroy(); return xmlfile; // alert("The File" + xmlfile.fsName); } else { // user canceld } } // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // ------------ END OF SCRIPT EXECUTION ------------ // // ------------ Functions ------------ // // _ _ _______ _____ _ _____ _______ _____ ______ _____ // | | | |__ __|_ _| | |_ _|__ __|_ _| ____|/ ____| // | | | | | | | | | | | | | | | | | |__ | (___ // | | | | | | | | | | | | | | | | | __| \___ \ // | |__| | | | _| |_| |____ _| |_ | | _| |_| |____ ____) | // \____/ |_| |_____|______|_____| |_| |_____|______|_____/ /** * MAKE GUID 2013_08_22 * http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript * usage * * var uuid = guid(); * */ function s4() { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); } function guid() { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); } // Test GUID // // function check_uuid(_uuid) { var regExp = new RegExp(uuid); return regExp.test(_uuid); } // ------------ older utils ------------ function myGetFileName() { var myFolder = app.activeDocument.filePath; var myFile = new File(myFolder + '/log.txt'); // if ( myFile === null ){exit()}; return myFile; } /* * a function prcs_to check the operating system * * @returns true if the OS is windows */ function checkOS(myString) { var myOS = $.os; var myOSSubString = myOS.charAt(0); var myOSBoolean; if (myOSSubString === "w" || myOSSubString === "W") { myOSBoolean = true; } else { myOSBoolean = false; } if (myOSBoolean === true) { //this is for windows var myHREFString = myString; var myHREFSubString = myHREFString.substring(8); return myHREFSubString; } else { // this is for macintosh return myString; } } function build_simple_dialog() { var win = new Window('dialog', 'Import Modes'); win.orientation = 'column'; win.alignChildren = ["fill", "fill"]; var modeDropdown = win.add('dropdownlist', undefined, ["Quick And Dirty", "Advanced", "Xml Import Only", "Place all Prices" ]); modeDropdown.onChange = function () { mpo_data.mode = this.selection; }; var xmlExistChkBx = win.add('checkbox', undefined, "xml structure exists"); xmlExistChkBx.onClick = function () { mpo_data.xmlexist = this.value; }; var xmlRmvChkBx = win.add('checkbox', undefined, "remove xml @ end"); xmlRmvChkBx.onClick = function () { mpo_data.rmvxml = this.value; }; var dummyChkBx = win.add('checkbox', undefined, "use dummys"); dummyChkBx.value = mpo_data.usedummy; xmlRmvChkBx.onClick = function () { mpo_data.usedummy = this.value; }; win.add("button", undefined, "Yes", { name: "ok" }); win.add("button", undefined, "No", { name: "cancel" }); return win; } /** * This builds the advanced dialog * @param {[type]} myDoc [description] * @param {[type]} myPage [description] * @param {[type]} myPageName [description] * @param {[type]} myList [description] * @param {[type]} myItemsList [description] * @param {[type]} myErrorLog [description] * @param {[type]} myLogFile [description] * @param {[type]} mode [description] * @return {[type]} [description] */ function myUI(doc, myPage, myPageName, myList, myItemsList, myErrorLog, myLogFile, mode) { var myNumOItems = 0; var minW = 400; var advancedDialog = app.dialogs.add({ name: "XMLImporter", canCancel: true, minWidth: minW }); var adiag_column1 = advancedDialog.dialogColumns.add(); // var allSelector = adiag_column1.enablingGroups.add({ // staticLabel: "place all and remove", // checkedState: true, // minWidth: minW // }); var myPlaceAll = adiag_column1.checkboxControls.add({ staticLabel: "place every item!", checkedState: true }); adiag_column1.staticTexts.add({ staticLabel: " " }); // var myClearStructureCheckbox = allSelector.checkboxControls.add({ // staticLabel: "remove all xml elements after import?", // checkedState: true // }); var pageSelector = adiag_column1.enablingGroups.add({ staticLabel: "choose page", checkedState: false, minWidth: minW }); var pgsel_column1 = pageSelector.dialogColumns.add(); var pgsel_column2 = pageSelector.dialogColumns.add(); // pgsel_column1.staticTexts.add({ // staticLabel: " " // }); var myPageDropdown = pgsel_column2.dropdowns.add({ stringList: myList, minWidth: (minW / 3) + 20 }); // var groupSelector = enablingGroups.add({staticLabel: "place group", checkedState: false,minWidth :minW}); // with (groupSelector) { // with (dialogColumns.add()) { // staticTexts.add({ // staticLabel: "chose group to place" // }); // } // with (dialogColumns.add()) { // //Create a pop-up menu ("dropdown") control. // var myGroupDropdown = dropdowns.add({ // stringList: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], // selectedIndex: 0 // }); // } // staticTexts.add({ // staticLabel: "choose scope:" // }); // var myRadioButtonGroup = radiobuttonGroups.add(); // with (myRadioButtonGroup) { // var myLeftRadioButton = radiobuttonControls.add({ // staticLabel: "focus", // checkedState: true // }); // var myCenterRadioButton = radiobuttonControls.add({ // staticLabel: "normal" // }); // var myRightRadioButton = radiobuttonControls.add({ // staticLabel: "small" // }); // } // } var itemSelector = adiag_column1.enablingGroups.add({ staticLabel: "place single item", checkedState: false, minWidth: minW }); var itemsel_column1 = itemSelector.dialogColumns.add(); var myArtikelDropdown = itemsel_column1.dropdowns.add({ stringList: myItemsList, minWidth: (minW / 3) + 20 //selectedIndex:0 }); var tbAndPrSelector = adiag_column1.enablingGroups.add({ staticLabel: "tables and prices", checkedState: false, minWidth: minW }); var tbAndPrSel_column1 = tbAndPrSelector.dialogColumns.add(); var tbAndPrSel_row1 = tbAndPrSel_column1.dialogRows.add(); var tbAndPrSel_row2 = tbAndPrSel_column1.dialogRows.add(); var tbAndPrSel_row3 = tbAndPrSel_column1.dialogRows.add(); var myPlaceTablesCheckbox = tbAndPrSel_row1.checkboxControls.add({ staticLabel: "place tables" // checkedState: true }); var myPlacePricesCheckbox = tbAndPrSel_row2.checkboxControls.add({ staticLabel: "place prices" // checkedState: true }); // } var myPlaceTablesExitCheckbox = tbAndPrSel_row3.checkboxControls.add({ staticLabel: "don't place articles", checkedState: true }); var myClearStructureCheckbox = adiag_column1.checkboxControls.add({ staticLabel: "remove xml @ end", checkedState: true }); /** * @todo Move Data-Processing to own function * From here on is processing data * should be taken to own function * */ var placeAllBool; var focusBool; var normalBool; var smallBool; var itemBool; var groupSelector; var theItem; var placeTables = false; var exitAfterTables = true; var placePrices = false; //Display the dialog box. if (mpo_data.mode === 0) { myPage = doc.pages.add(); myPageName = myPage.name; placeAllBool = true; focusBool = false; normalBool = false; smallBool = false; itemBool = false; theItem = null; // call function placeData // in processXMLv2.jsx prcsXMLv02_placeData(doc, myPage, groupSelector, placeAllBool, focusBool, normalBool, smallBool, itemBool, theItem, myErrorLog, myLogFile); // process_images(doc); if (mpo_data.rmvxml) { doc.xmlElements.everyItem().remove(); } // end of --> else if (mpo_data.mode === 0) } else if (mpo_data.mode === 1) { if (advancedDialog.show() === true) { // var myPage; // var myPageName; // page selector box if (pageSelector.checkedState !== true) { myPage = doc.pages.add(); myPageName = myPage.name; } else { // myPage = myList[myPageDropdown.selectedIndex]; myPageName = myList[myPageDropdown.selectedIndex]; } if (tbAndPrSelector.checkedState === true && myPlacePricesCheckbox.checkedState === true) { // myPage = doc.pages.add(); // myPageName = myPage.name; } if (tbAndPrSelector.checkedState === true) { if (myPlaceTablesCheckbox.checkedState === true) { placeTables = true; placePrices = false; } else { placeTables = false; } if (myPlacePricesCheckbox.checkedState === true) { placePrices = true; placeTables = false; } else { placePrices = false; } if (myPlaceTablesExitCheckbox.checkedState === true) { exitAfterTables = true; } else { exitAfterTables = false; } } if (placeTables === true) { var myNewPage = doc.pages.item(myPageName); for (var i = 0; i < 11; i++) { prcs_placeAllTables(doc, myNewPage, i); } if (exitAfterTables === true) { exit(); } } if (placePrices === true) { prcs_placeAllPrices(doc); if (exitAfterTables === true) { exit(); } } // if(allSelector.checkedState !== true){ // placeAllBool = false; // clearStructure = false; // } if ((myPlaceAll.checkedState === true)) { placeAllBool = true; focusBool = false; normalBool = false; smallBool = false; itemBool = false; // groupSelector = 0; } else { // if(groupSelector.checkedState === true){ // groupSelector = myGroupDropdown.selectedIndex; // placeAllBool = false; // if(myRadioButtonGroup.selectedButton === 0){ // focusBool = true; // normalBool = false; // smallBool = false; // itemBool = false; // }else if(myRadioButtonGroup.selectedButton === 1){ // focusBool = false; // normalBool = true; // smallBool = false; // itemBool = false; // }else if(myRadioButtonGroup.selectedButton === 2){ // focusBool = false; // normalBool = false; // smallBool = true; // itemBool = false; // } // } if (itemSelector.checkedState === true) { placeAllBool = false; focusBool = false; normalBool = false; smallBool = false; itemBool = true; var preTheItem = myItemsList[myArtikelDropdown.selectedIndex]; theItem = preTheItem.substring(4); } } var clearStructure; if (myClearStructureCheckbox.checkedState === true) { clearStructure = true; } else { clearStructure = false; } advancedDialog.destroy(); myPage = doc.pages.item(myPageName); // call function placeData // in processXML.jsx prcsXMLv02_placeData(doc, myPage, groupSelector, placeAllBool, focusBool, normalBool, smallBool, itemBool, theItem, myErrorLog, myLogFile); // process_images(doc); if (clearStructure === true) { doc.xmlElements.everyItem().remove(); } /* END OF ADVANCED DIALOG*/ } else { advancedDialog.destroy(); var myFile = myLogFile; var myData = myErrorLog; prcs_writeData(myFile, myData); alert("all that thinking for nothing? Better luck nexttime!"); } // end of dialog show } else if (mpo_data.mode === 2) { alert("Your import is done"); } else if (mpo_data.mode === 3) { prcs_placeAllPrices(doc); if (mpo_data.rmvxml) { doc.xmlElements.everyItem().remove(); } return; // }; } else if (mpo_data.mode === 4) { place_tables(doc); if (mpo_data.rmvxml) { doc.xmlElements.everyItem().remove(); } }else if(mpo_data.mode === 5) // this is build link button alert("Sorry there is an error with the link button function. Please use the old script"); return; // link_button(); } // end of myUI method function place_tables(doc, myPageName) { var myNewPage = doc.pages.add(); //doc.pages.item(myPageName); for (var i = 0; i < 11; i++) { prcs_placeAllTables(doc, myNewPage, i); } return; } // __ ____ __ _ ___ // \ \ / / \/ | | |__ \ // _ __ _ __ ___ ___ ___ ___ ___ \ V /| \ / | | __ __ ) | // | '_ \| '__/ _ \ / __/ _ \/ __/ __| > < | |\/| | | \ \ / // / // | |_) | | | (_) | (_| __/\__ \__ \/ . \| | | | |___\ V // /_ // | .__/|_| \___/ \___\___||___/___/_/ \_\_| |_|______\_/|____| // | | // |_| /* * written for JustMusic 2011 * * @author fabiantheblind * * */ // Copyright (C) 2011 Fabian "fabiantheblind" Morón Zirfas // http://www.the-moron.net // info [at] the - moron . net // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/. /** * This is the structure of the info object */ /* * { * importid: 23344455556, * artnr : "J01233445", * type: "image", * imagedata : { * path:"", * folder:"" * } * } */ // function Info (_current_import_id, _artnr, _type){ // this.importid = _current_import_id; // this.artnr = _artnr; // this.type = _type; // this.imagedata = null; // function set_imagedata(_path, _folder){ // var obj = { // "path":_path, // "folder":_folder // }; // this.imagedata = obj; // } // } function prcs_countItems(myRoot) { var myElement = myRoot.xmlElements.item(0).xmlElements.everyItem(); return myElement.xmlElements.length - 2; } // This is the main thing that gets called function prcsXMLv02_placeData(myDoc, myPage, count, placeAllBool, focusBool, normalBool, smallBool, itemBool, theItem, myErrorLog, myLogFile) { var itemCounter = 0; var myRuleSet = new Array(new prcs_getGroupData(myDoc, myPage, count, itemCounter, placeAllBool, focusBool, normalBool, smallBool, itemBool, theItem, myErrorLog, myLogFile)); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); // } } function prcs_getXPath(xpathChoice, errorLog, count) { var xpath; if (xpathChoice.placeAll === true) { xpath = "//artikel"; errorLog = errorLog + "selected the following elements(xPath) " + xpath .toString() + "\n"; } if ((xpathChoice.focus === true)) { xpath = "//group[@id ='" + count + "']/focus/artikel[@iPrioritaet='fokus']"; errorLog = errorLog + "selected the following elements(xPath) " + xpath .toString() + "\n"; } if ((xpathChoice.normal === true)) { xpath = "//group[@id ='" + count + "']/normal/artikel[@iPrioritaet='normal']"; errorLog = errorLog + "selected the following elements(xPath) " + xpath .toString() + "\n"; } if ((xpathChoice.small === true)) { xpath = "//group[@id ='" + count + "']/small/artikel[@iPrioritaet='klein']"; errorLog = errorLog + "selected the following elements(xPath) " + xpath .toString() + "\n"; } if ((xpathChoice.item === true)) { xpath = "//artikel[@iArtikelNr='Art-Nr. " + xpathChoice.theItemNum + "']"; errorLog = errorLog + "selected the following elements(xPath) " + xpath .toString() + "\n"; } return xpath; } /* * this is the RuleSet for makeAttributesFromInfo * * @returns nothing */ function prcs_getGroupData(myDoc, myPage, count, itemCounter, placeAllBool, focusBool, normalBool, smallBool, itemBool, theItem, myErrorLog, myLogFile) { this.name = "getGroupData"; // this holds the choices coming from the UI var xpathChoice = {}; xpathChoice.placeAll = placeAllBool; xpathChoice.focus = focusBool; xpathChoice.normal = normalBool; xpathChoice.small = smallBool; xpathChoice.item = itemBool; xpathChoice.theItemNum = theItem; // select the xpath exprrssion this.xpath = prcs_getXPath(xpathChoice, myErrorLog, count); var metaData = {}; metaData.scrptLabel = ""; metaData.ArtNr = ""; metaData.id = ""; var myLine = 0; var myItemImgHeight = []; myItemImgHeight[0] = 40; myItemImgHeight[1] = 30; // myItemImgHeight[2] = 25; // myItemImgHeight[3] = 15; var myItemTxtHeight = []; myItemTxtHeight[0] = myItemImgHeight[0] + 20; myItemTxtHeight[1] = myItemImgHeight[1] + 20; // myItemTxtHeight[2] = myItemImgHeight[2] = + 20; // myItemTxtHeight[3] = myItemImgHeight[3] = + 20; var ULHeight = 20; var myLineHeight = []; myLineHeight[0] = myItemImgHeight[0] + myItemTxtHeight[0]; var myLineController; var errorLog = myErrorLog; var usedummy = false; this.apply = function (myElement, myRuleProcessor) { errorLog = errorLog + "processing Element " + myElement.xmlAttributes.item( "iArtikelNr").value.toString() + "\n"; metaData.scrptLabel = myElement.xmlAttributes.item("iArtikelNr").value; metaData.ArtNr = metaData.scrptLabel; metaData.scp = myElement.xmlAttributes.item("iPrioritaet").value.toString(); metaData.id = ""; var id; var myParentGroup; if (placeAllBool === true) { myParentGroup = myElement.parent.parent; // count = myElement.parent.parent.xmlAttributes.item("id").value; id = myElement.parent.parent.xmlAttributes.item("id").value; metaData.id = id; } else { myParentGroup = myElement.parent.parent; id = count; } var myItemsNum = myParentGroup.xmlElements.length; if (myItemsNum < 10) { myLineController = 0; } else if ((myItemsNum > 10) && (myItemsNum < 17)) { myLineController = 1; } else { } var myColumnNum = myPage.marginPreferences.columnCount; var myLeftMargin = myPage.marginPreferences.left; var myRightMargin = myPage.marginPreferences.right; var myCGutterWidth = myPage.marginPreferences.columnGutter; var myPageWidth = myDoc.documentPreferences.pageWidth; var myOffset = myPageWidth - myLeftMargin - myRightMargin - myCGutterWidth; //*2 ;// - myCGutterWidth; var myGroup = []; var mySubGroup = []; // tets where on the page we are try { var myTestFrame = myPage.rectangles.add(); // set_label(myTestFrame,"Delete Me"); var myTestBounds = []; myTestBounds = prcs_myGetColumns(myDoc, myPage, itemCounter); var testTempY1 = (myTestBounds[0]) + (myLine * myLineHeight[ myLineController]); var testTempX1 = myTestBounds[1] - (myOffset * myLine); var testTempY2 = testTempY1 + myItemImgHeight[myLineController]; var testTempX2 = myTestBounds[3] - (myOffset * myLine); myTestFrame.geometricBounds = [testTempY1, testTempX1, testTempY2, testTempX2 ]; if (myTestFrame.geometricBounds[0] >= 300) { myPage = myDoc.pages.add(); itemCounter = 0; myLine = 0; //alert("made a new Page"); } myTestFrame.remove(); } catch (e) { errorLog = errorLog + e.toString() + "\n"; } var myImages = myElement.xmlElements.item("images"); var myImgCounter; if (myImages.xmlElements.length > 4) { myImgCounter = 4; usedummy = false; } else if ((myImages.xmlElements.length === 0) && (mpo_data.usedummy === true)) { usedummy = true; myImgCounter = 1; } else { myImgCounter = myImages.xmlElements.length; usedummy = false; } for (var i = 0; i < myImgCounter; i++) { var myImgFrame = myPage.rectangles.add(); //set the Script label // set_label(myImgFrame, metaData.scrptLabel); myImgFrame.appliedObjectStyle = myDoc.objectStyles.item(0); var myIMGBounds = []; myIMGBounds = prcs_myGetColumns(myDoc, myPage, itemCounter); var tempY1 = (myIMGBounds[0] + (i * 10)) + (myLine * myLineHeight[ myLineController]); var tempX1 = myIMGBounds[1] - (myOffset * myLine); var tempY2 = tempY1 + myItemImgHeight[myLineController] - (i * (10)); var tempX2 = myIMGBounds[3] - (myOffset * myLine); try { myImgFrame.geometricBounds = [tempY1, tempX1, tempY2, tempX2]; // = myGetColumns(myDoc,myPage,itemCounter); } catch (e) { myImgFrame.geometricBounds = [tempY1, tempY1, 10, 10]; // = myGetColumns(myDoc,myPage,itemCounter); errorLog = errorLog + e.toString() + "\n"; } /** * 2013_08_21 - 22_22_13 * This is where I have to look for the images placing. Error message is: * E/A-Fehler: Der Ordner "/Volumes/Users/fabiantheblind/Documents/_projects/just-music/jm-katalog-2014/katalog-workspace/files/7918_hkaudio/j0108335_01_n_1f62106b.jpg" kann nicht gefunden werden. */ // try{ // alert(myString); // alert(myString.substring(8)); var info = new Info(uuid, metaData.ArtNr, "image"); // var theimage = File(myString.substring(8)); // alert("image name " +theimage.name); if (usedummy === false) { var myString = myImages.xmlElements.item(i).xmlAttributes.item(1).value; info.set_imagedata(myString, ""); try{ myImgFrame.place(File(myDoc.filePath + "/" + myString)); }catch(e){ alert("The file '"+ myString+"' should be in your 'files' folder but it isn't. Did you load a image package from the MPO?\nIf so please report this error to your friendly neighboorhood scripter"); if(mpo_data.usedummy === true){ info.set_imagedata("files/dummy.jpg", ""); info.type = "dummy"; myImgFrame.place(mpo_data.dummy); } } errorLog += "Placing this file --> " + myDoc.filePath + "/" + myString + "\n"; } else if ((usedummy === true) && (mpo_data.usedummy === true)) { info.set_imagedata("files/dummy.jpg", ""); info.type = "dummy"; myImgFrame.place(mpo_data.dummy); errorLog += "Placing this file --> " + myDoc.filePath + "/dummy.jpg\n"; } usedummy = false; myImgFrame.label = info.jsondumb(); myImgFrame.fit(FitOptions.CENTER_CONTENT); myImgFrame.fit(FitOptions.PROPORTIONALLY); myGroup.push(myImgFrame); // }catch(e){ // alert("WARNING! \r THERE IS AN IMAGE MISSING! " +e ); // myImgFrame.fillColor = myDoc.swatches.item(2); // myImgFrame.fillTint = 42; // errorLog = errorLog + e.toString() + "\n"; // myGroup.push(myImgFrame); // } var myImgObjStyle = myDoc.objectStyles.item("BILD_schatten"); try { myImgFrame.applyObjectStyle(myImgObjStyle); } catch (e) { alert("DEBUG: applyObjectstyle error"); errorLog = errorLog + e.toString() + "\n"; } } // end of images loop var myTextBounds = []; myTextBounds = prcs_myGetColumns(myDoc, myPage, itemCounter); var Y1 = myTextBounds[0] + myItemImgHeight[myLineController] + (myLine * myLineHeight[myLineController]); var X1 = myTextBounds[1] - (myOffset * myLine); var Y2 = Y1 + myItemTxtHeight[myLineController]; var X2 = myTextBounds[3] - (myOffset * myLine); var myFrame = myPage.textFrames.add(); //set the Script label // set_label(myFrame, metaData.scrptLabel); var myNullObjStyle = myDoc.objectStyles.item(0); try { myFrame.applyObjectStyle(myNullObjStyle); } catch (e) { alert("DEBUG: applyObjectstyle error"); errorLog = errorLog + e.toString() + "\n"; } myFrame.geometricBounds = [Y1, X1, Y2, X2]; // myGetColumns(myDoc,myPage,itemCounter); var myTextContent = myElement.xmlElements.item("textPlatzieren").duplicate(); myTextContent.placeXML(myFrame); myTextContent.untag(); myGroup.push(myFrame); myFrame.paragraphs.item(0).remove(); var myULBounds = []; myULBounds = prcs_myGetColumns(myDoc, myPage, itemCounter); var ULY1 = myULBounds[0] + myItemImgHeight[myLineController] + (myLine * myLineHeight[myLineController]) + myItemTxtHeight[myLineController]; var ULX1 = myULBounds[1] - (myOffset * myLine); var ULY2 = ULY1 + ULHeight; var ULX2 = myULBounds[3] - (myOffset * myLine); var myUlFrame = myPage.textFrames.add(); //set the Script label // set_label(myUlFrame, metaData.scrptLabel); myUlFrame.appliedObjectStyle = myDoc.objectStyles.item(0); try { myUlFrame.applyObjectStyle(myNullObjStyle); } catch (e) { alert("DEBUG: applyObjectstyle error"); errorLog = errorLog + e.toString() + "\n"; } myUlFrame.geometricBounds = [ULY1, ULX1, ULY2, ULX2]; // myGetColumns(myDoc,myPage,itemCounter); var myULTextContent = myElement.xmlElements.item( "artikelZeileANBPohneLN").duplicate(); myULTextContent.placeXML(myUlFrame); myULTextContent.untag(); myGroup.push(myUlFrame); // From here on we have the meta objects like group colors and so on // // // // var myFocusText = myPage.textFrames.add(); //set the Script label // set_label(myFocusText, "meta: grp-" +metaData.id + " scp-"+ metaData.scp ); try { myFocusText.applyObjectStyle(myNullObjStyle); } catch (e) { alert("DEBUG: applyObjectstyle error"); errorLog = errorLog + e.toString() + "\n"; } myFocusText.geometricBounds = [Y1 - 21, X1 - 1, Y1 - 12, X1 + 31]; myFocusText.fillColor = myDoc.swatches.item(2); myFocusText.fillTint = 11; myFocusText.nonprinting = true; mySubGroup.push(myFocusText); var myGrText = myPage.textFrames.add(); //set the Script label // set_label(myGrText, "meta: grp-" +metaData.id + " scp-"+ metaData.scp ); myGrText.appliedObjectStyle = myDoc.objectStyles.item(0); try { myGrText.applyObjectStyle(myNullObjStyle); } catch (e) { alert("DEBUG: applyObjectstyle error"); errorLog = errorLog + e.toString() + "\n"; } myGrText.geometricBounds = [Y1 - 20, X1, Y1 - 13, X1 + 30]; myGrText.contents = id + ". Gruppe" + "\n" + myElement.xmlAttributes.item( "iPrioritaet").value.toString(); myGrText.nonprinting = true; try { myGrText.fillColor = myDoc.swatches.item("Gr_0" + id); } catch (e) { alert("DEBUG: fillColor error"); errorLog = errorLog + e.toString() + "\n"; } myGrText.paragraphs.everyItem().characters.everyItem().appliedCharacterStyle = myDoc.characterStyles.item("ERROR"); myGrText.paragraphs.everyItem().clearOverrides(OverrideType.all); mySubGroup.push(myGrText); var subMetaGroup = myPage.groups.add(mySubGroup); // set_label(subMetaGroup, "meta: grp-" +metaData.id + " scp-"+ metaData.scp ); var objGroup = null; try { objGroup = myPage.groups.add(myGroup); // set_label(objGroup,metaData.scrptLabel); objGroup.sendToBack(); } catch (e) { errorLog = errorLog + e.toString() + "\n"; } var finalGroup = []; finalGroup.push(subMetaGroup); if (objGroup !== null) { finalGroup.push(objGroup); } myPage.groups.add(finalGroup); // set_label(finalGroup,metaData.scrptLabel); itemCounter++; if (itemCounter % myColumnNum === 0) { myLine++; } // write ErrorLog var myFile = myLogFile; var myData = errorLog; prcs_writeData(myFile, myData); }; } // end GroupData /* * basic get columns needs an iterator */ function prcs_myGetColumns(myDoc, myPage, itemCounter) { var pw = myDoc.documentPreferences.pageWidth; var ph = myDoc.documentPreferences.pageHeight; var pcc = myPage.marginPreferences.columnCount; var pcgw = myPage.marginPreferences.columnGutter; var tm = myPage.marginPreferences.top; var bm = myPage.marginPreferences.bottom; var lm = myPage.marginPreferences.left; var rm = myPage.marginPreferences.right; var pcsw = pw - lm - rm - (pcgw * (pcc - 1)); var pcw = pcsw / pcc; // alert(" a column has :"+pcw_2 + "mm"); var myFocusHeight = (ph - tm - bm) / 2; var myNormalHeight = (ph - tm - bm) / 4; var mySmallHeight; if (pcc === 3) { // alert("there are 3 colums"); } else if (pcc === 4) { } var myX1, myY1, myX2, myY2; if (itemCounter === 0) { myX1 = lm; } else { myX1 = lm + ((pcw * itemCounter) + (pcgw * (itemCounter))); // alert("DEBUG: myX1--> " + myX1); } myY1 = tm; myX2 = myX1 + ((pw - lm - rm - (pcgw * (pcc - 1))) / pcc); myY2 = ph - bm; // alert("top "+tm+" Left "+lm+" bottom "+bm+" right "+rm); // return[tm,lm,bm,rm]; return [myY1, myX1, myY2, myX2]; } /* * Set the xml import preferences */ function prcs_xmlImportPref(myDoc) { myXMLImportPreferences = myDoc.xmlImportPreferences; myXMLImportPreferences.allowTransform = false; myXMLImportPreferences.createLinkToXML = false; myXMLImportPreferences.ignoreUnmatchedIncoming = false; myXMLImportPreferences.ignoreWhitespace = false; myXMLImportPreferences.importCALSTables = false; myXMLImportPreferences.importStyle = XMLImportStyles.mergeImport; myXMLImportPreferences.importTextIntoTables = false; myXMLImportPreferences.importToSelected = false; myXMLImportPreferences.removeUnmatchedExisting = false; myXMLImportPreferences.repeatTextElements = false; } /* * this makes attributes from the element artikelInformation * * @param myDoc * @returns nothing */ function prcs_makeAttributesFromInfo(myDoc) { var myRuleSet = new Array(new prcs_findInfoElement(), new prcs_makeGroups()); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); // } } /* * this is the RuleSet for makeAttributesFromInfo * * @returns nothing */ function prcs_findInfoElement() { this.name = "findInfoElement"; this.xpath = "/Root/seite/artikel/artikelInformation"; this.apply = function (myElement, myRuleProcessor) { var myItem; for (var i = 0; i < myElement.xmlElements.length; i++) { myItem = myElement.xmlElements.item(i); myElement.parent.xmlAttributes.add(myItem.markupTag.name, myItem.texts .item(0).contents); } }; } function prcs_placeAllTables(myDoc, myNewPage, count) { var itemCounter = 0; var myRuleSet = new Array(new prcs_findTables(myDoc, myNewPage, count, itemCounter)); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); // } } /* * this is the RuleSet for makeAttributesFromInfo * * @returns nothing */ function prcs_findTables(myDoc, myNewPage, count, itemCounter) { this.name = "findTables"; if (count === 10) { this.xpath = "//tabelleGruppe" + count.toString(); } else { this.xpath = "//tabelleGruppe0" + count.toString(); } this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); var mySubGroup = []; var Y1 = 0 + (itemCounter * 23); var X1 = 0 + (count * 23); var Y2 = Y1 + 50; var X2 = X1 + 123; var myFrame = myNewPage.textFrames.add(); // set_label(myFrame,"table: grp-" + count ); // myFrame.appliedObjectStyle = myDoc.objectStyles.item(0); var myNullObjStyle = myDoc.objectStyles.item(0); try { myFrame.applyObjectStyle(myNullObjStyle); } catch (e) { alert("DEBUG: applyObjectstyle error"); errorLog = errorLog + e.toString() + "\n"; } myFrame.geometricBounds = [Y1, X1, Y2, X2]; var myTextContent = myElement.duplicate(); myFrame.placeXML(myTextContent); myTextContent.untag(); if ((myElement.parent.markupTag.name.toString() === "tabelleMitLN") || (myElement.parent.markupTag.name.toString() === "tabelleMinimalMitLN") ) { myFrame.paragraphs.everyItem().appliedParagraphStyle = myDoc.paragraphStyles .item("TABELLE_mit_LN"); } else { myFrame.paragraphs.everyItem().appliedParagraphStyle = myDoc.paragraphStyles .item("TABELLE_ohne_LN"); } var myFocusText = myNewPage.textFrames.add(); // set_label(myFocusText,"table: grp-"+count + " scp-focus"); myFocusText.geometricBounds = [Y1, X1, Y2 - 20, X2 - 100]; myFocusText.texts.everyItem().appliedCharacterStyle = myDoc.characterStyles .item("ERROR"); myFocusText.paragraphs.everyItem().appliedParagraphStyle = myDoc.paragraphStyles .item("ERROR"); myFocusText.fillColor = myDoc.swatches.item(2); myFocusText.fillTint = 11; myFocusText.nonprinting = true; mySubGroup.push(myFocusText); var myGrText = myNewPage.textFrames.add(); // set_label(myGrText,"table: grp-"+count); myGrText.geometricBounds = [Y1 + 1, X1 + 1, Y2 - 1 - 20, X2 - 1 - 100]; myGrText.contents = count + ". Gruppe" + "\n" + myElement.parent.markupTag .name.toString(); myGrText.nonprinting = true; myGrText.fillColor = myDoc.swatches.item("Gr_0" + count); myFocusText.texts.everyItem().appliedCharacterStyle = myDoc.characterStyles .item("ERROR"); myFocusText.paragraphs.everyItem().appliedParagraphStyle = myDoc.paragraphStyles .item("ERROR"); mySubGroup.push(myGrText); var mySubMetaGroup = myNewPage.groups.add(mySubGroup); var myGroup = []; myGroup.push(mySubMetaGroup); myGroup.push(myFrame); myNewPage.groups.add(myGroup); itemCounter++; }; } /* * this is the function prcs_for makeGroupElements * * @returns */ function prcs_makeGroups() { this.name = "makeGroups"; this.xpath = "/Root/seite"; this.apply = function (myElement, myRuleProcessor) { for (var i = 10; i >= 0; i--) { var myNewGroupElement = myElement.xmlElements.add("group"); myNewGroupElement.xmlAttributes.add("id", i.toString()); myNewGroupElement.xmlElements.add("small"); myNewGroupElement.xmlElements.add("normal"); myNewGroupElement.xmlElements.add("focus"); myNewGroupElement.move(LocationOptions.AT_BEGINNING, myElement); } }; } /* * * @param myDoc * @returns nothing */ function prcs_sortInGroupByPriority(myDoc) { var myRuleSetSmall = new Array(new prcs_sortSmall()); // with(myDoc){ var elements_small = myDoc.xmlElements; __processRuleSet(elements_small.everyItem(), myRuleSetSmall); // } var myRuleSetNormal = new Array(new prcs_sortNormal()); // with(myDoc){ var elements_normal = myDoc.xmlElements; __processRuleSet(elements_normal.everyItem(), myRuleSetNormal); // } var myRuleSetFocus = new Array(new prcs_sortFocus()); // with(myDoc){ var elements_focus = myDoc.xmlElements; __processRuleSet(elements_focus.everyItem(), myRuleSetFocus); // } } /* * * @returns nothing */ function prcs_sortFocus() { this.name = "sortFocus"; this.xpath = "/Root/seite/group/artikel[@iPrioritaet ='fokus']"; this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); var myContainer = myElement.parent.xmlElements.item("focus"); myElement.move(LocationOptions.AT_END, myContainer); }; } function prcs_sortNormal() { this.name = "sortNormal"; this.xpath = "/Root/seite/group/artikel[@iPrioritaet ='normal']"; this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); var myContainer = myElement.parent.xmlElements.item("normal"); myElement.move(LocationOptions.AT_END, myContainer); }; } function prcs_sortSmall() { this.name = "sortSmall"; this.xpath = "/Root/seite/group/artikel[@iPrioritaet ='klein']"; this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); var myContainer = myElement.parent.xmlElements.item("small"); myElement.move(LocationOptions.AT_END, myContainer); }; } function prcs_sortGroups(myDoc) { for (var i = 0; i < 11; i++) { prcs_sortToGroupsByAttributes(myDoc, i); } } /* * reorganizes the xmlStructure in element <seite> to groups * * @param myDoc * @param count * @returns */ function prcs_sortToGroupsByAttributes(myDoc, count) { var myRuleSet = new Array(new prcs_findGroupAttribute(count)); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); // } } /* * moves the grouped items into a new xmlElement needed for * sortToGroupsByAttributes(myDoc,count) needs the for loop to process * * @param count * @returns */ function prcs_findGroupAttribute(count) { this.name = "findGroupAttribute"; this.xpath = "/Root/seite/artikel[@iGruppenFarbe ='" + count + ". Gruppenfarbe']"; this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); myElement.move(LocationOptions.UNKNOWN, myElement.parent.xmlElements.item( count)); }; } function prcs_makeItemList(myDoc) { var myItemsListElement = myDoc.xmlElements.item(0).xmlElements.add( "itemsList"); var myItemCounter = 0; var myRuleSet = new Array(new prcs_findItem(myDoc, myItemsListElement, myItemCounter)); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); // } } /* * moves the grouped items into a new xmlElement needed for * sortToGroupsByAttributes(myDoc,count) needs the for loop to process * * @param count * @returns */ function prcs_findItem(myDoc, myItemsListElement, myItemCounter) { this.name = "findItem"; this.xpath = "//artikel"; this.apply = function (myElement, myRuleProcessor) { var myItemsID = myElement.xmlAttributes.item("iArtikelNr").value; var mySubId = myItemsID.substring(8); //alert(mySubId); //exit(); var myId = myItemsListElement.xmlAttributes.add("Art_" + mySubId, myItemsID); myId.convertToElement(); myItemCounter++; }; } function prcs_findGroupAttributeNone() { this.name = "findGroupAttribute"; this.xpath = "/Root/seite/artikel[@iGruppenFarbe ='']"; this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); myElement.move(LocationOptions.UNKNOWN, myElement.parent.xmlElements.item( 0)); }; } /* * this makes new elements for grouping all the <artikel> elements * * @param myDoc * @returns */ function prcs_makeImgElement(myDoc) { var myRuleSet = new Array(new prcs_makeImgContainer(), new prcs_findMoveImages()); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); // } } /* * this is the function prcs_for makeGroupElements * * @returns */ function prcs_makeImgContainer() { this.name = "makeImgElement"; this.xpath = "//artikel"; this.apply = function (myElement, myRuleProcessor) { var imgElement = myElement.parent.xmlElements.add("images"); imgElement.move(LocationOptions.AT_BEGINNING, myElement); }; } /* * this is the function prcs_for makeGroupElements * * @returns */ function prcs_findMoveImages() { this.name = "findMoveImages"; this.xpath = "//artikel/bild"; this.apply = function (myElement, myRuleProcessor) { __skipChildren(myRuleProcessor); var imgElement = myElement.parent.xmlElements.item("images"); myElement.move(LocationOptions.AT_END, imgElement); }; } function prcs_placeAllPrices(myDoc) { for(var l = 0; l < app.activeDocument.layers.length;l++){ app.activeDocument.layers.item(l).locked = false; } var locklayers = true;// confirm("Should I lock all layers except the \"Preise\" layer afterwards?"); var myRuleSet = new Array(new prcs_findItemsNumber(myDoc)); // with(myDoc){ var elements = myDoc.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet); if(locklayers === true){ for(var k = 0; k< app.activeDocument.layers.length;k++){ app.activeDocument.layers.item(k).locked = true; } } try { app.activeDocument.layers.item("Preise").locked = false; } catch (e) { alert(e); } } /* * moves the grouped items into a new xmlElement needed for * sortToGroupsByAttributes(myDoc,count) needs the for loop to process * * @param count * @returns */ function prcs_findItemsNumber(myDoc) { this.name = "findItemsNumber"; this.xpath = "//artikel"; this.apply = function (myElement, myRuleProcessor) { // __skipChildren(myRuleProcessor); app.findGrepPreferences = NothingEnum.nothing; app.changeGrepPreferences = NothingEnum.nothing; //Set the find options. app.findTextPreferences = NothingEnum.nothing; app.changeTextPreferences = NothingEnum.nothing; //Search the document for the string "Text". // alert(myElement.xmlAttributes.item("iArtikelNr").value); var myTempArtNrString = myElement.xmlAttributes.item("iArtikelNr").value; var myArtNrString = myTempArtNrString.substring(8); app.findTextPreferences.findWhat = myArtNrString; //var Test = app.findGrepPreferences.findWhat = myArtNrString+"(.+\t)(\d*?.\d*?)(~=)"; //alert(myDoc.findGrep()); //Set the find options. app.findChangeTextOptions.caseSensitive = false; app.findChangeTextOptions.includeFootnotes = false; app.findChangeTextOptions.includeHiddenLayers = false; app.findChangeTextOptions.includeLockedLayersForFind = false; app.findChangeTextOptions.includeLockedStoriesForFind = false; app.findChangeTextOptions.includeMasterPages = false; app.findChangeTextOptions.wholeWord = false; var myPrice = myElement.xmlElements.item("preis").contents; //app.changeGrepPreferences.changeTo = myArtNrString+"$1"+myPrice+"$3"; var FondItem = myDoc.findText(); if (FondItem.length > 0) { var myGeoBounds = []; myGeoBounds[0] = FondItem[0].parent.textContainers[0].geometricBounds[ 0] - 10; myGeoBounds[1] = FondItem[0].parent.textContainers[0].geometricBounds[ 1]; myGeoBounds[2] = FondItem[0].parent.textContainers[0].geometricBounds[ 0]; myGeoBounds[3] = FondItem[0].parent.textContainers[0].geometricBounds[ 3]; myPrice = FondItem[0].parent.textContainers[0].duplicate(); // set_label(myPrice,myTempArtNrString + " price"); myPrice.geometricBounds = myGeoBounds; myPrice.paragraphs.everyItem().remove(); var myPriceElement = myElement.xmlElements.item("preis").duplicate(); myPriceElement.placeXML(myPrice); myPriceElement.untag(); myPrice.bringToFront(); var grep = mpo_data.greps;// {"fw":"(\\d)\\,--","ct":"$1,–"}; app.findGrepPreferences = NothingEnum.nothing; app.changeGrepPreferences = NothingEnum.nothing; app.findGrepPreferences.findWhat = grep.fw; app.changeGrepPreferences.changeTo = grep.ct; myPrice.changeGrep(); app.findTextPreferences = NothingEnum.nothing; app.changeTextPreferences = NothingEnum.nothing; // try { // app.activeDocument.layers.item("Preise").locked = false; // } catch (e) { // } try { myPrice.itemLayer = app.activeDocument.layers.item("Preise"); } catch (e) { } var myPriceObjStyle = myDoc.objectStyles.item("PREIS_schatten"); myPrice.applyObjectStyle(myPriceObjStyle); // myPrice.appliedObjectStyle = myDoc.objectStyles.item("PREIS_schatten"); myPrice.paragraphs.everyItem().appliedParagraphStyle = myDoc.paragraphStyles .item("PREIS"); } app.findTextPreferences = NothingEnum.nothing; app.changeTextPreferences = NothingEnum.nothing; }; } //---------- functions taken from RecordFindChange_CS3-CS5.jsx function prcs_writeData(myFile, aData) { var myResult; if (myFile !== '') { //Open the file for writing. myResult = myFile.open('w', undefined, undefined); } if (myResult !== false) { myFile.seek(0); myFile.writeln(aData); myFile.close(); // if (DEBUG) myFile.execute(); } } // _____ _________ ___ ______ _____ // / ____|__ __\ \ / / | | ____|/ ____| // | (___ | | \ \_/ /| | | |__ | (___ // \___ \ | | \ / | | | __| \___ \ // ____) | | | | | | |____| |____ ____) | // |_____/ |_| |_| |______|______|_____/ /** * this is for having some parstyxles * */ // Copyright (C) 2011 -2013 Fabian "fabiantheblind" Morón Zirfas // http://www.the-moron.net // info [at] the - moron . net // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/. // // /** * mapping paragraph styles to xml tags * @param {Document} doc the active Document * @return {Nothing} */ function mapManually(doc) { //myDoc.xmlImportMaps.add(myDoc.xmlTags.item("artikelNr"),myDoc.paragraphStyles.item("ARTIKEL_Nr")); doc.xmlImportMaps.add(doc.xmlTags.item("laufNummer"), doc.characterStyles .item("laufNummer")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelBezeichnungMitLN"), doc.paragraphStyles .item("ARTIKEL_Bezeichnung")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelBezeichnung"), doc.paragraphStyles .item("ARTIKEL_Bezeichnung")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelBeschreibung"), doc.paragraphStyles .item("ARTIKEL_Beschreibung")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelText"), doc.paragraphStyles .item("ARTIKEL_Text")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelText_Aufzaehlung"), doc.paragraphStyles .item("ARTIKEL_Text")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelZeileANBPmitLN"), doc.paragraphStyles .item("ARTIKEL_Zeile_ANBP_mit_LN")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelZeileANPmitLN"), doc.paragraphStyles .item("ARTIKEL_Zeile_ANP_mit_LN")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelZeileABPmitLN"), doc.paragraphStyles .item("ARTIKEL_Zeile_ABP_mit_LN")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelZeileANBPohneLN"), doc.paragraphStyles .item("ARTIKEL_Zeile_ANBP_ohne_LN")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelZeileANPohneLN"), doc.paragraphStyles .item("ARTIKEL_Zeile_ANP_ohne_LN")); doc.xmlImportMaps.add(doc.xmlTags.item("artikelZeileABPohneLN"), doc.paragraphStyles .item("ARTIKEL_Zeile_ABP_ohne_LN")); doc.xmlImportMaps.add(doc.xmlTags.item("laufNummerBild"), doc.paragraphStyles .item("LAUFNUMMER_am_Bild")); doc.xmlImportMaps.add(doc.xmlTags.item("preis"), doc.paragraphStyles.item( "PREIS")); doc.mapXMLTagsToStyles(); } function makeParstylesArray(myDoc) { var myStyles = []; var myName; for (var count = 0; count < 13; count++) { try { myStyles[count] = myDoc.paragraphStyles.item("pSt" + count.toString()); myName = myStyles[count].name; } catch (e) { //The style did not exist, so create it. myStyles[count] = myDoc.paragraphStyles.add({ name: "pSt" + count.toString() }); myStyles[count].appliedFont = "Arial"; } } return myStyles; } function makeCharstylesArray(myDoc) { var myStyles = []; var myName; for (var count = 0; count < 13; count++) { try { myStyles[count] = myDoc.characterStyles.item("chSt" + count.toString()); myName = myStyles[count].name; } catch (e) { //The style did not exist, so create it. myStyles[count] = myDoc.characterStyles.add({ name: "chSt" + count.toString() }); myStyles[count].appliedFont = "Arial"; } } return myStyles; } function makeMetaStyle(myDoc) { var myName; var myMetaStyle; var MetaParStyle; try { myMetaStyle = myDoc.characterStyles.item("ERROR"); myName = myMetaStyle.name; } catch (e) { //The style did not exist, so create it. myMetaStyle = myDoc.characterStyles.add({ name: "ERROR" }); myMetaStyle.properties = { appliedFont: "Arial", pointSize: 8 }; } try { MetaParStyle = myDoc.paragraphStyles.item("ERROR"); myName = MetaParStyle.name; } catch (e) { //The style did not exist, so create it. MetaParStyle = myDoc.paragraphStyles.add({ name: "ERROR" }); MetaParStyle.properties = { appliedFont: "Arial", pointSize: 8, leading: 8 }; } } // _ _ _ _ _ _ _____ ______ _____ // | | | | \ | | | | |/ ____| ____| __ \ // | | | | \| | | | | (___ | |__ | | | | // | | | | . ` | | | |\___ \| __| | | | | // | |__| | |\ | |__| |____) | |____| |__| | // \____/|_| \_|\____/|_____/|______|_____/ // ------------ 2013 ------------ /** * This is a Meta object used in the whole project * */ function Info(_current_import_id, _artnr, _type) { this.uuid = _current_import_id; this.artnr = _artnr; this.type = _type; this.imagedata = { path: "", folder: "" }; this.set_imagedata = function (_path, _folder) { this.imagedata.path = _path; this.imagedata.folder = _folder; }; this.jsondumb = function () { var result = { 'uuid': this.uuid, 'artnr': this.artnr, 'type': this.type, 'imagedata': { 'path': this.imagedata.path, 'folder': this.imagedata.folder } }; return result.toSource(); }; } /** * This is a workaround to get hte job done until * JM-Kat 2014 * @todo fix bug not workaound * @param {Document} doc the current doc * @return {nothing} */ function process_images(doc) { /** * loop all items * */ var docpath = doc.filePath; // alert(docpath); for (var i = 0; i < doc.allPageItems.length; i++) { var one_item = doc.allPageItems[i]; // isolate if (one_item instanceof Rectangle) { /* check wheather we have a rectangle*/ var rect = one_item; // for clearance var label_str = rect.label; // extract label /** * We are expecting an json object with this structure * { * importid: 23344455556, * artnr : "J01233445", * type: "image", * imagedata : { * path:"", * folder:"" * } * } * */ // alert(label_str); // eval(label_str); // var res = confirm(label_str); // if (res === false){ // return; // } // var reg = new RegExp("^\({"); if (/^\(\{uuid/.test(label_str)) { var item_info = null; // try{ item_info = eval(label_str); // this should be an json object // } catch (e) { // if (e instanceof SyntaxError) { // alert("Syntax error" + e.message); // }else if (e instanceof URIError) { // alert("URi error" + e.message); // }else if (e instanceof RangeError) { // alert("Range error" + e.message); // }else if (e instanceof ReferenceError) { // alert("Reference error" + e.message); // }else if (e instanceof TypeError) { // alert("Type error" + e.message); // }else if (e instanceof EvalError) { // alert("Eval error" + e.message); // }else if (e instanceof SyntaxError) { // alert("Syntax error" + e.message); // }else{ // alert( "Error " + e.message); // } // } // try { if ((item_info !== undefined) && (item_info !== null)) { // alert("item info is null"); if (item_info.hasOwnProperty('uuid')) { // alert("got uuid " + item_info.uuid); if (item_info.uuid !== null) { // var regExp = new RegExp(guid); if (check_uuid(item_info.uuid)) { // alert(item_info.imagedata.path); if (File(docpath + "/" + item_info.imagedata.path).exists) { rect.place(File((docpath + "/" + item_info.imagedata.path))); } else { alert("the image does not life at\n" + item_info.imagedata .path); } } } } } } } } } function include(fn) { var keepon = false; /** * own include 2013 replacing JSXses include. Does not work well with a linter * #include "./meta/glue code.jsx"; */ var script_file = File($.fileName); // get the location of the scriptfile var script_file_folder = script_file.parent; var script_file_path = script_file.path; // get the path var file_to_read = File(script_file.path + fn /*"/meta/glue code.jsx"*/ ); var content = ""; // alert(file_to_read); if (file_to_read.exists) { // if it is really there file_to_read.open('r'); // open it content = file_to_read.read(); // read it eval(content); keepon = true; } else { alert("The file " + fn + " is missing"); } return keepon; } // function include_dummy() { // var keepon = false; // /** // * own include 2013 replacing JSXses include. Does not work well with a linter // * #include "./meta/glue code.jsx"; // */ // var script_file = File($.fileName); // get the location of the scriptfile // var script_file_folder = script_file.parent; // var script_file_path = script_file.path; // get the path // var file_to_read = File(script_file.path + fn /*"/meta/glue code.jsx"*/ ); // var content = ""; // // alert(file_to_read); // if (file_to_read.exists) { // if it is really there // file_to_read.open('r'); // open it // content = file_to_read.read(); // read it // eval(content); // mpo_data.dummy = dummy; // keepon = true; // } else { // alert("The file " + fn + " is missing"); // } // return keepon; // }/** * LINK BUTTON * */ function link_button() {return; var d; // test for a doc try { d = app.activeDocument; } catch(e){ if(obj.WARNINGS) alert("No no no, you have no document.\nMaybe you should drink some coffee"); return; } var myItemsList = []; var myList; var myPageName, myPage, myItemsListElement; try{ d.paragraphStyles.item("ERROR").appliedFont = "Arial"; }catch(e){ } myList = d.pages.everyItem().name; try{ myItemsListElement = d.xmlElements.item(0).xmlElements.item("itemsList"); }catch(e){ if(obj.WARNINGS) alert("You need to import an xml with the importer"); return; } try{ for (var i =0 ;i < myItemsListElement.xmlElements.length;i++){ myItemsList[i] = myItemsListElement.xmlElements.item(i).markupTag.name; } }catch(e){ if(obj.WARNINGS) alert("you have no xml structure.\nuse the MPO_Importer"); return; }// Sorry there is an error with the linklink_buttonUI(d, myPage,myPageName, myList,myItemsList);}function myGetColumns(dument, myPage){ var myPageWidth = dument.documentPreferences.pageWidth; var myPageHeight = dument.documentPreferences.pageHeight; var myPageColumnCount= myPage.marginPreferences.columnCount; var myPageColumnGutterWidth= myPage.marginPreferences.columnGutter; var myX1 = myPage.marginPreferences.left; var myY1 = myPage.marginPreferences.top; var myX2 = myX1+ ((myPageWidth-myPage.marginPreferences.left - myPage.marginPreferences.right - (myPageColumnGutterWidth * (myPageColumnCount-1))) /myPageColumnCount); var myY2 = myPageHeight - myPage.marginPreferences.bottom; return [myY1, myX1, myY2, myX2];}function myGetBounds(dument, myPage){ var myPageWidth = dument.documentPreferences.pageWidth; var myPageHeight = dument.documentPreferences.pageHeight; var myX1 ,myX2, myY1, myY2; if(myPage.side == PageSideOptions.leftHand){ myX2 = myPage.marginPreferences.left; myX1 = myPage.marginPreferences.right; }else{ myX1 = myPage.marginPreferences.left; myX2 = myPage.marginPreferences.right; } myY1 = myPage.marginPreferences.top; myX2 = myPageWidth - myX2; myY2 = myPageHeight - myPage.marginPreferences.bottom; return [myY1, myX1, myY2, myX2];}function placeData(d , myPage , theItem){ var myRuleSet = new Array(new makeButton(theItem, myPage, d)); var elements = d.xmlElements; __processRuleSet(elements.everyItem(), myRuleSet);}function makeButton(theItem, myPage, d){ if(obj.DEBUG) alert("DEBUG1: " + theItem + " in makeButton.\nlength of the item: "+theItem.length ); var myString = ""; var myFile; this.name = "placeButtons"; this.xpath = "//artikel[@iArtikelNr='Art-Nr. " + theItem + "']"; this.apply = function(myElement, myRuleProcessor){ var myGroup = []; var myNullObjStyle = d.objectStyles.item(0); var myPriceObjStyle = d.objectStyles.item("PREIS_schatten"); var myTempBounds = []; myTempBounds = myGetColumns(d, myPage); var myY1 = myTempBounds[0]; var myX1 = myTempBounds[1]; var myY2 = myTempBounds[2]; var myX2 = myTempBounds[3]; var myImages = myElement.xmlElements.item("images"); var OY1 = 19;//myY1 + 7.5; var OX1 = 19.5;//myX1 + 7.5 ; var OY2 = OY1 + 30; var OX2 = OX1 + 30; var myOV01 = myPage.ovals.add(); set_label(myOV01,"Art-Nr. " + theItem); myOV01.geometricBounds = [OY1, OX1 ,OY2 , OX2]; myOV01.applyObjectStyle(myNullObjStyle); var bgov = myOV01.duplicate(); // addition in 2013_09_26 - 14_05_49 bgov.fillColor = d.swatches[1]; bgov.sendToBack(myOV01); try{ myString = myImages.xmlElements.item(0).xmlAttributes.item(1).value; }catch(e){ if(obj.WARNINGS) alert("there is no image available!"); exit(); } try { myOV01.place( File( d.filePath + "/" + myString )); myOV01.fit(FitOptions.CENTER_CONTENT); myGroup.push(myOV01); myGroup.push(bgov); } catch (e) { if(obj.WARNINGS) alert("there is no image available!"); exit(); } var RY1 = myY1; var RX1 = myX1; var RY2 = RY1 + 53.166; var RX2 = RX1 + 84.279; var myRect01 = myPage.rectangles.add(); set_label(myRect01,"Art-Nr. " + theItem); myRect01.geometricBounds = [RY1, RX1, RY2, RX2]; myRect01.applyObjectStyle(myNullObjStyle); try{ if(!thelinkbuttonfile){ myFile = File.openDialog("Choose the File \"Button_Lupe_Hintergrund.bmp\"\nI will ask only once per session."); if(!myFile){ if(obj.WARNINGS) alert("Are you shure?\nWithout the \"Button_Lupe_Hintergrund.bmp\" it looooooooks sillyyyyyy"); } thelinkbuttonfile = myFile; }else{ myFile = thelinkbuttonfile; } myRect01.place(thelinkbuttonfile); myRect01.fit(FitOptions.CENTER_CONTENT); //myRect01.fit(FitOptions.PROPORTIONALLY); myRect01.fit(FitOptions.FRAME_TO_CONTENT); myGroup.push(myRect01); }catch(e){ } var TY1 = 18.861; var TX1 = 32.217; var TY2 = 100; var TX2 = myX2*2; var myTF01 = myPage.textFrames.add(); if (obj.DEBUG) alert("DEBUG2: " + theItem + " in makeButton.\nlength of the item: "+theItem.length ); set_label(myTF01,"Art-Nr. " + theItem); myTF01.geometricBounds = [TY1, TX1, TY2, TX2]; myTF01.applyObjectStyle(myNullObjStyle); //var myContentElement = myElement.xmlElements.add("buttontext"); //myContentElement.insertTextAsContent("Dazu passt:\n", XMLElementPosition.elementStart); var myContentString = "Dazu passt:"+"\r"+ myElement.xmlElements.item("artikelInformation").xmlElements.item("iHersteller").contents +"\r"+ myElement.xmlElements.item("artikelInformation").xmlElements.item("iArtikelBezeichnung").contents +"\r"+ myElement.xmlElements.item("artikelInformation").xmlElements.item("iArtikelBeschreibung").contents +"\r"+ myElement.xmlElements.item("artikelInformation").xmlElements.item("iArtikelNr").contents +"\r"+ "Dies und mehr findet Ihr auf Seite XXX"; myTF01.contents = myContentString; myTF01.paragraphs.item(0).appliedParagraphStyle = d.paragraphStyles.item("BUTTON_Headline"); myTF01.paragraphs.item(1).appliedParagraphStyle = d.paragraphStyles.item("BUTTON_Hersteller"); myTF01.paragraphs.item(2).appliedParagraphStyle = d.paragraphStyles.item("BUTTON_Bezeichnung"); myTF01.paragraphs.item(3).appliedParagraphStyle = d.paragraphStyles.item("BUTTON_Beschreibung"); myTF01.paragraphs.item(4).appliedParagraphStyle = d.paragraphStyles.item("BUTTON_Artikelnummer"); myTF01.paragraphs.item(5).appliedParagraphStyle = d.paragraphStyles.item("BUTTON_Unterzeile"); myTF01.characters.everyItem().appliedCharacterStyle = d.characterStyles.item(0); myTF01.texts.everyItem().clearOverrides(OverrideType.all); myTF01.fit(FitOptions.FRAME_TO_CONTENT); myGroup.push(myTF01); var myNewPriceElement = myElement.xmlElements.item("preis").duplicate(); var PY1 = 42.411; var PX1 = 28.729 ; var PY2 = PY1 + 50; var PX2 = PX1 + 50; var myPF01 = myPage.textFrames.add(); set_label(myPF01,"Art-Nr. " + theItem); myPF01.geometricBounds = [PY1, PX1, PY2, PX2]; myPF01.applyObjectStyle(myPriceObjStyle); myNewPriceElement.placeXML(myPF01); myNewPriceElement.untag(); myPF01.paragraphs.item(0).appliedParagraphStyle = d.paragraphStyles.item("PREIS_KLEIN"); myPF01.fit(FitOptions.FRAME_TO_CONTENT); myGroup.push(myPF01); myPage.groups.add(myGroup); };}/* * a function to check the operating system * * @returns true if the OS is windows */// function checkOS(myString){// var myOS = $.os;// var myOSSubString = myOS.charAt(0);// var myOSBoolean;// if (myOSSubString == "w" || myOSSubString == "W") {// myOSBoolean = true;// }// else {// myOSBoolean = false;// }// if (myOSBoolean === true) {// //this is for windows// var myHREFString = myString;// var myHREFSubString = myHREFString.substring(8);// return myHREFSubString;// } else {// // this is for macintosh// return myString;// }// }// Sorry there is an error with the link function link_buttonUI(d, myPage,myPageName, myList,myItemsList){var myNumOItems = 0;var ddw = 150; // dropdownwidthvar stw = 80;//static text widthmyList.push("add new page");var myPageDropdown, myArtikelDropdown; var myDialog = app.dialogs.add({name:"the Link Button", canCancel:true,minWidth:300}); var column_one = myDialog.dialogColumns.add(); // with(myDialog){ //Add a dialog column. // with(dialogColumns.add()){ //Create a border panel. var row_one = column_one.dialogRows.add(); var row_two = column_one.dialogRows.add(); var art_text = row_one.staticTexts.add({ staticLabel: "Article --> ",minWidth:stw}); //Create a pop-up menu ("dropdown") control. myArtikelDropdown = row_one.dropdowns.add({ stringList: myItemsList, selectedIndex: 0,minWidth:ddw }); row_two.staticTexts.add({staticLabel: "To Page --> ",minWidth:stw}); //Create a pop-up menu ("dropdown") control. myPageDropdown = row_two.dropdowns.add({ stringList: myList, selectedIndex: myList.length - 1, minWidth:ddw}); // } // with(dialogColumns.add()){ // var gutter = staticTexts.add({staticLabel:" ",minWidth:25}); // } // } //Display the dialog box. if(myDialog.show() === true){ if(myPageDropdown.selectedIndex == myList.length -1){ myPage = d.pages.add(); myPageName = myPage.name; }else{ myPageName = myList[myPageDropdown.selectedIndex]; } var preTheItem = myItemsList[myArtikelDropdown.selectedIndex]; var theItem = preTheItem.substring(4); if (obj.DEBUG) alert("DEBUG: "+ theItem); myDialog.destroy(); myPage = d.pages.item(myPageName); placeData(d,myPage,theItem); alert("Done"); }else{ myDialog.destroy(); } // }}function set_label(obj,str){ try{ obj.label = str; }catch(e){ }}})(this);