ScriptyStrokes, a StrokesPlus.net Scripting Framework
This was made this for fun because I love StrokesPlus.net and I also love Javascript.
Initially I tried to use the load external script feature but when I moved the file on accident, it caused a crash loop where I couldn't even start the program anymore. I put the old file back and started thinking how to over come this, something more dynamic.
I like the require()
function used in CommonJs to load other modules, so I put to work to try and make an implementation of this functionality for myself. I started with a little bootstrapper that sets up __dirname
to reference the framework files, then a simple version of the code for the loader.
Adding The ScriptyStrokes Bootstrapper
Under Global Action
, pick the Load/Unload
tab, and check the box to enable the load script.
Replace the path with the absolute path to the cloned repository.
function ScriptyStrokes() {
var ROOT = String.raw`<PATH_TO_REPO>`;
return eval("("+File.ReadAllText(`${ROOT}/bootstrap.js`)+")")(ROOT);
}
The bootstrapper takes care of providing a rich standard library that wraps many common sp.xxxx
methods with simple APIs.
Examples
var alert = ; ;
var toast = ; ;
var toast = ; var toaster = toast; ;
var balloon = ; ;
These are just a few of the many modules that come included. Check out the stdlib modules as well as application specific modules too.
Writing Modules
Scripty Modules look just like CJS modules, with a defined module.exports
containing what you want to export from the module.
Classes
{ return clrSystemEnvironment; } moduleexports = ;
Functions
/** * Create a modal dialog box notification. * * @param message string * @param title string */ { sp;} moduleexports = alert;
Complex Functionality & Multiple Exports
{ return Object ;} { var httpHandler = ; httpHandlerAutomaticDecompression = host; var client = httpHandler; clientBaseAddress = baseUrl; return { var endpoint = params ? `?` : url; var response = clientResult; var result = responseContentResult; httpHandler; client; return result; };} moduleexports = queryString request ;
With the simple StrokesPlus.net actions usage:
var request = ; var stackExchange = ; var res = ; clip;