1(function($) { 2 3window.gspeechFront = function(options) { 4 5 var $this = this, 6 thisPage = this; 7 8 this.initVars = function() { 9 10 // get options 11 this.options = options; 12 this.is_touch_devise = 'ontouchstart' in window ? true : false; 13 this.options.lazy_load_timeout = 400; 14 15 }; 16 17 this.init = function() { 18 19 this.initVars(); 20 21 this.runFunctions(); 22 }; 23 24 // Start /////////////////////////////////////////////////////////////////////// 25 26 this.runFunctions = function() { 27 28 this.applyCookies(); 29 30 this.applyFunctions(); 31 }; 32 33 this.applyFunctions = function() { 34 35 if($("#gsp_data_html").length) { 36 37 var $gsp_data_html = $("#gsp_data_html"); 38 39 var lazy_load = $gsp_data_html.data("lazy_load"); 40 var widget_id = $gsp_data_html.data("w_id"); 41 var v_ind = $gsp_data_html.data("vv_index"); 42 var s_enc = $gsp_data_html.data("s_enc"); 43 var h_enc = $gsp_data_html.data("h_enc"); 44 var hh_enc = $gsp_data_html.data("hh_enc"); 45 var gt_w = $gsp_data_html.data("gt-w"); 46 } 47 else { 48 49 if($("#wpgs-script777").length) { 50 51 $("#wpgs-script777").attr("id", "wpgsp_front_script"); 52 } 53 else { // for old wordpress versions, which does not set ID to scripts 54 55 $("script").each(function(i) { 56 57 var src = $(this).attr("src"); 58 59 if(src == undefined || src == '') 60 return; 61 62 if(src.match(/gspeech_front/g)) { 63 64 $(this).attr("id", "wpgsp_front_script"); 65 66 return false; 67 } 68 }); 69 } 70 71 var $gspeech_cloud_data = $("#wpgsp_front_script"); 72 73 if(!$gspeech_cloud_data.length) 74 return; 75 76 var src = $gspeech_cloud_data.attr("src"); 77 78 src = src.replace(/gsp___del/gi, '\&'); 79 src = src.replace(/gsp___eq/gi, '\='); 80 src = src.replace(/\?/gi, '\&'); 81 82 // create options array 83 var gsp_opts = {}; 84 var gsp_opts_array = src.split("&"); 85 gsp_opts_array.forEach(function(option_item, i) { 86 87 var opt_data = option_item.split("="); 88 gsp_opts[opt_data[0]] = opt_data[1]; 89 }); 90 91 var lazy_load = gsp_opts["lazy_load"]; 92 var widget_id = gsp_opts["w_id"]; 93 var v_ind = gsp_opts["vv_index"]; 94 var s_enc = gsp_opts["s_enc"]; 95 var h_enc = gsp_opts["h_enc"]; 96 var hh_enc = gsp_opts["hh_enc"]; 97 var gt_w = gsp_opts["gt_w"]; 98 } 99 100 var load_timeout = lazy_load == 1 ? thisPage.options.lazy_load_timeout : 0; 101 102 var $gspeech_widget_code = '<script id="gspeech_cloud_widget" defer src="https://widget.gspeech.io/'+widget_id+'?v_ind='+v_ind+'" data-widget_id="'+widget_id+'" data-s="'+s_enc+'" data-h="'+h_enc+'" data-hh="'+hh_enc+'" data-gt_w="'+gt_w+'"></script>'; 103 104 setTimeout(function() { 105 106 $("body").append($gspeech_widget_code); 107 108 }, load_timeout); 109 }; 110 111 // Inner methods /////////////////////////////////////////////////////////////////////// 112 113 this.bytesToHex = function(bytes) { 114 115 var hexstring='', h; 116 for(var i=0; i<bytes.length; i++) { 117 h=bytes[i].toString(16); 118 if(h.length==1) { h='0'+h; } 119 hexstring+=h; 120 } 121 return hexstring; 122 }; 123 124 this.applyCookies = function() { 125 126 this.setCookie = function(key, value, expiry) { 127 128 var cookie_val = key + '=' + value + ';path=/'; 129 if(expiry != -1) { 130 var expires = new Date(); 131 expires.setTime(expires.getTime() + (expiry * 60 * 60 * 1000)); // in hours 132 cookie_val += ';expires=' + expires.toUTCString(); 133 } 134 document.cookie = cookie_val; 135 }; 136 137 this.getCookie = function(key) { 138 139 var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 140 return keyValue ? keyValue[2] : ''; 141 }; 142 143 this.eraseCookie = function(key) { 144 145 var keyValue = this.getCookie(key); 146 this.setCookie(key, keyValue, '-2'); 147 }; 148 }; 149
150 // Call init /////////////////////////////////////////////////////////////////////// 151 152 this.init(); 153}; 154 155$(document).ready(function() { 156 157 // gspeech 3.x 158 var gsp_options = {}; 159 window.gspeech_front = new gspeechFront(gsp_options); 160}); 161})(jQuery);
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.