Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
72e3271b
Commit
72e3271b
authored
2 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Load section or keys form [module:lang=<user-lang>] if it exists
This allow language-specific module options
parent
b94ee020
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#8200
passed
2 months ago
Stage: build
Stage: test
Stage: cleanup
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/modopts.js
+11
-8
11 additions, 8 deletions
exec/load/modopts.js
with
11 additions
and
8 deletions
exec/load/modopts.js
+
11
−
8
View file @
72e3271b
/* modopts.js */
/* $Id: modopts.js,v 1.4 2019/01/11 09:26:34 rswindell Exp $ */
/* 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 */
/* To avoid over-writing the parent script's "argc" and "argv" values,
/* If the section [module:lang=user-lang] exists in the .ini file,
that section (or key value from it) will be returned instead of the [module] section.
*/
/* To avoid over-writing the parent script's "argc" and "argv" values,
pass a scope object to load(), like this:
options=load(new Object, "modopts.js", "your_module_name");
...
...
@@ -25,13 +25,16 @@ function get_mod_options(modname, optname, default_optval)
return
undefined
;
}
var
section
=
modname
+
'
:lang=
'
+
user
.
lang
;
if
(
!
user
.
lang
||
ini_file
.
iniGetSections
().
indexOf
(
section
)
<
0
)
section
=
modname
;
var
val
;
if
(
optname
)
// Get a specific option value (optionally, with default value)
val
=
ini_file
.
iniGetValue
(
modname
,
optname
,
default_optval
);
val
=
ini_file
.
iniGetValue
(
section
,
optname
,
default_optval
);
else
// Get all options
val
=
ini_file
.
iniGetObject
(
modname
,
/* lowercase */
false
,
/* blanks: */
true
);
val
=
ini_file
.
iniGetObject
(
section
,
/* lowercase */
false
,
/* blanks: */
true
);
ini_file
.
close
();
return
val
;
}
get_mod_options
(
argv
[
0
],
argv
[
1
],
argv
[
2
]);
\ No newline at end of file
get_mod_options
(
argv
[
0
],
argv
[
1
],
argv
[
2
]);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment