From acf1d4201274a648e9b30c422f0b5402de05ceab Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sat, 2 Jul 2011 03:07:32 +0000 Subject: [PATCH] New library module used to load a set of options (for a particular module) from ctrl/modsopts.ini and return the key=value pairs as properties of an object. This allows optional behavior/features in any JS modules (stock or 3rd party) to be enabled/controlled by editing ctrl/modopts.ini rather than modifying the JS module/script file itself (for Ree). --- exec/load/modopts.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 exec/load/modopts.js diff --git a/exec/load/modopts.js b/exec/load/modopts.js new file mode 100644 index 0000000000..b6b26d173f --- /dev/null +++ b/exec/load/modopts.js @@ -0,0 +1,23 @@ +/* modopts.js */ + +/* $Id$ */ + +/* Load Synchronet JS Module Control/Enable options from ctrl/modopts.ini */ +/* Parse a single .ini section using the argument (to load) as the section name */ +/* and return an object containing the key=value pairs as properties */ + + +function get_mod_options(modname) +{ + var ini_file = new File(file_cfgname(system.ctrl_dir, "modopts.ini")); + if(!ini_file.open("r")) { + delete ini_file; + return undefined; + } + + var obj = ini_file.iniGetObject(modname); + delete ini_file; + return obj; +} + +return get_mod_options(argv[0]); \ No newline at end of file -- GitLab