Skip to content

Instantly share code, notes, and snippets.

@humbletim
Last active July 15, 2019 00:59
Show Gist options
  • Save humbletim/2965e3c7dea30570a2b425f789ec4bf6 to your computer and use it in GitHub Desktop.
Save humbletim/2965e3c7dea30570a2b425f789ec4bf6 to your computer and use it in GitHub Desktop.
CustomAPIExample test scripts
// multicontext test script
var script = typeof Script === 'object' ? Script : { type: typeof window === 'object' ? 'browser' : 'unknown' };
var api = typeof KasenAPIExample === 'object' ? KasenAPIExample : {};
var details = {
type: script.type + '',
api: api + '',
now: api.now && api.now() + '',
};
// all contexts
if (typeof console === 'object') {
console.log("=== TEST ===", JSON.stringify(details));
} else if (script.type !== 'unknown' && typeof print === 'function') {
print("=== TEST ===", JSON.stringify(details));
}
// edit_filter expects a global function named "filter"
function filter(properties, type, originalProperties) {
print('=== TEST === editFilter / edit type: ' + type, 'entity type: ' + properties.type, properties.id, properties.name);
if (!properties.userData) properties.userData = JSON.stringify(details);
return properties;
}
// entity_client and entity_server expect the final value to be a constructor function
function EntityConstructor() {
console.log("EntityConstructor");
}
EntityConstructor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment