forked from wabimochi/2dActorTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PProPanel.jsx
66 lines (65 loc) · 1.78 KB
/
PProPanel.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2014 Adobe
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in
* accordance with the terms of the Adobe license agreement accompanying
* it. If you have received this file from a source other than Adobe,
* then your use, modification, or distribution of it requires the prior
* written permission of Adobe.
**************************************************************************/
if(typeof($)=='undefined'){
$={};
}
$._ext = {
//Evaluate a file and catch the exception.
evalFile : function(path) {
try {
$.evalFile(path);
} catch (e) {alert("Exception:" + e);}
},
// Evaluate all the files in the given folder
evalFiles: function(jsxFolderPath) {
var folder = new Folder(jsxFolderPath);
if (folder.exists) {
var jsxFiles = folder.getFiles("*.jsx");
for (var i = 0; i < jsxFiles.length; i++) {
var jsxFile = jsxFiles[i];
$._ext.evalFile(jsxFile);
}
}
},
// entry-point function to call scripts more easily & reliably
callScript: function(dataStr) {
try {
var dataObj = JSON.parse(decodeURIComponent(dataStr));
if (
!dataObj ||
!dataObj.namespace ||
!dataObj.scriptName ||
!dataObj.args
) {
throw new Error('Did not provide all needed info to callScript!');
}
// call the specified jsx-function
var result = $[dataObj.namespace][dataObj.scriptName].apply(
null,
dataObj.args
);
// build the payload-object to return
var payload = {
err: 0,
result: result
};
return encodeURIComponent(JSON.stringify(payload));
} catch (err) {
var payload = {
err: err
};
return encodeURIComponent(JSON.stringify(payload));
}
}
};