<div id="nothingSelected" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'warning_title'}</h4>
            </div>
            <div class="modal-body">
                <h5>$text{'nothing_selected'}</h5>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_ok'}</button>
            </div>
        </div>
    </div>
</div>

<div id="createFolderDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'create_folder'}</h4>
            </div>
            <div class="modal-body">
                <form id="createFolderForm" action="create_folder.cgi" method="post">
                    <div class="form-group">
                        <label>$text{'new_folder_name'}</label>
                        <input id="name" name="name" type="text" class="form-control" data-placement="right" data-content="$text{'provide_folder_name'}" data-trigger="manual">
                        <input type='hidden' name='path' value='$quote_escaped_path'>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="createFolder()">$text{'create'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="createFileDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'create_file'}</h4>
            </div>
            <div class="modal-body">
                <form id="createFileForm" action="create_file.cgi" method="post">
                    <div class="form-group">
                        <label>$text{'new_file_name'}</label>
                        <input name="name" type="text" class="form-control" data-placement="right" data-content="$text{'provide_file_name'}" data-trigger="manual">
                        <input type='hidden' name='path' value='$quote_escaped_path'>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="createFile()">$text{'create'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="renameDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'rename'}</h4>
            </div>
            <div class="modal-body">
                <form id="renameForm" action="rename.cgi" method="post">
                    <div class="form-group">
                        <label>$text{'new_name'}</label>
                        <input name="name" type="text" class="form-control" data-placement="right" data-content="$text{'provide_new_file_name'}" data-trigger="manual">
                        <input type='hidden' name='file' value='' required>
                        <input type='hidden' name='path' value='$quote_escaped_path'>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="renameSelected()" name="button">$text{'rename'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="compressDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'compress_selected'}</h4>
            </div>
            <div class="modal-body">
                <form id="compressSelectedForm" class="form-inline">
                    <div class="form-group">
                        <label>$text{'archive_name'}</label>
                        <input name="filename" type="text" class="form-control" data-placement="right" data-content="$text{'provide_file_name'}" data-trigger="manual">
                    </div>
                    <select name="method">
                        <option value="plain-tar">.tar</option>
                        <option value="xz-tar">.tar.xz</option>
                        <option selected value="tar">.tar.gz</option>
                        <option value="zstd-tar">.zstd</option>
                        <option value="zip">.zip</option>
                    </select>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="compressSelected()">$text{'dialog_compress'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="removeDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'remove_selected'}</h4>
            </div>
            <div class="modal-body">
                $text{'about_to_delete'}
                <div id="items-to-remove" class="well">
                </div>
                $text{'are_you_sure'}
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" onclick="removeSelected()">$text{'remove_selected'}</button>
                <button type="button" class="btn bnt-primary" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="chownDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'chown_selected'}</h4>
            </div>
            <div class="modal-body">
                <form id="chownForm">
                    <div class="form-group">
                        <label>$text{'user_name'}</label>
                        <input name="owner" type="text" class="form-control" data-placement="right" data-content="$text{'provide_user_name'}" data-trigger="manual">
                        <label>$text{'group_name'}</label>
                        <input name="group" type="text" class="form-control" data-placement="right" data-content="$text{'provide_group_name'}" data-trigger="manual">
                        <label>$text{'dialog_recursive'}</label>
                        <input id="chown-recursive" type="checkbox" name="recursive" class="form-control">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="chownSelected()">$text{'dialog_change'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="chattrDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'chattr_selected'}</h4>
            </div>
            <div class="modal-body">
                <form id="chattrForm">
                    <div class="form-group">
                        <label>$text{'attr_label'}</label>
                        <input name="label" type="text" class="form-control">
                        <label>$text{'dialog_recursive'}</label>
                        <input id="chattr-recursive" type="checkbox" name="recursive" class="form-control">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="chattrSelected()">$text{'dialog_change'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="chconDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'chcon_selected'}</h4>
            </div>
            <div class="modal-body">
                <form id="chconForm">
                    <div class="form-group">
                        <label>$text{'context_label'}</label>
                        <input name="label" type="text" class="form-control">
                        <label>$text{'dialog_recursive'}</label>
                        <input id="chcon-recursive" type="checkbox" name="recursive" class="form-control">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="chconSelected()">$text{'dialog_change'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="aclsDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'acls_selected'}</h4>
            </div>
            <div class="modal-body">
                <form id="aclsForm">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-sm-12">
                            <label>$text{'acls_action'}</label><br>
                                <select name="action">
                                  <option value=""></option>
                                  <option selected value="-m">Modify (-m)</option>
                                  <option value="-x">Remove (-x)</option>
                                  <option value="-b">Remove all extended (-b)</option>
                                  <option value="-k">Remove default (-k)</option>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <label>$text{'acls_applyto'}</label><br>
                                <select multiple size=4 name="apply_to">
                                  <option value="u">$text{'acls_user'}</option>
                                  <option value="g">$text{'acls_group'}</option>
                                  <option value="m">$text{'acls_mask'}</option>
                                  <option value="o">$text{'acls_other'}</option>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-3">
                                <label>$text{'acls_perms'}</label><br>
                                <select name="perms">
                                  <option value=""></option>              
                                  <option value="---">---</option>
                                  <option value="r--">r--</option>
                                  <option value="-w-">-w-</option>
                                  <option value="--x">--x</option>
                                  <option value="r-x">r-x</option>
                                  <option value="rw-">rw-</option>
                                  <option value="-wx">-wx</option>
                                  <option value="rwx">rwx</option>
                                </select>
                            </div>
                            <div class="col-sm-3">
                                <label>$text{'acls_user'}</label><br>
                                $acl_user_select
                            </div>
                            <div class="col-sm-3">
                                <label>$text{'acls_group'}</label><br>
                                $acl_group_select
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <label>$text{'dialog_recursive'}</label>
                                <input id="acls-recursive" type="checkbox" name="recursive">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                $acl_manual
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="aclsSelected()">$text{'dialog_change'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="chmodDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'chmod_selected'}</h4>
            </div>
            <div class="modal-body">
                <form name="chmod" id="chmodForm">
                    <div class="form-group">
                        <label for="t_total">$text{'permissions'}:&nbsp; </label>
                        <input id="perms" type="text" oninput="if(this.value.length>4)this.value=this.value.slice(0,4)" name="t_total" value="0644" size="4" onKeyUp="octalchange()" class="form-group-item">
                        <input type="text" name="sym_total" value="" size="12" readonly="true" class="form-group-item">
                    </div>
                    <table class="table">
                        <tr>
                            <th></th>
                            <th><b>$text{'chmod_owner'}</b></th>
                            <th><b>$text{'chmod_group'}</b></th>
                            <th><b>$text{'chmod_others'}<b></th>
                        </tr>
                        <tr>
                            <td>$text{'chmod_read'}</td>
                            <td><input type="checkbox" name="owner4" value="4" onclick="calc_chmod()"></td>
                            <td><input type="checkbox" name="group4" value="4" onclick="calc_chmod()"></td>
                            <td><input type="checkbox" name="other4" value="4" onclick="calc_chmod()"></td>
                        </tr>
                        <tr>
                            <td>$text{'chmod_write'}</td>
                            <td><input type="checkbox" name="owner2" value="2" onclick="calc_chmod()"></td>
                            <td><input type="checkbox" name="group2" value="2" onclick="calc_chmod()"></td>
                            <td><input type="checkbox" name="other2" value="2" onclick="calc_chmod()"></td>
                        </tr>
                        <tr>
                            <td>$text{'chmod_execute'}</td>
                            <td><input type="checkbox" name="owner1" value="1" onclick="calc_chmod()"></td>
                            <td><input type="checkbox" name="group1" value="1" onclick="calc_chmod()"></td>
                            <td><input type="checkbox" name="other1" value="1" onclick="calc_chmod()"></td>
                        </tr>
                        <tr>
                            <td>----------</td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>$text{'chmod_sticky'}</td>
                            <td><input type="checkbox" name="sticky" value="1" onclick="calc_chmod()"></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>$text{'chmod_setgid'}</td>
                            <td><input type="checkbox" name="setgid" value="2" onclick="calc_chmod()"></td>
                            <td></td>
                            <td></td>
                        </tr>
                    </table>
                    <label>$text{'chmod_apply_to'}:&nbsp; </label>
                    <select name="applyto">
                        <option value="1">$text{'chmod_dir_only'}</option>
                        <option value="2">$text{'chmod_dir_and_its_files'}</option>
                        <option value="3">$text{'chmod_all'}</option>
                        <option value="4">$text{'chmod_dir_files_and_subs_files'}</option>
                        <option value="5">$text{'chmod_dir_and_subs'}</option>
                    </select>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="chmodSelected()">$text{'dialog_change'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

<div id="downFromUrlDialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="warning">$text{'get_from_url'}</h4>
      </div>
      <div class="modal-body">
        <form id="downFromUrlForm" action="http_download.cgi" method="post">
          <div class="form-group">
            <label style="display: block;">$text{'dialog_file_url'} <sup class="text-danger">&nbsp;*</sup>
                <input name="link" type="url" class="form-control" data-placement="top" data-content="$text{'provide_url'}" data-trigger="manual" autocomplete="url" style="font-weight: normal;">
            </label>
          </div>
          <div class="form-group">
            <label style="display: block;">$text{'dialog_user_name'}
                <input name="username" type="text" class="form-control" autocomplete="off" style="font-weight: normal;">
            </label>
          </div>
          <div class="form-group">
            <label style="display: block;">$text{'dialog_user_pass'}
                <input name="password" type="password" class="form-control" autocomplete="new-password" style="font-weight: normal;">
            </label>
          </div>
          <input type='hidden' name='path' value='$quote_escaped_path'>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" onclick="downFromUrl()">$text{'dialog_download'}</button>
        <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
      </div>
    </div>
  </div>
</div>

<div id="readyForUploadDialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="warning">$text{'upload_files'}</h4>
      </div>
      <div class="modal-body">
        <form id='upload-form' method='post' action='upload.cgi?path=$urlized_path&id=$upid' enctype='multipart/form-data' onsubmit='window.open("@{[&get_webprefix()]}/uptracker.cgi?id=$upid&uid=$uid", "uptracker", "toolbar=no, menubar=no, scrollbars=no, location=no, resizable=no, width=screen.width, height=screen.height")'>
            <input type='file' id='upfiles' name='upfiles' multiple onchange='countUploads(this)'>
            <input type='hidden' name='path' value='$quote_escaped_path'>
        </form>
          <div id="readyForUploadList" class="well">
          </div>
          <input type="checkbox" data-id="webkitdirectory" onchange="document.querySelector('#upload-form > #upfiles').toggleAttribute('webkitdirectory')"> $text{'upload_dirs'}
          <input type="checkbox" data-id="extract_uploaded" onchange="t=document.querySelector('#upload-form'),v=t.getAttribute('action'),x='&extract_uploaded=1',this.checked?t.setAttribute('action', t.getAttribute('action') + x):t.setAttribute('action',t.getAttribute('action').replace(x,''))"> $text{'extract_uploaded'}
          <input type="checkbox" data-id="overwrite_existing" onchange="t=document.querySelector('#upload-form'),v=t.getAttribute('action'),x='&overwrite_existing=1',this.checked?t.setAttribute('action', t.getAttribute('action') + x):t.setAttribute('action',t.getAttribute('action').replace(x,''))"> $text{'overwrite_existing'}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" onclick="uploadFiles()">$text{'upload_files'}</button>
        <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
      </div>
    </div>
  </div>
</div>

<div id="searchDialog" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="warning">$text{'search'}</h4>
            </div>
            <div class="modal-body">
                <form id="searchForm" action="search.cgi" method="post">
                    <div class="form-group">
                        <label>$text{'search_label'}</label>
                        <input id="query" name="query" type="text" class="form-control" data-placement="right" data-content="$text{'provide_search_query'}" data-trigger="manual"><br>
                        <input id="caseins" name="caseins" type="checkbox" checked="checked"> $text{'search_insensitive'}
                        <input type='hidden' name='path' value='$quote_escaped_path'>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="search()">$text{'search_go'}</button>
                <button type="button" class="btn bnt-default" data-dismiss="modal">$text{'dialog_cancel'}</button>
            </div>
        </div>
    </div>
</div>

