Skip to content

Instantly share code, notes, and snippets.

View jkcox's full-sized avatar

John Cox jkcox

  • Tempe, AZ
  • 00:25 (UTC -07:00)
View GitHub Profile
@jkcox
jkcox / form-js.html
Created February 9, 2022 19:51
Form input JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>form</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<div class="container border rounded m-3">
@jkcox
jkcox / getHeadings.js
Created June 30, 2021 22:18
Get all heading tags in console
for (var i = 0, headings = $$('h1,h2,h3,h4,h5,h6'); i < headings.length; i++) {
console.log(headings[i].textContent.trim() + " " + headings[i].tagName, headings[i]);
}
@jkcox
jkcox / apply_user_roles_webform.php
Last active June 30, 2021 22:51
Drupal 8 Webform custom module: create hook: Apply webform creator roles to webform
<?php
use Drupal\webform\WebformInterface;
function my_module_name_webform_create(WebformInterface $webform) {
$user = \Drupal::currentUser();
$roles = $user->getRoles();
//remove global roles