1/* 2 Copyright 2012 KAKAO 3 */ 4 5(function (window, undefined) { 6 var kakao = {}; 7 window.kakao = window.kakao || kakao; 8 9 var uagent = navigator.userAgent.toLocaleLowerCase(); 10 if (uagent.search("android") > -1) { 11 kakao.os = "android"; 12 if (uagent.search("chrome") > -1) { 13 kakao.browser = "android+chrome"; 14 } 15 } else if (uagent.search("iphone") > -1 || uagent.search("ipod") > -1 || uagent.search("ipad") > -1) { 16 kakao.os = "ios"; 17 } 18 19 var app = { 20 talk: { 21 base_url: "kakaolink://sendurl?", 22 apiver: "2.0.1", 23 store: { 24 android: "market://details?id=com.kakao.talk", 25 ios: "http://itunes.apple.com/app/id362057947" 26 }, 27 package: "com.kakao.talk" 28 }, 29 story: { 30 base_url: "storylink://posting?", 31 apiver: "1.0", 32 store: { 33 android: "market://details?id=com.kakao.story", 34 ios: "http://itunes.apple.com/app/id486244601" 35 }, 36 package: "com.kakao.story" 37 } 38 }; 39 40 kakao.link = function (name) { 41 var link_app = app[name]; 42 if (!link_app) return { send: function () { 43 throw "No App exists"; 44 }}; 45 return { 46 send: function (params) { 47 var _app = this.app; 48 params['apiver'] = _app.apiver; 49 var full_url = _app.base_url + serialized(params); 50 51 var install_block = (function (os) { 52 return function () { 53 window.location = _app.store[os]; 54 }; 55 })(this.os); 56 57 if (this.os == "ios") { 58 var timer = setTimeout(install_block, 2 * 1000); 59 window.addEventListener('pagehide', clearTimer(timer)); 60 window.location = full_url; 61 } else if (this.os == "android") { 62 if (this.browser == "android+chrome") { 63 window.location = "intent:" + full_url + "#Intent;package=" + _app.package + ";end;"; 64 } else { 65 var iframe = document.createElement('iframe'); 66 iframe.style.display = 'none'; 67 iframe.src = full_url; 68 iframe.onload = install_block; 69 document.body.appendChild(iframe); 70 } 71 } 72 }, 73 app: link_app, 74 os: kakao.os, 75 browser: kakao.browser 76 }; 77 78 function serialized(params) { 79 var stripped = []; 80 for (var k in params) { 81 if (params.hasOwnProperty(k)) { 82 stripped.push(k + "=" + encodeURIComponent(params[k])); 83 } 84 } 85 return stripped.join("&"); 86 } 87 88 function clearTimer(timer) { 89 return function () { 90 clearTimeout(timer); 91 window.removeEventListener('pagehide', arguments.callee); 92 }; 93 } 94 }; 95}(window));
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.