Skip to main content
Participant
September 4, 2023
Question

Javacript warnings

  • September 4, 2023
  • 2 replies
  • 506 views

I want to remove this warnigs , i made 2 js file one is customMenu.js second is folderLevelScript.js
code here : 
customMenu.js

function createTopMenu() {
  app.addSubMenu({
    cName: "LegalEdge",
    cParent: "File",
  });

  app.addMenuItem({
    cName: "Upload",
    cParent: "LegalEdge",
    cExec: "showUploadDialog()",
  });
  app.addMenuItem({
    cName: "config",
    cParent: "LegalEdge",
    cExec: "configdialouge()",
  });
  app.addMenuItem({
    cName: "About",
    cParent: "LegalEdge",
    cExec: "showUploadDialog()",
  });
}

function showUploadDialog() {
  // Dialog Definition
  var oDlg = {
    usnm: {
      // Define a nested object for usnm
      flnm: "",
      vers: "",
      lfnu: "",
      lccn: "",
    },

    initialize: function (dialog) {
      dialog.load(this.usnm); // Load the nested object directly
    },
    commit: function (dialog) {
      var data = dialog.store();
      this.usnm.flnm = data.flnm; // Access the nested object's properties
      this.usnm.vers = data.vers;
      this.usnm.lfnu = data.lfnu;
      this.usnm.lccn = data.lccn;
    },
    description: {
      name: "Test Dialog",
      elements: [
        {
          type: "view",
          elements: [
            { name: "Filename:", type: "static_text" },
            { item_id: "flnm", type: "edit_text", char_width: 30 }, // Use "flnm" instead of "usnm.flnm"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the vers field
            { name: "Version:", type: "static_text" },
            { item_id: "vers", type: "edit_text", char_width: 30 }, // Use "vers" instead of "usnm.vers"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the lfnu field
            { name: "LegalEdge File Number:", type: "static_text" },
            { item_id: "lfnu", type: "edit_text", char_width: 30 }, // Use "lfnu" instead of "usnm.lfnu"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the lfnu field
            { name: "LegalEdge Court Case Number:", type: "static_text" },
            { item_id: "lccn", type: "edit_text", char_width: 30 }, // Use "lfnu" instead of "usnm.lfnu"
            { type: "ok_cancel" },
          ],
        },
      ],
    },
  };

  // Dialog Activation
  oDlg.usnm.flnm = "Larry";
  oDlg.usnm.vers = "1.0";
  oDlg.usnm.lfnu = "Sample";
  oDlg.usnm.lccn = "Sample2";

  if ("ok" == app.execDialog(oDlg)) {
    app.alert(
      "flnm: " +
        oDlg.usnm.flnm +
        "\nvers: " +
        oDlg.usnm.vers +
        "\nlfnu: " +
        oDlg.usnm.lfnu +
        "\nlfns: " +
        oDlg.usnm.lccn
    );
  }
}

function configdialouge() {
  // Dialog Definition
  var oDlg = {
    usnm: {
      // Define a nested object for usnm
      flnm: "",
      vers: "",
      lfnu: "",
      lccn: "",
    },

    initialize: function (dialog) {
      dialog.load(this.usnm); // Load the nested object directly
    },
    commit: function (dialog) {
      var data = dialog.store();
      this.usnm.flnm = data.flnm; // Access the nested object's properties
      this.usnm.vers = data.vers;
      this.usnm.lfnu = data.lfnu;
      this.usnm.lccn = data.lccn;
    },
    description: {
      name: "Test Dialog",
      elements: [
        {
          type: "view",
          elements: [
            {
              name: "Provide Baseurl of the Web Service Api:",
              type: "static_text",
            },
            { item_id: "flnm", type: "edit_text", char_width: 30 }, // Use "flnm" instead of "usnm.flnm"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the vers field
            { name: "Username:", type: "static_text" },
            { item_id: "vers", type: "edit_text", char_width: 30 }, // Use "vers" instead of "usnm.vers"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the lfnu field
            { name: "PassWord:", type: "static_text" },
            { item_id: "lfnu", type: "edit_text", char_width: 30 }, // Use "lfnu" instead of "usnm.lfnu"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the lfnu field
            { name: "Cofirm Password:", type: "static_text" },
            { item_id: "lccn", type: "edit_text", char_width: 30 }, // Use "lfnu" instead of "usnm.lfnu"
            { type: "ok_cancel" },
          ],
        },
      ],
    },
  };

  // Dialog Activation
  oDlg.usnm.flnm = "https://localhost:3000";
  oDlg.usnm.vers = "Alfred";
  oDlg.usnm.lfnu = "********";
  oDlg.usnm.lccn = "********";

  if ("ok" == app.execDialog(oDlg)) {
    app.alert(
      "flnm: " +
        oDlg.usnm.flnm +
        "\nvers: " +
        oDlg.usnm.vers +
        "\nlfnu: " +
        oDlg.usnm.lfnu +
        "\nlfns: " +
        oDlg.usnm.lccn
    );
  }
}

folderLevelScript.js
function
myTrustedFunction() {
  createTopMenu();
}

// Call the trusted function when Acrobat starts
myTrustedFunction();

and then paste the code in this location



Still facing this issue . How can i resolve this 




This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
September 4, 2023

Besides the trust issue pointed out by Bernd, the menus in the new 64bit Acrobat have changed. This code, once its working, will only work in the old Acrbat DC UI. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
September 4, 2023

You must create a trusted function. The name myTrustedFunction is not enough.

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm