Remove use of Function constructor in global.js

Same change as in global.jsm previously.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Fix error message in LogMessage.toString

Need to use this.error, not error.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Convert Log4Moz from JSM file to plain JS file

To allow use outside of SpiderMonkey, convert the JSM file to a JS file
by renaming the file and preventing pollution of the global namespace
(which is no longer limited to the file).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Declare variables for for-in loops

The variables used in for-in loops need to be declared within the
function to prevent them from being implicit globals.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Fix getter syntax for ES5

The getter syntax in ES5 requires a function body.  So add one.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Change let statements to var statements

V8 does not support the let statement, so make use of var instead.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Handle undefined Components

When running outside of Gecko, Components may not be defined.  Handle
this case.

Note:  This will cause ConsoleAppender to fail.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Use ES5 Strict Mode

Switch to using ES5 Strict Mode for the code in this file.  The only
change necessary is to replace octal literals with parseInt.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Create non-Mozilla-specific ConsoleAppender

Use the console.log family of functions generally provided by modern
browsers to make a more-portable ConsoleAppender class.  Rename the
(more-featureful) Mozilla-specific ConsoleAppender MozConsoleAppender
and return it when Components.interfaces is available.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Don't dump on Log4Moz internal errors

We can't rely on dump being defined (e.g. it is not defined in Chrome).
Instead, report internal error conditions to the Log4Moz error and
remember error conditions in the appender to prevent infinite recursion
on persistent error conditions.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Cleanup

Fix some outstanding issues for the linters.  No functionality changes.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Add merge and mergeUniq to arrayutils

More utility functions that may come in handy when dealing with sorted
arrays.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Drop "for Firefox" from the license header

With any luck, this extension will be running on Chrome eventually, so
there's no need to have "for Firefox" in the formal name.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Create new platform import and move Preferences into it

In order to support multiple platforms, several modules will need
platform-specific implementations.  To do this, alias
omnivalidator/platform to the platform-specific directory.

Move the current Preferences implementation into the XULRunner-specific
platform directory.  Rename to NSPreferences to distinguish the
implementation from others.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Split common functionality from Preferences into prefutils

Several methods in Preferences can be implemented based on the others.
Split these out into prefutils to reduce the size of the Preferences API
and reduce code duplication in the future implementation for Chrome.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Support default branches in NSPreferences

Attempt to present a unified API for Preferences objects where all
methods manipulate the branch they refer to (default or not) with
fallback to default branch for get operations and delete operations.

Some operations (reset) left partially implemented due to the difficulty
of implementing the operation on the default branch (which is currently
not used).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Documentation update for NSPreferences

The documentation is severely lacking.  Update it a bit (more is
needed...).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Test/Spec for Preferences with Jasmine

This project is sorely lacking for testing, about time to add some.
Starting with Preferences, which will be implemented for each platform.

These specs can be run in Firefox by creating a page with Jasmine and
loading it from a chrome:// URL.  It's hacky, so I'm hoping for a better
solution before committing it to version control.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Misc. fixups and documentation for prefutils

Add some documentation to the functions missing it.

Make getArray consistent with getObject and Preferences.getValue when
the value does not exist, always return undefined.

Other style and minor fixes.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Add spec for prefutils

Lets ensure that prefutils does what it is specified to do.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>