function isMobile(){ var is_mobile = false; if(navigator.userAgent.match(/android/i)){ // Android is_mobile = true; }else if(navigator.userAgent.match(/(iphone)|(ipod)|(ipad)/i)){ // Apple is_mobile = true; } return is_mobile; } function doShareSns(type, title, summary, image){ switch(type){ case 'facebook': doShareFacebook(title, summary, image); break; case 'twitter': doShareTwitter(title, summary); break; case 'kakaotalk': if(isMobile()){ doShareKakaotalk(title, summary, image); }else{ alert("ÀÌ ±â´ÉÀº ¸ð¹ÙÀÏ¿¡¼­¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù."); } break; case 'kakaostory': doShareKakaostory(title, summary, image); break; case 'pinterest': doSharePinterest(title, summary, image); break; case 'band': doShareBand(title, summary, image); break; case 'url': if(isMobile()){ alert("ÀÌ ±â´ÉÀº PC¿¡¼­¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù."); }else{ doShareURL(); } break; } } // ÆäÀ̽ººÏ °øÀ¯ function doShareFacebook(title, summary, image){ $( 'meta[name="url"]' ).attr( 'content' , encodeURIComponent(document.location.href)); $( 'meta[name="title"]' ).attr( 'content' , title); $( 'meta[name="description"]' ).attr( 'content' , summary); $( 'link[name="image_src"]' ).attr( 'content' , image); window.open("http://www.facebook.com/sharer.php?u=" + encodeURIComponent(document.location.href) + "&t=" + title, "FaceBook", "height=500, width=620, scrollbars=yes"); } // Æ®À§ÅÍ °øÀ¯ function doShareTwitter(title, summary) { var newwindow; var goUrl = 'http://twitter.com/share?'; var new_desc = title + ' - ' + summary; new_desc = new_desc.substring(0,50); var arr = []; arr.push("url=" + encodeURIComponent(document.location.href)); arr.push("text=" + encodeURIComponent(new_desc)); var url = arr.join("&"); goUrl += url; newwindow = window.open(goUrl, 'TwitterPopup', 'width=600, height=400, scrollbars=yes'); } // Ä«Ä«¿À½ºÅ丮 °øÀ¯ function doShareKakaostory(title, summary, image){ var newwindow; var goUrl = "https://story.kakao.com/share?"; summary = summary.substring(0,100); var arr = []; arr.push("url=" + encodeURIComponent(document.location.href)); arr.push("img=" + encodeURIComponent(image)); arr.push("title=" + encodeURIComponent(title)); arr.push("summary=" + encodeURIComponent(summary)); var url = arr.join("&"); goUrl += url; var w = 530; var h = 480; var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; var left = ((width / 2) - (w / 2)) + dualScreenLeft - 20; var top = ((height / 2) - (h / 2)) + dualScreenTop + 30; newwindow = window.open(goUrl, 'kakaoPopup', 'width=600, height=600, scrollbars=yes, top=' + top + ',left=' + left); } //Ä«Ä«¿À ÀÚ¹Ù½ºÅ©¸³Æ® key // Kakao.init('692446cb235a77b815a9619b6'); // Ä«Ä«¿ÀÅå - ¸ð¹ÙÀϸ¸ Áö¿ø function doShareKakaotalk(title, summary, image){ var new_desc = title + ' - ' + summary; new_desc = new_desc.substring(0,100); Kakao.Link.sendTalkLink({ label: new_desc, image: {src: image, width: '300', height: '200'}, webButton: {text: 'ÀÚ¼¼È÷ º¸·¯°¡±â',url: document.location.href} }); } // kakao share function loadKakaoTalkSDK(callback) { const script = document.createElement('script'); script.src = 'https://developers.kakao.com/sdk/js/kakao.min.js'; script.async = true; script.onload = callback; document.head.appendChild(script); } function kakaotalkShare() { Kakao.Share.createScrapButton({ container: '#share-kakao', requestUrl: window.location.href, }); } // for Mobile app function shareMessage() { Kakao.Share.sendScrap({ requestUrl: window.location.href, }); } document.addEventListener('DOMContentLoaded', function() { if (typeof Kakao === 'undefined') { loadKakaoTalkSDK(function() { Kakao.init('1fbee50dda24f083911991c7b548cdf8'); kakaotalkShare(); }); } document.getElementById('share-kakao').addEventListener('click', function() { kakaotalkShare(); }); }); // ÇÉÅÍ·¹½ºÆ® °øÀ¯ function doSharePinterest(title, summary, image){ var newwindow; var goUrl = 'http://www.pinterest.com/pin/create/bookmarklet/?'; var new_desc = title + ' - ' + summary; new_desc = new_desc.substring(0,100); var arr = []; arr.push("media=" + encodeURIComponent(image)); arr.push("is_video=false"); arr.push("url=" + encodeURIComponent(document.location.href)); arr.push("description=" + encodeURIComponent(new_desc)); var url = arr.join("&"); goUrl += url; newwindow = window.open(goUrl, 'PinterestPopup', 'width=600, height=600, scrollbars=yes'); } // ¹êµå °øÀ¯ function doShareBand(title, summary, image){ var enstr = encodeURIComponent(title); var u_str = encodeURIComponent(document.location.href); var url = "http://www.band.us/plugin/share?body="+enstr+" "+u_str; window.open(url, "share_band", "width=410, height=540, resizable=no"); //var BandshareUrl = "http://www.band.us/plugin/share?body="+encodeURIComponent(title)+"&route="+encodeURIComponent(shareUrl); //window.open(BandshareUrl, "share_band", "width=410, height=540, resizable=no"); } // URL °øÀ¯ function doShareURL() { var code; code = document.location.href; window.clipboardData.setData('Text', code); alert('URLÁÖ¼Ò¸¦ Ŭ¸³º¸µå¿¡ º¹»çÇÏ¿´½À´Ï´Ù.'); }