1; 2function ch_parseInt(data) { 3 if (!data) { return undefined; } 4 try { 5 return parseInt(data); 6 } catch (e) { 7 return undefined; 8 } 9} 10 11(function() { 12 var w = window; 13 if (w.ChannelIO) { 14 return (window.console.error || window.console.log || function(){})('ChannelIO script included twice.'); 15 } 16 var ch = function() { 17 ch.c(arguments); 18 }; 19 ch.q = []; 20 ch.c = function(args) { 21 ch.q.push(args); 22 }; 23 w.ChannelIO = ch; 24 25 function loadSdk() { 26 if (w.ChannelIOInitialized) { 27 return; 28 } 29 w.ChannelIOInitialized = true; 30 var s = document.createElement('script'); 31 s.type = 'text/javascript'; 32 s.async = true; 33 s.src = 'https://cdn.channel.io/plugin/ch-plugin-web.js'; 34 s.charset = 'UTF-8'; 35 var x = document.getElementsByTagName('script')[0]; 36 x.parentNode.insertBefore(s, x); 37 } 38 39 function buildBaseSettings() { 40 return { 41 "pluginKey": channel_io_options.channel_io_plugin_key, 42 "hideChannelButtonOnBoot": channel_io_options.channel_io_hide_default_launcher === 'on', 43 "customLauncherSelector": channel_io_options.channel_io_custom_launcher_selector, 44 "mobileMessengerMode": channel_io_options.channel_io_mobile_messenger_mode === 'on' ? 'iframe' : undefined, 45 "zIndex": ch_parseInt(channel_io_options.channel_io_z_index), 46 "scriptProvider": "channel", 47 "scriptPlatform": "wordpress", 48 "scriptVersion": "2.0.0" 49 }; 50 } 51 52 function bootAnonymous() { 53 ChannelIO('boot', buildBaseSettings()); 54 } 55 56 function bootWithProfile(me) { 57 var settings = buildBaseSettings(); 58 if (me && me.login && me.memberId) { 59 settings.memberId = me.memberId; 60 if (me.memberHash) { 61 settings.memberHash = me.memberHash; 62 } 63 settings.profile = me.profile || {}; 64 } 65 ChannelIO('boot', settings); 66 } 67 68 // íì´ì§ HTML ì íì ì 보를 ë°ì§ ìê³ , AJAX profile endpoint ìì ë°ì boot íë¤. 69 // ì´ë ê² íë©´ ì´ë¤ íì´ì§ ìºì (LiteSpeed Cache, WP Rocket ë±) íê²½ììë 70 // í íìì ì ë³´ê° ë¤ë¥¸ 방문ììê² ë ¸ì¶ëë ëì¶ì´ ë°ìíì§ ìëë¤. 71 // 72 // fetch / XHR ì ì ì ìëµ / ìë¬ ì¸ì ìëµì´ stalled ëì´ promise ê° ìì 73 // settle ì ëë ì¼ì´ì¤(slow 3G, ë긴 ë¤í¸ìí¬, ìë² hang ë±)ë ë§ìì¼ íë¤. 74 // settle ì ëë©´ start() ì started ê°ë ë문ì ì¬ìëë ìì´ ChannelIO('boot') 75 // ìì²´ê° í¸ì¶ëì§ ìì ìì ¯ì´ ììí ì ë¬ë¤. settled íëê·¸ + 5ì´ íìììì¼ë¡ 76 // ì´ë¤ ê²½ë¡ë¡ë ì íí í ë² ìµëª ë¶í¸ fallback ì´ ë³´ì¥ëëë¡ íë¤. 77 function fetchProfileAndBoot() { 78 if (!channel_io_options || !channel_io_options.profile_url) { 79 bootAnonymous(); 80 return; 81 } 82 83 var settled = false; 84 var timeoutId = window.setTimeout(function() { 85 if (settled) { 86 return; 87 } 88 settled = true; 89 bootAnonymous(); 90 }, 5000); 91 92 function finish(callback) { 93 if (settled) { 94 return; 95 } 96 settled = true; 97 window.clearTimeout(timeoutId); 98 callback(); 99 } 100 101 if (typeof window.fetch === 'function') { 102 window.fetch(channel_io_options.profile_url, { 103 credentials: 'same-origin' 104 }) 105 .then(function(res) { return res.ok ? res.json() : null; }) 106 .then(function(me) { 107 finish(function() { bootWithProfile(me); }); 108 }) 109 .catch(function() { finish(bootAnonymous); }); 110 return; 111 } 112 113 // fetch 미ì§ì ë¸ë¼ì°ì ì© fallback 114 try { 115 var xhr = new XMLHttpRequest(); 116 xhr.open('GET', channel_io_options.profile_url, true); 117 xhr.withCredentials = true; 118 xhr.onreadystatechange = function() { 119 if (xhr.readyState !== 4) return; 120 if (xhr.status >= 200 && xhr.status < 300) { 121 try { 122 var me = JSON.parse(xhr.responseText); 123 finish(function() { bootWithProfile(me); }); 124 } catch (e) { 125 finish(bootAnonymous); 126 } 127 } else { 128 finish(bootAnonymous); 129 } 130 }; 131 xhr.onerror = function() { finish(bootAnonymous); }; 132 xhr.send(); 133 } catch (e) { 134 finish(bootAnonymous); 135 } 136 } 137 138 // start() ë í ë²ë§ ì¤íëì´ì¼ íë¤. document.readyState ê²ì¬ + DOMContentLoaded 139 // + load ì¸ ê²½ë¡ ì¤ ë ì´ìì´ ëìí ì ìì´ (ì: load ê° DOMContentLoaded ë¤ì 140 // í ë² ë ë°ì) ê°ë ìì´ ëë©´ fetchProfileAndBoot() ê° ë ë² í¸ì¶ëì´ /profile 141 // í¸ì¶ê³¼ ChannelIO('boot', ...) ê° ì¤ë³µ ì¤íëë¤. loadSdk() ë ìì²´ ê°ë( 142 // ChannelIOInitialized) ê° ìì§ë§ boot í¸ì¶ ìì²´ë ë§ì§ 못íë¯ë¡ ì¬ê¸°ì ì°¨ë¨. 143 var started = false;
144 function start() { 145 if (started) { 146 return; 147 } 148 started = true; 149 loadSdk(); 150 fetchProfileAndBoot(); 151 } 152 153 if (document.readyState === 'complete') { 154 start(); 155 } else if (window.attachEvent) { 156 window.attachEvent('onload', start); 157 } else { 158 window.addEventListener('DOMContentLoaded', start, false); 159 window.addEventListener('load', start, false); 160 } 161})();
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.