1import { Controller } from '@hotwired/stimulus' 2 3/* global document */ 4 5// Cookie name is shared with the read side in 6// SharedBlocks::MainContent::Organized::Component#pos_callout_dismissed? 7const COOKIE_NAME = 'dismissed_pos_callout_organization_ids' 8const COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 365 9 10// Connects to data-controller='org--pos-callout' 11export default class extends Controller { 12 static values = { organizationId: Number } 13 14 dismissForever () { 15 this.persist() 16 this.hide() 17 } 18 19 hide () { 20 this.element.classList.add('tw:hidden') 21 } 22 23 persist () { 24 const ids = new Set(this.storedIds) 25 ids.add(String(this.organizationIdValue)) 26 document.cookie = `${COOKIE_NAME}=${[...ids].join(',')}; path=/; max-age=${COOKIE_MAX_AGE_SECONDS}; samesite=lax` 27 } 28 29 get storedIds () { 30 const match = document.cookie.match(new RegExp(`(?:^|; )${COOKIE_NAME}=([^;]*)`)) 31 return match ? decodeURIComponent(match[1]).split(',').filter(Boolean) : [] 32 } 33};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.