Skip to content

Instantly share code, notes, and snippets.

const likeButtons = document.querySelectorAll('.likeButton');
// Initialise an empty array to hold our count values.
const countValues = [];
// Foreach is more concise than regular for loops, but do pretty much the same thing.
// Each iteration is passed the current item of the loop, the index of that item
// and a copy of the array. We only need the two first values, so no need to mention the third. :)
likeButtons.forEach((btn, index) => {
// Start off by setting the index corresponding to the button to 0;
const name = document.querySelector('.name');
const email = document.querySelector('.email');
const firstpassword = document.querySelector('.password1');
const secondpassword = document.querySelector('.password2');
const textName = document.querySelector('.nameText');
const textEmail = document.querySelector('.emailText');
const textPassword = document.querySelector('.passwordText');
const textPassword2 = document.querySelector('.passwordText2');
const button = document.querySelector('button');
const popup = document.querySelector('.popup');
const name = document.querySelector('.name');
const email = document.querySelector('.email');
const error = document.querySelector('.error');
const firstpassword = document.querySelector('.password1');
const secondpassword = document.querySelector('.password2');
const textName = document.querySelector('.nameText');
const textEmail = document.querySelector('.emailText');
const textPassword = document.querySelector('.passwordText');
const button = document.querySelector('button');
// Ideally you would import the Jump library explicitly, but don't sweat it. ;)
const jump = Jump;
// ⬇ Moved this up here as there is no reason for the variable to be set to undefined first.
const imageArray = [
{
image: 'img/mattias@400px.png',
description:
'Hemsida för content marketing specialisten och tidigare SVT-sportjournalist Mattias Brännholm. Wordpress.',
},
{
/**
* This sets up a very lightweight App State based on React Context API
* with a familiar reducer / actions / dispatcher syntax, and also exposes
* this to Redux Devtools which is good and not bad.
* More info here: https://medium.com/simply/state-management-with-react-hooks-and-context-api-at-10-lines-of-code-baf6be8302c
* ...and here: https://github.com/troch/reinspect
*/
import React, { createContext, useContext } from 'react';
import { useReducer } from 'reinspect';
import PropTypes from 'prop-types';
@mmgj
mmgj / art-embellish.js
Created September 22, 2018 17:02
Sanity -> Webtask.io
/**
* Cloud function triggered by changes in dataset which will generate metadata for art asset.
*/
const Promise = require('es6-promise').Promise;
const sanityClient = require('@sanity/client');
/** Setup */
const client = token => sanityClient({
projectId: '<projectId>',
@mmgj
mmgj / getType.js
Last active June 8, 2018 20:18
Get type for any object
export function getBaseType(input) {
return ({}).toString.call(input).match(/\s([a-zA-Z]+)/)[1];
}
export function getType(input, restricted = false) {
let output = getBaseType(input);
if (restricted) return output;
if (output.toLowerCase() === 'object') output = input.type ? input.type.name : input.constructor.name;
return output;
}
@mmgj
mmgj / noment.js
Last active June 8, 2018 20:20
Simple date operations
export function isDateInRange(checkPointIn, startPointIn, endPointIn) {
if ([checkPointIn, startPointIn, endPointIn].some((point) => point === undefined)) {
console.warn('Function expects three parameters; checkPoint: Date, startPoint: Date, endPoint: Date');
return;
}
const checkPoint = new Date(checkPointIn).getTime();
const startPoint = new Date(startPointIn).getTime();
const endPoint = new Date(endPointIn).getTime();
return checkPoint > startPoint && checkPoint < endPoint;
@mmgj
mmgj / getShape.js
Last active June 8, 2018 20:13
Returns PropTypes.shape({}) for given object
export function getShape(object, depth = 1) {
const tab = ' ';
const prefix = tab;
let output = '{\n';
Object.keys(object).forEach((key) => {
const type = typeof (object[key]);
let desc = '';
if (type === 'function') {
desc = 'func';
package com.ctrloptcmd.string {
/**
* Copyright 2009 Martin Jacobsen.
*
* @langversion ActionScript 3.0
* @playerversion Flash 10.0
*
* @author Martin Jacobsen
* @since 2009-02-02