JDownloader Community - Appwork GmbH
 

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 25.12.2024, 17:19
FWD079 FWD079 is offline
Baby Loader
 
Join Date: Apr 2020
Location: England
Posts: 6
Default JavaScript confirm dialog

Hi and Merry Christmas to all celebrating
Firstly thank you for wonderful Even Scripter, I started playing around, and tried using convert to mp3 script which works. Was just thinking of adding an "Are you sure" box before converting to mp3 file as below:

Code:
// Convert aac/m4a/ogg files to mp3.
// Trigger required: "A Download Stopped".
// Requires ffmpeg/ffprobe. Uses JD ffmpeg/ffprobe settings if available.
// Overwrites destination file (mp3) if it already exists.
disablePermissionChecks();
//confirm("Pree OK to convert AAC to MP3, Cancel to ignore");
if (window.confirm("Convert to Mp3?")) {   
    if (link.finished) {
        var input = link.downloadPath;
        var output = input.replace(/(aac)$/, "mp3");
    
        if (input != output) {
            try {
                var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
                var bitrate = callSync(ffmpeg, "-i", input).match(/bitrate: (\d+) kb/)[1];
    
                callAsync(function(error) {
                    !error && getPath(input).delete();
                }, ffmpeg, "-y", "-i", input, "-b:a", bitrate + "k", output);
            } catch (e) {};
        }
    }
}
But I get an error:



Details tell me:

Code:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "window" is not defined.
I also tried just "confirm" without "window" too. I thought it was one of the basic JavaScript code, am I missing something?

Please can you advise?
Thanks.

Last edited by FWD079; 25.12.2024 at 17:23.
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 10:48.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.