1(function waitForjQuery(attempts){ 2 if (typeof window.jQuery !== "undefined") { 3 4(function($) { 5 6window.gspeechFront = function(options) { 7 8 var $this = this, 9 thisPage = this; 10 11 this.initVars = function() { 12 13 // get options 14 this.options = options; 15 this.is_touch_devise = 'ontouchstart' in window ? true : false; 16 this.options.lazy_load_timeout = 400; 17 18 }; 19 20 this.init = function() { 21 22 this.initVars(); 23 24 this.runFunctions(); 25 }; 26 27 // Start /////////////////////////////////////////////////////////////////////// 28 29 this.runFunctions = function() { 30 31 this.applyCookies(); 32 33 this.applyFunctions(); 34 }; 35 36 this.applyFunctions = function() { 37 38 var $gsp_data_html = $("#gsp_data_html"); 39 40 if (!$gsp_data_html.length) { 41 console.log("GSpeech: required html is missing.") 42 return; 43 } 44 45 var lazy_load = $gsp_data_html.data("lazy_load"); 46 var reload_session = parseInt($gsp_data_html.data("reload_session")); 47 var widget_id = $gsp_data_html.data("w_id"); 48 var v_ind = $gsp_data_html.data("vv_index"); 49 var gt_w = $gsp_data_html.data("gt-w"); 50 51 let storage; 52 try { 53 storage = window.localStorage; 54 storage.setItem('test', 'test'); 55 storage.removeItem('test'); 56 } catch (e) { 57 storage = window.sessionStorage; 58 } 59 60 let encData = storage.getItem('gsp_enc_data') ? JSON.parse(storage.getItem('gsp_enc_data')) : {}; 61 62 var canAjax = (typeof window.gsp_ajax_obj === 'object') && 63 window.gsp_ajax_obj && 64 typeof gsp_ajax_obj.ajax_url === 'string' && 65 gsp_ajax_obj.ajax_url && 66 typeof gsp_ajax_obj.nonce === 'string' && 67 gsp_ajax_obj.nonce; 68 69 if (reload_session == 1 || !encData.h_enc || !encData.s_enc || !encData.hh_enc) { 70 71 if (canAjax) { 72 jQuery.post(gsp_ajax_obj.ajax_url, { 73 action: 'wpgsp_validate_enc_data', 74 _ajax_nonce: gsp_ajax_obj.nonce 75 }, function(response) { 76 if (response && response.success && response.data) { 77 encData = { 78 s_enc: response.data.s_enc || '', 79 h_enc: response.data.h_enc || '', 80 hh_enc: response.data.hh_enc || '' 81 }; 82 try { storage.setItem('gsp_enc_data', JSON.stringify(encData)); } catch(e){} 83 } 84 loadCloudWidget(encData); 85 }).fail(function() { 86 loadCloudWidget(encData); 87 }); 88 } else { 89 console.warn('[GSpeech] gsp_ajax_obj is missing â loading widget without enc data'); 90 loadCloudWidget(encData); 91 } 92 93 } else { 94 loadCloudWidget(encData); 95 } 96 97 function loadCloudWidget(encData) { 98 var load_timeout = lazy_load == 1 ? thisPage.options.lazy_load_timeout : 0; 99 100 if ($("#gspeech_cloud_widget").length) return; // already loaded 101 102 setTimeout(function () { 103 if ($("#gspeech_cloud_widget").length) return; // double-check 104 $("body").append( 105 '<script id="gspeech_cloud_widget" defer src="https://widget.gspeech.io/' + widget_id + 106 '?v_ind=' + v_ind + '"' + 107 ' data-widget_id="' + widget_id + '"' + 108 ' data-s="' + (encData.s_enc || '') + '"' + 109 ' data-h="' + (encData.h_enc || '') + '"' + 110 ' data-hh="' + (encData.hh_enc || '') + '"' + 111 ' data-gt_w="' + gt_w + '"></script>' 112 ); 113 }, load_timeout); 114 } 115 116 }; 117 118 // Inner methods /////////////////////////////////////////////////////////////////////// 119 120 this.bytesToHex = function(bytes) { 121 122 var hexstring='', h; 123 for(var i=0; i<bytes.length; i++) { 124 h=bytes[i].toString(16); 125 if(h.length==1) { h='0'+h; } 126 hexstring+=h; 127 } 128 return hexstring; 129 }; 130 131 this.applyCookies = function() { 132 133 this.setCookie = function(key, value, expiry) { 134 135 var cookie_val = key + '=' + value + ';path=/'; 136 if(expiry != -1) { 137 var expires = new Date(); 138 expires.setTime(expires.getTime() + (expiry * 60 * 60 * 1000)); // in hours 139 cookie_val += ';expires=' + expires.toUTCString(); 140 } 141 document.cookie = cookie_val; 142 }; 143 144 this.getCookie = function(key) { 145 146 var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 147 return keyValue ? keyValue[2] : ''; 148 }; 149 150 this.eraseCookie = function(key) { 151 152 var keyValue = this.getCookie(key); 153 this.setCookie(key, keyValue, '-2'); 154 }; 155 }; 156
157 // Call init /////////////////////////////////////////////////////////////////////// 158 159 this.init(); 160}; 161 162$(document).ready(function() { 163 164 // gspeech 3.x 165 var gsp_options = {}; 166 window.gspeech_front = new gspeechFront(gsp_options); 167}); 168 169})(jQuery); 170 171} else if (attempts < 100) { 172 setTimeout(function(){ waitForjQuery(attempts+1); }, 50); 173} else { 174 console.warn("[GSpeech] jQuery not available after waiting."); 175} 176})(0);
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.