-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
90 lines (77 loc) · 3.51 KB
/
index.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!--
Written by Ole Henrik Stabell - [email protected]
-->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link id="ccstyleTheme" href="css/styles-darker.css" rel="stylesheet" type="text/css" />
<link href="css/styles-custom.css" rel="stylesheet" type="text/css" />
<script src="js/libs/jquery-2.0.2.min.js"></script>
<script src="js/libs/CSInterface.js"></script>
<script src="js/XMPBridge.js"></script>
<script src="js/main.js"></script>
<script src="js/aucolors.js"></script>
<script src="js/debug.js"></script>
<title>Notes</title>
</head>
<body class="hostElt" enable-nodejs>
<div id="content">
<form id="notes-form">
<textarea id="notes" data-property="logComment" data-namespace-ref="NS_DM"
data-namespace="http://ns.adobe.com/xmp/1.0/DynamicMedia/"></textarea>
<center><button type="button" class="btn-small" id="save-as">Save As</button></center>
</form>
<br>
<center><button type="button" class="btn-small debuglink" id="debug">Debug</button></center>
</div>
<script>
var csInterface = new CSInterface();
// This works in Photoshop but not in Audition... Why not?
// Look for the debug control file, and if it exists,
// enable debugging controls
var path = require("path");
var fs = require("fs");
var debugPath = path.join(csInterface.getSystemPath(SystemPath.EXTENSION), ".debug");
if (fs.existsSync(debugPath)) {
$(".debuglink").toggle(true);
var debugText = fs.readFileSync(debugPath, "utf8");
var m = debugText.match(/<Host.*Port="(\d+)"[/]>/m);
// Enable the debug link only if we know the port.
if (m)
debugPort = m[1];
else
$("#debug").toggle(false);
} else
$(".debuglink").toggle(false);
//Set up the event listener on the ExtendScript side:
csInterface.evalScript("addDocumentListeners()");
// Save the notes when Audition saves the document.
csInterface.addEventListener("com.adobe.csxs.events.DocumentSaveAs", function (event) {
$('#notes-form').submit()
})
// This does not work, unsure as to why, the custom event never fires despite unsupported documents being used...
csInterface.addEventListener("DocumentNotSupported", function (event) {
$('#notes').prop('disabled', true);
$('#save-as').prop('disabled', true);
})
// Same with this as the one above.
csInterface.addEventListener("DocumentSupported", function (event) {
$('#notes').prop('disabled', false);
$('#save-as').prop('disabled', false);
})
// Reload the notes panel when changing active document aswell as save the current notes before switching
csInterface.addEventListener("com.adobe.csxs.events.DocumentAfterActivate", function (event) {
$('#notes-form').submit()
location.reload();
})
// Save the file using a savedialog
$("#save-as").click(function () {
var result = window.cep.fs.showSaveDialogEx("Save As", "", ["txt"], "notes.txt", "", "Save",
"File name");
var targetFilePath = result.data;
var writeResult = window.cep.fs.writeFile(targetFilePath, $("#notes").val());
})
</script>
</body>
</html>