var substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { matches.push(str); } }); cb(matches); }; }; var products = ['1 - HDB 3000mm Galaxy Woollen Card Year 2005, 160 good ends (Ref. 12169)','16092A Barmag DD2000GT Twisting 24 spindles Year 2018','16092B Barmag STC DD2000GT Twisting 24 spindles Year 2019','16092C 8 off Twistechnology TWISTUP 2 spindle each Year 2017','16092D Barmag STC MaryTex Texturiser 24 spindles Year 2023','16092E Barmag Oerlikon Texturising WRM 8 spindles Year 2017','2 - HDB Woollen Spinning Frames Year 2002 160 spindles (Ref. 12169)','2 HDB Woollen Spinning Frames Year 1996 (Ref. 12179)','5 off Vald Henricksen Dye Jiggers for Fabric (Ref. 16090E)','A Frames for textile fabric rolling/unrolling (Ref. 16090C)','ANDAR 5 Bowl Wool Scouring and Lattice Dryer Line Year 1991','Battenfeld Smartpower 60 Injection Mould Press Year 2018','Bruckner 1 Coating Line 2000mm','Bruckner 2 Blackout Coating Line 3200mm','Bruckner 3 - Padding & Curing Stenter 3200mm','Bruckner 5 Stenter 1800mm 1998?','Brugman Continuous Rope Fabric Bleaching Range 3200mm Year 1990 Stainless Steel (Ref. 16090B)','CA6 Worsted Card Double Doffer 2500mm Year 1994 (13065)','Calator/Durrant/Menzel Fabric Inspection 2000 and 3200mm','Caratsch Scatter Coating with Laminating Line 1800mm','Carbon Fibre Yarn Spinning and Coating Line Year 2013 (Ref. 12178)','Cliffe Tow Cutter (Ref. 12174)','Cushion Fibre Filling Production Line (Ref. 12185)','Dataweave 90cm Sample Loom with Bonas Electronic Jacquard (Ref. 16093)','Dornier P2 Year 2022 for Carbon Fibre or Glass Fibre Weaving','Fabotex WF1 Fringing Machine Year 2015','Fully Automated Fibre Filling System (Ref. 12186)','Gaudino Ring Spinning FPK03 (12178)','Gaudino Ring Twisting BRH (12178)','Haigh Chadwick Fearnought 1800mm (Ref. 12169A)','Haigh-Chadwick Hopper Feeder (Ref.12157)','HDB Double Doffer Nonwoven Card 2500mm (Ref. 13058)','Hunt and Moscrop Fabric Dampner 1800mm (Ref. 16090H)','KARL MAYER ROB Warping Machine Year 2003 (Ref. 16082)','Kusters 2 bowl Calender 3200mm','Montfort 2200mm Kombi 8 Bay Stenter Year 1999 (Ref. 16090D)','NSC Scglumberger FM8 Horizontal Rubbing Frame Year 1997 14082D','NSC Schlumberger FM8N Horizontal rubbing frame 20 spindles Year 1996 (Ref. 14082B)','Paco-Colman &Kirschner Roll goods packing machine','Pillow Fibre Filling Line (Ref. 12185)','Ramish Kleinwefers 2 bowl Calendar (Shreiner)','Saladin 2 Laminating Powder Point Coating Line 1800mm','Saladin 3 Powder Dot Coating Line 1800mm','Seydel NSC Schlumberger Converter FB20 (12178)','Staubli Unival 512 Electronic Jacquard Year 2010 (16081)','Tatham BLOW FILLING PRODUCTION LINE FOR PILLOW / CUSHIONS','Tatham Laboratory( Research/Sample) Non Woven Card','Texkimp Flanged bobbin yarn creel with tensioners brake (12178)','Thibeau CA6 Non Woven Card Double Doffer 2500mm Year 1994 (13065)','Thibeau CA6 Worsed Card Double Doffer 1500mm (13065)','TVE ESCALE High Efficiency Washing System - Open width scour machine (Ref. 12184)' ]; var productsIDs = [ ]; $('#our-products .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'products', limit: 40, source: substringMatcher(products) });