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:
functionsaveData() {
data = document.getElementById('text').value;
cs = newCSInterface;
cs.evalScript('$.json.myDump(' + JSON.stringify(data) + ')');
};
Here's the extendscript code:
myDump: function(data) {
file = filePath(app.project.path) + '\\\\JSONs\\\\data.json';
jsonDump(data, file)
}
}
functionfilePath(file) {
file = file.split('\\').slice(0, -1).join('\\\\');
while(file.charAt(0) != 'D'){
file = file.substr(1);
};
returnfile
};
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.