vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   New Posting Features - Unit Converter for DownloadsII (https://vborg.vbsupport.ru/showthread.php?t=237713)

Arcade Fire 03-06-2010 10:00 PM

Unit Converter for DownloadsII
 
1 Attachment(s)
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&amp;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">&nbsp;&nbsp;Kilobyte&nbsp;&nbsp;</font></td>
        <td align="center"><font size="4" face="Arial, Helvetica, sans-serif">&nbsp;&nbsp;Megabyte&nbsp;&nbsp;</font></td>
        <td align="center"><font size="4" face="Arial, Helvetica, sans-serif">&nbsp;&nbsp;Gigabyte&nbsp;&nbsp;</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="  &gt;  "
        onClick="convert(this.form)">
        </td>
        <td align="center">
          <input type="button" name="B22" value="  &lt; &gt;  "
        onClick="convertkb(this.form)">

        </td>
        <td align="center">
          <input type="button" name="B23" value="  &lt; &gt;  "
        onClick="convertmb(this.form)">
        </td>
        <td align="center">
          <input type="button" name="B24" value="  &lt;  "
        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>

3. Click to Mark as Installed.


Screenshot:

https://vborg.vbsupport.ru/external/2010/03/75.jpg

Conflicts: "Add File" button doesn't work after installation (working on it)

Kolbi 03-07-2010 12:07 PM

Nice widget :)

But I guess not very needed...
A little notice would be enough I guess.

But thank yoU!

synseal 03-07-2010 03:28 PM

Thank you, this is actually very handy for my forum especially when linking to downloads.

Arcade Fire 03-07-2010 03:48 PM

Quote:

Originally Posted by synseal (Post 1999172)
Thank you, this is actually very handy for my forum especially when linking to downloads.

Your welcome. This specially designed for that. When we link a file, we usually know their size in MB or GB and we have to look in other websites which is its size in bytes. This saves us having to find converters and makes it more convenient for our users, avoiding stop-sized box with no value. :up:

Dr.osamA 01-05-2011 04:28 AM

thank you good work

installed

Arcade Fire 01-05-2011 12:28 PM

You?re welcome :)

yin9 01-24-2011 05:11 AM

Thanks Arcade Fire, works well in VB 4.1.0 PL2. Installed, 5 Stars.

Edit: Error, uninstalled.

Raptor 03-10-2011 06:38 AM

works fine with vb4.1.2

cnrr 03-12-2011 03:52 PM

very usefull. thank you but "Add File" button doesn't work after installation.

Sai01 04-17-2011 09:57 AM

add file button doesn't work after this installed


All times are GMT. The time now is 09:38 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01078 seconds
  • Memory Usage 1,787KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete