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
;(() => { | |
// Make sure that all forms have actual up-to-date tokens (cached forms contain old ones) | |
function refreshCSRFTokens () { | |
const token = csrfToken() | |
const param = csrfParam() | |
if (token != null && param != null) { | |
document.querySelectorAll(`form input[name="${param}"]`).forEach(input => { | |
const inputEl = input | |
inputEl.value = token |
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
# Guide to parsing: https://randombits.dev/articles/number-localization/intro | |
# Table of data: https://randombits.dev/articles/number-localization/locale-list | |
# SCRIPT to grab from table of data: | |
# | |
=begin | |
;(() => { | |
const DECIMAL_SYMBOLS = { | |
"Period": ".", // U+002E | |
"Comma": ",", // U+002C | |
"Arabic Decimal Separator": "٫", // U+066B |
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
<template component="MyComponent" store="global"> | |
<div | |
@click="(e) => console.log('Clicked on: ' + this.name)" // event listeners | |
.name={{ name }} // properties | |
name="{{ name }}" // attributes | |
> | |
Hello {{ name }} | |
</div> | |
</template> |
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
const originalFetch = window.fetch | |
window.fetch = function (url, options = {}) { | |
if (url === "http://example.net/locale") { | |
return new Response(JSON.stringify({ | |
locale: "en-US", | |
timeZone: "UTC" | |
})) | |
} else { |
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
const selection = document.getSelection() | |
if (!selection) { return } | |
let hasNode = false | |
if (typeof selection.getComposedRanges === "function") { | |
const staticRange = selection.getComposedRanges(this.contentEditableElement.getRootNode())[0] | |
if (!staticRange) { return } |
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
# test/application_system_test_case.rb | |
require "test_helper" | |
require "playwright" | |
require "fileutils" | |
class CapybaraNullDriver < Capybara::Driver::Base | |
def needs_server? | |
true | |
end | |
end |
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
/** | |
* @param {InputEvent} e | |
*/ | |
handleBeforeInput (e) { | |
// All level 2 input types: <https://w3c.github.io/input-events/#interface-InputEvent-Attributes> | |
switch (e.inputType) { | |
// insert typed plain text | |
case "insertText": | |
break; | |
// insert or replace existing text by means of a spell checker, auto-correct, writing suggestions or similar |
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
<button type="button" data-controller="refresh">Refresh</button> | |
<script type="module"> | |
import { Controller } from "@hotwired/stimulus" | |
export default class RefreshController extends Controller { | |
connect () { | |
this.element.addEventListener("click", this.sendRefresh) | |
} | |
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
<!-- Case 1 --> | |
<my-input value="foo"> | |
<template shadowrootmode="open"> | |
<input value="foo"> | |
</template> | |
</my-input> | |
<script> | |
myInput.value = "bar" | |
customElements.define("my-input", MyInput) |
NewerOlder