diff --git a/include/js/jquery-barcode-1.3.3.js b/include/js/jquery-barcode-1.3.3.js new file mode 100644 index 000000000..65f91b092 --- /dev/null +++ b/include/js/jquery-barcode-1.3.3.js @@ -0,0 +1,828 @@ +/* + * BarCode Coder Library (BCC Library) + * BCCL Version 1.0 + * + * Porting : Jquery barcode plugin + * Version : 1.3.3 + * + * Date : October 17 2009 + * Author : DEMONTE Jean-Baptiste (firejocker) + * Contact : jbdemonte @ gmail.com + * Web site: http://barcode-coder.com/ + * dual licence : http://www.cecill.info/licences/Licence_CeCILL_V2-fr.html + * http://www.gnu.org/licenses/gpl.html + * + * Managed : + * + * standard 2 of 5 (std25) + * interleaved 2 of 5 (int25) + * ean 8 (ean8) + * ean 13 (ean13) + * code 11 (code11) + * code 39 (code39) + * code 93 (code93) + * code 128 (code128) + * codabar (codabar) + * msi (msi) + * + * Output : + * + * CSS (compatible with any browser) - To print, you must set the option in your browser "print background image" + * SVG inline (not compatible with IE) + * BMP inline (not compatible with IE) + * + * + * 1.1 - 2009/05/26 + * -> std25 fixed + * + * 1.2 - 2009/09/10 + * parseInt replaced by intval (nb: parseInt("09") => 0) + * code128 fixed (C Table analyse) + * Thanks to Vadim for the bug reporting + * 1.3 - 2009/09/26 + * add bmp and svg image renderer + * 1.3.2 - 2009/10/03 + * manage int and string formated values for barcode width/height + * 1.3.3 - 2009/10/17 + * no wait document is ready to add plugin + * + */ + +$.barcode = { + settings:{ + barWidth: 1, + barHeight: 50, + showHRI: true, + marginHRI: 5, + bgColor: "#FFFFFF", + color: "#000000", + fontSize: "10px", + output: "css" + }, + intval: function(val){ + var type = typeof( val ); + if (type == 'string'){ + val = val.replace(/[^0-9-.]/g, ""); + val = parseInt(val * 1, 10); + if (isNaN(val) || !isFinite(val)){ + return 0; + } else{ + return val; + } + } else if (type == 'number' && isFinite(val) ){ + return Math.floor(val); + } else{ + return 0; + } + }, + i25: { // std25 int25 + encoding: [ "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", + "WNWNN", "NWWNN", "NNNWW", "WNNWN","NWNWN"], + compute: function(code, crc, type){ + if (! crc) { + if (code.length % 2 != 0) code = '0' + code; + } else { + if ( (type == "int25") && (code.length % 2 == 0) ) code = '0' + code; + var odd = true, v, sum = 0; + for(var i=code.length-1; i>-1; i--){ + v = $.barcode.intval(code.charAt(i)); + if (isNaN(v)) return(""); + sum += odd ? 3 * v : v; + odd = ! odd; + } + code += ((10 - sum % 10) % 10).toString(); + } + return(code); + }, + getDigit: function(code, crc, type){ + code = this.compute(code, crc, type); + if (code == "") return(""); + result = ""; + + var i, j; + if (type == "int25") { + // Interleaved 2 of 5 + + // start + result += "1010"; + + // digits + CRC + var c1, c2; + for(i=0; i '9') ){ + return(""); + } + } + // get checksum + code = this.compute(code, type); + + // process analyse + var result = "101"; // start + + if (type == "ean8"){ + + // process left part + for(var i=0; i<4; i++){ + result += this.encoding[$.barcode.intval(code.charAt(i))][0]; + } + + // center guard bars + result += "01010"; + + // process right part + for(var i=4; i<8; i++){ + result += this.encoding[$.barcode.intval(code.charAt(i))][2]; + } + + } else { // ean13 + // extract first digit and get sequence + var seq = this.first[ $.barcode.intval(code.charAt(0)) ]; + + // process left part + for(var i=1; i<7; i++){ + result += this.encoding[$.barcode.intval(code.charAt(i))][ $.barcode.intval(seq.charAt(i-1)) ]; + } + + // center guard bars + result += "01010"; + + // process right part + for(var i=7; i<13; i++){ + result += this.encoding[$.barcode.intval(code.charAt(i))][ 2 ]; + } + } // ean13 + + result += "101"; // stop + return(result); + }, + compute: function (code, type){ + var len = type == "ean13" ? 12 : 7; + code = code.substring(0, len); + var sum = 0, odd = true; + for(i=code.length-1; i>-1; i--){ + sum += (odd ? 3 : 1) * $.barcode.intval(code.charAt(i)); + odd = ! odd; + } + return(code + ((10 - sum % 10) % 10).toString()); + } + }, + msi: { + encoding:[ "100100100100", "100100100110", "100100110100", "100100110110", + "100110100100", "100110100110", "100110110100", "100110110110", + "110100100100", "110100100110"], + compute: function(code, crc){ + if (typeof(crc) == "object"){ + if (crc.crc1 == "mod10"){ + code = this.computeMod10(code); + } else if (crc.crc1 == "mod11"){ + code = this.computeMod11(code); + } + if (crc.crc2 == "mod10"){ + code = this.computeMod10(code); + } else if (crc.crc2 == "mod11"){ + code = this.computeMod11(code); + } + } else if (typeof(crc) == "boolean"){ + if (crc){ + code = this.computeMod10(code); + } + } + return(code); + }, + computeMod10:function(code){ + var i, + toPart1 = code.length % 2; + var n1 = 0, sum = 0; + for(i=0; i=0; i--){ + sum += weight * $.barcode.intval(code.charAt(i)); + weight = weight == 7 ? 2 : weight + 1; + } + return(code + ((11 - sum % 11) % 11).toString()); + }, + getDigit: function(code, crc){ + var table = "0123456789"; + var index = 0; + var result = ""; + + code = this.compute(code, false); + + // start + result = "110"; + + // digits + for(i=0; i=0; i--){ + weightC = weightC == 10 ? 1 : weightC + 1; + weightK = weightK == 10 ? 1 : weightK + 1; + + index = table.indexOf( code.charAt(i) ); + + weightSumC += weightC * index; + weightSumK += weightK * index; + } + + var c = weightSumC % 11; + weightSumK += c; + var k = weightSumK % 11; + + result += this.encoding[c] + intercharacter; + + if (code.length >= 10){ + result += this.encoding[k] + intercharacter; + } + + // stop + result += "1011001"; + + return(result); + } + }, + code39: { + encoding:[ "101001101101", "110100101011", "101100101011", "110110010101", + "101001101011", "110100110101", "101100110101", "101001011011", + "110100101101", "101100101101", "110101001011", "101101001011", + "110110100101", "101011001011", "110101100101", "101101100101", + "101010011011", "110101001101", "101101001101", "101011001101", + "110101010011", "101101010011", "110110101001", "101011010011", + "110101101001", "101101101001", "101010110011", "110101011001", + "101101011001", "101011011001", "110010101011", "100110101011", + "110011010101", "100101101011", "110010110101", "100110110101", + "100101011011", "110010101101", "100110101101", "100100100101", + "100100101001", "100101001001", "101001001001", "100101101101"], + getDigit: function(code){ + var table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"; + var i, index, result="", intercharacter='0'; + + if (code.indexOf('*') >= 0) return(""); + + // Add Start and Stop charactere : * + code = ("*" + code + "*").toUpperCase(); + + for(i=0; i 0) result += intercharacter; + result += this.encoding[ index ]; + } + return(result); + } + }, + code93:{ + encoding:[ "100010100", "101001000", "101000100", "101000010", + "100101000", "100100100", "100100010", "101010000", + "100010010", "100001010", "110101000", "110100100", + "110100010", "110010100", "110010010", "110001010", + "101101000", "101100100", "101100010", "100110100", + "100011010", "101011000", "101001100", "101000110", + "100101100", "100010110", "110110100", "110110010", + "110101100", "110100110", "110010110", "110011010", + "101101100", "101100110", "100110110", "100111010", + "100101110", "111010100", "111010010", "111001010", + "101101110", "101110110", "110101110", "100100110", + "111011010", "111010110", "100110010", "101011110"], + getDigit: function(code, crc){ + var table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%____*", // _ => ($), (%), (/) et (+) + c, result = ""; + + if (code.indexOf('*') >= 0) return(""); + + code = code.toUpperCase(); + + // start : * + result += this.encoding[47]; + + // digits + for(i=0; i=0; i--){ + weightC = weightC == 20 ? 1 : weightC + 1; + weightK = weightK == 15 ? 1 : weightK + 1; + + index = table.indexOf( code.charAt(i) ); + + weightSumC += weightC * index; + weightSumK += weightK * index; + } + + var c = weightSumC % 47; + weightSumK += c; + var k = weightSumK % 47; + + result += this.encoding[c]; + result += this.encoding[k]; + } + + // stop : * + result += this.encoding[47]; + + // Terminaison bar + result += '1'; + return(result); + } + + }, + code128: { + encoding:[ "11011001100", "11001101100", "11001100110", "10010011000", + "10010001100", "10001001100", "10011001000", "10011000100", + "10001100100", "11001001000", "11001000100", "11000100100", + "10110011100", "10011011100", "10011001110", "10111001100", + "10011101100", "10011100110", "11001110010", "11001011100", + "11001001110", "11011100100", "11001110100", "11101101110", + "11101001100", "11100101100", "11100100110", "11101100100", + "11100110100", "11100110010", "11011011000", "11011000110", + "11000110110", "10100011000", "10001011000", "10001000110", + "10110001000", "10001101000", "10001100010", "11010001000", + "11000101000", "11000100010", "10110111000", "10110001110", + "10001101110", "10111011000", "10111000110", "10001110110", + "11101110110", "11010001110", "11000101110", "11011101000", + "11011100010", "11011101110", "11101011000", "11101000110", + "11100010110", "11101101000", "11101100010", "11100011010", + "11101111010", "11001000010", "11110001010", "10100110000", + "10100001100", "10010110000", "10010000110", "10000101100", + "10000100110", "10110010000", "10110000100", "10011010000", + "10011000010", "10000110100", "10000110010", "11000010010", + "11001010000", "11110111010", "11000010100", "10001111010", + "10100111100", "10010111100", "10010011110", "10111100100", + "10011110100", "10011110010", "11110100100", "11110010100", + "11110010010", "11011011110", "11011110110", "11110110110", + "10101111000", "10100011110", "10001011110", "10111101000", + "10111100010", "11110101000", "11110100010", "10111011110", + "10111101110", "11101011110", "11110101110", "11010000100", + "11010010000", "11010011100", "11000111010"], + getDigit: function(code){ + var tableB = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + var result = ""; + var sum = 0; + var isum = 0; + var i = 0; + var j = 0; + var value = 0; + + // check each characters + for(i=0; i 1; + var c = ''; + for(i=0; i<3 && i= '0' && c <= '9'; + } + + sum = tableCActivated ? 105 : 104; + + // start : [105] : C table or [104] : B table + result = this.encoding[ sum ]; + + i = 0; + while( i < code.length ){ + + if (! tableCActivated){ + j = 0; + // check next character to activate C table if interresting + while ( (i + j < code.length) && (code.charAt(i+j) >= '0') && (code.charAt(i+j) <= '9') ) j++; + + // 6 min everywhere or 4 mini at the end + tableCActivated = (j > 5) || ((i + j - 1 == code.length) && (j > 3)); + + if ( tableCActivated ){ + result += this.encoding[ 99 ]; // C table + sum += ++isum * 99; + } + // 2 min for table C so need table B + } else if ( (i == code.length) || (code.charAt(i) < '0') || (code.charAt(i) > '9') || (code.charAt(i+1) < '0') || (code.charAt(i+1) > '9') ) { + tableCActivated = false; + result += this.encoding[ 100 ]; // B table + sum += ++isum * 100; + } + + if ( tableCActivated ) { + value = $.barcode.intval(code.charAt(i) + code.charAt(i+1)); // Add two characters (numeric) + i += 2; + } else { + value = tableB.indexOf( code.charAt(i) ); // Add one character + i += 1; + } + result += this.encoding[ value ]; + sum += ++isum * value; + } + + // Add CRC + result += this.encoding[ sum % 103 ]; + + // Stop + result += this.encoding[106]; + + // Termination bar + result += "11"; + + return(result); + } + }, + codabar: { + encoding:[ "101010011", "101011001", "101001011", "110010101", + "101101001", "110101001", "100101011", "100101101", + "100110101", "110100101", "101001101", "101100101", + "1101011011", "1101101011", "1101101101", "1011011011", + "1011001001", "1010010011", "1001001011", "1010011001"], + getDigit: function(code){ + var table = "0123456789-$:/.+"; + var i, index, result="", intercharacter = '0'; + + // add start : A->D : arbitrary choose A + result += this.encoding[16] + intercharacter; + + for(i=0; iD : arbitrary choose A + result += this.encoding[16]; + return(result); + } + }, + // little endian convertor + lec:{ + // convert an int + cInt: function(value, byteCount){ + var le = ''; + for(var i=0; i> 8; + } + return le; + }, + // return a byte string from rgb values + cRgb: function(r,g,b){ + return String.fromCharCode(b) + String.fromCharCode(g) + String.fromCharCode(r); + }, + // return a byte string from a hex string color + cHexColor: function(hex){ + var v = parseInt('0x' + hex.substr(1)); + var b = v & 0xFF; + v = v >> 8; + var g = v & 0xFF; + var r = v >> 8; + return(this.cRgb(r,g,b)); + } + }, + // test if a string is a hexa string color (like #FF0000) + isHexColor: function (value){ + var r = new RegExp("#[0-91-F]", "gi"); + return value.match(r); + }, + // encode data in base64 + base64Encode: function(value) { + var r = '', c1, c2, c3, b1, b2, b3, b4; + var k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var i = 0; + while (i < value.length) { + c1 = value.charCodeAt(i++); + c2 = value.charCodeAt(i++); + c3 = value.charCodeAt(i++); + b1 = c1 >> 2; + b2 = ((c1 & 3) << 4) | (c2 >> 4); + b3 = ((c2 & 15) << 2) | (c3 >> 6); + b4 = c3 & 63; + if (isNaN(c2)) b3 = b4 = 64; + else if (isNaN(c3)) b4 = 64; + r += k.charAt(b1) + k.charAt(b2) + k.charAt(b3) + k.charAt(b4); + } + return r; + }, + // bmp barcode renderer + digitToBmp: function($container, settings, digit, hri){ + var barWidth = $.barcode.intval(settings.barWidth); + var barHeight = $.barcode.intval(settings.barHeight); + var i = 0; + var c0 = this.isHexColor(settings.bgColor) ? this.lec.cHexColor(settings.bgColor) : this.lec.cRgb(255,255,255); + var c1 = this.isHexColor(settings.color) ? this.lec.cHexColor(settings.color) : this.lec.cRgb(0,0,0); + var bar0 = ''; + var bar1 = ''; + // create one bar 0 and 1 of "barWidth" byte length + for(i=0; i"; + current = digit.charAt(i); + len=1; + } + } + if (len > 0){ + content += (current == '0' ? bar0 : bar1) + (len * barWidth) + "px\">"; + } + if (settings.showHRI){ + // add HRI centered + content += "
"+hri+"
"; + } + // set "css" image to the container + $container + .css("padding", "0px") + .css("overflow", "auto") + .css("width", (barWidth * digit.length) + "px") + .html(content); + }, + // svg barcode renderer + digitToSvg: function($container, settings, digit, hri){ + var barWidth = $.barcode.intval(settings.barWidth); + var barHeight = $.barcode.intval(settings.barHeight); + var width = digit.length * barWidth; + var height = barHeight; + var fontSize = $.barcode.intval(settings.fontSize); + if (settings.showHRI){ + height += $.barcode.intval(settings.marginHRI) + fontSize; + } + // svg header + var svg = ''; + + // background + svg += ''; + + var len = 0; + var current = digit.charAt(0); + for(var i=0; i'; + } + current = digit.charAt(i); + len=1; + } + } + if ( (len > 0) && (current == '1') ){ + svg += ''; + } + if (settings.showHRI){ + // add HRI as centered text + svg += ''; + svg += '' + hri + ''; + svg += ''; + } + // svg footer + svg += ''; + + // create a dom object, flush container and add object to the container + var object = document.createElement('object'); + object.setAttribute('type', 'image/svg+xml'); + object.setAttribute('data', 'data:image/svg+xml,'+ svg); + $container.html("").append(object); + } +} + + +$.fn.extend({ + barcode: function(datas, type, settings) { + var digit = "", + hri = "", + code = "", + crc = true; + + if (typeof(datas) == "string"){ + code = datas; + } else if (typeof(datas) == "object"){ + code = typeof(datas.code) == "string" ? datas.code : ""; + crc = typeof(datas.crc) != "undefined" ? datas.crc : true; + } + + if (code == "") return(false); + + + switch(type){ + case "std25": + case "int25": + digit = $.barcode.i25.getDigit(code, crc, type); + hri = $.barcode.i25.compute(code, crc, type); + break; + case "ean8": + case "ean13": + digit = $.barcode.ean.getDigit(code, type); + hri = $.barcode.ean.compute(code, type); + break; + case "code11": + digit = $.barcode.code11.getDigit(code); + hri = code; + break; + case "code39": + digit = $.barcode.code39.getDigit(code); + hri = code; + break; + case "code93": + digit = $.barcode.code93.getDigit(code, crc); + hri = code; + break; + case "code128": + digit = $.barcode.code128.getDigit(code); + hri = code; + break + case "codabar": + digit = $.barcode.codabar.getDigit(code); + hri = code; + break; + case "msi": + digit = $.barcode.msi.getDigit(code, crc); + hri = $.barcode.msi.compute(code, crc); + break; + } + if (digit.length == 0) return($(this)); + // add Quiet Zone + digit = "0000000000" + digit + "0000000000"; + + // merge default settings with call settings + if (settings == undefined){ + settings = []; + } + for(var name in $.barcode.settings){ + if (settings[name] == undefined) settings[name] = $.barcode.settings[name]; + } + + var $this = $(this); + + // call the god renderer + switch(settings.output){ + case "bmp": + $.barcode.digitToBmp($this, settings, digit, hri); + break; + case "svg": + $.barcode.digitToSvg($this, settings, digit, hri); + break; + default: + $.barcode.digitToCss($this, settings, digit, hri); + break; + } + + + return($this); + } +}); \ No newline at end of file diff --git a/include/js/jquery.autocomplete.min.js b/include/js/jquery.autocomplete.min.js new file mode 100644 index 000000000..4b021c167 --- /dev/null +++ b/include/js/jquery.autocomplete.min.js @@ -0,0 +1,13 @@ +/* + * jQuery Autocomplete plugin 1.1 + * + * Copyright (c) 2009 Jörn Zaefferer + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $ + */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false;}progress+=seperator;});words[wordAt]=v;v=words.join(options.multipleSeparator);}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&¤tValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value)return[""];if(!options.multiple)return[$.trim(value)];return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null;});}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);if(words.length==1)return words[0];var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""));}return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else{$input.val("");$input.trigger("result",null);}}});}};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase());}if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else +if(data[q]){return data[q];}else +if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("
").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("
    ").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select();}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}}else if(this.setSelectionRange){this.setSelectionRange(start,end);}else if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end;}});}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}};})(jQuery); \ No newline at end of file