From 5f907fcf5b98c5be780bb0edfe830b96d068e585 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 6 Nov 2012 20:59:25 -0800 Subject: Use node and express --- public/js/searchjs.js | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 public/js/searchjs.js (limited to 'public/js/searchjs.js') diff --git a/public/js/searchjs.js b/public/js/searchjs.js new file mode 100644 index 00000000..d77f46e9 --- /dev/null +++ b/public/js/searchjs.js @@ -0,0 +1,107 @@ +/*jslint node:true,nomen:false */ +(function(exports){ + var matchObj, matchArray, singleMatch; + + singleMatch = function(field,s) { + var oneMatch = false, t, re, i, j; + // for numbers, exact match; for strings, ignore-case match; for anything else, no match + t = typeof(field); + if (field === null) { + oneMatch = s === null; + } else if (field === undefined) { + oneMatch = false; + } else if (t === "number") { + oneMatch = field === s; + } else if (t === "string") { + re = new RegExp(s,"i"); + oneMatch = field && field.match(re) !== null; + } else if (typeof(field.length) !== "undefined") { + // array, so go through each + for (j=0;j 0) { + for (i=0;i