Download File Automatically

The Download File Automatically (NullDownloader) is a plugin that enables automatic file download functionality with countdown and translation support. It simplifies the process of creating a download button that triggers an automatic download after a specified countdown period.

To add the plugin into your project, you will need to include JS file that are situated in the JS/Plugins/Download-File-Automatically.

Make sure that "null-components" CSS file is included in your project to ensure the proper styling of the plugin.

To ensure better control over the download process and prevent users from directly accessing the download link, the plugin initially removes the manual download link from the DOM. After the countdown finishes, it appends the link back to the DOM, allowing users to access the file only through the automated download process.

The HTML structure:

HTML |
<div class="null-download-container">
    
                <a   data-null-download="null-download-button" href="javascript:void(null)" class="null-button null-button-primary"></a>
    
                <div data-null-download="null-download-downcount" class="null-font-size-24 null-font-weight-bold null-margin-bottom-10"></div>
    
                <div data-null-download="null-download-please-wait-text" class="null-font-size-17 null-font-weight-bold"></div>

                <div class="null-download-manual-container null-display-flex">

                       <span data-null-download="null-download-manual-text"></span>

                       <a data-null-download="null-download-manual-link" href="your-document"  class="null-color-main null-font-weight-bold"></a>

                </div><!--End null-download-manual-container-->
                
</div><!--End null-download-container-->

Noting that you do not need to pass any text to the HTML structure, you will initialize the text through JavaScript function. (there is no default values for text)

JS |
  const nullDownloader = new NullDownloader({
      text: {
        "null-download-button": {
          en: "Download File",
          ar: "تحميل الملف"
        },
        "null-download-downcount": {
          en: "Downloaded",
          ar: "تم التحميل"
        },
        "null-download-please-wait-text": {
          en: "Please wait ...",
          ar: "يرجى الانتظار"
        },
        "null-download-manual-text": {
          en: "If the download did not start automatically,",
          ar: "اذا لم يقم بالتحميل"
        },
        "null-download-manual-link": {
          en: "Click Here",
          ar: "اضغط"
        },
        "null-download-message-after-click": {
          en: "Download will begin automatically in",
          ar: "سوف يبدا التحميل بعد"
        },
        "null-download-second": {
          en: "seconds",
          ar: "ثواني"
        }
      },
      second: 5,
    });

Options:

The plugin provides the following options:

text (object): Contains translations for various text elements in different languages. 

second (number): Specifies the countdown time in seconds. The default value is 10 if not provided.