Skip to content

Instantly share code, notes, and snippets.

View rjcorwin's full-sized avatar

R.J. (Steinert) Corwin rjcorwin

View GitHub Profile
{
"id": "village",
"formId": "village-manifest",
"name": "Village",
"caseRoles": [
{
"id": "village",
"label": "Village",
"templateListItem": "Village ${participant.data.id}"
},
@rjcorwin
rjcorwin / my-counter.js
Created July 17, 2020 18:32
Basic web component example
class MyCounter extends HTMLElement {
constructor() {
super();
this.count = 0;
}
render() {
this.innerHTML = `
<style>
const first = {
foo: 1,
bar: 1
}
// Copy the first object into a new one and override the bar property. This is useful when you
// want to make a copy of a complex object and want to override just one particular part of it.
const second = {
...first,
bar: 2
const language = {
_numberOfTimesCalled: 0,
set foo(name) {
this._numberOfTimesCalled++
this._foo = name
},
get foo() {
return this._foo
}
const yes_no = function() {
const possibilities = [
[
{
"label": "yes",
"name": "1",
"value": ""
},
{
"label": "no",
shouldGridAutoStop() {
const firstXButtons = tangyToggleButtons.slice(0, this.autoStop)
const hasAtLeastOneUnpressedButton = firstXButtons
.reduce((hasAtLeastOne, button) => hasAtLeastOne || button.pressed === false ? true : false, false)
return hasAtLeastOneUnpressedButton ? false : true
}
@rjcorwin
rjcorwin / debugger-statement-in-a-template-literal.js
Created April 16, 2020 20:20
How to put a debugger statement in a Javascript template literal.
var foo = `
Here is a debugger statment in a template...
${(()=>{ debugger })()}
`
var message = 'Hello world'
var number = '555-555-5555'
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without opening any other app
}
};
var success = function () { alert('Message sent successfully'); };
find . -type f | xargs -I $0 ls -ll --time-style=long-iso $0 | awk '{print $6" "$7" "$8}' | sort | grep -E '2019-[0[7-9]|1]'
// When viewing a form, the EventInstance's ID will be at position 5 in the URL hash.
const eventInstanceId = window.location.hash.split('/')[5]
// With the eventInstanceId, we can find the matching eventInstance in caseService.case.events.
const eventInstance = caseService.case.events.find(eventInstance => eventInstance.id === eventInstanceId)
// With the eventInstance handy, we can use the eventInstance.caseEventDefinitionId to find the EventDefinition inside of caseService.caseDefinition.eventDefinitions.
const eventDefinition = caseService.caseDefinition.eventDefinitions.find(eventDefinition => eventDefinition.id === eventInstance.caseEventDefinitionId)