PageSourceSearch

https://yuagariart.com/uag/wp/wp-content/themes/affinger/js/st-copy-text.js?ver=7.1.2

js yuagariart.com collected 2026-10-02 18:38:28 UTC 1,667 bytes, 92 lines download raw bytes

1(function (window, document, $, undefined) {
2	'use strict';
3
4	function create_$fake(text) {
5		var $fake = $('<textarea></textarea>');
6
7		$fake.css({
8			fontSize: '12pt',
9			position: 'fixed',
10			top     : '100%'
11		});
12
13		$fake.prop('readonly', true);
14
15		$fake.val(text);
16
17		return $fake;
18	}
19
20	function select($element) {
21		var element    = $element.get(0);
22		var isReadOnly = $element.prop('readonly');
23
24		if (!isReadOnly) {
25			$element.prop('readonly', true);
26		}
27
28		element.select();
29		element.setSelectionRange(0, $element.val().length);
30
31		if (!isReadOnly) {
32			$element.prop('readonly', false);
33		}
34
35		return $element.val();
36	}
37
38	function exec_copy() {
39		var succeeded;
40
41		try {
42			succeeded = document.execCommand('copy');
43		} catch (err) {
44			succeeded = false;
45		}
46
47		return succeeded;
48	}
49
50	function copy(text) {
51		var $container = $('body');
52
53		var $fake = create_$fake(text);
54
55		$container.append($fake);
56
57		select($fake);
58
59		if (!exec_copy()) {
60			return false;
61		}
62
63		window.getSelection().removeAllRanges();
64
65		$fake.remove();
66
67		return true;
68	}
69
70	function onClick(event) {
71		var $element = $(this);
72		var text     = $element.attr('data-st-copy-text');
73
74		event.preventDefault();
75
76		if (copy(text)) {
77			$element.trigger('focus');
78
79			alert('記事タイトルとURLをコピーしました');
80		} else {
81			alert('ご利用の環境はコピーに対応していません');
82		}
83	}
84
85	function onReady() {
86		$('[data-st-copy-text]').each(function (index, element) {
87			$(element).on('click', onClick);
88		});
89	}
90
91	$(onReady);
92}(window, window.document, jQuery));

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.