Skip to content

Instantly share code, notes, and snippets.

var event = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true
});
var buttons = document.querySelectorAll('.btn-link.show-outdated-button') || [];
buttons.forEach(button => button.dispatchEvent(event));
var initializationPromise = utilsAsync.makePromise(function (resolve, reject) {
checkPendo();
function checkPendo () {
var delay = 0;
if (window.pendo === undefined) {
if (delay < 8) {
setTimeout(checkPendo, (delay = Math.max(delay *= 2, 1)) * 1000);
<style>
.campaigns {
margin-left: 30px;
-ms-flex-direction: column;
flex-direction: column;
position: relative;
}
table {
list-style: none; /* table's do not have list styles */
display: -ms-flexbox;

parseInt can take a second value - the radix. This is a base for interpreting the string into a number. For example

// base10
parseInt('10', 10); // 10

// binary
parseInt('10', 2); // 2

// base8
@adambankin
adambankin / item.js
Created December 16, 2016 22:17
src/js/modules/strategy/views/item.js
/*global define*/
define([
'jQuery',
'Underscore',
'T1',
'T1View',
'T1Model',
'T1Layout',
'text!modules/strategy/templates/item.html',
'text!modules/strategy/templates/spendMode.html',
@adambankin
adambankin / setTimeout and rAF.md
Last active October 27, 2016 21:33
Explaining setTimeout and requestAnimationFrame

Single-threaded

JavaScript runtimes give each window access to one "main" CPU thread. An iframe creates a new main window and therefore gets its own thread. When the main thread is busy running code it can't run other code, so it queues it to be run when the current code has completed.

Call Stack

This is a synchronous stack of procedures filled with the current running procedure and the ancestry of procedures that directly spawned it.

By "procedure" I mean things like: calling functions, assigning values, evaluating conditions, etc…

/* use the View to control its associated Controller */
// file:: MyView1.js
var MyView1 = T1View.extend({
processResults: function (results) {
// yadda, yadda
renderResults();
},
// do everything for the Collection in the View
onSearch: function () {
operatorToFromSDL: (function () {
// create hash of values once
var obj = {
'equal to': 'equals',
'not equal to': 'not equals',
'starts with': 'startswith',
'does not start with': 'not startswith',
'ends with': 'endswith',
'does not end with': 'not endswith',
'does not contain': 'not contains',
var counter = window.performance.now();
var inc = 0;
function doCounter () {
console.log(
parseInt(
(window.performance.now() - counter) / 16, 10
)
);