Quantcast
Channel: Adobe Community : Unanswered Discussions - General and cross-application scripting
Viewing all articles
Browse latest Browse all 84

Script working for one panel and not another

$
0
0

Hello,

 

I've designed a panel that includes a text area. I'm trying to write a function that collects the text in this panel, and saves it in a JSON file in the same directory that the PPro.proj file is saved in.

 

Here's the javascript code:

 

 

/** Exports data to JSON file */

 

functionsaveData() {

    data = document.getElementById('text').value;

  

  cs = newCSInterface;                 

  cs.evalScript('$.json.myDump(' + JSON.stringify(data) + ')');

};

 

Here's the extendscript code:

 

#include json2.jsx
$.json = {

     myDump:  function(data) {

        file = filePath(app.project.path) + '\\\\JSONs\\\\data.json';

        jsonDump(data, file)

}

 

 

/** determine file path */

functionfilePath(file) {

    file = file.split('\\').slice(0, -1).join('\\\\');

    while(file.charAt(0) != 'D'){

        file = file.substr(1);

    };

    returnfile

};

 

 

/** Store a data structure in a JSON file */

 

functionjsonDump(data, jsonFile) {

   varfile = newFile(jsonFile);

   if (file.open('w')) {

   file.encoding = 'UTF-8';

   file.write(JSON.stringify(data));

   file.close();

  }; 

};

 

This script works perfectly well in one of my panels, and won't work at all in another (I'm just working on updating an existing panel, so the HTML and other features are nearly identical as well).

 

Any help on this problem would be appreciated. Thank You.


Viewing all articles
Browse latest Browse all 84

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>