Skip to content

Instantly share code, notes, and snippets.

@ten-A
Created June 29, 2016 05:46
Show Gist options
  • Save ten-A/6596fbfe218553116ec6f64b26aba0d6 to your computer and use it in GitHub Desktop.
Save ten-A/6596fbfe218553116ec6f64b26aba0d6 to your computer and use it in GitHub Desktop.
Integrated CSInterface and Vulcan libraries.
function CSInterface(){}function CSXSWindowType(){}CSXSWindowType._PANEL="Panel";CSXSWindowType._MODELESS="Modeless";CSXSWindowType._MODAL_DIALOG="ModalDialog";EvalScript_ErrMessage="EvalScript error.";function Version(a,b,c,d){this.major=a;this.minor=b;this.micro=c;this.special=d}Version.MAX_NUM=999999999;function VersionBound(a,b){this.version=a;this.inclusive=b}function VersionRange(a,b){this.lowerBound=a;this.upperBound=b}function Runtime(a,b){this.name=a;this.versionRange=b}
function Extension(a,b,c,d,e,f,g,h,k,l,n,p,q,r,t,u){this.id=a;this.name=b;this.mainPath=c;this.basePath=d;this.windowType=e;this.width=f;this.height=g;this.minWidth=h;this.minHeight=k;this.maxWidth=l;this.maxHeight=n;this.defaultExtensionDataXml=p;this.specialExtensionDataXml=q;this.requiredRuntimeList=r;this.isAutoVisible=t;this.isPluginExtension=u}function CSEvent(a,b,c,d){this.type=a;this.scope=b;this.appId=c;this.extensionId=d}function SystemPath(){}SystemPath.USER_DATA="userData";
SystemPath.COMMON_FILES="commonFiles";SystemPath.MY_DOCUMENTS="myDocuments";SystemPath.APPLICATION="application";SystemPath.EXTENSION="extension";SystemPath.HOST_APPLICATION="hostApplication";function ColorType(){}ColorType.RGB="rgb";ColorType.GRADIENT="gradient";ColorType.NONE="none";function RGBColor(a,b,c,d){this.red=a;this.green=b;this.blue=c;this.alpha=d}function Direction(a,b){this.x=a;this.y=b}function GradientStop(a,b){this.offset=a;this.rgbColor=b}
function GradientColor(a,b,c,d){this.type=a;this.direction=b;this.numStops=c;this.arrGradientStop=d}function UIColor(a,b,c){this.type=a;this.antialiasLevel=b;this.color=c}function AppSkinInfo(a,b,c,d,e,f,g){this.baseFontFamily=a;this.baseFontSize=b;this.appBarBackgroundColor=c;this.panelBackgroundColor=d;this.appBarBackgroundColorSRGB=e;this.panelBackgroundColorSRGB=f;this.systemHighlightColor=g}
function HostEnvironment(a,b,c,d,e,f,g){this.appName=a;this.appVersion=b;this.appLocale=c;this.appUILocale=d;this.appId=e;this.isAppOnline=f;this.appSkinInfo=g}function HostCapabilities(a,b,c,d,e){this.EXTENDED_PANEL_MENU=a;this.EXTENDED_PANEL_ICONS=b;this.DELEGATE_APE_ENGINE=c;this.SUPPORT_HTML_EXTENSIONS=d;this.DISABLE_FLASH_EXTENSIONS=e}function ApiVersion(a,b,c){this.major=a;this.micro=this.minor=b}function MenuItemStatus(a,b,c){this.menuItemLabel=a;this.enabled=b;this.checked=c}
function ContextMenuItemStatus(a,b,c){this.menuItemID=a;this.enabled=b;this.checked=c}CSInterface.THEME_COLOR_CHANGED_EVENT="com.adobe.csxs.events.ThemeColorChanged";CSInterface.prototype.hostEnvironment=JSON.parse(window.__adobe_cep__.getHostEnvironment());CSInterface.prototype.getHostEnvironment=function(){return this.hostEnvironment=JSON.parse(window.__adobe_cep__.getHostEnvironment())};CSInterface.prototype.closeExtension=function(){window.__adobe_cep__.closeExtension()};
CSInterface.prototype.getSystemPath=function(a){a=decodeURI(window.__adobe_cep__.getSystemPath(a));var b=this.getOSInformation();0<=b.indexOf("Windows")?a=a.replace("file:///",""):0<=b.indexOf("Mac")&&(a=a.replace("file://",""));return a};CSInterface.prototype.evalScript=function(a,b){if(null==b||void 0==b)b=function(a){};window.__adobe_cep__.evalScript(a,b)};CSInterface.prototype.getApplicationID=function(){return this.hostEnvironment.appId};CSInterface.prototype.getHostCapabilities=function(){return JSON.parse(window.__adobe_cep__.getHostCapabilities())};
CSInterface.prototype.dispatchEvent=function(a){"object"==typeof a.data&&(a.data=JSON.stringify(a.data));window.__adobe_cep__.dispatchEvent(a)};CSInterface.prototype.addEventListener=function(a,b,c){window.__adobe_cep__.addEventListener(a,b,c)};CSInterface.prototype.removeEventListener=function(a,b,c){window.__adobe_cep__.removeEventListener(a,b,c)};CSInterface.prototype.requestOpenExtension=function(a,b){window.__adobe_cep__.requestOpenExtension(a,b)};
CSInterface.prototype.getExtensions=function(a){a=JSON.stringify(a);a=window.__adobe_cep__.getExtensions(a);return JSON.parse(a)};CSInterface.prototype.getNetworkPreferences=function(){var a=window.__adobe_cep__.getNetworkPreferences();return JSON.parse(a)};
CSInterface.prototype.initResourceBundle=function(){for(var a=JSON.parse(window.__adobe_cep__.initResourceBundle()),b=document.querySelectorAll("[data-locale]"),c=0;c<b.length;c++){var d=b[c],e=d.getAttribute("data-locale");if(e)for(var f in a)if(0==f.indexOf(e)){var g=a[f];if(f.length==e.length)d.innerHTML=g;else if("."==f.charAt(e.length)){var h=f.substring(e.length+1);d[h]=g}}}return a};CSInterface.prototype.dumpInstallationInfo=function(){return window.__adobe_cep__.dumpInstallationInfo()};
CSInterface.prototype.getOSInformation=function(){var a=navigator.userAgent;if("Win32"==navigator.platform||"Windows"==navigator.platform){var b="Windows",c="";-1<a.indexOf("Windows")&&(-1<a.indexOf("Windows NT 6.1")?b="Windows 7 ":-1<a.indexOf("Windows NT 6.2")?b="Windows 8 ":-1<a.indexOf("Windows NT 10.0")&&(b="Windows 10 "),c=-1<a.indexOf("WOW64")?"64-bit":"32-bit");return b+c}return"MacIntel"==navigator.platform||"Macintosh"==navigator.platform?(b="Mac OS X",new String,-1<a.indexOf("Mac OS X")&&
(b=a.indexOf(")")-a.indexOf("Mac OS X"),b=a.substr(a.indexOf("Mac OS X"),b).replace("_","."),b=b.replace("_",".")),b):"Unknown Operation System"};CSInterface.prototype.openURLInDefaultBrowser=function(a){return cep.util.openURLInDefaultBrowser(a)};CSInterface.prototype.getExtensionID=function(){return window.__adobe_cep__.getExtensionId()};CSInterface.prototype.getScaleFactor=function(){return window.__adobe_cep__.getScaleFactor()};CSInterface.prototype.setScaleFactorChangedHandler=function(a){window.__adobe_cep__.setScaleFactorChangedHandler(a)};
CSInterface.prototype.getCurrentApiVersion=function(){return JSON.parse(window.__adobe_cep__.getCurrentApiVersion())};CSInterface.prototype.setPanelFlyoutMenu=function(a){"string"==typeof a&&window.__adobe_cep__.invokeSync("setPanelFlyoutMenu",a)};CSInterface.prototype.updatePanelMenuItem=function(a,b,c){a=!1;this.getHostCapabilities().EXTENDED_PANEL_MENU&&(b=new MenuItemStatus(m,b,c),a=window.__adobe_cep__.invokeSync("updatePanelMenuItem",JSON.stringify(b)));return a};
CSInterface.prototype.setContextMenu=function(a,b){"string"==typeof a&&window.__adobe_cep__.invokeAsync("setContextMenu",a,b)};CSInterface.prototype.updateContextMenuItem=function(a,b,c){a=new ContextMenuItemStatus(a,b,c);ret=window.__adobe_cep__.invokeSync("updateContextMenuItem",JSON.stringify(a))};
function Vulcan(){}Vulcan.prototype.getTargetSpecifiers=function(){return JSON.parse(window.__adobe_cep__.invokeSync("vulcanGetTargetSpecifiers",JSON.stringify({})))};
Vulcan.prototype.launchApp=function(a,b,c){if(!requiredParamsValid(a))return!1;var d={};d.targetSpecifier=a;d.focus=b?"true":"false";d.cmdLine=void 0===c||null===c?"":c;return JSON.parse(window.__adobe_cep__.invokeSync("vulcanLaunchApp",JSON.stringify(d))).result};Vulcan.prototype.isAppRunning=function(a){if(!requiredParamsValid(a))return!1;var b={};b.targetSpecifier=a;return JSON.parse(window.__adobe_cep__.invokeSync("vulcanIsAppRunning",JSON.stringify(b))).result};
Vulcan.prototype.isAppInstalled=function(a){if(!requiredParamsValid(a))return!1;var b={};b.targetSpecifier=a;return JSON.parse(window.__adobe_cep__.invokeSync("vulcanIsAppInstalled",JSON.stringify(b))).result};Vulcan.prototype.getAppPath=function(a){if(!requiredParamsValid(a))return"";var b={};b.targetSpecifier=a;return JSON.parse(window.__adobe_cep__.invokeSync("vulcanGetAppPath",JSON.stringify(b))).result};
Vulcan.prototype.addMessageListener=function(a,b,c){if(requiredParamsValid(a,b)&&strStartsWith(a,VulcanMessage.TYPE_PREFIX)){var d={};d.type=a;window.__adobe_cep__.invokeAsync("vulcanAddMessageListener",JSON.stringify(d),b,c)}};Vulcan.prototype.removeMessageListener=function(a,b,c){if(requiredParamsValid(a,b)&&strStartsWith(type,VulcanMessage.TYPE_PREFIX)){var d={};d.type=a;window.__adobe_cep__.invokeAsync("vulcanRemoveMessageListener",JSON.stringify(d),b,c)}};
Vulcan.prototype.dispatchMessage=function(a){if(requiredParamsValid(a)&&strStartsWith(a.type,VulcanMessage.TYPE_PREFIX)){var b={},c=new VulcanMessage(a.type);c.initialize(a);b.vulcanMessage=c;window.__adobe_cep__.invokeSync("vulcanDispatchMessage",JSON.stringify(b))}};Vulcan.prototype.getPayload=function(a){if(!requiredParamsValid(a)||!strStartsWith(a.type,VulcanMessage.TYPE_PREFIX))return null;var b=new VulcanMessage(a.type);b.initialize(a);return b.getPayload()};var VulcanInterface=new Vulcan;
function VulcanMessage(a){this.type=a;this.scope=VulcanMessage.SCOPE_SUITE;this.appId=VulcanMessage.DEFAULT_APP_ID;this.appVersion=VulcanMessage.DEFAULT_APP_VERSION;this.data=VulcanMessage.DEFAULT_DATA}VulcanMessage.TYPE_PREFIX="vulcan.SuiteMessage.";VulcanMessage.SCOPE_SUITE="GLOBAL";VulcanMessage.DEFAULT_APP_ID="UNKNOWN";VulcanMessage.DEFAULT_APP_VERSION="UNKNOWN";VulcanMessage.DEFAULT_DATA="<data><payload></payload></data>";VulcanMessage.dataTemplate="<data>{0}</data>";
VulcanMessage.payloadTemplate="<payload>{0}</payload>";VulcanMessage.prototype.initialize=function(a){this.type=a.type;this.scope=a.scope;this.appId=a.appId;this.appVersion=a.appVersion;this.data=a.data};VulcanMessage.prototype.xmlData=function(){if(void 0===this.data){var a;a=String.format(VulcanMessage.payloadTemplate,"");this.data=String.format(VulcanMessage.dataTemplate,a)}return this.data};
VulcanMessage.prototype.setPayload=function(a){a=String.format(VulcanMessage.payloadTemplate,cep.encoding.convertion.utf8_to_b64(a));this.data=String.format(VulcanMessage.dataTemplate,a)};VulcanMessage.prototype.getPayload=function(){var a=GetValueByKey(this.data,"payload");return null!==a?cep.encoding.convertion.b64_to_utf8(a):null};
VulcanMessage.prototype.toString=function(){var a="type="+this.type,a=a+(", scope="+this.scope),a=a+(", appId="+this.appId),a=a+(", appVersion="+this.appVersion);return a+=", data="+this.xmlData()};String.format=function(a){if(0===arguments.length)return null;var b=Array.prototype.slice.call(arguments,1);return a.replace(/\{(\d+)\}/g,function(a,d){return b[d]})};
function GetValueByKey(a,b){if(window.DOMParser){var c=new window.DOMParser;try{var d=c.parseFromString(a,"text/xml").getElementsByTagName(b)[0];if(d&&d.childNodes[0])return d.childNodes[0].nodeValue}catch(e){}}return""}function requiredParamsValid(){for(var a=0;a<arguments.length;a++){var b=arguments[a];if(void 0===b||null===b)return!1}return!0}function strStartsWith(a,b){return"string"!=typeof a?!1:0===a.indexOf(b)};
@ten-A
Copy link
Author

ten-A commented Jun 29, 2016

replace CSInterface.js and Vulcan.js.
Compatibility : up to CSInterface ver.5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment