Ignore:
Timestamp:
Jun 17, 2013, 5:42:09 PM (11 years ago)
Author:
mistic100
Message:

WORK IN PROGRESS: allow to download derivatives
TODO: only working with images files, finish download page

Location:
extensions/BatchDownloader/template
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/template/init_zip.tpl

    r17517 r23290  
    66{/footer_script}
    77{/if}
     8
     9{if $missing_derivatives}
     10{combine_script id='jquery.progressBar' load='footer' path='themes/default/js/plugins/jquery.progressbar.min.js'}
     11{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
     12
     13{footer_script}
     14var derivatives = {ldelim}
     15        elements: ["{'","'|@implode:$missing_derivatives}"],
     16        done: 0,
     17        total: {$missing_derivatives|@count},
     18       
     19        finished: function() {ldelim}
     20                return derivatives.done == derivatives.total;
     21        }
     22};
     23
     24function progress(success) {ldelim}
     25  jQuery('#progressBar').progressBar(derivatives.done, {ldelim}
     26    max: derivatives.total,
     27    textFormat: 'fraction',
     28    boxImage: '{$ROOT_PATH}themes/default/images/progressbar.gif',
     29    barImage: '{$ROOT_PATH}themes/default/images/progressbg_red.gif'
     30  });
     31  if (success !== undefined) {ldelim}
     32                var type = success ? '.regenerateSuccess': '.regenerateError',
     33                        s = parseInt(jQuery(type).html());
     34                jQuery(type).html(++s);
     35        }
     36}
     37
     38{literal}
     39var queuedManager = jQuery.manageAjax.create('queued', {
     40  queue: true, 
     41  cacheResponse: false,
     42  maxRequests: 1
     43});
     44
     45function next_derivative() {
     46  if (derivatives.finished()) {
     47                alert("finish");
     48    return;
     49        }
     50 
     51  $("#damn").append(derivatives.elements[ derivatives.done ]+"<br>");
     52 
     53  jQuery.manageAjax.add("queued", {
     54    type: 'GET',
     55    url: derivatives.elements[ derivatives.done ]+'&ajaxload=true',
     56    dataType: 'json',
     57    success: function(data) {
     58      derivatives.done++;
     59      progress(true);
     60      next_derivative();
     61    },
     62    error: function(data) {
     63      derivatives.done++;
     64      progress(false);
     65      next_derivative();
     66    }
     67  });
     68}
     69
     70$("#begin").click(function() {
     71  progress();
     72  next_derivative();
     73});
     74{/literal}{/footer_script}
     75
     76{/if}
     77
    878
    979{* <!-- Menubar & titrePage --> *}
     
    32102    <li class="error">{$elements_error}</li>
    33103    <li><b>{'%d photos'|@translate|@sprintf:$set.NB_IMAGES}</b>{if $set.U_EDIT_SET}, <a href="{$set.U_EDIT_SET}" rel="nofollow">{'Edit the set'|@translate}</a>{/if}</li>
     104    <li><b>{'Size'|@translate}:</b> {$set.SIZE} {if $set.SIZE_INFO}<span class="downloadSizeDetails">({$set.SIZE_INFO})</span>{/if}</li>
    34105    <li><b>{'Estimated size'|@translate}:</b> {$set.TOTAL_SIZE} MB</li>
    35106    <li><b>{'Estimated number of archives'|@translate}:</b> {$set.NB_ARCHIVES} <i>({'real number of archives can differ'|@translate})</i></li>
     
    38109</fieldset>
    39110
     111{if $missing_derivatives}
     112<fieldset>
     113  <legend>Stuff happening</legend>
     114 
     115  <a id="begin">GO</a>
     116 
     117  <div id="regenerationMsg" class="bulkAction">
     118    <span class="progressBar" id="progressBar"></span>
     119  </div>
     120 
     121  <span class="regenerateSuccess">0</span> -
     122  <span class="regenerateError">0</span>
     123 
     124  <div id="damn">
     125  </div>
     126</fieldset>
     127{/if}
     128
     129{if $zip_links}
    40130<fieldset>
    41131  <legend>{'Download links'|@translate}</legend>
    42132 
    43133  <ul class="download-links">
    44     {$set.LINKS}
     134    {$zip_links}
    45135    <li class="warning">{'<b>Warning:</b> all files will be deleted within %d hours'|@translate|@sprintf:$archive_timeout}</li>
    46136  </ul>
    47137 
    48   <a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a>
     138  {if $set.U_CANCEL}<a href="{$set.U_CANCEL}" class="cancel-down" onClick="return confirm('{'Are you sure?'|@translate}');">{'Cancel this download'|@translate}</a>{/if}
    49139</fieldset>
     140{/if}
    50141{/if}
    51142
  • extensions/BatchDownloader/template/style.css

    r16392 r23290  
    3838    border-color:#f00;
    3939  }
     40 
     41.downloadSizeDetails {font-style:italic; font-size:80%;}
Note: See TracChangeset for help on using the changeset viewer.