1class CleverLogin { 2 constructor(selector) { 3 var h = document.head; 4 5 if (typeof selector != "undefined") { 6 this.selector = selector; 7 } else { 8 this.selector = "login"; 9 } 10 11 this.config = this.getConfig(); 12 this.frameAppended = false; 13 14 this.addIframe(); 15 this.addEvents(); 16 } 17 18 addIframe() { 19 var target = document.getElementById(this.config.target); 20 21 if (target) { 22 var types = this.config.types.join("|"); 23 var app_id = this.config.app_id ? this.config.app_id : "none"; 24 25 var options = ""; 26 if (typeof this.config.options == "object") { 27 options = "?" + encodeQueryData(this.config.options) + "&selector=" + this.selector; 28 } else { 29 options = "?selector=" + this.selector; 30 } 31 32 this.frame = document.createElement("iframe"); 33 this.frame.setAttribute("src", "https://login.cleverreach.com/multi/"+app_id+"/"+types + options); 34 this.frame.setAttribute("scrolling", "no"); 35 this.frame.setAttribute("border", "0pt"); 36 this.frame.setAttribute("border", "none"); 37 this.frame.setAttribute("id", this.config.id ? this.config.id : "cr-social-login-frame"); 38 this.frame.setAttribute("style", "border: none; width: 100%;"); 39 40 target.appendChild(this.frame); 41 this.frameAppended = true; 42 } 43 } 44 45 addEvents() { 46 if (this.frameAppended) { 47 cleverLoginCallBacks.push(this); 48 this.init = true; 49 } 50 } 51 52 workEvent(event) { 53 var functionName = "receiveClever" + this.selector.charAt(0).toUpperCase() + this.selector.slice(1) 54 if (typeof window[functionName] == "function") { 55 window[functionName](event.data); 56 } 57 } 58 59 getConfig() { 60 var h = document.head; 61 var s; 62 for (var i = 0, e=(s=h.getElementsByTagName("script")).length; i<e; i++) { 63 if (s[i].type.toLowerCase() === "clever/" + this.selector) { 64 return JSON.parse(s[i].innerHTML); 65 } 66 } 67 return false; 68 } 69} 70 71var cleverlogin; 72var cleverLoginCallBacks = new Array(); 73 74window.addEventListener("load", function() { 75 cleverlogin = new CleverLogin(); 76}); 77 78function cleverLoginReceiveMessage(event) { 79 cleverLoginCallBacks.forEach(function(cb, index) { 80 if (cb.selector == event.data.crlgnselector) { 81 cb.workEvent(event); 82 } 83 }); 84} 85 86window.addEventListener("message", cleverLoginReceiveMessage, false); 87 88function encodeQueryData(data) { 89 const ret = []; 90 for (let d in data) 91 ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d])); 92 return ret.join('&'); 93 }
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.