Unit Converter for DownloadsII
This template change is for the product DownloadsII by RS_Jelle What makes this modification? adds a unit conversion when a user upload a new file through a link. Thus, you can fill in box size in bytes, converted directly from larger units (Mb, Gb), preventing the box is empty on input size. Instructions: 1. Open downloads2_file_addit template. 2. Replaces all content by this: Code:
<script type="text/javascript"> <!-- function uploading_file() { if (document.getElementById('uploadfield').value != '' && document.getElementById('title').value != '') { document.getElementById('uploadbusy').style.display = 'block'; } } //--> </script> <form class="vbform block" enctype="multipart/form-data" action="downloads.php?do=<vb:if condition="$_GET['do']=='edit'">edit&id={vb:raw file.id}<vb:else />add</vb:if>" method="post" onsubmit="return vB_Editor['{vb:raw editorid}'].prepare_submit(this.title.value, {vb:raw vboptions.postminchars})"> <vb:if condition="$show['errors']"> <div class="blockbody errorblock"> <h2 class="blockhead">{vb:rawphrase dl2_errors_occured_when_submitted}:</h2> <ul class="blockrow error"> {vb:raw errorlist} </ul> </div> </vb:if> <h2 class="blockhead">{vb:raw dlcustomtitle}</h2> <div class="blockbody formcontrols"> <div class="blockrow"> <label for="title">{vb:rawphrase dl2_file_name}:</label> <div><input type="text" class="primary textbox" name="title" id="title" value="{vb:raw newfile.title}" maxlength="50" tabindex="1" /></div> </div> <div class="blockrow"> <label for="dlauthor_ctrl">{vb:rawphrase dl2_author}:</label> <div id="dlauthor" class="popupmenu nomouseover noclick nohovermenu"> <textarea class="primary textbox popupctrl" id="dlauthor_ctrl" name="author" rows="1" cols="50" tabindex="1">{vb:raw newfile.author}</textarea> </div> <vb:if condition="$vboptions['dl2namesugg'] != 'disabled'"> <script type="text/javascript" src="clientscript/vbulletin_ajax_suggest.js?v={vb:raw vboptions.simpleversion}"></script> <script type="text/javascript"> <!-- dlauthor_sugg = new vB_AJAX_NameSuggest('dlauthor_sugg', 'dlauthor_ctrl', 'dlauthor'); dlauthor_sugg.allow_multiple = <vb:if condition="$vboptions['dl2namesugg'] == 'multiple'">true<vb:else />false</vb:if>; //--> </script> </vb:if> </div> {vb:raw messagearea} <div class="blockrow"> <label for="category">{vb:rawphrase dl2_category}:</label> <div> <select class="primary" name="category" id="category" tabindex="1"> {vb:raw category_select} </select> </div> </div> <div class="blockrow"> <label for="cb_pin"><input type="checkbox" name="pin" id="cb_pin" value="1" tabindex="1" {vb:raw pinned} /> {vb:rawphrase dl2_pinned}</label> </div> </div> <vb:if condition="$_GET['do'] == 'edit'"> <h2 class="blockhead">{vb:rawphrase dl2_assign_new_uploader}</h2> <div class="blockbody formcontrols"> <div class="blockrow"> <label for="dlassign_ctrl">{vb:rawphrase dl2_new_uploader}:</label> <p class="description">{vb:rawphrase dl2_assign_new_match}</p> <div id="dlassign" class="popupmenu nomouseover noclick nohovermenu"> <input type="text" class="textbox popupctrl" id="dlassign_ctrl" name="uploader" value="{vb:raw newfile.uploader}" tabindex="1" /> </div> <vb:if condition="$vboptions['dl2namesugg'] == 'disabled'"> <script type="text/javascript" src="clientscript/vbulletin_ajax_suggest.js?v={vb:raw vboptions.simpleversion}"></script> </vb:if> <script type="text/javascript"> <!-- snc = new vB_AJAX_NameSuggest('snc', 'dlassign_ctrl', 'dlassign'); //--> </script> </div> </div> </vb:if> <h2 class="blockhead">{vb:rawphrase dl2_upload_or_link_to}</h2> <div class="blockbody formcontrols"> <vb:if condition="$show['uploadfiles']"> <div class="blockrow"> <label for="uploadfield">{vb:rawphrase dl2_upload_a_file}:</label> <p class="description" id="uploadbusy" style="display:none"><img class="inlineimg" src="{vb:stylevar imgdir_misc}/progress.gif" alt="" /> {vb:rawphrase dl2_uploading_file_please_wait}</p> <vb:comment><input type="hidden" name="MAX_FILE_SIZE" value="{vb:raw inimaxattach}" /></vb:comment> <div><input type="file" class="primary textbox" name="upload" id="uploadfield" tabindex="1" /></div> </div> </vb:if> <vb:if condition="$show['linktofiles']"> <div class="blockrow"> <label for="link">{vb:rawphrase dl2_link_to_a_file}:</label> <div><input type="text" class="primary textbox" name="link" id="link" maxlength="250" tabindex="1" <vb:if condition="$newfile['link']">value="{vb:raw newfile.url}"</vb:if> /></div> </div> <div class="blockrow"> <label for="size">{vb:rawphrase dl2_link_file_size}:</label> <div><input type="text" class="textbox" name="size" id="size" maxlength="10" tabindex="1" <vb:if condition="$newfile['link']">value="{vb:raw newfile.size}"</vb:if> /></div> </div> <div class="blockrow"> <div align="center"><font style='font-size: 30px;' face='Verdana, Arial, Helvetica, sans-serif'><b>Unit Converter</b></font><hr></div> <p align="left">With this unit converter, you can go from bytes to gigabytes through Kbs. and Mbs. with a single click.</p> <p align="left">It is very intuitive to use, enter the amount you want in the corresponding box and click the button underneath. <script language="JavaScript"> <!-- function convert(f) { f.kb.value=Math.round(f.byte.value/1024*100000)/100000 f.mb.value=Math.round(f.byte.value/1048576*100000)/100000 f.gb.value=Math.round(f.byte.value/1073741824*100000)/100000 } function convertkb(f) { f.byte.value=Math.round(f.kb.value*1024*100000)/100000 f.mb.value=Math.round(f.kb.value/1024*100000)/100000 f.gb.value=Math.round(f.kb.value/1048576*100000)/100000 } function convertmb(f) { f.byte.value=Math.round(f.mb.value*1048576*100000)/100000 f.kb.value=Math.round(f.mb.value*1024*100000)/100000 f.gb.value=Math.round(f.mb.value/1024*100000)/100000 } function convertgb(f) { f.byte.value=Math.round(f.gb.value*1073741824*100000)/100000 f.kb.value=Math.round(f.gb.value*1048576*100000)/100000 f.mb.value=Math.round(f.gb.value*1024*100000)/100000 } // --> </script> </p> <form> <div align="center"> <table border="1" style="dashed" border-color="#ccc" bgcolor="#ffffff" cellpadding="3" cellspacing="3"> <tr> <td align="center"><font size="4" face="Arial, Helvetica, sans-serif">Byte</font></td> <td align="center"><font size="4" face="Arial, Helvetica, sans-serif"> Kilobyte </font></td> <td align="center"><font size="4" face="Arial, Helvetica, sans-serif"> Megabyte </font></td> <td align="center"><font size="4" face="Arial, Helvetica, sans-serif"> Gigabyte </font></td> </tr> <tr> <td align="center"> <input type="text" size="10" name="byte" value="0"> </td> <td align="center"> <input type="text" size="10" name="kb" value="0"> </td> <td align="center"> <input type="text" size="10" name="mb" value="0"> </td> <td align="center"> <input type="text" size="10" name="gb" value="0"> </td> </tr> <tr> <td align="center"> <input type="button" name="B2" value=" > " onClick="convert(this.form)"> </td> <td align="center"> <input type="button" name="B22" value=" < > " onClick="convertkb(this.form)"> </td> <td align="center"> <input type="button" name="B23" value=" < > " onClick="convertmb(this.form)"> </td> <td align="center"> <input type="button" name="B24" value=" < " onClick="convertgb(this.form)"> </td> </tr> </table> <br></div> </form> </div> </vb:if> </div> <div class="blockfoot actionbuttons"> <div class="group"> <input type="hidden" name="s" value="{vb:raw session.sessionhash}" /> <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" /> <input type="submit" onclick="uploading_file()" class="button" name="submit" value="{vb:raw dlcustomtitle}" accesskey="s" tabindex="1" /> </div> </div> </form> Screenshot: Conflicts: "Add File" button doesn't work after installation (working on it) Download No files for download. |
Similar Mods
Forum Home Enhancements Adsense Link Unit in Navbar | vBulletin 3.6 Template Modifications |
Mini Mods ... | Modification Graveyard |