1import {Controller} from '@hotwired/stimulus'; 2 3// /prayers/:slug ã® canonical URL ãã³ãã¼ãã 4// data-controller="slug-url-copy" data-slug-url-copy-url-value="https://hotokami.jp/prayers/koya/" 5// data-action="click->slug-url-copy#copy" 6// data-slug-url-copy-target="label" ãæã¤è¦ç´ ã®ããã¹ããä¸æå·®ãæ¿ããã¦ãã£ã¼ããã㯠7export default class extends Controller { 8 static values = {url: String}; 9 static targets = ['label']; 10 11 copy(event) { 12 event.preventDefault(); 13 if (!this.urlValue) { 14 return; 15 } 16 17 navigator.clipboard.writeText(this.urlValue).then(() => { 18 this.flashLabel('<i class="fas fa-check mr-1"></i>ã³ãã¼ãã¾ãã'); 19 }).catch(err => { 20 console.error('clipboard write failed:', err); 21 this.flashLabel('<i class="fas fa-times mr-1"></i>ã³ãã¼ã«å¤±æãã¾ãã'); 22 }); 23 } 24 25 flashLabel(html) { 26 if (!this.hasLabelTarget) { 27 return; 28 } 29 30 // 飿ããã¦ãå ã® HTML ã失ããªããããæåã® original ã®ã¿ä¿æãã 31 if (this._flashTimer) { 32 clearTimeout(this._flashTimer); 33 } else { 34 this._originalLabel = this.labelTarget.innerHTML; 35 } 36 37 this.labelTarget.innerHTML = html; 38 this._flashTimer = setTimeout(() => { 39 this.labelTarget.innerHTML = this._originalLabel; 40 this._flashTimer = null; 41 this._originalLabel = null; 42 }, 2000); 43 } 44}
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.