1/** 2 * @license 3 * Fuse - Lightweight fuzzy-search 4 * 5 * Copyright (c) 2012 Kirollos Risk <[email protected]>. 6 * All Rights Reserved. Apache Software License 2.0 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20!function(t){function e(t,n){this.list=t,this.options=n=n||{};var i,o,s,r;for(i=0,r=["sort","includeScore","shouldSort"],o=r.length;o>i;i++)s=r[i],this.options[s]=s in n?n[s]:e.defaultOptions[s];for(i=0,r=["searchFn","sortFn","keys","getFn"],o=r.length;o>i;i++)s=r[i],this.options[s]=n[s]||e.defaultOptions[s]}var n=function(t,e){if(e=e||{},this.options=e,this.options.location=e.location||n.defaultOptions.location,this.options.distance="distance"in e?e.distance:n.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:n.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||n.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen>this.options.maxPatternLength)throw new Error("Pattern length is too long");this.matchmask=1<<this.patternLen-1,this.patternAlphabet=this._calculatePatternAlphabet()};n.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},n.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]|=1<<this.pattern.length-e-1;return t},n.prototype._bitapScore=function(t,e){var n=t/this.patternLen,i=Math.abs(this.options.location-e);return this.options.distance?n+i/this.options.distance:i?1:n},n.prototype.search=function(t){if(t=this.options.caseSensitive?t:t.toLowerCase(),this.pattern===t)return{isMatch:!0,score:0};var e,n,i,o,s,r,a,h,p,c=t.length,l=this.options.location,f=this.options.threshold,u=t.indexOf(this.pattern,l),d=this.patternLen+c,g=1,m=[];for(-1!=u&&(f=Math.min(this._bitapScore(0,u),f),u=t.lastIndexOf(this.pattern,l+this.patternLen),-1!=u&&(f=Math.min(this._bitapScore(0,u),f))),u=-1,e=0;e<this.patternLen;e++){for(i=0,o=d;o>i;)this._bitapScore(e,l+o)<=f?i=o:d=o,o=Math.floor((d-i)/2+i);for(d=o,s=Math.max(1,l-o+1),r=Math.min(l+o,c)+this.patternLen,a=Array(r+2),a[r+1]=(1<<e)-1,n=r;n>=s;n--)if(p=this.patternAlphabet[t.charAt(n-1)],a[n]=0===e?(a[n+1]<<1|1)&p:(a[n+1]<<1|1)&p|((h[n+1]|h[n])<<1|1)|h[n+1],a[n]&this.matchmask&&(g=this._bitapScore(e,n-1),f>=g)){if(f=g,u=n-1,m.push(u),!(u>l))break;s=Math.max(1,2*l-u)}if(this._bitapScore(e+1,l)>f)break;h=a}return{isMatch:u>=0,score:g}};var i=function(t,e,n){var s,r,a;if(e){a=e.indexOf("."),-1!==a?(s=e.slice(0,a),r=e.slice(a+1)):s=e;var h=t[s];if(h)if(r||"string"!=typeof h&&"number"!=typeof h)if(o.isArray(h))for(var p=0,c=h.length;c>p;p++)i(h[p],r,n);else r&&i(h,r,n);else n.push(h)}else n.push(t);return n},o={deepValue:function(t,e){return i(t,e,[])},isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)}};e.defaultOptions={id:null,caseSensitive:!1,includeScore:!1,shouldSort:!0,searchFn:n,sortFn:function(t,e){return t.score-e.score},getFn:o.deepValue,keys:[]},e.prototype.search=function(t){var e,n,i,s,r=new this.options.searchFn(t,this.options),a=this.list,h=a.length,p=this.options,c=this.options.keys,l=c.length,f=[],u={},d=[],g=function(t,e,n){if(void 0!==t&&null!==t)if("string"==typeof t)i=r.search(t),i.isMatch&&(s=u[n],s?s.score=Math.min(s.score,i.score):(u[n]={item:e,score:i.score},f.push(u[n])));else if(o.isArray(t))for(var a=0;a<t.length;a++)g(t[a],e,n)};if("string"==typeof a[0])for(var m=0;h>m;m++)g(a[m],m,m);else for(var m=0;h>m;m++)for(n=a[m],e=0;l>e;e++)g(p.getFn(n,c[e]),n,m);p.shouldSort&&f.sort(p.sortFn);for(var y=p.includeScore?function(t){return f[t]}:function(t){return f[t].item},v=p.id?function(t){f[t].item=p.getFn(f[t].item,p.id)[0]}:function(){},m=0,b=f.length;b>m;m++)v(m),d.push(y(m));return d},"object"==typeof exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}
20):t.Fuse=e}(this); 21 22/** 23 * jQuery.query - Query String Modification and Creation for jQuery 24 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com) 25 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/). 26 * Date: 2009/8/13 27 * 28 * @author Blair Mitchelmore 29 * @version 2.2.3 30 * 31 **/ 32new function(a){var b=a.separator||"&",c=!1!==a.spaces,e=(a.suffix,!1!==a.prefix),f=e?!0===a.hash?"#":"?":"",g=!1!==a.numbers;jQuery.query=new function(){var a=function(a,b){return void 0!=a&&null!==a&&(!b||a.constructor==b)},d=function(a){for(var b,c=/\[([^[]*)\]/g,d=/^([^[]+)(\[.*\])?$/.exec(a),e=d[1],f=[];b=c.exec(d[2]);)f.push(b[1]);return[e,f]},e=function(b,c,d){var g=c.shift();if("object"!=typeof b&&(b=null),""===g)if(b||(b=[]),a(b,Array))b.push(0==c.length?d:e(null,c.slice(0),d));else if(a(b,Object)){for(var h=0;null!=b[h++];);b[--h]=0==c.length?d:e(b[h],c.slice(0),d)}else b=[],b.push(0==c.length?d:e(null,c.slice(0),d));else if(g&&g.match(/^\s*[0-9]+\s*$/)){var i=parseInt(g,10);b||(b=[]),b[i]=0==c.length?d:e(b[i],c.slice(0),d)}else{if(!g)return d;var i=g.replace(/^\s*|\s*$/g,"");if(b||(b={}),a(b,Array)){for(var j={},h=0;h<b.length;++h)j[h]=b[h];b=j}b[i]=0==c.length?d:e(b[i],c.slice(0),d)}return b},h=function(a){var b=this;return b.keys={},a.queryObject?jQuery.each(a.get(),function(a,c){b.SET(a,c)}):b.parseNew.apply(b,arguments),b};return h.prototype={queryObject:!0,parseNew:function(){var a=this;return a.keys={},jQuery.each(arguments,function(){var b=""+this;b=b.replace(/^[?#]/,""),b=b.replace(/[;&]$/,""),c&&(b=b.replace(/[+]/g," ")),jQuery.each(b.split(/[&;]/),function(){var b=decodeURIComponent(this.split("=")[0]||""),c=decodeURIComponent(this.split("=")[1]||"");b&&(g&&(/^[+-]?[0-9]+\.[0-9]*$/.test(c)?c=parseFloat(c):/^[+-]?[1-9][0-9]*$/.test(c)&&(c=parseInt(c,10))),c=!c&&0!==c||c,a.SET(b,c))})}),a},has:function(b,c){var d=this.get(b);return a(d,c)},GET:function(b){if(!a(b))return this.keys;for(var c=d(b),e=c[0],f=c[1],g=this.keys[e];null!=g&&0!=f.length;)g=g[f.shift()];return"number"==typeof g?g:g||""},get:function(b){var c=this.GET(b);return a(c,Object)?jQuery.extend(!0,{},c):a(c,Array)?c.slice(0):c},SET:function(b,c){var f=a(c)?c:null,g=d(b),h=g[0],i=g[1],j=this.keys[h];return this.keys[h]=e(j,i.slice(0),f),this},set:function(a,b){return this.copy().SET(a,b)},REMOVE:function(b,c){if(c){var d=this.GET(b);if(a(d,Array)){for(tval in d)d[tval]=d[tval].toString();var e=$.inArray(c,d);if(!(e>=0))return;b=d.splice(e,1),b=b[e]}else if(c!=d)return}return this.SET(b,null).COMPACT()},remove:function(a,b){return this.copy().REMOVE(a,b)},EMPTY:function(){var a=this;return jQuery.each(a.keys,function(b,c){delete a.keys[b]}),a},load:function(a){var b=a.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1"),c=a.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new h(a.length==c.length?"":c,a.length==b.length?"":b)},empty:function(){return this.copy().EMPTY()},copy:function(){return new h(this)},COMPACT:function(){function b(c){function e(b,c,d){a(b,Array)?b.push(d):b[c]=d}var d="object"==typeof c?a(c,Array)?[]:{}:c;return"object"==typeof c&&jQuery.each(c,function(c,f){if(!a(f))return!0;e(d,c,b(f))}),d}return this.keys=b(this.keys),this},compact:function(){return this.copy().COMPACT()},toString:function(){var e=[],g=[],i=function(a){return a+="",a=encodeURIComponent(a),c&&(a=a.replace(/%20/g,"+")),a},j=function(b,c,d){if(a(d)&&!1!==d){var e=[i(c)];!0!==d&&(e.push("="),e.push(i(d))),b.push(e.join(""))}},k=function(a,b){var c=function(a){return b&&""!=b?[b,"[",a,"]"].join(""):[a].join("")};jQuery.each(a,function(a,b){"object"==typeof b?k(b,c(a)):j(g,c(a),b)})};return k(this.keys),g.length>0&&e.push(f),e.push(g.join(b)),e.join("")}},new h(location.search,location.hash)}}(jQuery.query||{}); 33/** 34* Define the browser and OS 35* 36* @var string userAgent Useragent string 37* @var boolean bIsIE IE 38* @var boolean bIsWin Windows 39*/ 40var sClientInfo = navigator.userAgent.toLowerCase(); 41var bIsIE = (sClientInfo.indexOf("msie") != -1); 42var bIsWin = ((sClientInfo.indexOf("win")!=-1) || (sClientInfo.indexOf("16bit") != -1)); 43var matched, browser; 44 45jQuery.uaMatch = function( ua ) { 46 ua = ua.toLowerCase(); 47 48 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || 49 /(webkit)[ \/]([\w.]+)/.exec( ua ) || 50 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || 51 /(msie) ([\w.]+)/.exec( ua ) || 52 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || 53 []; 54 55 return { 56 browser: match[ 1 ] || "", 57 version: match[ 2 ] || "0" 58 }; 59}; 60 61matched = jQuery.uaMatch( navigator.userAgent ); 62browser = {}; 63 64if ( matched.browser ) { 65 browser[ matched.browser ] = true; 66 browser.version = matched.version; 67} 68 69// Chrome is Webkit, but Webkit is also Safari. 70if ( browser.chrome ) { 71 browser.webkit = true; 72} else if ( browser.webkit ) { 73 browser.safari = true; 74} 75 76jQuery.browser = browser; 77 78function getParam(sParam, sDefault) 79{ 80 if (!oParams.hasOwnProperty(sParam) && typeof sDefault !== 'undefined') { 81 return sDefault; 82 } 83 84 return oParams[sParam]; 85} 86 87function getPhrase(sParam) 88{ 89 return oTranslations[sParam]; 90} 91 92function isModule(sModule) 93{ 94 return (typeof(oModules[sModule]) != 'undefined' ? true : false); 95} 96 97function debug(sMessage) 98{ 99 if (getCookie('js_console')) 100 { 101 if ($('#firebug_no_console').length <= 0) 102 { 103 var $sConsole = ''; 104 $sConsole += '<div id="firebug_no_console" style="position:fixed; bottom:0px; left:0px; z-index:9000; border-top:2px #000 solid; width:100%; text-align:left;">'; 105 $sConsole += '<div style="background:#5F5F5F; color:#fff; padding:4px; font-size:14px; font-weight:bold;">Javascript Console</div>'; 106 $sConsole += '<div style="background:#5F5F5F; color:#fff; padding:4px; font-size:12px; font-weight:bold; border-top:1px #3F3F3F solid;"><a href="#" onclick="$(\'#firebug_no_console_content\').html(\'\'); return false;">Clear</a></div>'; 107 $sConsole += '<div id="firebug_no_console_content" style="height:200px; overflow:auto; background:#0F0F0F; color:#fff;"></div>'; 108 $sConsole += '</div>'; 109 110 $('body').prepend($sConsole); 111 } 112 $('#firebug_no_console_content').prepend('<div style="border-bottom:1px #4F4F4F solid; padding:5px 0px 5px 10px;">' + sMessage + '</div>'); 113 } 114 115 if (typeof console === 'undefined' || typeof console.log == 'undefined') 116 { 117 return false;
118 } 119} 120 121function p(sMessage) 122{ 123 debug(sMessage); 124} 125 126function d(aArray) 127{ 128 p(print_r(aArray, true)); 129} 130 131function setCookie(name, value, expires) 132{ 133 var today = new Date(); 134 135 today.setTime( today.getTime() ); 136 137 if (expires) 138 { 139 expires = expires * 1000 * 60 * 60 * 24; 140 } 141 var expires_date = new Date( today.getTime() + (expires) ); 142 143 document.cookie = getParam('sJsCookiePrefix') + name + "=" +escape( value ) + 144 ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 145 ( ( getParam('sJsCookiePath') ) ? ";path=" + getParam('sJsCookiePath') : "" ) + 146 ( ( getParam('sJsCookieDomain') ) ? ";domain=" + getParam('sJsCookieDomain') : "" ); 147 148 debug('Adding Cookie: ' + name + ' -> ' + value); 149} 150 151function deleteCookie(name) 152{ 153 if (this.getCookie(name)) 154 { 155 document.cookie = getParam('sJsCookiePrefix') + name + "=" + 156 ( ( getParam('sJsCookiePath') ) ? ";path=" + getParam('sJsCookiePath') : "") + 157 ( ( getParam('sJsCookieDomain') ) ? ";domain=" + getParam('sJsCookieDomain') : "" ) + 158 ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; 159 debug('Deleting Cookie: ' + name); 160 } 161} 162 163function getCookie(check_name) 164{ 165 var a_all_cookies = document.cookie.split( ';' ); 166 var a_temp_cookie = ''; 167 var cookie_name = ''; 168 var cookie_value = ''; 169 var b_cookie_found = false; 170 var check_name = getParam('sJsCookiePrefix') + check_name; 171 172 for (var i = 0; i < a_all_cookies.length; i++ ) 173 { 174 a_temp_cookie = a_all_cookies[i].split( '=' ); 175 176 cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); 177 178 if ( cookie_name == check_name ) 179 { 180 b_cookie_found = true; 181 182 if ( a_temp_cookie.length > 1 ) 183 { 184 cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); 185 } 186 return cookie_value; 187 break; 188 } 189 a_temp_cookie = null; 190 cookie_name = ''; 191 } 192 193 if ( !b_cookie_found ) 194 { 195 return null; 196 } 197} 198 199function parse(strInputCode) 200{ 201 strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1) 202 { 203 return (p1 == "lt")? "<" : ">"; 204 }); 205 return strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); 206} 207 208/** 209 * PHP 210 */ 211function substr(sString, iStart, iLength) 212{ 213 if(iStart < 0) 214 { 215 iStart += sString.length; 216 } 217 218 if(iLength == undefined) 219 { 220 iLength = sString.length; 221 } 222 else if(iLength < 0) 223 { 224 iLength += sString.length; 225 } 226 else 227 { 228 iLength += iStart; 229 } 230 231 if(iLength < iStart) 232 { 233 iLength = iStart; 234 } 235 236 return sString.substring(iStart, iLength); 237} 238 239function str_repeat(str, repeat) 240{ 241 var output = ''; 242 for (var i = 0; i < repeat; i++) 243 { 244 output += str; 245 } 246 return output; 247} 248 249function print_r( array, return_val ) 250{ 251 var output = "", pad_char = " ", pad_val = 4; 252 253 var formatArray = function (obj, cur_depth, pad_val, pad_char) 254 { 255 if (cur_depth > 0) 256 { 257 cur_depth++; 258 } 259 260 var base_pad = repeat_char(pad_val*cur_depth, pad_char); 261 var thick_pad = repeat_char(pad_val*(cur_depth+1), pad_char); 262 var str = ""; 263 264 if (obj instanceof Array || obj instanceof Object) { 265 str += "Array\n" + base_pad + "(\n"; 266 for (var key in obj) { 267 if (obj[key] instanceof Array) { 268 str += thick_pad + "["+key+"] => "+formatArray(obj[key], cur_depth+1, pad_val, pad_char); 269 } else { 270 str += thick_pad + "["+key+"] => " + obj[key] + "\n"; 271 } 272 } 273 str += base_pad + ")\n"; 274 } else if(obj == null || obj == undefined) { 275 str = ''; 276 } else { 277 str = obj.toString(); 278 } 279 280 return str; 281 }; 282 283 var repeat_char = function (len, pad_char) { 284 var str = ""; 285 for(var i=0; i < len; i++) { 286 str += pad_char; 287 }; 288 return str; 289 }; 290 output = formatArray(array, 0, pad_val, pad_char); 291 292 if (return_val !== true) { 293 document.write("<pre>" + output + "</pre>"); 294 return true; 295 } else { 296 return output; 297 } 298} 299 300function isset() 301{ 302 var a=arguments; var l=a.length; var i=0; 303 304 if (l==0) { 305 throw new Error('Empty isset'); 306 } 307 308 while (i!=l) { 309 if (typeof(a[i])=='undefined' || a[i]===null) { 310 return false; 311 } else { 312 i++; 313 } 314 } 315 return true; 316} 317 318function empty(mixed_var) { 319 var key; 320 321 if (mixed_var === "" 322 || mixed_var === 0 323 || mixed_var === "0" 324 || mixed_var === null 325 || mixed_var === false 326 || mixed_var === undefined 327 || trim(mixed_var) == "" 328 ){ 329 return true; 330 } 331 if (typeof mixed_var == 'object') { 332 for (key in mixed_var) { 333 if (typeof mixed_var[key] !== 'function' ) { 334 return false;
335 } 336 } 337 return true; 338 } 339 return false; 340} 341 342function trim(str, charlist) { 343 var whitespace, l = 0, i = 0; 344 str += ''; 345 346 if (!charlist) { 347 whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000"; 348 } else { 349 charlist += ''; 350 whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); 351 } 352 353 l = str.length; 354 for (i = 0; i < l; i++) { 355 if (whitespace.indexOf(str.charAt(i)) === -1) { 356 str = str.substring(i); 357 break; 358 } 359 } 360 361 l = str.length; 362 for (i = l - 1; i >= 0; i--) { 363 if (whitespace.indexOf(str.charAt(i)) === -1) { 364 str = str.substring(0, i + 1); 365 break; 366 } 367 } 368 369 return whitespace.indexOf(str.charAt(0)) === -1 ? str : ''; 370} 371 372function ltrim ( str, charlist ) { 373 charlist = !charlist ? ' \s\xA0' : (charlist+'').replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); 374 var re = new RegExp('^[' + charlist + ']+', 'g'); 375 return (str+'').replace(re, ''); 376} 377 378function rtrim ( str, charlist ) { 379 charlist = !charlist ? ' \s\xA0' : (charlist+'').replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); 380 var re = new RegExp('[' + charlist + ']+$', 'g'); 381 return (str+'').replace(re, ''); 382} 383 384function function_exists( function_name ) { 385 if (typeof function_name == 'string'){ 386 return (typeof window[function_name] == 'function'); 387 } else{ 388 return (function_name instanceof Function); 389 } 390} 391 392function explode( delimiter, string, limit ) { 393 var emptyArray = { 0: '' }; 394 395 if ( arguments.length < 2 396 || typeof arguments[0] == 'undefined' 397 || typeof arguments[1] == 'undefined' ) 398 { 399 return null; 400 } 401 402 if ( delimiter === '' 403 || delimiter === false 404 || delimiter === null ) 405 { 406 return false; 407 } 408 409 if ( typeof delimiter == 'function' 410 || typeof delimiter == 'object' 411 || typeof string == 'function' 412 || typeof string == 'object' ) 413 { 414 return emptyArray; 415 } 416 417 if ( delimiter === true ) { 418 delimiter = '1'; 419 } 420 421 if (!limit) { 422 return string.toString().split(delimiter.toString()); 423 } else { 424 var splitted = string.toString().split(delimiter.toString()); 425 var partA = splitted.splice(0, limit - 1); 426 var partB = splitted.join(delimiter.toString()); 427 partA.push(partB); 428 return partA; 429 } 430} 431 432function in_array(needle, haystack, strict) { 433 var found = false, key, strict = !!strict; 434 435 for (key in haystack) { 436 if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) { 437 found = true; 438 break; 439 } 440 } 441 442 return found; 443} 444 445function getResizedWindow() 446{ 447 var myWidth = 0; 448 var myHeight = 0; 449 if( typeof( window.innerWidth ) == 'number' ) 450 { 451 //Non-IE 452 myWidth = window.innerWidth; 453 myHeight = window.innerHeight; 454 } 455 else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) 456 { 457 //IE 6+ in 'standards compliant mode' 458 myWidth = document.documentElement.clientWidth; 459 myHeight = document.documentElement.clientHeight; 460 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight )) 461 { 462 //IE 4 compatible 463 myWidth = document.body.clientWidth; 464 myHeight = document.body.clientHeight; 465 } 466 467 return myHeight; 468} 469 470function htmlspecialchars (string, quote_style, charset, double_encode) { 471 // http://kevin.vanzonneveld.net 472 // + original by: Mirek Slugen 473 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 474 // + bugfixed by: Nathan 475 // + bugfixed by: Arno 476 // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 477 // + bugfixed by: Brett Zamir (http://brett-zamir.me) 478 // + input by: Ratheous 479 // + input by: Mailfaker (http://www.weedem.fr/) 480 // + reimplemented by: Brett Zamir (http://brett-zamir.me) 481 // + input by: felix 482 // + bugfixed by: Brett Zamir (http://brett-zamir.me) 483 // % note 1: charset argument not supported 484 // * example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES'); 485 // * returns 1: '<a href='test'>Test</a>' 486 // * example 2: htmlspecialchars("ab\"c'd", ['ENT_NOQUOTES', 'ENT_QUOTES']); 487 // * returns 2: 'ab"c'd' 488 // * example 3: htmlspecialchars("my "&entity;" is still here", null, null, false); 489 // * returns 3: 'my "&entity;" is still here' 490 491 var optTemp = 0, i = 0, noquotes= false; 492 if (typeof quote_style === 'undefined' || quote_style === null) { 493 quote_style = 2; 494 } 495 string = string.toString(); 496 if (double_encode !== false) { // Put this first to avoid double-encoding
497 string = string.replace(/&/g, '&'); 498 } 499 string = string.replace(/</g, '<').replace(/>/g, '>'); 500 501 var OPTS = { 502 'ENT_NOQUOTES': 0, 503 'ENT_HTML_QUOTE_SINGLE' : 1, 504 'ENT_HTML_QUOTE_DOUBLE' : 2, 505 'ENT_COMPAT': 2, 506 'ENT_QUOTES': 3, 507 'ENT_IGNORE' : 4 508 }; 509 if (quote_style === 0) { 510 noquotes = true; 511 } 512 if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags 513 quote_style = [].concat(quote_style); 514 for (i=0; i < quote_style.length; i++) { 515 // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4 516 if (OPTS[quote_style[i]] === 0) { 517 noquotes = true; 518 } 519 else if (OPTS[quote_style[i]]) { 520 optTemp = optTemp | OPTS[quote_style[i]]; 521 } 522 } 523 quote_style = optTemp; 524 } 525 if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { 526 string = string.replace(/'/g, '''); 527 } 528 if (!noquotes) { 529 string = string.replace(/"/g, '"'); 530 } 531 532 return string; 533} 534 535 // getPageScroll() by quirksmode.com 536 function getPageScroll() { 537 var xScroll; 538 var yScroll; 539 if (self.pageYOffset) { 540 yScroll = self.pageYOffset; 541 xScroll = self.pageXOffset; 542 } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict 543 yScroll = document.documentElement.scrollTop; 544 xScroll = document.documentElement.scrollLeft; 545 } else if (document.body) {// all other Explorers 546 yScroll = document.body.scrollTop; 547 xScroll = document.body.scrollLeft; 548 } 549 return new Array(xScroll,yScroll); 550 } 551 552 // Adapted from getPageSize() by quirksmode.com 553 function getPageHeight() { 554 var windowHeight; 555 if (self.innerHeight) { // all except Explorer 556 windowHeight = self.innerHeight; 557 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode 558 windowHeight = document.documentElement.clientHeight; 559 } else if (document.body) { // other Explorers 560 windowHeight = document.body.clientHeight; 561 } 562 return windowHeight; 563 } 564 565function htmlentities (str) { 566 return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); 567 568} 569 570function parse_url (str, component) { 571 // http://kevin.vanzonneveld.net 572 // + original by: Steven Levithan (http://blog.stevenlevithan.com) 573 // + reimplemented by: Brett Zamir (http://brett-zamir.me) 574 // % note: Based on http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js 575 // % note: blog post at http://blog.stevenlevithan.com/archives/parseuri 576 // % note: demo at http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js 577 // % note: Does not replace invaild characters with '_' as in PHP, nor does it return false with 578 // % note: a seriously malformed URL. 579 // % note: Besides function name, is the same as parseUri besides the commented out portion 580 // % note: and the additional section following, as well as our allowing an extra slash after 581 // % note: the scheme/protocol (to allow file:/// as in PHP) 582 // * example 1: parse_url('http://username:password@hostname/path?arg=value#anchor'); 583 // * returns 1: {scheme: 'http', host: 'hostname', user: 'username', pass: 'password', path: '/path', query: 'arg=value', fragment: 'anchor'} 584 585 var o = { 586 strictMode: false, 587 key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], 588 q: { 589 name: "queryKey", 590 parser: /(?:^|&)([^&=]*)=?([^&]*)/g 591 }, 592 parser: { 593 strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, 594 loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-protocol to catch file:/// (should restrict this) 595 } 596 }; 597 598 var m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), 599 uri = {}, 600 i = 14; 601 while (i--) {uri[o.key[i]] = m[i] || "";} 602 // Uncomment the following to use the original more detailed (non-PHP) script 603 /* 604 uri[o.q.name] = {}; 605 uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { 606 if ($1) {uri[o.q.name][$1] = $2;} 607 }); 608 return uri; 609 */ 610 611 switch (component) { 612 case 'PHP_URL_SCHEME': 613 return uri.protocol; 614 case 'PHP_URL_HOST': 615 return uri.host; 616 case 'PHP_URL_PORT': 617 return uri.port; 618 case 'PHP_URL_USER': 619 return uri.user; 620 case 'PHP_URL_PASS': 621 return uri.password; 622 case 'PHP_URL_PATH': 623 return uri.path; 624 case 'PHP_URL_QUERY': 625 return uri.query; 626 case 'PHP_URL_FRAGMENT': 627 return uri.anchor; 628 default: 629 var retArr = {}; 630 if (uri.protocol !== '') {retArr.scheme=uri.protocol;} 631 if (uri.host !== '') {retArr.host=uri.host;} 632 if (uri.port !== '') {retArr.port=uri.port;} 633 if (uri.user !== '') {retArr.user=uri.user;} 634 if (uri.password !== '') {retArr.pass=uri.password;} 635 if (uri.path !== '') {retArr.path=uri.path;} 636 if (uri.query !== '') {retArr.query=uri.query;} 637 if (uri.anchor !== '') {retArr.fragment=uri.anchor;} 638 return retArr; 639 } 640} 641 642function isScrolledIntoView(elem) 643{ 644 if (!$Core.exists(elem)){ 645 return; 646 } 647 648 var docViewTop = $(window).scrollTop(); 649 var docViewBottom = docViewTop + $(window).height(); 650 651 var elemTop = $(elem).offset().top; 652 var elemBottom = elemTop + $(elem).height(); 653 654 return ((docViewTop < elemTop) && (docViewBottom > elemBottom)); 655}
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.