From 94073d6d8f8134ef450fb673be37227c56e3cfdc Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 13 Nov 2024 07:20:55 +0100 Subject: [PATCH 1/2] defaults.js: fix the opened event with mp.input.get The opened event doesn't send any arguments. Don't call JSON.parse(undefined) in that case because it errors. Fixes eb4c6be630, fixes #15301. --- player/javascript/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index 247c88ad993db..538f71cbe78de 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -653,7 +653,7 @@ mp.options = { read_options: read_options }; function register_event_handler(t) { mp.register_script_message("input-event", function (type, args) { if (t[type]) { - args = JSON.parse(args) + args = args ? JSON.parse(args) : []; var result = t[type](args[0], args[1]); if (type == "complete" && result) { From bf83870b8cfbce0aacd20192d55cdf72bc9dc303 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 13 Nov 2024 08:10:55 +0100 Subject: [PATCH 2/2] defaults.js: send the right number of arguments to input.get callbacks Only send how many arguments were actually passed by console.lua instead of sending extra undefined arguments. --- player/javascript/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index 538f71cbe78de..57e4b1646b751 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -654,7 +654,7 @@ function register_event_handler(t) { mp.register_script_message("input-event", function (type, args) { if (t[type]) { args = args ? JSON.parse(args) : []; - var result = t[type](args[0], args[1]); + var result = t[type].apply(null, args); if (type == "complete" && result) { mp.commandv("script-message-to", "console", "complete",