From de296fbdb079055227df3d6063d6ef20f8db2972 Mon Sep 17 00:00:00 2001 From: Ian Neal Date: Sun, 24 Nov 2024 18:17:49 +0000 Subject: [PATCH] Bug 1933093 - Move matchEntry helper into static.js in cZ. r=frg --- suite/chatzilla/js/lib/utils.js | 27 -------------------------- suite/chatzilla/xul/content/static.js | 28 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/suite/chatzilla/js/lib/utils.js b/suite/chatzilla/js/lib/utils.js index c223b81bc9..dbf722243f 100644 --- a/suite/chatzilla/js/lib/utils.js +++ b/suite/chatzilla/js/lib/utils.js @@ -293,33 +293,6 @@ function utils_lcfn(text) return text.toLowerCase(); } -function matchEntry (partialName, list, lcFn) -{ - - if ((typeof partialName == "undefined") || - (String(partialName) == "")) - { - var ary = new Array(); - for (var i in list) - ary.push(i); - return ary; - } - - if (typeof lcFn != "function") - lcFn = utils_lcfn; - - ary = new Array(); - - for (i in list) - { - if (lcFn(list[i]).indexOf(lcFn(partialName)) == 0) - ary.push(i); - } - - return ary; - -} - function encodeChar(ch) { return "%" + ch.charCodeAt(0).toString(16); diff --git a/suite/chatzilla/xul/content/static.js b/suite/chatzilla/xul/content/static.js index 020c5260de..244fb83487 100644 --- a/suite/chatzilla/xul/content/static.js +++ b/suite/chatzilla/xul/content/static.js @@ -5422,3 +5422,31 @@ function showEventAlerts (type, event, message, nick, o, thisp, msgtype) // yup. it is probably a MAC or NsIAlertsService is not initialized } } + +function matchEntry(partialName, list, lcFn) +{ + function utils_lcfn(text) + { + return text.toLowerCase(); + }; + + let ary = new Array(); + + if ((typeof partialName == "undefined") || (String(partialName) == "")) + { + for (let i in list) + ary.push(i); + return ary; + } + + if (typeof lcFn != "function") + lcFn = utils_lcfn; + + for (let i in list) + { + if (lcFn(list[i]).indexOf(lcFn(partialName)) == 0) + ary.push(i); + } + + return ary; +}