summaryrefslogtreecommitdiffstats
path: root/player/javascript
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2019-12-22 14:17:22 +0200
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2019-12-22 14:51:13 +0200
commitb670838b3d8970db1932b3f83fedb7edaa324c80 (patch)
treebe10617c1a72caef1fb051e3bf1f025eba7b0713 /player/javascript
parent3267bcd210af431c7f8b22f4a7653d3881209b36 (diff)
downloadmpv-b670838b3d8970db1932b3f83fedb7edaa324c80.tar.bz2
mpv-b670838b3d8970db1932b3f83fedb7edaa324c80.tar.xz
js: read_options: on_update: don't re-read the config file
Now that 00af718a made the lua read_options behavior much more similar to the js behavior, the main difference was that lua does not re-read the config file at on_update (but it does re-apply its stored content) while js did re-read it. Now the js on_update also does not re-read the config file and instead applies its stored original content. This is slightly hacky by adding an undocumented optional 4th argument to read_options which allows overriding the config file content.
Diffstat (limited to 'player/javascript')
-rw-r--r--player/javascript/defaults.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js
index 4520373886..fba5b10144 100644
--- a/player/javascript/defaults.js
+++ b/player/javascript/defaults.js
@@ -511,13 +511,13 @@ g.require = new_require(SCRIPTDIR_META + "/" + main_script[1]);
/**********************************************************************
* mp.options
*********************************************************************/
-function read_options(opts, id, on_update) {
+function read_options(opts, id, on_update, conf_override) {
id = String(id ? id : mp.get_script_name());
mp.msg.debug("reading options for " + id);
var conf, fname = "~~/script-opts/" + id + ".conf";
try {
- conf = mp.utils.read_file(fname);
+ conf = arguments.length > 3 ? conf_override : mp.utils.read_file(fname);
} catch (e) {
mp.msg.verbose(fname + " not found.");
}
@@ -561,7 +561,7 @@ function read_options(opts, id, on_update) {
mp.observe_property("options/script-opts", "native", function(_n, _v) {
var saved = JSON.parse(JSON.stringify(opts)); // clone
var changelist = {}, changed = false;
- read_options(opts, id); // re-apply conf-file + script-opts
+ read_options(opts, id, 0, conf); // re-apply orig-file + script-opts
for (var key in opts) {
if (opts[key] != saved[key]) // type always stays the same
changelist[key] = changed = true;