From 400c903a3799818c25f27431de7c5b28270688f1 Mon Sep 17 00:00:00 2001 From: Jerry Jalava Date: Tue, 30 Oct 2007 08:29:54 +0200 Subject: [PATCH] Place for common utilities --- js/ajatus.utils.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 js/ajatus.utils.js diff --git a/js/ajatus.utils.js b/js/ajatus.utils.js new file mode 100644 index 0000000..0402cb8 --- /dev/null +++ b/js/ajatus.utils.js @@ -0,0 +1,32 @@ +(function($){ + $.ajatus = $.ajatus || {}; + + $.ajatus.utils = { + }; + $.ajatus.utils.array = { + has_match: function(needles, haystack) { + if ( typeof haystack != 'object' + || haystack.length <= 0) { + return false; + } + + if (typeof needles == 'object') { + var matched = false; + $.each(needles, function(i,needle){ + if ($.inArray(needle, haystack) != -1) { + matched = true; + } + // if (typeof(haystack[needle]) != 'undefined') { + // matched = true; + // } + }); + return matched; + } else if (typeof needles == 'string') { + return (typeof(haystack[needles]) != 'undefined'); + } + + return false; + } + }; + +})(jQuery); \ No newline at end of file -- 2.11.4.GIT