Created
March 1, 2019 17:34
-
-
Save undavide/d4cd799c8cc3ebd0244bc7c0ac209c9a to your computer and use it in GitHub Desktop.
Revisions
-
undavide created this gist
Mar 1, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ /*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ /*global $, window, location, CSInterface, SystemPath, themeManager*/ line (function () { 'use strict'; var csInterface = new CSInterface(); var extensionId = csInterface.getExtensionID(); function PersistentOn() { var event = new CSEvent("com.adobe.PhotoshopPersistent", "APPLICATION"); event.extensionId = extensionId; csInterface.dispatchEvent(event); } function init() { // Styling themeManager.init(); // Persistence PersistentOn(); // Listener for PhotoshopJSONCallback csInterface.addEventListener("com.adobe.PhotoshopJSONCallback" + extensionId, PhotoshopCallbackUnique); function PhotoshopCallbackUnique(csEvent) { console.log(csEvent.toString()); try { if (typeof csEvent.data === "string") { var eventData = csEvent.data.replace("ver1,{", "{"); var eventDataObject = JSON.parse(eventData); csEvent.data = eventDataObject; console.log(csEvent); } else { console.log("PhotoshopCallbackUnique expecting string for csEvent.data!"); } } catch(e) { console.log("PhotoshopCallbackUnique catch: " + e); } } function toggleEventRegistering (eventStringID, isOn) { var event; if (isOn) { event = new CSEvent("com.adobe.PhotoshopRegisterEvent", "APPLICATION"); } else { event = new CSEvent("com.adobe.PhotoshopUnRegisterEvent", "APPLICATION"); } event.extensionId = extensionId; csInterface.evalScript("app.stringIDToTypeID('" + eventStringID + "')", function (typeID) { event.data = typeID; csInterface.dispatchEvent(event); console.log("Dispatched Event " + eventStringID, event); }); } $('#make').change(function() { toggleEventRegistering(this.id, this.checked); }); $('#duplicate').change(function() { toggleEventRegistering(this.id, this.checked); }); $('#delete').change(function() { toggleEventRegistering(this.id, this.checked); }); $('#close').change(function() { toggleEventRegistering(this.id, this.checked); }); } init(); }());