HTML
Code: Select all
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link id="hostStyle" rel="stylesheet" href="css/theme.css" />
<link id="theme" rel="stylesheet" href="css/light.css" />
<title></title>
</head>
<body>
<div style="width: 80%; margin:0 auto">
<h3 class="center">PS Events</h3>
<label class="topcoat-switch">
<input id="registerEvent" type="checkbox" class="topcoat-switch__input">
<div class="topcoat-switch__toggle"></div>
</label>
<input type="text" id="result" class="topcoat-text-input" style="margin-left:10px" placeholder="Listen for Events" value="">
</div>
<script src="js/libs/CSInterface.js"></script>
<script src="js/libs/jquery-2.0.2.min.js"></script>
<script src="js/themeManager.js"></script>
<script src="js/main.js"></script>
</body>
</html>
Code: Select all
(function()
{
'use strict';
var csInterface = new CSInterface();
function Register(inOn)
{
if (inOn)
{
var event = new CSEvent("com.adobe.PhotoshopRegisterEvent", "APPLICATION");
}
else
{
var event = new CSEvent("com.adobe.PhotoshopUnRegisterEvent", "APPLICATION");
};
event.extensionId = "my_extension_id";
// #region // EVENT CODES //
// ╔════════╦═════════╦════════════╗
// ║ Name ║ Char ID ║ Type ID ║
// ╠════════╬═════════╬════════════╣
// ║ Hide ║ Hd ║ 1214521376 ║
// ║ Select ║ slct ║ 1936483188 ║
// ║ Set ║ setd ║ 1936028772 ║
// ║ Show ║ Shw ║ 1399355168 ║
// ╚════════╩═════════╩════════════╝
// #endregion
event.data = "1936483188";
csInterface.dispatchEvent(event);
}
function init()
{
themeManager.init();
$('#registerEvent').change(function()
{
Register($(this).is(':checked'));
});
};
function PSCallback(csEvent)
{
var dataArray = csEvent.data.split(",");
csInterface.evalScript('convertTypeID(' + JSON.stringify(dataArray\[0\]) + ')', function(res)
{
$('#result').val(res.toString());
});
};
init();
csInterface.addEventListener("PhotoshopCallback", PSCallback);
}());
Code: Select all
function convertTypeID (typeArray)
{
return typeIDToStringID(Number(typeArray));
};