Skip to content

Commit

Permalink
Adding PhotoshopEvents sample
Browse files Browse the repository at this point in the history
  • Loading branch information
lesavage committed Jun 17, 2015
1 parent ee6ff33 commit 6a3bc38
Show file tree
Hide file tree
Showing 7 changed files with 1,542 additions and 0 deletions.
80 changes: 80 additions & 0 deletions PhotoshopEvents/CSXS/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ExtensionManifest ExtensionBundleId="com.example.photoshopevents" ExtensionBundleName="PhotoshopEvents" ExtensionBundleVersion="1.0" Version="4.0">
<ExtensionList>
<Extension Id="com.example.photoshopevents.extension" Version="1.0"/>
<Extension Id="com.example.photoshopevents.extension2" Version="1.0"/>
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<Host Name="PHXS" Version="[14.0,99.9]"/>
</HostList>
<LocaleList>
<Locale Code="All"/>
</LocaleList>
<RequiredRuntimeList>
<RequiredRuntime Name="CSXS" Version="4.0"/>
</RequiredRuntimeList>
</ExecutionEnvironment>
<DispatchInfoList>
<Extension Id="com.example.photoshopevents.extension">
<DispatchInfo>
<Resources>
<MainPath>./index.html</MainPath>
<ScriptPath>./host/ps.jsx</ScriptPath>
</Resources>
<UI>
<Type>Panel</Type>
<Menu>PhotoshopEvents</Menu>
<Geometry>
<Size>
<Height>460</Height>
<Width>320</Width>
</Size>
<MaxSize>
<Height>800</Height>
<Width>1200</Width>
</MaxSize>
<MinSize>
<Height>100</Height>
<Width>100</Width>
</MinSize>
</Geometry>
<Icons>
<Icon Type="Normal">./PhotoshopEventsNormal.png</Icon>
<Icon Type="RollOver">./PhotoshopEventsRollover.png</Icon>
</Icons>
</UI>
</DispatchInfo>
</Extension>
<Extension Id="com.example.photoshopevents.extension2">
<DispatchInfo>
<Resources>
<MainPath>./index.html</MainPath>
<ScriptPath>./host/ps.jsx</ScriptPath>
</Resources>
<UI>
<Type>Panel</Type>
<Menu>PhotoshopEvents 2</Menu>
<Geometry>
<Size>
<Height>460</Height>
<Width>320</Width>
</Size>
<MaxSize>
<Height>800</Height>
<Width>1200</Width>
</MaxSize>
<MinSize>
<Height>100</Height>
<Width>100</Width>
</MinSize>
</Geometry>
<Icons>
<Icon Type="Normal">./PhotoshopEventsNormal.png</Icon>
<Icon Type="RollOver">./PhotoshopEventsRollover.png</Icon>
</Icons>
</UI>
</DispatchInfo>
</Extension>
</DispatchInfoList>
</ExtensionManifest>
Binary file added PhotoshopEvents/PhotoshopEventsNormal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PhotoshopEvents/PhotoshopEventsRollover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions PhotoshopEvents/host/ps.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Fri May 22 2015 11:56:37 GMT-0700 (Pacific Daylight Time)
var gScriptVersion = "0.1";

// some events we are interested in
var eventMake = 1298866208; // "Mk "
var eventDelete = 1147958304; // "Dlt "
var eventClose = 1131180832; // "Cls "
var eventSelect = 1936483188; // "slct"
var eventSet = 1936028772; // "setd"

function LogIt( inMessage ) {
try {
var a = new Logger();
var b = decodeURIComponent( inMessage );
a.log( b + "\n");
}
catch(e) {
alert("LogIt catch : " + e + ":" + e.line);
}
}

///////////////////////////////////////////////////////////////////////////////
// Object: Logger
// Usage: Log information to a text file
// Input: String to full path of file to create or append, if no file is given
// then output file Logger.log is created on the users desktop
// Return: Logger object
// Example:
//
// var a = new Logger();
// a.print( 'hello' );
// a.print( 'hello2\n\n\nHi\n' ) ;
// a.remove();
// a.log( Date() );
// a.print( Date() );
// a.display();
//
///////////////////////////////////////////////////////////////////////////////
function Logger( inFile ) {

// member properties

// the file we are currently logging to
if ( undefined == inFile ) {
this.file = new File( Folder.desktop + "/PhotoshopEvents.log" );
} else {
this.file = new File( inFile );
}

// member methods

// output to the ESTK console
// note that it behaves a bit differently
// when using the BridgeTalk section
this.print = function( inMessage ) {
if ( app.name == "ExtendScript Toolkit" ) {
print (inMessage);
} else {
var btMessage = new BridgeTalk();
btMessage.target = "estoolkit";
btMessage.body = "print(" + inMessage.toSource() + ")";
btMessage.send ();
}
}

// write out a message to the log file
this.log = function( inMessage ) {
if ( this.file.exists ) {
this.file.open( 'e' );
this.file.seek( 0, 2 ); // end of file
} else {
this.file.open( 'w' );
}
this.file.write( inMessage );
this.file.close();
}

// show the contents with the execute method
this.display = function() {
this.file.execute();
}

// remove the file
this.remove = function() {
this.file.remove();
}
}

// end ps.jsx
31 changes: 31 additions & 0 deletions PhotoshopEvents/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<!-- Wed Apr 29 2015 08:40:46 GMT-0700 (Pacific Daylight Time) -->
<html>
<style>
.labellong {
width: 240px;
text-align: left;
display:inline-block;
}
</style>
<body onload="Initialize()">
<h3 align="center">Photoshop JSON Events v0.1</h3>
<button id="btnClose">Close</button>
<div>
<label><input type="checkbox" id="cbMake" checked="true" onClick="EventClick(this);">Make</label>
<label id="lblMake"> 0</label><br>
<label><input type="checkbox" id="cbDelete" checked="true" onClick="EventClick(this);">Delete</label>
<label id="lblDelete"> 0</label><br>
<label><input type="checkbox" id="cbClose" checked="true" onClick="EventClick(this);">Close</label>
<label id="lblClose"> 0</label><br>
<label><input type="checkbox" id="cbSelect" checked="true" onClick="EventClick(this);">Select</label>
<label id="lblSelect"> 0</label><br>
<label><input type="checkbox" id="cbSet" checked="true" onClick="EventClick(this);">Set</label>
<label id="lblSet"> 0</label><br>
</div>
<div><label id="lblResult" class="labellong">Results go here</label></div>
<div><label id="lblTiming" class="labellong">Timing info goes here</label></div>
</body>
<script src="js/CSInterface.js"></script>
<script src="js/main.js"></script>
</html>
Loading

0 comments on commit 6a3bc38

Please sign in to comment.