This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getStreetNumber(lat, lng) { | |
var json = getRGeocodeJSON(lat, lng); | |
var obj = JSON.parse(json); | |
try { return obj.results[0].address_components[0].short_name; } | |
catch(e) { return ''; } | |
} | |
function getStreetName(lat, lng) { | |
var json = getRGeocodeJSON(lat, lng); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A function to access a value in an option in a multi-select element. | |
* by converting the value of the multi-select element into a bit and | |
* @param {integer} i the integer representation from a multi-select element | |
* @param {position} p the number of the option list value to look-up | |
* the last option is #1 and increments up | |
* @return {integer} value of the binary string at the given position | |
*/ | |
function getValueOfBitPosition(i,p) { | |
var bit = (i >>> 0).toString(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNumSelected(i) { | |
var bit = (i >>> 0).toString(2); | |
var count = 0; | |
for(var i = 0;i<bit.length;i++) { | |
if(bit[i] == 1) {count ++;} | |
} | |
return count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* convertStateToFull transforms a state abbreviation to its full name | |
* @param {string} abbreviation two-letter state abbreviation | |
* @return {string} full name of the state | |
*/ | |
function convertStateToFull(abbreviation) { | |
var states = { | |
"AL": "Alabama", | |
"AK": "Alaska", | |
"AZ": "Arizona", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* multiToKVPs convert a csv list to a set of objects with a value of 1 or 0 | |
* @param {json_object} obj a JSON object | |
* @param {string} key the key of the csv list | |
* @param {array} masterlist the list of possible values in the csv | |
* @return {json_object} original object with KVPs from masterlist | |
*/ | |
function multiToKVPs(obj,key,masterlist) { | |
var multiArray = obj[key].split(','); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var record = { | |
"supervisor": "Ryan Coleman", | |
"supervisor_email": "rcoleman@zerionsoftware.com", | |
"team_members": [ | |
{ | |
"member_name": "mnesgoda", | |
"quarterly_goals": "3", | |
"motivation": "4", | |
"communication": "5", | |
"professionalism": "4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record = { | |
"ID": "118", | |
"PARENT_RECORD_ID": "0", | |
"PARENT_PAGE_ID": "0", | |
"PARENT_ELEMENT_ID": "0", | |
"CREATED_DATE": "2017-04-18 17:06:09", | |
"CREATED_BY": "Sandbox2", | |
"CREATED_LOCATION": "", | |
"CREATED_DEVICE_ID": "8bd823a04e1fd2cb04c6c7d6bff9f08355f44523", | |
"MODIFIED_DATE": "2017-04-26 12:39:44", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* removeIFBMetaData cleans an IFB/DC record of the 13 metadata fields | |
* @param {json_object} r a record from iFormBuilder or Data Collector | |
* @return {json_object} original record cleaned of any metadata fields | |
*/ | |
function removeIFBMetaData(r) { | |
var metaDataKeys = ["ID", "PARENT_RECORD_ID", "PARENT_PAGE_ID", "PARENT_ELEMENT_ID", "CREATED_DATE", "CREATED_BY", "CREATED_LOCATION", "CREATED_DEVICE_ID", "MODIFIED_DATE", "MODIFIED_BY", "MODIFIED_LOCATION", "MODIFIED_DEVICE_ID", "SERVER_MODIFIED_DATE"]; | |
for (var key in r) { | |
if (r[key] !== null && Array.isArray(r[key])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* kvpListToArray transforms a dictionary style object to an 'array of objects' | |
* @param {object} kvps dictionary style object with key-value-pairs | |
* @param {type} key_label label for the key in each key-value-pair | |
* @param {type} value_label label for the value in each key-value-pair | |
* @return {type} an array of objects | |
*/ | |
function kvpListToArray(obj,key_label,value_label) { | |
var array = []; | |
var tempObj = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* function to flatten a list of values into multiple records | |
* @param {object} r record with list of values, normally csv | |
* @param {string} multi_dcn name of property in record | |
* @param {string} new_dcn custom name to replace property name | |
* @param {string} delimeter custom delimeter, comma by default | |
* @return {array} array of records | |
*/ | |
function list_to_subform(r,multi_dcn,new_dcn,delimeter) { | |
if(typeof r !== "object" || r.hasOwnProperty(multi_dcn) === false) return r; |
OlderNewer