미디어위키:Common.js: 두 판 사이의 차이
Resultofunion (토론 | 기여) 편집 요약 없음 |
Resultofunion (토론 | 기여) 편집 요약 없음 |
||
| 16번째 줄: | 16번째 줄: | ||
gtag('js', new Date()); | gtag('js', new Date()); | ||
gtag('config', 'G-YGT3D2Q9QW'); | gtag('config', 'G-YGT3D2Q9QW'); | ||
/* TOP 버튼 */ | /* TOP 버튼 */ | ||
| 54번째 줄: | 52번째 줄: | ||
}); | }); | ||
} | } | ||
} | } | ||
| 109번째 줄: | 106번째 줄: | ||
elem.classList.add('a2a_button_' + shares[i].toLowerCase()); | elem.classList.add('a2a_button_' + shares[i].toLowerCase()); | ||
} | } | ||
document.querySelector('[title="Share on KakaoTalk"] a').href = ' | document.querySelector('[title="Share on KakaoTalk"] a').href = '#'; | ||
document.querySelector('[title="Share on KakaoTalk"] a').removeAttribute('target'); | document.querySelector('[title="Share on KakaoTalk"] a').removeAttribute('target'); | ||
| 119번째 줄: | 116번째 줄: | ||
document.body.appendChild(kakao_cdn); | document.body.appendChild(kakao_cdn); | ||
window. | // 페이지 로딩 이후 초기화해야할 내용 정의 | ||
initScript(); | |||
function initScript() { | |||
var retry = false; | |||
// 카카오 링크 초기화 | |||
if (window.initKakaoLink != true) { | |||
}); | var $kakao = document.querySelector('[title="Share on KakaoTalk"]'); | ||
} | if (window.Kakao && $kakao) { | ||
// 사용할 앱의 JavaScript 키를 설정해 주세요. | |||
Kakao.init('5bbf33cb4d93dd3d2100996872cf8e44'); | |||
$kakao.children[0].style.display = 'inline'; | |||
}; | $kakao.onclick = function () { | ||
// 카카오 Link 공유 API 사용 | |||
Kakao.Link.sendScrap({ | |||
requestUrl: location.href, | |||
}); | |||
}; | |||
window.initKakaoLink = true; | |||
} else retry = true; | |||
} | |||
// 링크 복사 초기화 | |||
if (window.initCopyLink != true) { | |||
var $copy = document.querySelector('.wikishare_button_Copy'); | |||
if ($copy) { | |||
$copy.style.display = 'inline'; | |||
$copy.addEventListener('click', function (e) { | |||
copyStringToClipboard(location.href); | |||
alert('링크를 클립보드에 저장했습니다.'); | |||
e.preventDefault(); | |||
}); | |||
window.initCopyLink = true; | |||
} else retry = true; | |||
} | |||
// 애널리틱스 | |||
if (window.initWcs != true) { | |||
if (window.wcs) { | |||
wcs_do(); | |||
window.initWcs = true; | |||
} else retry = true; | |||
} | |||
if (retry) setTimeout(initScript, 300); | |||
} | |||
} | |||
// 문자열을 클립보드에 저장 | |||
function copyStringToClipboard(str) { | |||
var el = document.createElement('textarea'); | |||
el.value = str; | |||
el.setAttribute('readonly', ''); | |||
el.style = { position: 'absolute', left: '-9999px' }; | |||
document.body.appendChild(el); | |||
el.select(); | |||
document.execCommand('copy'); | |||
document.body.removeChild(el); | |||
} | } | ||