1var _CRP_LAST_GENERATED_ID = 100000; 2function crp_generateId(){ 3 return "tmpid_" + (++_CRP_LAST_GENERATED_ID).toString(); 4} 5 6var crpUids = []; 7function crp_generateUniqueId() { 8 var uid = new Date().valueOf() + Math.floor(Math.random() * 11); 9 if (jQuery.inArray(uid, crpUids) != -1) { 10 return crp_generateUniqueId(); 11 } 12 crpUids.push(uid); 13 return uid; 14} 15 16 17function crp_showSpinner(message="Loading...") { 18 jQuery("#crp-spinner").css('display', 'block'); 19 jQuery("#crp-spinner-message").css('display', 'block'); 20 jQuery("#crp-spinner-message").html(message); 21 jQuery("#crp-spinner-background").css('display', 'block'); 22} 23 24function crp_hideSpinner() { 25 setTimeout(function(){ 26 jQuery("#crp-spinner").css('display', 'none'); 27 jQuery("#crp-spinner-message").css('display', 'none'); 28 jQuery("#crp-spinner-background").css('display', 'none'); 29 }, 1000); 30} 31 32function crp_openMediaUploader( callback, multipleSelection, notSelectedCallback, type ) { 33 'use strict'; 34 35 multipleSelection = typeof multipleSelection !== 'undefined' ? multipleSelection : false; 36 var uploader, imgData, json; 37 38 if ( undefined !== uploader ) { 39 uploader.open(); 40 return; 41 } 42 43 var params = { 44 frame: 'post', 45 state: 'insert', 46 multiple: multipleSelection 47 }; 48 if (typeof type == 'undefined') { 49 type = 'image'; 50 } 51 params.library = { 52 type: [ type ] 53 }; 54 uploader = wp.media.frames.file_frame = wp.media(params); 55 56 if (typeof notSelectedCallback != 'undefined') { 57 uploader.on('close', function () { 58 var selection = uploader.state('insert').get('selection'); 59 if (!selection.length) { 60 notSelectedCallback(); 61 } 62 }); 63 } 64 65 uploader.on( 'insert', function() { 66 var selections = uploader.state().get( 'selection').toJSON(); 67 var picInfos = []; 68 69 for(var sIdx = 0; sIdx < selections.length; sIdx++){ 70 var json = selections[sIdx]; 71 if ( 0 > jQuery.trim( json.url.length ) ) { 72 continue; 73 } 74 75 var picInfo = {}; 76 picInfo.id = json.id; 77 if (json.type == 'image') { 78 picInfo.src = json.sizes.full.url; 79 80 if (json.sizes.medium) { 81 picInfo.src = json.sizes.medium.url; 82 } 83 } else if(json.type == 'video') { 84 picInfo.src = json.url; 85 picInfo.thumb = crpPluginUrl + '/images/general/video_default.jpg'; 86 // if (json.thumb.src) { 87 // picInfo.thumb = json.thumb.src; 88 // } else { 89 // picInfo.thumb = json.icon; 90 // } 91 } 92 picInfos.push(picInfo); 93 } 94 95 if(multipleSelection){ 96 callback(picInfos); 97 }else{ 98 callback(picInfos.length > 0 ? picInfos[0] : null); 99 } 100 }); 101 uploader.open(); 102} 103 104function crp_isJSArray(obj){ 105 return (Object.prototype.toString.call( obj ) === '[object Array]') 106} 107 108function crp_truncateIfNeeded(text, maxLength){ 109 if(text){ 110 if(text.length > 3 && text.length > maxLength - 3){ 111 text = text.substring(0,maxLength - 3); 112 text += "..." 113 } 114 } 115 return text; 116} 117 118function crp_loadHref(href, blank){ 119 if(!blank){ 120 window.location.href = href; 121 }else{ 122 window.open(href, '_blank'); 123 } 124} 125 126function crp_mgfCloseButtonMarkup(){ 127 128 var html = ""; 129 html += "<button class='mfp-close'>"; 130 html += "x"; //"<img class='mfp-close-img'/>"; 131 html += "</button>" 132 133 return html; 134} 135 136 137var CrpBase64 = { 138 139// private property 140_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 141 142// public method for encoding 143encode : function (input) { 144 var output = ""; 145 var chr1, chr2, chr3, enc1, enc2, enc3, enc4; 146 var i = 0; 147 148 if(!input) return output; 149 input = CrpBase64._utf8_encode(input); 150 151 while (i < input.length) { 152 153 chr1 = input.charCodeAt(i++); 154 chr2 = input.charCodeAt(i++); 155 chr3 = input.charCodeAt(i++); 156 157 enc1 = chr1 >> 2; 158 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 159 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 160 enc4 = chr3 & 63; 161 162 if (isNaN(chr2)) { 163 enc3 = enc4 = 64; 164 } else if (isNaN(chr3)) { 165 enc4 = 64; 166 } 167 168 output = output + 169 this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + 170 this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); 171 172 } 173 174 return output; 175}, 176 177// public method for decoding 178decode : function (input) { 179 var output = ""; 180 var chr1, chr2, chr3; 181 var enc1, enc2, enc3, enc4; 182 var i = 0; 183 184 if(!input) return output; 185 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 186 187 while (i < input.length) { 188 189 enc1 = this._keyStr.indexOf(input.charAt(i++)); 190 enc2 = this._keyStr.indexOf(input.charAt(i++)); 191 enc3 = this._keyStr.indexOf(input.charAt(i++)); 192 enc4 = this._keyStr.indexOf(input.charAt(i++)); 193 194 chr1 = (enc1 << 2) | (enc2 >> 4); 195 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 196 chr3 = ((enc3 & 3) << 6) | enc4; 197 198 output = output + String.fromCharCode(chr1); 199 200 if (enc3 != 64) { 201 output = output + String.fromCharCode(chr2); 202 } 203 if (enc4 != 64) { 204 output = output + String.fromCharCode(chr3); 205 } 206 207 } 208 209 output = CrpBase64._utf8_decode(output); 210 211 return output; 212 213}, 214 215// private method for UTF-8 encoding 216_utf8_encode : function (string) { 217 string = string.replace(/\r\n/g,"\n"); 218 var utftext = ""; 219 220 for (var n = 0; n < string.length; n++) { 221 222 var c = string.charCodeAt(n); 223 224 if (c < 128) { 225 utftext += String.fromCharCode(c); 226 } 227 else if((c > 127) && (c < 2048)) { 228 utftext += String.fromCharCode((c >> 6) | 192); 229 utftext += String.fromCharCode((c & 63) | 128); 230 } 231 else { 232 utftext += String.fromCharCode((c >> 12) | 224); 233 utftext += String.fromCharCode(((c >> 6) & 63) | 128); 234 utftext += String.fromCharCode((c & 63) | 128); 235 } 236 237 } 238 239 return utftext; 240}, 241 242// private method for UTF-8 decoding 243_utf8_decode : function (utftext) { 244 var string = ""; 245 var i = 0; 246 var c = c1 = c2 = 0; 247 248 while ( i < utftext.length ) { 249 250 c = utftext.charCodeAt(i); 251 252 if (c < 128) {
253 string += String.fromCharCode(c); 254 i++; 255 } 256 else if((c > 191) && (c < 224)) { 257 c2 = utftext.charCodeAt(i+1); 258 string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 259 i += 2; 260 } 261 else { 262 c2 = utftext.charCodeAt(i+1); 263 c3 = utftext.charCodeAt(i+2); 264 string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 265 i += 3; 266 } 267 268 } 269 270 return string; 271} 272 273} 274function crp_insertParam(url, key, value) 275{ 276 key = encodeURI(key); 277 value = encodeURI(value); 278 var kvp = url.substr(1).split('&'); 279 var i = kvp.length; 280 var x; 281 while(i--) { 282 x = kvp[i].split('='); 283 284 if (x[0]==key) { 285 x[1] = value; 286 kvp[i] = x.join('='); 287 break; 288 } 289 } 290 291 if (i<0) { 292 kvp[kvp.length] = [key,value].join('='); 293 } 294 295 return kvp.join('&'); 296} 297 298function crp_tagEscape(tag) { 299 return tag.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"); 300} 301 302function gkitConsoleLog(msg) { 303 console.log("GRID KIT ( " + (GKIT_PKG_TYPE == GKIT_PKG_TYPE_PREMIUM ? "PREMIUM" : "FREE") + " ) : " + msg); 304}
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.