Skip to content

Instantly share code, notes, and snippets.

@benzapier

benzapier/zap.js Secret

Created Mar 21, 2017
Embed
What would you like to do?
This is the Javascript that is used within a code-step for a Zap, that controls the Illuminated Zapier display: https://zapier.formstack.com/forms/geek
var bgshow = inputData.bgshow;
var bgcolor = inputData.bgcolor;
var fgshow = inputData.fgshow;
var fgcolor = inputData.fgcolor;
// changes a color name like "red" into an RGB object.
var mapColorToObject = function(colorName) {
var colorObject = { r:0, g:0, b:0 };
colorName = colorName.toLowerCase().trim();
switch (colorName) {
case 'red' : colorObject.r = 200; break;
case 'orange' : colorObject.r = 200; colorObject.g = 20; break;
case 'yellow' : colorObject.r = 200; colorObject.g = 200; break;
case 'green' : colorObject.g = 200; break;
case 'cyan' : colorObject.g = 200; colorObject.b = 200; break;
case 'blue' : colorObject.b = 200; break;
case 'purple' : colorObject.r = 200; colorObject.b = 200; break;
case 'white' : colorObject.r = 200; colorObject.g = 200; colorObject.b = 200; break;
};
return colorObject;
}
var everything = {
bgshow: bgshow
};
if (bgcolor) {
everything.bgcolor = mapColorToObject(bgcolor);
}
if (fgshow) {
everything.fgshow = fgshow;
}
if (fgcolor) {
everything.fgcolor = mapColorToObject(fgcolor);
}
var store = StoreClient('YOUR-SECRET-STORE-KEY'); // yup, pretty original, huh?
store.setMany(everything)
.then( function() {
callback(null, everything);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment