-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkko.min.js
More file actions
28 lines (27 loc) · 12.4 KB
/
kko.min.js
File metadata and controls
28 lines (27 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(function(b){b=b.userAgent=function(b){function r(a){var d={};a=a?a.split(/\.|-|_/):["0","0","0"];d.info=a.join(".");d.major=a[0]||"0";d.minor=a[1]||"0";d.patch=a[2]||"0";return d}b=(b||window.navigator.userAgent).toString().toLowerCase();return{ua:b,browser:function(a){var d={},b=/(dolfin)[ \/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(webkit)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||0>a.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||
["","unknown"];"webkit"===b[1]?b=/(iphone|ipad|ipod)[\S\s]*os ([\w._\-]+) like/.exec(a)||/(android)[ \/]([\w._\-]+);/.exec(a)||[b[0],"safari",b[2]]:"mozilla"===b[1]?/trident/.test(a)?b[1]="msie":b[1]="firefox":/polaris|natebrowser|([010|011|016|017|018|019]{3}\d{3,4}\d{4}$)/.test(a)&&(b[1]="polaris");d[b[1]]=!0;d.name=b[1];d.version=r(b[2]);return d}(b),platform:function(a){var b;b=a.match(/linux|windows (nt|98)|macintosh/)&&!a.match(/android|mobile|polaris|lgtelecom|uzard|natebrowser|ktf;|skt;/)?
!0:!1;if(b)return"pc";b=a.match(/ipad/)||a.match(/android/)&&!a.match(/mobi|mini|fennec/)?!0:!1;if(b)return"tablet";a=a.match(/ip(hone|od)|android.+mobile|windows (ce|phone)|blackberry|bb10|symbian|webos|firefox.+fennec|opera m(ob|in)i|polaris|iemobile|lgtelecom|nokia|sonyericsson|dolfin|uzard|natebrowser|ktf;|skt;/)?!0:!1;return a?"mobile":""}(b),os:function(a){var b={};a=/(iphone|ipad|ipod)[\S\s]*os ([\w._\-]+) like/.exec(a)||/(android)[ \/]([\w._\-]+);/.exec(a)||(/android/.test(a)?["","android",
"0.0.0"]:!1)||(/polaris|natebrowser|([010|011|016|017|018|019]{3}\d{3,4}\d{4}$)/.test(a)?["","polaris","0.0.0"]:!1)||/(windows)(?: nt | phone(?: os){0,1} | )([\w._\-]+)/.exec(a)||(/(windows)/.test(a)?["","windows","0.0.0"]:!1)||/(mac) os x ([\w._\-]+)/.exec(a)||(/(linux)/.test(a)?["","linux","0.0.0"]:!1)||(/webos/.test(a)?["","webos","0.0.0"]:!1)||/(bada)[ \/]([\w._\-]+)/.exec(a)||(/bada/.test(a)?["","bada","0.0.0"]:!1)||(/(rim|blackberry|bb10)/.test(a)?["","blackberry","0.0.0"]:!1)||["","unknown",
"0.0.0"];"iphone"===a[1]||"ipad"===a[1]||"ipod"===a[1]?a[1]="ios":"windows"===a[1]&&"98"===a[2]&&(a[2]="0.98.0");b[a[1]]=!0;b.name=a[1];b.version=r(a[2]);return b}(b),app:function(a){var b={};a=/(crios)[ \/]([\w.]+)/.exec(a)||/(daumapps)[ \/]([\w.]+)/.exec(a)||["",""];a[1]?(b.isApp=!0,b.name=a[1],b.version=r(a[2])):b.isApp=!1;return b}(b)}};"object"===typeof window&&window.navigator.userAgent&&(window.ua_result=b(window.navigator.userAgent)||null);window&&(window.util=window.util||{},window.util.userAgent=
b)})(function(){if("object"===typeof exports)return exports.daumtools="undefined"===typeof exports.daumtools?{}:exports.daumtools,exports.daumtools;if("object"===typeof window)return window.daumtools="undefined"===typeof window.daumtools?{}:window.daumtools,window.daumtools}());
(function(b){b.web2app=function(){function b(a){window.location.href=a}function r(b,h,e){a(300,h,e);q(b)}function a(a,b,e){var q=(new Date).getTime();return setTimeout(function(){var d=(new Date).getTime();z()&&d-q<a+100&&e(b)},a)}function d(a){setTimeout(function(){top.location.href=a},100)}function x(p,h,d){8>parseInt(e.os.version.major,10)?(h=a(2E3,h,d),v(h)):(h=b===d?a(1E3,h,d):a(2E3,h,d),C(h));q(p)}function v(a){window.addEventListener("pagehide",function w(){z()&&(clearTimeout(a),window.removeEventListener("pagehide",
w))})}function C(a){document.addEventListener("visibilitychange",function w(){z()&&(clearTimeout(a),document.removeEventListener("visibilitychange",w))})}function z(){for(var a=["hidden","webkitHidden"],b=0,e=a.length;b<e;b++)if("undefined"!==document[a[b]])return!document[a[b]];return!0}function q(a){setTimeout(function(){var b=document.createElement("iframe");b.id="appLauncher";b.style.border="none";b.style.width="0";b.style.height="0";b.style.display="none";b.style.overflow="hidden";document.body.appendChild(b);
b.src=a},100)}var e=daumtools.userAgent(),B=e.os,y=["firefox","opr"];return function(a){var q="function"===typeof a.onAppMissing?a.onAppMissing:b,z="function"===typeof a.onUnsupportedEnvironment?a.onUnsupportedEnvironment:function(){};("function"===typeof a.willInvokeApp?a.willInvokeApp:function(){})();B.android?(new RegExp(y.join("|"),"i")).test(e.ua)||a.useUrlScheme?a.storeURL&&r(a.urlScheme,a.storeURL,q):a.intentURI&&d(a.intentURI):B.ios&&a.storeURL?x(a.urlScheme,a.storeURL,q):setTimeout(function(){z()},
100)}}()})(window.daumtools="undefined"===typeof window.daumtools?{}:window.daumtools);(function(b){b.daumtools="undefined"===typeof b.daumtools?{}:b.daumtools;"undefined"!==typeof b.daumtools.web2app&&(b.daumtools.web2app.version="1.0.4")})(window);
(function(b){var A=[];"function"!==typeof window.CustomEvent&&(window.CustomEvent=function(a,b){var d;A.push(a);if("function"===typeof document.createEvent)return d=document.createEvent("CustomEvent"),d.initCustomEvent(a,!(!b||!b.bubbles),!(!b||!b.cancelable),b?b.details:null),d;document.documentElement["eventProperty"+a]=!1});var r=function(a,b){var d={},e={},r="function"===typeof document.addEventListener,y=function(a,b){"function"===typeof document.dispatchEvent?document.dispatchEvent(a):document.documentElement["eventProperty"+
b]=!0},p=function(a,b,l){if(!0===r)a.addEventListener(b,l);else{if("load"===b)b="onreadystatechange";else if(-1===A.indexOf(b))b="on"+b;else return document.documentElement.attachEvent("onpropertychange",function(){!0===document.documentElement["eventProperty"+b]&&l.call(null)});a.attachEvent(b,l)}},h=new CustomEvent("init"),w=new CustomEvent("login"),x=new CustomEvent("sdkReady");p(document,"init",function(){});var v=function(a){Kakao.init(a);y(h,"init")};d.init=function(a){if(window.Kakao)v(a);
else{var b=document.getElementsByTagName("body")[0],l=document.createElement("script");l.src="https://developers.kakao.com/sdk/js/kakao.min.js";p(l,"load",function(){y(x,"sdkEmit");!0===r?v(a):"loaded"!==l.readyState&&"complete"!==l.readyState||v(a)});void 0===b?p(document,"load",function(){b=document.getElementsByTagName("body")[0];b.insertBefore(l,b.lastChild)}):b.insertBefore(l,b.lastChild)}};d.on=function(a,b){p(document,a,b)};d.login=function(a,b){Kakao.Auth.login({success:function(b){Kakao.Auth.getStatus(function(b){e=
b;Kakao.API.request({url:"/v1/api/story/isstoryuser"}).then(function(a){e.isStoryUser=a.isStoryUser;if(e.isStoryUser)return Kakao.API.request({url:"/v1/api/story/profile"})}).then(function(g){e.kakaoStoryProfile=g;e.status="connected";"undefined"!==typeof a?(y(w,"login"),a.call(null,b)):(w.userProfile=b,y(w,"login"))})})},fail:function(a){"undefined"!==typeof b&&b.call(null,a)}})};d.logout=function(a){Kakao.Auth.logout(function(b){e.status=!1;"undefined"!==typeof a&&a.call(null,b)})};d.getInfo={status:function(){return"connected"===
e.status?!0:!1},me:function(){if("connected"===e.status&&e.user){var a={};a.id=e.user.id;a.iskakaoStoryUser=e.isStoryUser;a.kakaoStoryUser&&void 0!==e.kakaoStoryProfile&&(a.kakaoStoryProfile=e.kakaoStoryProfile);Object.keys(e.user.properties).map(function(b){a[b]=e.user.properties[b]});return a}return!1}};d.talk={sendLink:function(a){void 0!==a.image&&(a.image.width=a.image.width||"400",a.image.height=a.image.height||"300");Kakao.Link.sendTalkLink(a)}};d.story={sendLink:function(a,b,l,c){Kakao.Auth.login({success:function(){Kakao.API.request({url:"/v1/api/story/linkinfo",
data:{url:a}}).then(function(a){var c={};c.link_info=a;void 0!==b&&(c.content=b);return Kakao.API.request({url:"/v1/api/story/post/link",data:c})}).then(function(a){return Kakao.API.request({url:"/v1/api/story/mystory",data:{id:a.id}})}).then(function(a){l.call(null,a)})},fail:function(a){c.call(null,a)}})},openSharer:function(a,b){Kakao.Story.share({url:a,text:b})},openApp:function(d,e,l,c){var g={};g.appId=d;g.apiver="1.0";g.post=c&&!0===urlFist?e+" "+l:l+" "+e;d=[];for(var m in g)g.hasOwnProperty(m)&&
d.push(m+"="+encodeURIComponent(g[m]));g="storylink://posting?"+d.join("&");m="intent:"+g+"#Intent;package=com.kakao.story;end;";d=a().os.android?"market://details?id=com.kakao.story":"http://itunes.apple.com/app/id486244601";b({urlScheme:g,intentURI:m,storeURL:d,appName:"KakaoStory"})},getStory:function(a,b,d){var c,g,e={};if("function"===typeof a)c=a,g=b,e.url="/v1/api/story/mystories";else if("string"===typeof a)c=b,g=d,e.url="/v1/api/story/mystory",e.data={id:a};else return{error:"invaild parameters"};
Kakao.Auth.login({success:function(){Kakao.API.request(e).then(function(a){"undefined"!==typeof c&&c.call(null,a)})},fail:function(a){"undefined"!==typeof g&&g.call(null,a)}})},getStoriesBefore:function(a,b,d){Kakao.Auth.login({success:function(){Kakao.API.request({url:"/v1/api/story/mystories",data:{last_id:a}}).then(function(a){"undefined"!==typeof b&&b.call(null,a)})},fail:function(a){"undefined"!==typeof d&&d.call(null,a)}})},followStory:function(a,b,d,c){d=d||!0;c=c||"horizontal";var g=function(){Kakao.Story.createFollowButton({container:a,
id:b,showFollowerCount:d,type:c})};"undefined"!==typeof window.Kakao?g():p(document,"init",g)}};var t=function(a,b,d,c){a.style.width=b+"px";a.style.height=d+"px";a.style.backgroundImage="url('"+c+"')"};p(window,"load",function(){for(var a=document.getElementsByClassName("kko-login-button"),b=function(){return function(){d.login()}},e=0,c;c=a[e];e++){var g=c.getAttribute("data-lang"),m=c.getAttribute("data-text"),k=c.getAttribute("data-size"),f="https://developers.kakao.com/assets/img/about/logos/login/";
c.style.backgroundColor="transparent";c.style.backgroundRepeat="no-repeat";c.style.border="none";c.style.cursor="pointer";"kr"===g?f+="kr/":"en"===g&&(f+="en/");"short"===m?(f+="kakao_login_btn_","small"===k?(f+="small.png",t(c,70,31,f)):"medium"===k?(f+="medium.png",t(c,121,49,f)):"large"===k&&(f+="large.png",t(c,249,98,f))):"long"===m&&(f+="kakao_account_login_btn_","medium-narrow"===k?(f+="medium_narrow.png",t(c,222,49,f)):"medium-wide"===k?(f+="medium_wide.png",t(c,300,49,f)):"large-narrow"===
k?(f+="large_narrow.png",t(c,452,98,f)):"large-wide"===k&&(f+="large_wide.png",t(c,600,98,f)));g=b();p(c,"click",g)}});p(window,"load",function(){for(var a=document.getElementsByClassName("kko-talk-link-button"),b=function(a){return function(){Kakao.Link.sendTalkLink(a)}},d=0,c;c=a[d];d++){var g=c.getAttribute("data-label"),e=c.getAttribute("data-src"),k=c.getAttribute("data-width"),f=c.getAttribute("data-height"),h=c.getAttribute("data-text"),n=c.getAttribute("data-url"),r=c.getAttribute("data-size"),
q="https://developers.kakao.com/assets/img/about/logos/kakaolink/kakaolink_btn_",u={};c.style.backgroundColor="transparent";c.style.backgroundRepeat="no-repeat";c.style.border="none";c.style.cursor="pointer";u.label=g;e&&(u.image={},u.image.src=e,u.image.width=k||"400",u.image.height=f||"300");if(h||n)u.webButton={},h&&(u.webButton.text=h),n&&(u.webButton.url=n);"small"===r?(q+="small.png",t(c,34,35,q)):"medium"===r&&(q+="medium.png",t(c,68,69,q));g=b(u);p(c,"click",g);g=null}});p(window,"load",function(){for(var a=
document.getElementsByClassName("kko-story-share-button"),b=function(a,b){return function(){d.story.openSharer(a,b)}},e=0,c;c=a[e];e++){var g=c.getAttribute("data-url"),m=c.getAttribute("data-type"),k=c.getAttribute("data-size"),f=0,h=c.getAttribute("data-text"),n="https://developers.kakao.com/assets/img/about/buttons/kakaostory/button/",g=b(g,h);if("logotype_kr"===m||"logotype_en"===m)switch(n+="logotype/","logotype_kr"===m?n+="kr/story_logotype_kr_"+k+".png":"logotype_en"===m&&(n+="en/story_logotype_en_"+
k+".png"),k){case "64":f=222;break;case "96":f=333;break;case "128":f=444;break;case "256":f=888}else if("icon_text"===m)switch(n+="icon_text/story_icon_text_"+k+".png",k){case "64":f=338;break;case "96":f=507;break;case "128":f=676;break;case "256":f=1352}else"web"===m&&(n+="web/kakaostory_web_56x20.png",k=20,f=56);c.style.backgroundColor="transparent";c.style.backgroundRepeat="no-repeat";c.style.border="none";c.style.cursor="pointer";t(c,f,parseInt(k),n);p(c,"click",g);g=null}});p(window,"load",
function(){for(var a=document.getElementsByClassName("kko-follow-story"),b=0,e;e=a[b];b++){var c=e.getAttribute("data-story"),g=e.getAttribute("data-counter")||!0,h=e.getAttribute("data-type")||"horizontal";e=e.getAttribute("id");"true"===g?g=!0:"false"===g&&(g=!1);d.story.followStory("#"+e,c,g,h)}});return d}(x,v),a=function(a){a=a.join(", ");throw"dependency error: module not found("+a+")";},d=[],x=void 0!==b.daumtools.userAgent?b.daumtools.userAgent:null,v=void 0!==b.daumtools.web2app?b.daumtools.web2app:
null;null===x&&d.push("userAgent");null===v&&d.push("web2app");0<d.length&&a(d);"function"===typeof define&&define.amd?define(["kko","userAgent","web2app","exports"],function(a,b,d,e){e.kko=a}):b.kko=r})(window);
//@ sourceMappingURL=./kko.min.map