PageSourceSearch

https://www.inven.co.kr/common/lib/js/clipboard.js?v=cde2ed02a3fd705510eb59e9b7fd4273

js inven.co.kr collected 2026-09-24 09:02:02 UTC 15,778 bytes, 411 lines download raw bytes

1var INVEN = window.INVEN || {};
2
3INVEN.Clipboard = new (function() {
4	var module = this;
5
6	var callbackFunc = null;
7	var copyBox = null, messageBox = null;
8	var touchObj = { 'x': 0, 'y': 0, 'obj': null, 'click': null };
9
10	var isMobile = (function() {
11		if (!(typeof(navigator.platform) == 'string' && navigator.platform == 'Win32')) {
12			var ua = String(navigator.userAgent || '');
13			if ((/android/i).test(ua)) {
14				return 'android';
15			} else if ((/(ipod|iphone|ipad)/i).test(ua)) {
16				return 'ios';
17			} else if ((/mobile/i).test(ua)) {
18				return true;
19			}
20		}
21		return false;
22	})();
23
24	var hasClipboardDataObj = function(obj) {
25		return typeof(obj.clipboardData) == 'object' && typeof(obj.clipboardData.clearData) == 'function' && typeof(obj.clipboardData.setData) == 'function';
26	};
27
28	var getValue = function(value) {
29		switch (typeof(value)) {
30			case 'string':
31				return $.trim(value);
32				break;
33			case 'number':
34				return String(value);
35				break;
36			default:
37				return '';
38				break;
39		}
40	};
41
42	$(document).on('mouseup.InvenClipboard touchend.InvenClipboard', function(e) {
43		touchObj.x = e.pageX;
44		touchObj.y = e.pageY;
45		touchObj.obj = (e.target && e.target.tagName != 'HTML' && e.target.tagName != 'BODY') ? $(e.target) : null;
46	});
47
48	if (hasClipboardDataObj(window)) {
49		// 구버전 IE
50		this.copy = async function(value, callback) {
51			if (checkClickObject(window.event)) {
52				callbackFunc = typeof(callback) == 'function' ? callback : null;
53				var copy = getValue(value);
54				var success = false;
55				try {
56					await navigator.clipboard.writeText(copy);
57					success = true;
58				} catch (err) {
59					try {
60						window.clipboardData.clearData();
61						success = window.clipboardData.setData('text', copy);
62					} catch(r) {
63						success = false;
64					}
65				}
66				callbackResult(success, copy);
67			}
68		};
69	} else if (!document.queryCommandSupported('copy')) {
70		// 복사 지원 안함
71		this.copy = async function(value, callback) {
72			callbackFunc = typeof(callback) == 'function' ? callback : null;
73			var success = false;
74			value = getValue(value);
75			try {
76				await navigator.clipboard.writeText(value);
77				success = true;
78			} catch (ex) {}
79			callbackResult(success, value);
80		}
81	} else if (isMobile == 'ios') {
82		// iOS
83		this.copy = async function(value, callback) {
84			callbackFunc = typeof(callback) == 'function' ? callback : null;
85			var copy = getValue(value);
86			try {
87				await navigator.clipboard.writeText(copy);
88			} catch (ex) {
89				var textarea = document.createElement('TEXTAREA');
90				textarea.style.width = textarea.style.height = '1px';
91				textarea.style.padding = textarea.style.margin = '0px';
92				textarea.style.position = 'absolute';
93				textarea.style.left = touchObj.x + 'px';
94				textarea.style.top = document.body.scrollTop + 'px';
95				textarea.style.opacity = 0;
96				textarea.contentEditable = true;
97				textarea.readOnly = false;
98				textarea.value = copy;
99				document.body.appendChild(textarea);
100				var range = document.createRange();
101				range.selectNodeContents(textarea);
102				var sel = window.getSelection();
103				sel.removeAllRanges();
104				sel.addRange(range);
105				textarea.setSelectionRange(0, copy.length);
106				textarea.contentEditable = false;
107				textarea.readOnly = true;
108				document.execCommand('copy');
109				textarea.blur();
110				textarea.parentNode.removeChild(textarea);
111			}
112			callbackResult(true, copy);
113		};
114	} else {
115		this.copy = (function() {
116			var copy = null, copyTimeout = null, firstTry = true;
117
118			var clear = function() {
119				var copied = copy;
120				copy = null;
121				$(document).off('copy.InvenClipboard');
122				if (copyTimeout) {
123					clearTimeout(copyTimeout);
124					copyTimeout = null;
125				}
126				return copied;
127			};
128
129			var oncopy = function(e) {
130				var copied = clear();
131				if (copied !== null) {
132					var success = false;
133					e.preventDefault();
134					if (hasClipboardDataObj(e.originalEvent)) {
135						try {
136							e.originalEvent.clipboardData.clearData();	// 엣지는 간혹 첫 복사가 실패할때가 있는데.. -_-
137							e.originalEvent.clipboardData.setData('text/plain', copied);
138							success = true;
139						} catch(r) {
140							if (firstTry) {
141								firstTry = false;
142								return false;
143							}
144						}
145					}
146					callbackResult(success, copied);
147					return false;
148				}
149			}
150
151			return async function(value, callback) {
152				if (copy === null && checkClickObject(window.event)) {
153					clear();
154					callbackFunc = typeof(callback) == 'function' ? callback : null;
155					copy = getValue(value);
156					try {
157						await navigator.clipboard.writeText(copy);
158						callbackResult(true, clear());
159					} catch (ex) {
160						copyTimeout = setTimeout(function() {
161							if (copy !== null) callbackResult(false, clear());
162						}, 100);
163						$(document).on('copy.InvenClipboard', oncopy);
164						document.execCommand('copy');
165					}
166				}
167			};
168		})();
169	}
170
171	var checkClickObject = function(oe) {
172		if (typeof(oe) == 'object' && oe && oe.type == 'click' && oe.srcElement) {
173			touchObj.click = $(oe.srcElement);
174			if (copyBox && copyBox._obj && copyBox._obj[0] === oe.srcElement) {
175				showCopyBox(null);
176				return false;
177			}
178		}
179		return true;
180	};
181
182	var callbackResult = function(success, copied) {
183		const hostname = window.location.hostname;
184		const firstPathname = window.location.pathname.replace(/^\/|\/$/g, '').split('/')[0];
185		const enCheck = [
186			{'host': 'gamefi.inven.co.kr', 'path': 'en'}
187		];
188		let message ='클립보드에 복사되었습니다.';
189		let enMessage = 'Copied to Clipboard.';
190
191		if(enCheck.filter(x => x.host == hostname && x.path == firstPathname).length==1){
192			message=enMessage
193		};
194		
195		if (copied.length > 0) {
196			if (typeof(callbackFunc) == 'function') {
197				try {
198					if (callbackFunc(success, copied) === false) return;
199				} catch(r) {}
200			}
201			if (success) {
202				showMessage(message);
203				
204			} else {
205				// 복사 UI 출력
206				showCopyBox(copied);
207			}
208		}
209	};
210
211	var getSmartWindowPosition = function(x, y, width, height, offsetX, offsetY) {
212		x = (typeof(x) == 'number' && !isNaN(x)) ? x : 0;
213		y = (typeof(y) == 'number' && !isNaN(y)) ? y : 0;
214		width = (typeof(width) == 'number' && !isNaN(width)) ? width : 0;
215		height = (typeof(height) == 'number' && !isNaN(height)) ? height : 0;
216		offsetX = (typeof(offsetX) == 'number' && !isNaN(offsetX)) ? offsetX : 5;
217		offsetY = (typeof(offsetY) == 'number' && !isNaN(offsetY)) ? offsetY : 5;
218		var win = $(window);
219		var body = $('body');
220		var winWidth = win.width(), winHeight = win.height();
221		var px = x + offsetX, py = y + offsetY;
222		if (width >= 200 && winWidth < 415) {
223			px = Math.max(winWidth / 2 - width / 2, 0) + body[0].scrollLeft;
224		} else if ((px + width) > (winWidth + body[0].scrollLeft)) {
225			px = Math.max(x - width, body[0].scrollLeft);
226		}
227		if ((py + height) > (winHeight + body[0].scrollTop)) {
228			py = Math.max(py - offsetY * 1.5 - height, body[0].scrollTop);
229			if (py == body[0].scrollTop && height >= 300 && winWidth < 415) {
230				py = Math.max(winHeight / 2 - height / 2, 0) + body[0].scrollTop;
231			}
232		}
233		return { 'left': Math.floor(px), 'top': Math.floor(py) };
234	};
235
236	var showCopyBox = function(text) {
237		if (!text) {
238			if (copyBox) {
239				copyBox._obj = null;
240				if (copyBox._value[0].setSelectionRange) copyBox._value[0].setSelectionRange(0, 0);
241				copyBox.css('display', 'none')._value.off('copy.InvenClipboard');
242				$('html').off('mousedown.InvenClipboard');
243			}
244			return;
245		} else if (!copyBox || $('#InvenClipboardCopyBox').length == 0) {
246			var preventDefault = function(e) {
247				e.preventDefault();
248				return false;
249			};
250			copyBox = $('<div id="InvenClipboardCopyBox" style="display: block; float: none; clear: both; position: absolute; z-index: 10; width: 240px; padding: 5px; margin: 0px; overflow: hidden; border: 1px solid #aaa; border-radius: 3px; box-sizing: content-box; box-shadow: rgba(0, 0, 0, 0.2) 0px 4px 8px 0px, rgba(0, 0, 0, 0.188235) 0px 6px 20px 0px; color: #333; font-size: 14px; background: #f0f0f0; background-image: -webkit-gradient(linear,left top,left bottom,from(#e0e0e0),to(#f0f0f0)); background-image: -moz-linear-gradient(top,#e0e0e0 0%,#f0f0f0 100%); background-image: -o-linear-gradient(top,#e0e0e0 0%,#f0f0f0 100%); background-image: -ms-linear-gradient(top,#e0e0e0 0%,#f0f0f0 100%); background-image: linear-gradient(to bottom,#e0e0e0 0%,#f0f0f0 100%); font-family: gulim, 굴림; font-weight: normal; font-style: normal;"></div>').appendTo('body').on('click', function() {
251				copyBox._value.blur().focus();
252			});
253			copyBox._text = $('<div style="display:block; float: none; clear: both; font-weight: bold; margin-bottom: 4px;"></div>').appendTo(copyBox).on('selectstart dragstart', preventDefault);
254			$('<span style="display:block; position: absolute; top: 5px; right: 5px; cursor: pointer;">Ⅹ</span>').appendTo(copyBox).on('click', function() {
255				showCopyBox(null);
256			}).on('selectstart dragstart', preventDefault);
257			var holder = $('<div style="display: block; float: none; clear: both; width: 100%; height: 30px; box-sizing: border-box; border: 1px solid #aaa; overflow: hidden; background-color: #fff; color: #333; font-size: 12px;"></div>').appendTo(copyBox);
258			var textStyle = 'display: block; float: none; clear: both; width: 100%; height: 100%; line-height: 30px; box-sizing: border-box; margin: 0px; padding: 0px 4px; background-color: #fff; color: #333; font-size: 12px; font-family: gulim, 굴림; font-weight: normal; font-style: normal; text-decoration: none; overflow: hidden;';
259			copyBox._value = $('<textarea readonly style="' + textStyle + ' resize: none; border: none; outline: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; "></textarea>').appendTo(holder).on('focus focusin', function() {
260				if (copyBox._value.is(':visible')) {
261					if (isMobile == 'ios') {
262						var range = document.createRange();
263						range.selectNodeContents(copyBox._value[0]);
264						var sel = window.getSelection();
265						sel.removeAllRanges();
266						sel.addRange(range);
267						copyBox._value[0].setSelectionRange(0, copyBox._value.val().length);
268					} else {
269						copyBox._value.select();
270					}
271				}
272			}).on('click', function(e) {
273				if (copyBox._value.is(':visible')) {
274					copyBox._value.blur();
275					setTimeout(function() {
276						copyBox._value.focus();
277					}, 0);
278				}
279			});
280			copyBox._url = $('<a style="' + textStyle + '"></a>').appendTo(holder).on('click selectstart dragstart', preventDefault);
281		}
282		$('html').off('mousedown.InvenClipboard').on('mousedown.InvenClipboard', function(e) {
283			if (copyBox && e.target !== copyBox[0] && copyBox.find(e.target).length == 0) {
284				if (!(copyBox._obj && copyBox._obj[0] == e.target)) showCopyBox(null);
285			}
286		});
287		if ((/^http[s]?:\/\/[^\r\n\s\t]+$/).test(text) && (isMobile == 'android' || isMobile == 'ios')) {
288			copyBox._text.html('아래 내용을 길게 눌러 나오는<br>메뉴에서 복사하기를 선택해주세요.');
289			copyBox._value.val(text).css('display', 'none').off('copy.InvenClipboard');
290			copyBox._url.attr('href', text).text(text).css('display', 'block');
291		} else {
292			if (isMobile) {
293				copyBox._text.html('아래 내용을 복사해주세요.');
294			} else {
295				copyBox._text.html('CTRL+C 키를 눌러<br>아래 내용을 복사해주세요.');
296			}
297			copyBox._value.blur().val(text).css('display', 'block').focus().off('copy.InvenClipboard').on('copy.InvenClipboard', function(e) {
298				if (typeof(this.selectionStart) == 'number') {
299					if (Math.min(this.selectionStart, this.selectionEnd) === 0 && Math.max(this.selectionStart, this.selectionEnd) === this.value.length) {
300						copyBox._value.off('copy.InvenClipboard');
301						showCopyBox(null);
302						setTimeout(function() {
303							showMessage('클립보드에 복사되었습니다.');
304						}, 1);
305					}
306				}
307			})
308			copyBox._url.css('display', 'none');
309		}
310		copyBox.css({ 'display': 'block', 'left': '-1000px', 'top': '-1000px' })._obj = touchObj.obj;
311		var pos = getSmartWindowPosition(touchObj.x, touchObj.y, copyBox.outerWidth(), copyBox.outerHeight(), 5, 5);
312		copyBox.css({ 'left': pos.left+'px', 'top': pos.top+'px' });
313	};
314
315	var availableMessage = null;
316
317	this.availableMessage = function() {
318		if (availableMessage === null) {
319			availableMessage = false;
320			var tester = $('<div style="position: fixed; z-index: 10000; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); transform: translate(-50%, -50%); display: none; float: none; clear: both; background-color: #000; background-color: rgba(0, 0, 0, 0.75); color: #fff; border-radius: 8px; padding: 12px 8px; font-size: 14px; text-align: center;"></div>');
321			try {
322				var s = tester[0].style;
323				if (s.position == 'fixed' && (s.transformProperty || s.WebkitTransform || s.MozTransform || s.OTransform || s.msTransform)) {
324					availableMessage = true;
325				}
326			} catch(r) {}
327		}
328		return availableMessage;
329	};
330
331	var showMessage = function(msg) {
332		msg = String(msg);
333		if ($.trim(msg).length > 0) {
334			if (module.availableMessage()) {
335				if (messageBox === null) messageBox = $('<div style="position: fixed; z-index: 10000; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); transform: translate(-50%, -50%); display: none; float: none; clear: both; background-color: #000; background-color: rgba(0, 0, 0, 0.75); color: #fff; border-radius: 8px; padding: 12px 8px; font-size: 14px; text-align: center;"></div>').appendTo('body');
336				messageBox.text(msg).css('display', 'block').stop().css('opacity', 1).delay(2000).fadeOut(1000);
337			} else {
338				setTimeout(function() {
339					alert(msg);
340				}, 0);
341			}
342		}
343	};
344
345	// ZeroClipboard를 이용했던 구버전 지원
346	(function(core, enable) {
347		if (!enable) return;
348		var hasZeroClipboard = $.isPlainObject(window.ZeroClipboard) ? 2 : 0;
349		var client = null;
350		var classNames = [], processedClassNames = [];
351
352		var scriptOnLoad = function() {
353			if ($.isPlainObject(window.ZeroClipboard)) {
354				hasZeroClipboard = 3;
355				window.ZeroClipboard.setMoviePath('https://www.inven.co.kr/common/lib/js/framework/ZeroClipboard10.swf');
356				client = new ZeroClipboard.Client();
357				client.setHandCursor(true);
358				process();
359			}
360		};
361
362		var process = function() {
363			if (client) {
364				for (var i = 0; i < classNames.length; i++) {
365					if ($.inArray(classNames[i], processedClassNames) == -1) {
366						processedClassNames.push(classNames[i]);
367						$('div.' + classNames[i]).on('mouseover', onMouseOver);
368					}
369				}
370			}
371		};
372
373		var onMouseOver = function() {
374			if (typeof(this.clipdata) == 'string' || typeof(this.clipdata) == 'number') {
375				client.setText(this.clipdata);
376				if (client.div) {
377					client.receiveEvent('mouseout', null);
378					client.reposition(this);
379				} else {
380					client.glue(this);
381				}
382				client.receiveEvent('mouseover', null);
383			}
384		};
385
386		core.object = function() {
387			this.init = function(className) {
388				if (typeof(className) == 'string' && $.trim(className).length > 0 && $.inArray(className, classNames) == -1) {
389					classNames.push(className);
390					process();
391				}
392			};
393		};
394
395		core.create = function() {
396			if (hasZeroClipboard == 2) {
397				scriptOnLoad();
398			} else if (hasZeroClipboard === 0) {
399				hasZeroClipboard = 1;
400				try {
401					var script = document.createElement('SCRIPT');
402					script.type = 'text/javascript';
403					script.src = 'https://www.inven.co.kr/common/lib/js/framework/ZeroClipboard.js';
404					script.onload = scriptOnLoad;
405					(document.head || document.getElementsByTagName('HEAD')[0]).appendChild(script);
406				} catch(r) {}
407			}
408			return new core.object();
409		};
410	})(this, true);
411})();

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.