Skip to content

Instantly share code, notes, and snippets.

@jon-merchant
jon-merchant / string2bool.js
Last active November 9, 2022 16:45
Convert String to Boolean
JSON.parse("true"); //true
JSON.parse("false"); //false
/****************
* Can you pass values from a widget to a UI Script, and back again?
* The Widget is used as the $scope source and grabbed by using angular.element and class of the widget
* The MutationObserver is used to detect changes at the DOM level as UI Scripts are loaded once at the load of the portal, need to know a change happens when page changes
* This may not be pratical, as for my use case I found it working as expected just using the widget to control the changes I needed, but it's cool to know you can interact with with the scope/widgets outside the scope/widget
****************/
(function(angular) {
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
@jon-merchant
jon-merchant / standardChangeProposal.onBeforeTransformScript.js
Last active May 24, 2022 16:30
standardChangeProposal.onBeforeTransformScript.js
/***********
* Need to be able to bulk upload Stand Change Proposals
* onBefore Transform Script
***********/
//convert impact to value
var impactRaw = source.u_i + "";
var impact = "";
switch (impactRaw) {
@jon-merchant
jon-merchant / flatten_dedupe.js
Created May 13, 2022 14:37
Javascript Flatten and De-dupe Array
//Flatten array [a,[a,b],b,[c,d]] into [a,a,b,b,c,d]
var flattenList = [].concat.apply([], c.data.records);
//remove dupes [a,a,b,b,c,d] into [a,b,c,d]
flattenList = [...new Set(flattenList.map(JSON.stringify))].map(JSON.parse);
@jon-merchant
jon-merchant / gist:0e511fd265812696b4bbe3e431e90649
Last active April 22, 2022 16:05
SCSS Custom Class Variables
/**
* Use case: Need multiple "containers" of a specific widget (in this case something like the icon widget
or image link widget, where you might have a grid of 3x3 or a single row of 3 or something). There are
different styles needed for each "container"
of the widget(s)
* You can assign a CSS name on the container, but what does SCSS offer me?
**/
//CSS Include
@jon-merchant
jon-merchant / Hash Scroll.js
Created March 31, 2021 20:23
Hash change scroll to
$location.hash('anchorString'); //no #
$anchorScroll();
//https://docs.angularjs.org/api/ng/service/$anchorScroll#!
_getDataDriven: function(table, condition, valueField) {
var gr = new GlideRecord(table);
gr.addEncodedQuery(condition);
gr.query();
while (gr.next()) {
return gr.getValue(valueField) || "";
}
return "";
}
h1 , h2, h3{
font-family: 'Alfa Slab One', cursive;
}
<p>
<link href="https://fonts.googleapis.com/css?family=Alfa+Slab+One" rel="stylesheet">
<link href="e7a8db83db3123c025350f95ca96197f.cssdbx" rel="stylesheet" type="text/css" />
</p>
<p><link href="e7a8db83db3123c025350f95ca96197f.cssdbx" rel="stylesheet" type="text/css" /></p>